Combines values from arrays.
npm install @extra-array/zipCombines values from arrays.
:package:
:smiley_cat:
:running:
:vhs:
:moon:
:scroll:
:newspaper:
:blue_book:
> Similar: [cartesianProduct], [zip].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
``javascript`
array.zip(xs, [fm], [ft], [vd]);
// xs: arrays
// fm: map function (vs, i)
// ft: till function (dones) (some)
// vd: default value
`javascript
const array = require("extra-array");
var x = [1, 2, 3];
var y = [4, 5];
array.zip([x, y]);
// [ [ 1, 4 ], [ 2, 5 ] ] (shortest)
array.zip([x, y], ([a, b]) => a + b);
// [ 5, 7 ]
array.zip([x, y], null, array.some);
// [ [ 1, 4 ], [ 2, 5 ] ] (shortest)
array.zip([x, y], null, array.every, 0);
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (longest)
array.zip([x, y], null, array.head, 0);
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (first)
``
- Data.List.zipWith: Haskell
- List-Extra.zip: elm
- zip: Python
- itertools.zip_longest: Python
- zip: Ruby
- _.zip: lodash
- _.zipWith: lodash
- Array.zip: sugarjs
[cartesianProduct]: https://github.com/nodef/extra-array/wiki/cartesianProduct
[zip]: https://github.com/nodef/extra-array/wiki/zip