I want to calculate the mean of every two consecutive elements in array a, and return a new array. The parameter type T can be any of the numerical type such as Byte, Short, Int, Float, and Double. I don't know how to make it work. Thanks in advance!
def center[T](a: Array[T]): Array[T] = {
for (i <- 0 until a.size - 1) yield (a(i) + a(i + 1)) / 2
}