Cartesian Product

Build every ordered pair picking one element from each of two lists.

Description

Generate every ordered pair formed by choosing one number from each of two lists.

The Cartesian product combines two lists exhaustively. If the first list has m entries and the second has n entries, the result contains m × n ordered pairs. This is useful for parameter grids, coordinate construction, and enumerating two independent choices.

When to use Cartesian Product Calculator

  • Build a two-parameter test grid
  • Generate coordinates from separate x and y values
  • Enumerate every pairing between two numeric lists

How the calculation works

For each value in the first list, the calculator pairs it with every value in the second list. Input order is preserved: all pairs for the first left-hand value appear before pairs for the next one. Repeated values remain repeated.

Interpreting the result

Each output row is `[firstValue, secondValue]`. The row count is the product of the two input lengths. Ordered pairs are directional: `[1, 2]` and `[2, 1]` represent different combinations when both occur.

Important limitations

  • Both lists must be non-empty.
  • Output size grows multiplicatively, so modest input lists can create many rows.
  • This tool creates pairs only; use permutations or combinations for selections from one list.
Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies