View previous topic :: View next topic
|
Author |
Message |
TGarcia
New User
Joined: 24 Jul 2021 Posts: 3 Location: United States
|
|
|
|
Hello!
How can I add multiple variables from String?
ex:
a.1 = 'red apples'
a.2 = 'green apples'
a.3 = 'yellow bananas'
a.4 = 'red apples'
a.5 = 'yellow bananas'
desire output:
red apples 2
green apples 1
yellow bananas 2 |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
This is a forum for experts, 'nuff said! |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
TGarcia wrote: |
How can I add multiple variables from String? |
You need mandatory attend training classes for beginners at your school. |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
I assume that by 'add' you mean 'concatenate', for that you use the concatenation operator || , which is described in the 'z/OS TSO/E REXX Reference' manual 'REXX General Concepts' section. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
NO, the TS wants to count the occurrences of each stem value |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
Quote: |
How can I add multiple variables from String? |
Sorry, but your statement is unclear. Perhaps you can restate it. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
there is certainly a language barrier
but the sample input and the expected output are clear enough to provide an answer |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
Ah, I should have spent a few more minutes reading the question, it really is about counting,
That makes it much more interesting and relevant to this forum.
Here is my take on a solution:
Code: |
a.1 = 'red apples'
a.2 = 'green apples'
a.3 = 'yellow bananas'
a.4 = 'red apples'
a.5 = 'yellow bananas'
a.0 = 5
count.=''
cn =0
do n=1 to a.0
v=a.n
if count.v='' then do /* new */
cn=cn+1
count.v=1
count.cn=v
end
else count.v=count.v+1
end
do n=1 to cn
v=count.n
say "Count of '"v"'="count.v
end |
|
|
Back to top |
|
|
TGarcia
New User
Joined: 24 Jul 2021 Posts: 3 Location: United States
|
|
|
|
Thank you Willy Jensen!!!! |
|
Back to top |
|
|
|