import { Arity2, curry } from '@typed/lambda' export const reduce: { (reducer: Arity2, seed: B, iterable: Iterable): Promise (reducer: Arity2, seed: B): (iterable: Iterable) => Promise (reducer: Arity2): { (seed: B, iterable: Iterable): Promise (seed: B): (iterable: Iterable) => Promise } } = curry(__reduce) as any function __reduce(reducer: Arity2, seed: B, iterable: Iterable): B { let accumulator = seed for (const x of iterable) { accumulator = reducer(accumulator, x) } return accumulator }