-
Notifications
You must be signed in to change notification settings - Fork 1
zip
Subhajit Sahu edited this page May 17, 2020
·
32 revisions
Combines values from iterables. 🏃 [:vhs:] 📦 🌔 📒
Similar: cartesianProduct, zip.
iterable.zip(xs, [fm], [ft], [vd]);
// xs: iterables
// fm: map function (vs, i, xs)
// ft: till function (dones) (some)
// vd: default value
const iterable = require('extra-iterable');
var x = [1, 2, 3];
var y = [4, 5];
[...iterable.zip([x, y])];
// [ [ 1, 4 ], [ 2, 5 ] ] (shortest)
[...iterable.zip([x, y], ([a, b]) => a + b)];
// [ 5, 7 ]
[...iterable.zip([x, y], null, iterable.some)];
// [ [ 1, 4 ], [ 2, 5 ] ] (shortest)
[...iterable.zip([x, y], null, iterable.every, 0)];
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (longest)
[...iterable.zip([x, y], null, iterable.head, 0)];
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (first)