What would be the most elegant way to turn any array of (equal length) rows into an array of columns?
Eg:
[1,2,3]
[4,5,6]
# To
[1,4]
[2,5]
[3,6]
This is what I have so far:
grid = [
[1,2,3]
[4,5,6]
]
grid2 = []
for i in grid[0]
grid2.push []
for row, y in grid
for el, x in row
grid2[x].push el
Is there maybe even a 1-liner that would do it?
CoffeeScript: