I am not sure what is the difference between fold
and foldLeft
in Scala.
The question Difference between fold and foldLeft or foldRight? has an
It has been mentioned, but without example: If you want to allow parallelism with different data types for output and input, you could use aggregate:
Array("1","2","3").aggregate(0)(_ + _.toInt, _ + _)
The first function gets called first. Its results are then reduced with the second function. See Explanation of the aggregate scala function.