• Transposes the rows and columns. Passing an infinite list will hang forever.

    Type Parameters

    • T

    Parameters

    • listList: List<List<T>>

      The source list of list.

    Returns List<List<T>>

    The transposed list.

    Examples

    import { fromArray, transpose, toArray } from "./list.ts";
    import { assertEquals } from "../deps.ts";

    const matrix = fromArray([fromArray([1, 2, 3]), fromArray([4, 5, 6])]);
    const transposed = transpose(matrix);
    const actual = toArray(transposed).map((col) => toArray(col));
    assertEquals(actual, [
    [1, 4],
    [2, 5],
    [3, 6],
    ]);

Generated using TypeDoc