Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

fold

import { fold } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/pair.ts";

Reduces a pair with an initial value, also passing the second value into the foldr as well.

@example
import { pair, fold } from "./pair.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  pair(10, 20),
  fold(Math.max, Number.NEGATIVE_INFINITY),
); // 20
function fold<A, B, O>(foao: (
acc: O,
first: A,
second: B,
) => O
, initial: O): (ua: Pair<A, B>) => O;
§
fold<A, B, O>(foao: (acc: O, first: A, second: B) => O, initial: O): (ua: Pair<A, B>) => O
[src]

§Type Parameters

§Parameters

§
foao: (acc: O, first: A, second: B) => O
[src]
§
initial: O
[src]

§Return Type

§
(ua: Pair<A, B>) => O
[src]