forked from waja/action-debian-package
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
|
import _curry3 from "./internal/_curry3.js";
|
||
|
/**
|
||
|
* Creates a new list out of the two supplied by applying the function to each
|
||
|
* equally-positioned pair in the lists. The returned list is truncated to the
|
||
|
* length of the shorter of the two input lists.
|
||
|
*
|
||
|
* @function
|
||
|
* @memberOf R
|
||
|
* @since v0.1.0
|
||
|
* @category List
|
||
|
* @sig ((a, b) -> c) -> [a] -> [b] -> [c]
|
||
|
* @param {Function} fn The function used to combine the two elements into one value.
|
||
|
* @param {Array} list1 The first array to consider.
|
||
|
* @param {Array} list2 The second array to consider.
|
||
|
* @return {Array} The list made by combining same-indexed elements of `list1` and `list2`
|
||
|
* using `fn`.
|
||
|
* @example
|
||
|
*
|
||
|
* const f = (x, y) => {
|
||
|
* // ...
|
||
|
* };
|
||
|
* R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']);
|
||
|
* //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')]
|
||
|
* @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)]
|
||
|
*/
|
||
|
|
||
|
var zipWith =
|
||
|
/*#__PURE__*/
|
||
|
_curry3(function zipWith(fn, a, b) {
|
||
|
var rv = [];
|
||
|
var idx = 0;
|
||
|
var len = Math.min(a.length, b.length);
|
||
|
|
||
|
while (idx < len) {
|
||
|
rv[idx] = fn(a[idx], b[idx]);
|
||
|
idx += 1;
|
||
|
}
|
||
|
|
||
|
return rv;
|
||
|
});
|
||
|
|
||
|
export default zipWith;
|