Hyperlinkv0.8.0-beta.28

HashSet

HashSet.reduceconsteffect/HashSet.ts:599
<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

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.
folding
Source effect/HashSet.ts:5997 lines
export 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
} = Dual.dual<
  <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
>(3, internal.reduce)
Referenced by 1 symbols