From e8948452fdc18f8a85af34bc4687e304cd39c987 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Thu, 6 Sep 2018 02:28:04 +0900 Subject: Resolve #2629 (#2630) --- src/prelude/array.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/prelude/array.ts') diff --git a/src/prelude/array.ts b/src/prelude/array.ts index e944030a7f..aee17640ed 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -5,3 +5,7 @@ export function countIf(f: (x: T) => boolean, xs: T[]): number { export function count(x: T, xs: T[]): number { return countIf(y => x === y, xs); } + +export function intersperse(sep: T, xs: T[]): T[] { + return [].concat(...xs.map(x => [sep, x])).slice(1); +} -- cgit v1.2.3-freya