Last active
August 29, 2015 14:02
-
-
Save hallski/7733cf0c68b82fcf20a1 to your computer and use it in GitHub Desktop.
Simple implementation of a partial function in Swift
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 partial<T, S, A>(f: ((T, S) -> A), t : T) -> (S -> A) { | |
return { (s:S) in | |
return f(t, s) | |
} | |
} | |
// Bind the first argument | |
let addTwenty = partial(+, 20) | |
// Call the new function | |
addTwenty(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment