DRAFT: implement sequence

This commit is contained in:
2026-04-23 22:54:07 +02:00
parent 6c7fad267c
commit e2a18101cf
85 changed files with 1142 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
export function maxByOrNull<T>(value: Iterable<T>, transform: (it: T) => number): T | null {
let maxIt!: T;
let max!: number;
let found = false;
for (const it of value) {
const val = transform(it);
if (found && val <= max) continue;
maxIt = it;
max = val;
found = true;
}
if (!found) return null;
return maxIt;
}