• Reverses the list. If the list is infinite, it will hang forever.

    Type Parameters

    • T

    Parameters

    • list: List<T>

      The source list.

    Returns List<T>

    The reversed list.

    Examples

    import { empty, fromArray, fromString, reverse, toArray } from "./list.ts";
    import { assertEquals } from "../deps.ts";

    assertEquals(reverse(empty()), empty());
    assertEquals(toArray(reverse(fromArray([1, 4, 2, 3]))), [3, 2, 4, 1]);
    assertEquals(toArray(reverse(fromString("hoge"))), ["e", "g", "o", "h"]);

Generated using TypeDoc