Loryn Jenkins <lor...@gmail.com> writes: > Hi > > I'm attempting to adapt the code for cartesian-product into > 2cartesian-product, in order to produce the cartesian product of 3 > sequences.
I'm afraid I haven't got time to properly look at your code, but don't forget that the cartesian product is associative. That is: (A × B) × C = A × (B × C) and either of these two makes sense for the cartesian product of three sets. In your case, this means that { 1 2 } { 3 4 } { 5 6 } cartesian-product cartesian-product will almost do what you want (it's the right hand side of the equation above). But the nesting won't be quite right, since you'll have elements that look like { 1 { 3 5 } }, so you can fix that with something like [ first2 first2 ] map I think (untested). Rupert
pgpmeJ_yPTdeT.pgp
Description: PGP signature
------------------------------------------------------------------------------ Own the Future-Intel® Level Up Game Demo Contest 2013 Rise to greatness in Intel's independent game demo contest. Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk