> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# cartesianProduct (Functional Programming) es-toolkit

Creates a function that computes the Cartesian product with the piped array. Use it with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

```typescript
const result = pipe(array, cartesianProduct(...arrs));
```

::: info

Prefer the original es-toolkit [`cartesianProduct`](https://massaman.dev/reference/array/cartesianProduct.md) in ordinary code. Use this `fp` variant when composing transformations with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

:::

## Usage

`cartesianProduct` returns every possible tuple formed by taking one value from the piped array and one value from each configured array. The rightmost array advances fastest.

```typescript
import { cartesianProduct, pipe } from 'es-toolkit/fp';

pipe([1, 2], cartesianProduct(['a', 'b'])); // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]

pipe([], cartesianProduct(['a', 'b'])); // => []
```

#### Parameters


arrsArray<readonly T[]>required

The arrays to include after the piped array.

#### Returns

A function that maps the piped array to the Cartesian-product tuples.

```typescript
(array: readonly T[]) => T[][]
```


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/fp/reference/cartesianProduct.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
