Created
February 20, 2019 14:37
-
-
Save chemacortes/09fd2be32919e7aa824d5204a801fad9 to your computer and use it in GitHub Desktop.
Zip in typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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