• Concatenates two lists.

    Type Parameters

    • T

    Parameters

    • left: List<T>

      The left-side to concatenate.

    Returns ((right) => List<T>)

    The concatenated list.

    Examples

    import { List, empty, plus, singleton, toIterator, unCons } from "./list.ts";
    import * as Option from "./option.ts";
    import { assertEquals } from "../deps.ts";

    const singleZero = singleton(0);
    const emptiness = empty<number>();

    const iter = toIterator(plus(singleZero)(singleZero));
    assertEquals(iter.next(), { value: 0, done: false });
    assertEquals(iter.next(), { value: 0, done: false });
    assertEquals(iter.next(), { value: undefined, done: true });
    assertEquals(
    unCons(plus(singleZero)(emptiness)),
    Option.some([0, empty()] as [number, List<number>]),
    );
    assertEquals(
    unCons(plus(emptiness)(singleZero)),
    Option.some([0, empty()] as [number, List<number>]),
    );
    assertEquals(unCons(plus(emptiness)(emptiness)), Option.none());

Generated using TypeDoc