Created
March 30, 2016 22:28
-
-
Save Qata/1fda86c1fb09b9df1752b21f9251bc29 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
infix operator <<< { associativity right } | |
func <<< <A, B, C>(f: B -> C, g: A -> B) -> A -> C { | |
return composeBackward(f, g: g) | |
} | |
infix operator >>> { associativity left } | |
func >>> <A, B, C>(g: A -> B, f: B -> C) -> A -> C { | |
return composeForward(g, f: f) | |
} | |
func composeBackward <A, B, C>(f: B -> C, g: A -> B) -> A -> C { | |
return { x in f(g(x)) } | |
} | |
func composeForward <A, B, C>(g: A -> B, f: B -> C) -> A -> C { | |
return { x in f(g(x)) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment