Package: effect
Module: HashSet
Reduces the HashSet to a single value by iterating through the values and applying an accumulator function.
Example (Reducing HashSet values)
import { HashSet } from "effect"
const numbers = HashSet.make(1, 2, 3, 4, 5)
const sum = HashSet.reduce(numbers, 0, (acc, n) => acc + n)
console.log(sum) // 15
const strings = HashSet.make("a", "b", "c")
const concatenated = HashSet.reduce(strings, "", (acc, s) => acc + s)
console.log(concatenated) // Order may vary: "abc", "bac", etc.
Signature
declare const reduce: { <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => U; <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): U; }
Since v2.0.0