Element-wise sum of arrays in Scala -


how compute element-wise sum of arrays?

val = new array[int](5) val b = new array[int](5) // assign values // desired output: array -> [a(0)+b(0), a(1)+b(1), a(2)+b(2), a(3)+b(3), a(4)+b(4)]  a.zip(b).flatmap(_._1+_._2) 

missing parameter type expanded function

try:

a.zip(b).map { case (x, y) => x + y } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -