Implement dropLast/takeLast

This commit is contained in:
2026-05-08 22:04:32 +02:00
parent 88baaebcf5
commit 8feefc24a7
28 changed files with 142 additions and 48 deletions

View File

@@ -1,8 +1,8 @@
export function reduceOrNull<T>(value: T[], accumulate: (acc: T, it: T) => T): T | null {
if (value.length === 0) return null;
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;
}