next | previous | forward | backward | up | top | index | toc | home

Set ** Set -- Cartesian product

Synopsis

Description

i1 : set {1,2} ** set {a,b,c}

o1 = set {(2, a), (1, b), (2, b), (1, c), (2, c), (1, a)}

o1 : Set
Suppose we wish to form the set of all triples with entries either in the set A below.
i2 : A = set{1,2}

o2 = set {1, 2}

o2 : Set
i3 : A ** A ** A

o3 = set {((1, 1), 1), ((1, 2), 1), ((1, 1), 2), ((2, 1), 1), ((2, 2), 1),
     ------------------------------------------------------------------------
     ((1, 2), 2), ((2, 1), 2), ((2, 2), 2)}

o3 : Set
To make this last a set of triples, splice each element together. Or, use Tally ^** ZZ.
i4 : (A ** A ** A)/splice

o4 = set {(1, 1, 1), (1, 1, 2), (1, 2, 1), (2, 1, 1), (2, 1, 2), (2, 2, 1),
     ------------------------------------------------------------------------
     (1, 2, 2), (2, 2, 2)}

o4 : Set
i5 : A^**3

o5 = set {(1, 1, 1), (1, 2, 1), (1, 1, 2), (2, 1, 1), (2, 2, 1), (1, 2, 2),
     ------------------------------------------------------------------------
     (2, 1, 2), (2, 2, 2)}

o5 : Set

See also