Consider
val myseq = Array(1,2,3,4,5)
val mysum = myseq.foldLeft(0){_ + _}
Is there not a defined aggregator for sum(), count(), etc? Along the lines of:
import math.SomeLibraryClass._
val myseq = Array(1,2,3,4,5)
val mysum = myseq.foldLeft(0.0)(sum)
Or for the case of groups of (row-based) sums:
val rowSums = rows.map {sum}
(where by default the initial value is 0)
Update
So from the comments it appears there is no static (scala object-based) method for this and the correct syntax is:
val rowSums = rows.map {_.sum}
Here it is:
scala> val arr = Array(Array(1,2,3), Array(4,5,6))
arr: Array[Array[Int]] = Array(Array(1, 2, 3), Array(4, 5, 6))
scala> arr.map(_.sum)
res23: Array[Int] = Array(6, 15)
Array(1,2,3,4,5).sum