Add concat function (#2640)
This commit is contained in:
parent
f428372869
commit
3cace734c7
4 changed files with 14 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue