Created
October 10, 2017 07:04
-
-
Save schabluk/ec1d440ef09774b9650c6b7c1ee25479 to your computer and use it in GitHub Desktop.
Cartesian of arrays
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) | |
cartesian.apply(this, [["A", "B"], ["C", "D"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment