Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Create all possible combinations of series of letters
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 10:31 am    Post subject: Create all possible combinations of series of letters
Reply with quote

Hi All,
Is any way to get all combinations of series of letters using REXX.
I meant that i have letters A,E,I,O,U.I want to create the all possible combinations using this letters.
For this is any inbuilt function or do i have to write the logic for this?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 10, 2009 11:15 am    Post subject:
Reply with quote

It will be all down to you - based on your current description of the problem / request.

Maybe if you explained better and gave some example of what you want
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 11:24 am    Post subject:
Reply with quote

Example
I have the letters A,E,I,O,U. I want to create the all the combination of words using this letters.
Like
AEIOU
AEIUO
AEUIO
AUEIO
UAEIO............ etc

Now are you clear with my requirement?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 10, 2009 12:31 pm    Post subject:
Reply with quote

do you want permutations or combinations?
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 12:38 pm    Post subject:
Reply with quote

i want combinations
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 10, 2009 12:55 pm    Post subject:
Reply with quote

combinations would be:

AAAAA
AAAAE
AAAEE

whereas permutations means each letter can only be used once in the sequence.

so, which is it?
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 1:46 pm    Post subject:
Reply with quote

i want combination a letter can repeat more than once in a word.Is it possible?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 10, 2009 1:54 pm    Post subject:
Reply with quote

Quote:
i want combination a letter can repeat more than once in a word.Is it possible?


sure it is.

what logic have you designed? or do you expect us to design, develop and then deliver the product to you?

develop some pseudo-code and someone can help you with the commands necessary.
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 2:00 pm    Post subject:
Reply with quote

Still i didnt designed any logic.If you give some idea of logic,it will great help for me.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 10, 2009 2:32 pm    Post subject:
Reply with quote

Bipin, you tend to try solving your own problems, so I am not going to rant.

in fact, since it is so easy I am just going to give you the answer.

Code:

/* REXX */
stem1.0 = 5
stem1.1 = 'A'
stem1.2 = 'B'
stem1.3 = 'C'
stem1.4 = 'D'
stem1.5 = 'E'
stem2.0 = 5
stem2.1 = 'A'
stem2.2 = 'B'
stem2.3 = 'C'
stem2.4 = 'D'
stem2.5 = 'E'
stem3.0 = 5
stem3.1 = 'A'
stem3.2 = 'B'
stem3.3 = 'C'
stem3.4 = 'D'
stem3.5 = 'E'
stem4.0 = 5
stem4.1 = 'A'
stem4.2 = 'B'
stem4.3 = 'C'
stem4.4 = 'D'
stem4.5 = 'E'
stem5.0 = 5
stem5.1 = 'A'
stem5.2 = 'B'
stem5.3 = 'C'
stem5.4 = 'D'
stem5.5 = 'E'

outputstem. = ''
outputstem.0 = 1
/*then I would have a complex loop */

do r = 1 to stem1.0
  do s = 1 to stem2.0
     do t = 1 to stem3.0
       do u = 1 to stem4.0
         do v = 1 to stem5.0
            j = outputstem.0
            outputstem.j = stem1.r || stem2.s || stem3.t || stem4.u || stem5.v
            outputstem.0 = outputstem.0 + 1
         end
       end
     end
  end
end
outputstem.0 = outputstem.0 - 1
say outputstem.0
do r = 1 to outputstem.0
   say outputstem.r
end


you will have to figure out how to output the results to a dataset.
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 2:38 pm    Post subject:
Reply with quote

Thanks Dick,I got the logic which you given.This seems give the result which i expected.
Thanks alot
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 10, 2009 2:40 pm    Post subject:
Reply with quote

Code:

/* REXX *** CARTESIAN JOIN OVER 5 STEMS                              */
TRACE R                                                                 
STM0.1 = 'A'                                                           
STM0.2 = 'E'                                                           
STM0.3 = 'I'                                                           
STM0.4 = 'O'                                                           
STM0.5 = 'U'                                                           
STM0.0 = 5                                                             
DO AA = 1 TO STM0.0                                                     
  DO AB = 1 TO STM0.0                                                   
    INTERPRET "STM"AA"."AB "= STM0."AB                                 
  END                                                                   
END                                                                     
DO AA = 1 TO STM0.0                                                     
  DO AB = 1 TO STM0.0                                                   
    DO AC = 1 TO STM0.0                                                 
      DO AD = 1 TO STM0.0                                               
        DO AE = 1 TO STM0.0                                             
          OUTPUT = STM1.AA||STM2.AB||STM3.AC||STM4.AD||STM5.AE
          SAY OUTPUT                                           
        END                                                   
      END                                                     
    END                                                       
  END                                                         
END                                                           
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 10, 2009 2:42 pm    Post subject:
Reply with quote

Damn ..... beaten to it by Dick "the fingers" Brenholtz icon_lol.gif
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 2:48 pm    Post subject:
Reply with quote

Expat you are great..(excuse me if you are not icon_biggrin.gif icon_biggrin.gif )

I didnt get this statement
Code:
INTERPRET "STM"AA"."AB "= STM0."AB       


What is this doing?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 10, 2009 2:50 pm    Post subject:
Reply with quote

expat, I may have been faster, but yours is a much better script.

Besides, my sequence is A B C D E instead of A E I O U

Dick "the fumbler" Brenholtz icon_redface.gif
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 2:54 pm    Post subject:
Reply with quote

Dick and expat,
I think instead of using 5 different stems we can use one stem with 5 different indexes.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 10, 2009 2:58 pm    Post subject:
Reply with quote

Bipin,

enough freebies for today.

you could turn on the trace instruction and watch
or
read the 28 topics have matches for: INTERPRET in the REXX Reference Manuel
or the 9 topics have matches for: INTERPRET in the REXX users guide
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jul 10, 2009 3:00 pm    Post subject:
Reply with quote

bipinpeter wrote:
Dick and expat,
I think instead of using 5 different stems we can use one stem with 5 different indexes.


well, share your code.
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jul 10, 2009 3:03 pm    Post subject:
Reply with quote

here is the code

Code:
* REXX */
stem1.0 = 5
stem1.1 = 'A'
stem1.2 = 'B'
stem1.3 = 'C'
stem1.4 = 'D'
stem1.5 = 'E'

outputstem. = ''
outputstem.0 = 1
/*then I would have a complex loop */

do r = 1 to stem1.0
  do s = 1 to stem1.0
     do t = 1 to stem1.0
       do u = 1 to stem1.0
         do v = 1 to stem1.0
            j = outputstem.0
            outputstem.j = stem1.r || stem1.s || stem1.t || stem1.u || stem5.v
            outputstem.0 = outputstem.0 + 1
         end
       end
     end
  end
end
outputstem.0 = outputstem.0 - 1
say outputstem.0
do r = 1 to outputstem.0
   say outputstem.r
end
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 10, 2009 3:03 pm    Post subject:
Reply with quote

bipinpeter wrote:
Expat you are great..(excuse me if you are not icon_biggrin.gif icon_biggrin.gif )
I didnt get this statement
Code:
INTERPRET "STM"AA"."AB "= STM0."AB       

What is this doing?

Aaaaaaaah shucks icon_redface.gif

INTERPRET is a pretty powerful statement in REXX
The parts within the double quotes are literals, and the parts outside can be substituted by the current value of other variables.

For example
when using a value of 3 for AA, and 4 for AB becomes
STM3.4 = STM0.4

It is a great statement, I suggest you try doing that piece using TRACE R or TRACE I to follow it through. It's a great statement to have in the armoury, but it took me a couple of goes to get it right
Code:

TRACE R
DO AA = 1 TO STM0.0                                                     
  DO AB = 1 TO STM0.0                                                   
    INTERPRET "STM"AA"."AB "= STM0."AB                                 
  END                                                                   
END       
TRACE O
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need to create file with Dynamic Name... kapil27 JCL & VSAM 4 Wed May 25, 2016 9:45 am
No new posts How to create/edit/update a new GDG V... karthikbalakumar8 JCL & VSAM 2 Fri Feb 05, 2016 6:35 pm
No new posts Syntax to create new tableBASE library Sumeendar IBM Tools 1 Tue Sep 15, 2015 6:25 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us