• transpose a 2D array (row-major to column-major, or vice versa)

    Type Parameters

    • T

    Parameters

    Returns Array2DColMajor<T>

    the transposed 2D array

    Example

    const arr2d: Array2DRowMajor<T> = [
    [1 , 2 , 3 , 4 , 5 ],
    [6 , 7 , 8 , 9 , 10],
    [11, 12, 13, 14, 15],
    ]
    const arr2d_transposed: Array2DColMajor<number> = transposeArray2D(arr2d)
    arr2d_transposed === [
    [1 , 6 , 11],
    [2 , 7 , 12],
    [3 , 8 , 13],
    [4 , 9 , 14],
    [5 , 10, 15],
    ]
  • transpose a 2D array (row-major to column-major, or vice versa)

    Type Parameters

    • T

    Parameters

    Returns Array2DRowMajor<T>

    the transposed 2D array

    Example

    const arr2d: Array2DRowMajor<T> = [
    [1 , 2 , 3 , 4 , 5 ],
    [6 , 7 , 8 , 9 , 10],
    [11, 12, 13, 14, 15],
    ]
    const arr2d_transposed: Array2DColMajor<number> = transposeArray2D(arr2d)
    arr2d_transposed === [
    [1 , 6 , 11],
    [2 , 7 , 12],
    [3 , 8 , 13],
    [4 , 9 , 14],
    [5 , 10, 15],
    ]

Generated using TypeDoc