Skip to content

Instantly share code, notes, and snippets.

@chemacortes
Created February 20, 2019 14:37
Show Gist options
  • Save chemacortes/09fd2be32919e7aa824d5204a801fad9 to your computer and use it in GitHub Desktop.
Save chemacortes/09fd2be32919e7aa824d5204a801fad9 to your computer and use it in GitHub Desktop.
Zip in typescript
function zipWith<T, R, S>(as: T[], bs: R[], conv: (a: T, b: R) => S): S[] {
return as.map((a, i) => conv(a, bs[i]));
}
function zip<T, R>(as: T[], bs: R[]) {
return zipWith(as, bs, (a, b) => [a, b]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment