Answers for "javascript cartesian product"

0

javascript cartesian product

let f = (a, b) => [].concat(...a.map(a => b.map(b => [].concat(a, b))));
let cartesian = (a, b, ...c) => b ? cartesian(f(a, b), ...c) : a;
Posted by: Guest on February-20-2021
0

javascript cartesian product

const cartesian =
  (...a) => a.reduce((a, b) => a.flatMap(d => b.map(e => [d, e].flat())));
Posted by: Guest on February-20-2021

Code answers related to "javascript cartesian product"

Code answers related to "Javascript"

Browse Popular Code Answers by Language