Skip to content

Instantly share code, notes, and snippets.

@aleph-naught2tog
Last active February 28, 2022 18:14
Show Gist options
  • Save aleph-naught2tog/38d03b8390bd759f9d2e4564bcb2c3e2 to your computer and use it in GitHub Desktop.
Save aleph-naught2tog/38d03b8390bd759f9d2e4564bcb2c3e2 to your computer and use it in GitHub Desktop.
export const cartesianProduct = (...colls: unknown[][]) =>
colls.reduce<unknown[][]>(
(products, coll) =>
products.flatMap((product) => coll.map((value) => [...product, value])),
[[]]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment