You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
351 B
Scala

object Pipelining {
implicit def toPipe[T](x : T) = new { def |> [U](f : T => U) = f(x) }
}
object PipelineTest extends App {
def minusTen(x: Int) = x-10
def timesTwo(x: Int) = x*2
assert(minusTen(timesTwo(3)) == -4)
val f = timesTwo _ andThen minusTen _
assert(f(3) == -4)
val g = timesTwo compose minusTen
assert(g(3) == -4)
}