NOTE: I am on Scala 2.8—can that be a problem?
Why can\'t I use the fold function the same way as foldLeft or foldRight?
fold
foldLeft
foldRight
For your particular example you would code it the same way you would with foldLeft.
val ns = List(1, 2, 3, 4) val s0 = ns.foldLeft (0) (_+_) //10 val s1 = ns.fold (0) (_+_) //10 assert(s0 == s1)