Created
June 13, 2014 18:44
-
-
Save FWeinb/b911452474bdc131facf to your computer and use it in GitHub Desktop.
Some fun with swift
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
// Pipe operator | |
operator infix | { | |
associativity left | |
} | |
// Use the left side as a parameter for the function on the right. | |
func |<T, R>(left:T, right:(T) -> (R) ) -> R { return right(left) } | |
var upperCase:(String) -> (String) = { $0.uppercaseString } | |
// Pipe "test" through upperCase | |
"test" | upperCase | |
// Use a curried Function | |
func incrementGenerator(by:Int)(inc:Int) -> (Int){ | |
return inc + by; | |
} | |
var incBy5 = incrementGenerator(5); | |
5 | incBy5 | incBy5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment