-
Notifications
You must be signed in to change notification settings - Fork 5
zip
wolfram77 edited this page Apr 13, 2020
·
26 revisions
Combines values from n arrays. 🏃 📼 📦 🌔
array.zip(xs, [fn], [ths]);
// xs: n arrays
// fn: map function ([...vs], i, x)
// ths: this argument
const array = require('extra-array');
array.zip([[1, 2, 3], [4, 5, 6]]);
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
array.zip([[1, 2, 3], [4, 5, 6], [0, 0, 0]]);
// [ [ 1, 4, 0 ], [ 2, 5, 0 ], [ 3, 6, 0 ] ]
array.zip([[1, 2, 3], [4, 5, 6]], ([a, b]) => a + b);
// [ 5, 7, 9 ]