From 3cace734c70c752c57ed9a0057aef4d7ef788528 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Thu, 6 Sep 2018 21:31:15 +0900 Subject: Add concat function (#2640) --- src/prelude/array.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/prelude/array.ts') diff --git a/src/prelude/array.ts b/src/prelude/array.ts index aee17640ed..9a3c266d6d 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -6,6 +6,10 @@ export function count(x: T, xs: T[]): number { return countIf(y => x === y, xs); } +export function concat(xss: T[][]): T[] { + return ([] as T[]).concat(...xss); +} + export function intersperse(sep: T, xs: T[]): T[] { - return [].concat(...xs.map(x => [sep, x])).slice(1); + return concat(xs.map(x => [sep, x])).slice(1); } -- cgit v1.2.3-freya