• Makes the list into an Option having head and rest.

    Type Parameters

    • T

    Parameters

    • list: List<T>

      The list to be un-constructed.

    Returns Option<[T, List<T>]>

    The optional of the pair of head and rest.

    Examples

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

    assertEquals(unCons(empty()), Option.none());
    assertEquals(
    unCons(singleton(42)),
    Option.some([42, empty()] as [number, List<number>]),
    );

Generated using TypeDoc