18 lines
		
	
	
	
		
			351 B
		
	
	
	
		
			Scala
		
	
	
	
	
	
			
		
		
	
	
			18 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)
 | 
						|
}
 |