1 | var _curry2 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry2");
|
4 | /**
|
5 | * Creates a new list out of the two supplied by pairing up equally-positioned
|
6 | * items from both lists. The returned list is truncated to the length of the
|
7 | * shorter of the two input lists.
|
8 | * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`.
|
9 | *
|
10 | * @func
|
11 | * @memberOf R
|
12 | * @since v0.1.0
|
13 | * @category List
|
14 | * @sig [a] -> [b] -> [[a,b]]
|
15 | * @param {Array} list1 The first array to consider.
|
16 | * @param {Array} list2 The second array to consider.
|
17 | * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`.
|
18 | * @example
|
19 | *
|
20 | * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]
|
21 | * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]]
|
22 | */
|
23 |
|
24 |
|
25 | var zip =
|
26 | /*#__PURE__*/
|
27 | _curry2(function zip(a, b) {
|
28 | var rv = [];
|
29 | var idx = 0;
|
30 | var len = Math.min(a.length, b.length);
|
31 |
|
32 | while (idx < len) {
|
33 | rv[idx] = [a[idx], b[idx]];
|
34 | idx += 1;
|
35 | }
|
36 |
|
37 | return rv;
|
38 | });
|
39 |
|
40 | module.exports = zip; |
\ | No newline at end of file |