The cartesian product of two sequences is a sequence of all pairs where the first element of each pair is from the first sequence, and the second element of each pair is from the second sequence. The number of elements in the cartesian product is the product of the lengths of the two sequences.

Combinators which pair every element of the first sequence with every element of the second:

Computing the cartesian product of two sequences:

Combinators which pair every element of the first sequence with every element of the second:

cartesian-each ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) -- ... )

cartesian-map ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq )

Computing the cartesian product of two sequences:

cartesian-product ( seq1 seq2 -- newseq )