setCartesian

setCartesian(set1, set2)

Try it yourself:


Create ordered pairs with setCartesian

setCartesian returns the Cartesian product of sets: every ordered pairing of one item from each input set. It is useful for grids, state spaces, and combining independent choices.

Example

The product of {a,b} and {1,2} contains (a,1), (a,2), (b,1), and (b,2). Use setSize to check cardinality; for finite sets, sizes multiply. combinations instead selects items from one collection.

Caveats

Order in each resulting tuple matters, and products grow quickly. Deduplicate inputs first with setDistinct if repeated values are not meaningful. Use setUnion when you need merged members, not paired members.

Try Set Cartesian in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions