source: node_modules/ramda/es/zip.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1009 bytes
Line 
1import _curry2 from "./internal/_curry2.js";
2/**
3 * Creates a new list out of the two supplied by pairing up equally-positioned
4 * items from both lists. The returned list is truncated to the length of the
5 * shorter of the two input lists.
6 * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.1.0
11 * @category List
12 * @sig [a] -> [b] -> [[a,b]]
13 * @param {Array} list1 The first array to consider.
14 * @param {Array} list2 The second array to consider.
15 * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`.
16 * @example
17 *
18 * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]
19 * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]]
20 */
21
22var zip =
23/*#__PURE__*/
24_curry2(function zip(a, b) {
25 var rv = [];
26 var idx = 0;
27 var len = Math.min(a.length, b.length);
28
29 while (idx < len) {
30 rv[idx] = [a[idx], b[idx]];
31 idx += 1;
32 }
33
34 return rv;
35});
36
37export default zip;
Note: See TracBrowser for help on using the repository browser.