How do I make a set from a sequence in clojure
clojure
Solution
most collections have a function that produces them form anything seqable:
(set [1 1 2 2 3 3])
#{1 2 3}
for more interesting cases the `into` function is good to know about:
(into #{1} [2 2 3 3])
#{1 2 3}
Problem
What is an idiomatic way to convert a sequence to a set in Clojure? E.g what do I fill in at the dots? ``` (let s [1 1 2 2 3 3] ...) ``` So that it produces: ``` #{1 2 3} ``` I come up with: ``` (let [s [1 1 2 2 3 3]] (loop [r #{} s s] (if (empty? s) r (recur (conj r (first s)) (rest s))))) ``` But that seems not the way to go? Is there a function already that does this?