# setCartesian() Function & Examples

Use the setCartesian() set function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## setCartesian

#### setCartesian(set1, set2)

Try it yourself:

```calculio
setCartesian([1, 2], [3, 4])
```

---

## 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](https://calcul.io/function/setSize/index.md) to check cardinality; for finite sets, sizes multiply. [combinations](https://calcul.io/function/combinations/index.md) instead selects items from one collection.

## Caveats

Order in each resulting tuple matters, and products grow quickly. Deduplicate inputs first with [setDistinct](https://calcul.io/function/setDistinct/index.md) if repeated values are not meaningful. Use [setUnion](https://calcul.io/function/setUnion/index.md) when you need merged members, not paired members.

[All functions](https://calcul.io/functions/index.md)
