Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Js

Idiom #118 List to set

Create the set y from the list x.
x may contain duplicates. y is unordered and has no repeated values.

Turning the list [a,b,c,b] into the set {c,a,b}
var y = new Set(x);

The Set function was added to JS in ES2015 (a.k.a ES6).
(def y (set x))

New implementation...
< >
programming-idioms.org