[plt-scheme] The problem with Scala (OT, sorry)
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.