Skip to content
wolfram77 edited this page Apr 13, 2020 · 26 revisions

Combines values from n arrays. [:running:] [:vhs:] [:package:] [:moon:]

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 ]

references

Clone this wiki locally