Created
August 24, 2015 07:50
-
-
Save macbaszii/6f2c1fa96d22b00ac06f 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
| extension Optional { | |
| func apply<U>(f: (T -> U)?) -> U? { | |
| switch f { | |
| case .Some(let someF): return self.map(someF) | |
| case .None: return .None | |
| } | |
| } | |
| } | |
| extension Array { | |
| func apply<U>(fs: [Element -> U]) -> [U] { | |
| var result = [U]() | |
| for f in fs { | |
| for element in self.map(f) { | |
| result.append(element) | |
| } | |
| } | |
| return result | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment