Computes the cartesian product of the provided sequences while preserving source order.
Element type produced by each source iterable.
Iterable of iterables for which to compute the cartesian product.
A deferred iterable yielding every ordered combination of the source sequences.
const combinations = [ ...cartesian([ ["A", "B"], [1, 2], ].map((arr) => arr.values())),].map((combo) => [...combo]);console.log(combinations); // [["A", 1], ["A", 2], ["B", 1], ["B", 2]] Copy
const combinations = [ ...cartesian([ ["A", "B"], [1, 2], ].map((arr) => arr.values())),].map((combo) => [...combo]);console.log(combinations); // [["A", 1], ["A", 2], ["B", 1], ["B", 2]]
Computes the cartesian product of the provided sequences while preserving source order.