7
src/prelude/array.ts
Normal file
7
src/prelude/array.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function countIf<T>(f: (x: T) => boolean, xs: T[]): number {
|
||||
return xs.filter(f).length;
|
||||
}
|
||||
|
||||
export function count<T>(x: T, xs: T[]): number {
|
||||
return countIf(y => x === y, xs);
|
||||
}
|
Reference in New Issue
Block a user