Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(def a [[1 2 3] [4 5 6] [7 8 9]])
(def b (apply (partial mapv vector) a))
real :: a(n,m), b(m,n)
b = transpose(a)
const a = [[1, 2, 3], [4, 5, 6]]
const m = a[0].length
const b = Array.from({ length: m }, (_, n) => a.map(row => row[n]))
<T> T[][] transpose(T[][] a) {
int m, n, x = a[0].length, y = a.length;
Class<?> t = a.getClass().getComponentType()
.getComponentType();
T[][] b = (T[][]) newInstance(t, x, y);
for (m = 0; m < y; ++m)
for (n = 0; n < x; ++n)
b[n][m] = a[m][n];
return b;
}
local a = {}
for x = 1, n do
local t = {}
for y = 1, m do
t[y] = {x, y}
end
a[x] = t
end
local b = {}
for y = 1, m do
local t = {}
for x = 1, n do
t[x] = a[x][y]
end
b[y] = t
end
a = [[1,2], [3,4], [5,6]]
b = list(map(list, zip(*a)))
a = [[1,2], [3,4], [5,6]]
b = a.transpose