Last active
August 29, 2015 14:12
-
-
Save mbrandonw/2b43aabb0c62ca9d36ca to your computer and use it in GitHub Desktop.
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
| func unit <A, B> (f: A -> () -> B) -> (A -> B) { | |
| return { a in | |
| return f(a)() | |
| } | |
| } |
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
| extension Int { | |
| func square () -> Int { | |
| return self * self | |
| } | |
| } | |
| Int.square(2)() // 4 | |
| unit(Int.square)(2) // 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment