Created
October 4, 2017 15:16
-
-
Save zyuanming/d7267f46e972d65ce70e648b054ce20a to your computer and use it in GitHub Desktop.
UIKonf 2017 – Day 2 – Brandon Williams & Lisa Luo – Anything you can do, I can do better
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
| infix operator >>> : MultiplicationPrecedence | |
| func >>> <A, B, C>(f: @escaping (A) -> B, | |
| g: @escaping (B) -> C) -> (A) -> C { | |
| return { g(f($0)) } | |
| } | |
| func incr(_ x: Int) -> Int { return x + 1 } | |
| func square(_ x: Int) -> Int { return x * x } | |
| let f = incr >>> square >>> incr | |
| Array(1...10).map(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment