Last active
September 23, 2015 07:35
-
-
Save pgorzelany/08f086fd21f12036f86b to your computer and use it in GitHub Desktop.
Basic pipes implementation in 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
| /* Used for piping the results of consecutive functions | |
| */ | |
| infix operator |> { associativity left precedence 140 } | |
| func |> <I, O>(input: I, transform: (I) -> O) -> O { | |
| return transform(input) | |
| } | |
| let root = 4 + 3 * 4 |> {Double($0)} |> sqrt | |
| print(root) // 4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment