Skip to main content
Module

x/fun/mod.ts>pair.fold

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function pair.fold
import { pair } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { fold } = pair;

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

Examples

Example 1

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

const result = pipe(
  pair(10, 20),
  fold(Math.max, Number.NEGATIVE_INFINITY),
); // 20

Parameters

foao: (
acc: O,
first: A,
second: B,
) => O
initial: O

Returns

(ua: Pair<A, B>) => O