Skip to content

Instantly share code, notes, and snippets.

@Kiwka
Created January 27, 2020 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kiwka/866041237e982f8af868a948bd65ff8c to your computer and use it in GitHub Desktop.
Save Kiwka/866041237e982f8af868a948bd65ff8c to your computer and use it in GitHub Desktop.
Cartesian product
const f = (a, b) => [].concat(...a.map(d => b.map(e => [].concat(d, e))));
const cartesian = (a, b, ...c) => (b ? cartesian(f(a, b), ...c) : a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment