transpose function

float[]string[]bool[] transpose(array)

array float[]string[]bool[] Array to be transposed.

Returns the transposed array.

The transpose function transposes an array of any type.

array =                ["a","b";
                        "c","d";
                        "e","f"]

transpose(array) =     ["a","c","e";
                        "b","d","f"]

Related

Examples

Zipping

const a = [1,1,1]
const b = [2,2,2]

const c = transpose([a ; b])            // [1,2 ; 1,2 ; 1,2]
const d = c[0 : size(c)-1]              // [1,2 , 1,2 , 1,2]

Two 1D arrays a and b are zipped, meaning a new array is constructed that contains the elements of both arrays in alternating order. To do so, a combination of a and b is transposed and linearly indexed.

const c = [transpose(a) , transpose(b)] // [1,2 ; 1,2 ; 1,2]
const d = c[0 : size(c)-1]              // [1,2 , 1,2 , 1,2]

Alternatively, the arrays can be transposed first and combined.