There was an error while loading. Please reload this page.
List cartesian product of objects.
Similar: cartesianProduct, zip.
function cartesianProduct(xs, fm) // xs: objects // fm: map function (vs)
const object = require('extra-object'); var x = {a: 1, b: 2, c: 3}; var y = {d: 10, e: 20}; [...object.cartesianProduct([x, y])]; // → [ // → { a: 1, d: 10 }, // → { a: 1, e: 20 }, // → { b: 2, d: 10 }, // → { b: 2, e: 20 }, // → { c: 3, d: 10 }, // → { c: 3, e: 20 } // → ] [...object.cartesianProduct([x, y], a => object.max(a))]; // → [ 10, 20, 10, 20, 10, 20 ]