This commit is contained in:
Aya Morisawa
2018-09-06 02:16:08 +09:00
committed by syuilo
parent b5ff2abdb9
commit 395cfa6108
9 changed files with 25 additions and 9 deletions

7
src/prelude/array.ts Normal file
View 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);
}