views:

78

answers:

2

If I have a 2d array such as

smallArray = [[1,0],[0,1]]

and I have a larger 2d array such as

largeArray = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]

What would be the most efficient way to "tile" the smaller array in the bigger one so that the bigger array would end up looking like

largeArray = [[1,0,1,0],[0,1,0,1],[1,0,1,0],[0,1,0,1]]

A complicated sequence of for loops?

+2  A: 

In AS3,an array doesn't care what the types of its elements are, right? Why not just largeArray.push(smallArrayN). And if efficiency is a consideration, you should probably be using vectors, as they are like arrays only extremely faster.

Mark
A: 

Yes, it requires nested for-loop because you are merging small array elements to large array recursively. When each element is updated in array , we use loops or nested loops.

Muhammad Irfan