Created
January 27, 2020 22:05
-
-
Save Kiwka/866041237e982f8af868a948bd65ff8c to your computer and use it in GitHub Desktop.
Cartesian product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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