-
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. [: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 ]
- Data.List.zipWith(): Haskell
- _.zipWith: lodash
- zip: Python
- zip: Ruby
- List-Extra.zip(): elm [:running:]: https://npm.runkit.com/@extra-array/zip [:package:]: https://www.npmjs.com/package/@extra-array/zip [:moon:]: https://www.npmjs.com/package/@extra-array/zip.min [:vhs:]: https://asciinema.org/a/319471