This commit is contained in:
Aya Morisawa
2018-09-06 02:28:04 +09:00
committed by syuilo
parent ade7e62836
commit e8948452fd
2 changed files with 5 additions and 4 deletions

View File

@ -5,3 +5,7 @@ export function countIf<T>(f: (x: T) => boolean, xs: T[]): number {
export function count<T>(x: T, xs: T[]): number {
return countIf(y => x === y, xs);
}
export function intersperse<T>(sep: T, xs: T[]): T[] {
return [].concat(...xs.map(x => [sep, x])).slice(1);
}