How to apply function to each tuple of a multi-dimensional array in Scala?

(UPDATE: removed the for comprehension code which was not correct - it returned a one dimensional array) def foo(t: (Int, Int)): (Int, Int) = (t. _1 + 1, t. _2 + 1) array.

Map{_. Map{foo}} To apply to a mutable array val array = ArrayBuffer. Tabulate(2,2)((x,y) => (0,0)) for (sub ZipWithIndex) sub(i) = foo(cell.

_1, cell. _2).

Given that the for comprehensions corresponds to flatMap/map, either it or the following example is incorrect. – Daniel C. Sobral Oct 12 '10 at 16:46 You're right.

I removed the code – IttayD Oct 12 '10 at 17:41.

Scala> val array = Array. Foreach(i => i. //Takes two ints and return a Tuple2.

Not sure this is the best approach. Foreach(i => i.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions