Re: Creating all combinations of a dynamic sequence
- Posted by jimcbrown (admin) Jul 02, 2010
- 1186 views
cp said...
I have a sequence that looks like
sMySeq = {{a1,a2},{b1,b2},{c1,c2}}
I need to create a sequence of all possible combinations of the elements that looks like
sCombos = {{a1,b1,c1},{a1,b1,c2},{a1,b2,c1},{a1,b2,c2},{a2,b1,c1},{a2,b1,c2}.....
I know I can do this with nested for loops but sMySeq may contain 2 sequences or 20 or any number. Is there a way to do this dynamically regardless of how many sequences sMySeq contains.
Thanks
Uh... a for loop? Why can't a for loop handle this dynamically?