summaryrefslogtreecommitdiff
path: root/src/prelude/array.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/prelude/array.ts')
-rw-r--r--src/prelude/array.ts4
1 files changed, 4 insertions, 0 deletions
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<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);
+}