Created
June 23, 2018 08:55
-
-
Save H-Ghadirian/901f3adbfddba02a5a1c89e33d512ad8 to your computer and use it in GitHub Desktop.
Curry Function
This file contains 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
func curry<A, B, C>(f: (A, B) -> C) -> A -> B -> C { | |
return { a in { b in f(a, b) } } | |
} | |
let add = curry(+) | |
let xs = 1...100 | |
let x = xs.map(add(2)) // [3, 4, 5, 6, etc] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment