Created
January 4, 2015 14:31
-
-
Save ryoppy/f11b34d5a0329276abd8 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
implicit class RichFunction1[A, B](val f: A => B) extends AnyVal { | |
def |>[C](g: B => C) = f andThen g | |
def <|[C](g: C => A) = f compose g | |
} | |
val plus = (_: Int) + 1 | |
val minus = (_: Int) - 1 | |
val suffix = (_: Int) + "!" | |
val f = plus |> minus |> suffix | |
println(f(1)) | |
println(f(2)) | |
val g = suffix <| minus <| plus | |
println(g(1)) | |
println(g(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment