I have Scala code like this
var i = 1
for(e <- array) {
acc += e * i
i += 1
}
I need to multiply the first element in the array by 1, the next by 2, the next by 3 and so on adding it all into an accumulator. I feel that there is a better way of doing this in Scala, maybe even with folding?