Created
May 3, 2020 04:32
-
-
Save eMdOS/d1114c69e02b64888cad5daee0fc92de to your computer and use it in GitHub Desktop.
This file contains 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
func compose<A, B, C>( | |
f: @escaping (A) -> B, // f: A -> B | |
g: @escaping (B) -> C // g: B -> C | |
) -> (A) -> C { // h: A -> C = g • f | |
return { a in | |
g(f(a)) // g • f | |
} | |
} | |
// ... then | |
compose(f: Double.init(_:), g: String.init(_:))(1) | |
// which under the hood is the same that: | |
String(Double(Int(1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment