la.scala._
More Detuplings

From #scala, more ideas on passing tuples to functions:

// the original is to use case
List((1,2),(3,4),(5,6)) map { case (x,y) => x + y }

// @dcsobral
List((1,2),(3,4),(5,6)) map (x => {val (a,b) = x; a + b})
// @paulp: x._1 + x._2 is shorter yet

// @paulp
List((1,2),(3,4),(5,6)) map Function.tupled(_ + _)
Comments (View)
blog comments powered by Disqus