object CalculateDotProductOfTwoArrays_Scala {
private def calculateDotProduct(arr1: Array[Int], arr2: Array[Int]): Int = {
(arr1 zip arr2).map { case (a, b) => a * b }.sum
}
def main(args: Array[String]): Unit = {
val arr1 = Array(1, 4, 8, 9, 6)
val arr2 = Array(0, 7, 1, 3, 40)
println(s"Dot product = ${calculateDotProduct(arr1, arr2)}")
}
}
/*
run:
Dot product = 303
*/