• Folds the elements of list from right.

    Applying foldR to infinite structures usually doesn't terminate. But it may still terminate under one of the following conditions:

    • the folding function is short-circuiting,
    • the folding function is lazy on its second argument.

    Type Parameters

    • T

    • U

    Parameters

    • f: ((a) => ((b) => U))

      The fold operation.

        • (a): ((b) => U)
        • Parameters

          • a: T

          Returns ((b) => U)

            • (b): U
            • Parameters

              • b: U

              Returns U

    Returns ((init) => ((list) => U))

    The folded value.

    Examples

    import { foldR, fromString } from "./list.ts";
    import { assertEquals } from "../deps.ts";

    assertEquals(
    foldR((x: string) => (y: string) => x + y)("")(fromString("hoge")),
    "hoge",
    );
    assertEquals(
    foldR((x: string) => (y: string) => y + x)("")(fromString("")),
    "",
    );
      • (init): ((list) => U)
      • Parameters

        • init: U

        Returns ((list) => U)

          • (list): U
          • Parameters

            Returns U

Generated using TypeDoc