import { curryN } from "@unboxing/function"; interface Zip { (list1: ArrayLike, list2: ArrayLike): Array<[U, V]>; (list1: ArrayLike): (list2: ArrayLike) => Array<[U, V]>; } /** * Creates a new list out of the two supplied by pairing up equally-positioned * items from both lists. The returned list is truncated to the length of the * shorter of the two input lists. */ export const zip = curryN(2, (a: ArrayLike = [], b: ArrayLike = []) => { const len = Math.min(a.length, b.length); const result: Array<[U, V]> = new Array(len); for (let i = 0; i < len; i++) { result[i] = [a[i], b[i]]; } return result; }) as Zip