In Scala, when I have this expression
f1 ( f2 ( f3 (p)))
Is there a way that I can use something like in
F#
p |> f3 |> f2 |> f1
or Clojure?
(->> p f3 f2 f1)
There is no equivalent to F#'s pipe operator in Scala...
... but there is one in the scalaz library. And it's also named |>
. They nicknamed it the "thrush operator".
import scalaz._
import Scalaz._
def f(s: String) = s.length
"hi" |> f
Here's the scaladoc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With