fold
import { fold } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/iterable.ts";Fold an Iterable into a single value using a reducer function and initial value.
@example
import * as I from "./iterable.ts";
const numbers = I.wrap(1, 2, 3, 4, 5);
const sum = I.fold((acc: number, n: number) => acc + n, 0)(numbers);
// 15
const concatenated = I.fold(
(acc: string, s: string) => acc + s,
""
)(I.wrap("hello", " ", "world"));
// "hello world"
function fold<A, O>(foldr: (accumulator: O, value: A) => O, initial: O): (ua: Iterable<A>) => O;