Hi! I wonder if I can get a critique of the following two words:
: combine-single ( obj seq -- newseq ) tuck length swap <repetition>
swap zip ;
: combine-multiple ( seq seq -- newseq ) [ combine-single ] curry map
concat [ flatten ] map ;
So, { 1 2 3 4 } dup dup combine-multiple combine-multiple will
produce the following sequence:
{
{ 1 1 1 } { 1 1 2 } { 1 1 3 } { 1 2 1 } { 1 2 2 } { 1 2
3 } { 1 3 1 } { 1 3 2 } { 1 3 3 }
{ 2 1 1 } { 2 1 2 } { 2 1 3 } { 2 2 1 } { 2 2 2 } { 2 2
3 } { 2 3 1 } { 2 3 2 } { 2 3 3 }
{ 3 1 1 } { 3 1 2 } { 3 1 3 } { 3 2 1 } { 3 2 2 } { 3 2
3 } { 3 3 1 } { 3 3 2 } { 3 3 3 }
}
I have just started using Factor, and I'm sure I'm missing words that
will do this more elegantly.
Thanks,
rajat
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk