From ff0a05a2d67f45ec9ff06d50c5be821d559c2528 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 7 Sep 2018 00:10:03 +0900 Subject: Add unique function (#2644) --- 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 a2a6bbd4c6..abef6ca039 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -17,3 +17,7 @@ export function intersperse(sep: T, xs: T[]): T[] { export function erase(x: T, xs: T[]): T[] { return xs.filter(y => x !== y); } + +export function unique(xs: T[]): T[] { + return [...new Set(xs)]; +} -- cgit v1.2.3-freya