Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>set.fold

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

Reduce a ReadonlySet to a value O by iterating over the values of the set and collecting them with the reducing function.

Examples

Example 1

import * as S from "./set.ts";
import { pipe } from "./fn.ts";

const set = S.set(1, 2, 3, 4);

const result = pipe(
  set,
  S.fold((previous, current) => previous + current, 0),
); // 10

Parameters

foao: (o: O, a: A) => O
o: O

Returns

(ua: ReadonlySet<A>) => O