Implement dropLast/takeLast

This commit is contained in:
2026-05-08 22:04:32 +02:00
parent 78ae570bcb
commit 98bd6b573e
28 changed files with 142 additions and 48 deletions

View File

@@ -3,8 +3,8 @@ import {error} from "../util/error";
export function reduce<T>(value: T[], accumulate: (acc: T, it: T) => T): T {
if (value.length === 0) error();
let acc = value[0];
for (let index = 1; index < value.length; index++) {
acc = accumulate(acc, value[index]);
for (let i = 1; i < value.length; i++) {
acc = accumulate(acc, value[i]);
}
return acc;
}