parent
b5ff2abdb9
commit
395cfa6108
9 changed files with 25 additions and 9 deletions
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue