first map would give you each Array[T], second map would give you each element in that array.
given,
scala> val data = Array(Array(1,2),Array(-1,-2))
data: Array[Array[Int]] = Array(Array(1, 2), Array(-1, -2))
here's how you can apply function on each elem of second array,
scala> data.map(_.map(elem => if (elem > 0) 1 else -1 ))
res0: Array[Array[Int]] = Array(Array(1, 1), Array(-1, -1))
You can also use collect,
scala> data.map(_.collect{case elem if elem > 0 => 1 case _ => -1 })
res1: Array[Array[Int]] = Array(Array(1, 1), Array(-1, -1))
To simplify the same work using a function,
scala> def plusOneMinusOne(x: Int) = if (x > 0) 1 else -1
plusOneMinusOne: (x: Int)Int
scala> data.map(_.map(plusOneMinusOne))
res3: Array[Array[Int]] = Array(Array(1, 1), Array(-1, -1))
y =>before theif. Apart from that it should work fine.mapfunction with itself to give youmap2, which behaves as you require.