We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Obtain cartesian product of arrays.
Similar: cartesianProduct, zip.
function cartesianProduct(xs, fm) // xs: arrays // fm: map function (vs, i)
const xarray = require('extra-array'); var x = [1, 2, 3]; var y = [10, 20, 30]; xarray.cartesianProduct([x, y]); // → [ // [ 1, 10 ], [ 1, 20 ], // [ 1, 30 ], [ 2, 10 ], // [ 2, 20 ], [ 2, 30 ], // [ 3, 10 ], [ 3, 20 ], // [ 3, 30 ] // ] xarray.cartesianProduct([x, y], ([a, b]) => a + b); // → [ // 11, 21, 31, 12, 22, // 32, 13, 23, 33 // ]