Created
October 11, 2021 15:04
-
-
Save zakbarlow1995/a9fbed102b157312061fe21161cb3f1e to your computer and use it in GitHub Desktop.
Compose Functions - Returns a function that applies g to the result of f
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
precedencegroup CompositionPrecedence { | |
associativity: left | |
} | |
infix operator >>>: CompositionPrecedence | |
func >>><T, U, V>( | |
f: @escaping (T) -> U, | |
g: @escaping (U) -> V | |
) -> (T) -> V { | |
return { g(f($0)) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Heavily based on the ° operator from Swift 3-era
SwiftExperimental.swift
fileExample usage: