showing results for - "javascript cartesian product"
Beckett
24 Nov 2016
1let f = (a, b) => [].concat(...a.map(a => b.map(b => [].concat(a, b))));
2let cartesian = (a, b, ...c) => b ? cartesian(f(a, b), ...c) : a;
3
Mattia
02 Nov 2019
1const cartesian =
2  (...a) => a.reduce((a, b) => a.flatMap(d => b.map(e => [d, e].flat())));
3