DRAFT: implement sequence
This commit is contained in:
7
src/sequence/fold.ts
Normal file
7
src/sequence/fold.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function fold<T, R>(value: Iterable<T>, initial: R, accumulate: (acc: R, it: T) => R): R {
|
||||
let acc = initial;
|
||||
for (const it of value) {
|
||||
acc = accumulate(acc, it);
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
Reference in New Issue
Block a user