Skip to content

Instantly share code, notes, and snippets.

@prontiol
Created May 15, 2019 08:20
Show Gist options
  • Save prontiol/9e544c8c8223e139fd174e0cae262c3e to your computer and use it in GitHub Desktop.
Save prontiol/9e544c8c8223e139fd174e0cae262c3e to your computer and use it in GitHub Desktop.
Cartesian Product Array
const product = (...sets) =>
sets.reduce((acc, set) =>
[].concat(...acc.map(x => set.map(y => [ ...x, y ]))),
[[]]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment