Skip to main content
Module

x/ahh/mod.ts>I.fold

Idiomatic type-safety functions.
Go to Latest
method I.fold
import { I } from "https://deno.land/x/ahh@v0.10.1/mod.ts";

Consumes an Iterator and folds every item into an accumulator using f.

Examples

import { I } from "./mod.ts";

const iter = I.iter([1, 2, 3]);

console.log(I.fold(iter, 0, (a, b) => a + b)); // 6
console.log(iter.next()); // undefined

Parameters

iter: Iterator<T>
init: U
f: (_: U, _1: T) => U