Created
July 13, 2015 01:42
-
-
Save bartcone/ce9e729d1b89bb928175 to your computer and use it in GitHub Desktop.
Swift: Curry && Uncurry
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: A) -> (B -> C) in | |
return { (b: B) -> C in | |
return f(a,b) | |
} | |
} | |
} | |
func uncurry <A, B, C> (f: A -> B -> C) -> (A, B) -> C { | |
return { (a: A, b: B) -> C in | |
return f(a)(b) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment