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