• Counts elements in the list. If the list is infinite, it hangs forever.

    Type Parameters

    • T

    Parameters

    • list: List<T>

      The finite list to count the length.

    Returns number

    The number of elements in the list.

    Examples

    import { empty, fromString, length, singleton } from "./list.ts";
    import { assertEquals } from "../deps.ts";

    assertEquals(length(empty()), 0);
    assertEquals(length(singleton(42)), 1);
    assertEquals(length(fromString("foo")), 3);

Generated using TypeDoc