Created
May 15, 2019 08:20
-
-
Save prontiol/9e544c8c8223e139fd174e0cae262c3e to your computer and use it in GitHub Desktop.
Cartesian Product Array
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 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