DRAFT: implement sequence
This commit is contained in:
11
src/sequence/maxOrNull.ts
Normal file
11
src/sequence/maxOrNull.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function maxOrNull(value: Iterable<number>): number | null {
|
||||
let max!: number;
|
||||
let found = false;
|
||||
for (const it of value) {
|
||||
if (found && it <= max) continue;
|
||||
max = it;
|
||||
found = true;
|
||||
}
|
||||
if (!found) return null;
|
||||
return max;
|
||||
}
|
||||
Reference in New Issue
Block a user