[plt-scheme] The problem with Scala (OT, sorry)

From: Thomas Chust (chust at web.de)
Date: Thu Mar 4 20:34:13 EST 2010

2010/3/4 John Clements <clements at brinckerhoff.org>:
> [...]
> scala> List(3,4,5).foldLeft[List[Int]](List())({(x,y)=>y::x})
> res6: List[Int] = List(5, 4, 3)
> [...]

Hello,

you can also put a type annotation on the start value of the folding
operation itself to direct type inference:

  scala> (List[Int]() /: List(3, 4, 5)) { (x, y) => y :: x }
  res0: List[Int] = List(5, 4, 3)

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


Posted on the users mailing list.