Created
September 3, 2018 19:48
-
-
Save d-date/3b754ad209620c4cc3d4aa4baf15a58b to your computer and use it in GitHub Desktop.
talking about currying #CodePiece #tryswiftnyc
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
// Currying: | |
// curry((A, B) _> C) -> ((A) -> ((B) -> C) | |
func map<A, B>( | |
_ f: @escaping (A) -> B) | |
-> ([A]) -> [B] { | |
return { xs in xs.map(f) } | |
} | |
map(incr) // (Array<Int>) -> Array<Int> | |
map(square) // (Array<Int>) -> Array<Int> | |
Array(1...10) |> map(incr) >>> map(square) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment