I tried to use zip
and map
to create zipwith
function like:
def zipWithArray(f : (Int, Int) => Int)(xs : Array[Int], ys: Array[Int]) : Array[Int] = xs zip ys map f
But I got the following compile error:
type mismatch;
found : (Int, Int) => Int
required: ((Int, Int)) => ?
I know the zip
is (Array[Int], Array[Int])=>Array((Int, Int))
, so the f
should be (Int, Int) => Int
and the total result is Array[Int]
. Could anyone help to explain the case please. Thanks a lot.