Add concat function (#2640)

This commit is contained in:
Aya Morisawa
2018-09-06 21:31:15 +09:00
committed by syuilo
parent f428372869
commit 3cace734c7
4 changed files with 14 additions and 8 deletions

View File

@ -6,6 +6,10 @@ 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);
export function concat<T>(xss: T[][]): T[] {
return ([] as T[]).concat(...xss);
}
export function intersperse<T>(sep: T, xs: T[]): T[] {
return concat(xs.map(x => [sep, x])).slice(1);
}