- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1
 
cartesianProduct
        Subhajit Sahu edited this page Feb 3, 2021 
        ·
        15 revisions
      
    List cartesian product of iterables.
Similar: cartesianProduct, zip.
function cartesianProduct(xs, fm)
// xs: iterables
// fm: map function (vs, i)const xiterable = require('extra-iterable');
var x = [1, 2, 3];
var y = [10, 20, 30];
[...xiterable.cartesianProduct([x, y])];
// → [
//   [1, 10], [1, 20],
//   [1, 30], [2, 10],
//   [2, 20], [2, 30],
//   [3, 10], [3, 20],
//   [3, 30]
//]
[...xiterable.cartesianProduct([x, y], ([a, b]) => a + b)];
// → [
//   11, 21, 31, 12, 22,
//   32, 13, 23, 33
//]