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
, contrary to foldRight
and foldLeft
, does not offer any guarantee about the order in which the elements of the collection will be processed. You'll probably want to use fold
, with its more constrained signature, with parallel collections, where the lack of guaranteed processing order helps the parallel collection implements folding in a parallel way. The reason for changing the signature is similar: with the additional constraints, it's easier to make a parallel fold.