cartesian-product ( seq1 seq2 -- newseq )
Factor handbook » The language » Collections » Sequence operations » Cartesian product operations

Prev:cartesian-find ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... elt1 elt2 )


Vocabulary
sequences

Inputs
seq1a sequence
seq2a sequence


Outputs
newseqa new sequence of sequences of pairs


Word description
Outputs a sequence of all possible pairings of elements from the two sequences, using the type of seq2.

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

USING: prettyprint sequences ; "abc" "def" cartesian-product .
{ { "ad" "ae" "af" } { "bd" "be" "bf" } { "cd" "ce" "cf" } }


See also
cartesian-find, cartesian-each, cartesian-map, cartesian-product-as

Definition