function | since v0.0-927 | clojure.core/set | Edit |
(set coll)
Returns a set of the distinct elements of coll
.
Returns a set of the distinct elements of coll.
(defn set
[coll]
(if (set? coll)
(with-meta coll nil)
(let [in (seq coll)]
(cond
(nil? in) #{}
(and (instance? IndexedSeq in) (zero? (.-i in)))
(.createAsIfByAssoc PersistentHashSet (.-arr in))
:else
(loop [^not-native in in
^not-native out (-as-transient #{})]
(if-not (nil? in)
(recur (next in) (-conj! out (-first in)))
(persistent! out)))))))