Skip to content

Instantly share code, notes, and snippets.

@H-Ghadirian
Created June 23, 2018 08:55
Show Gist options
  • Save H-Ghadirian/901f3adbfddba02a5a1c89e33d512ad8 to your computer and use it in GitHub Desktop.
Save H-Ghadirian/901f3adbfddba02a5a1c89e33d512ad8 to your computer and use it in GitHub Desktop.
Curry Function
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