cartesian-product ( seq1 seq2 -- newseq )
Factor documentation > Factor handbook > The language > Collections > Sequence operations > Cartesian product operations
Prev:cartesian-map ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq )


Vocabulary
sequences

Inputs and outputs
seq1a sequence
seq2a sequence
newseqa new sequence of sequences of pairs


Word description
Outputs a sequence of all possible pairings of elements from the two sequences.

Examples
USING: prettyprint sequences ; { 1 2 } { 3 4 } cartesian-product .
{ { { 1 3 } { 1 4 } } { { 2 3 } { 2 4 } } }


Definition
IN: sequences

: cartesian-product ( seq1 seq2 -- newseq )
[ { } 2sequence ] cartesian-map ;