function/macro | since v0.0-1443 | clojure.core/hash-set | Edit |
(hash-set)
(hash-set & keys)
Returns a new hash set with supplied keys
.
Any equal keys are handled as if by repeated uses of conj
.
Returns a new hash set with supplied keys. Any equal keys are handled as if by repeated uses of conj.
(defn hash-set
([] #{})
([& keys] (set keys)))
(core/defmacro hash-set
([] `(.-EMPTY cljs.core/PersistentHashSet))
([& xs]
(if (core/and (core/<= (count xs) 8)
(every? #(= (:op (cljs.analyzer/unwrap-quote %)) :const)
(map #(cljs.analyzer/no-warn (cljs.analyzer/analyze &env %)) xs))
(= (count (into #{} xs)) (count xs)))
`(cljs.core/PersistentHashSet. nil
(cljs.core/PersistentArrayMap. nil ~(count xs) (array ~@(interleave xs (repeat nil))) nil)
nil)
(vary-meta
`(.createAsIfByAssoc cljs.core/PersistentHashSet (array ~@xs))
assoc :tag 'cljs.core/PersistentHashSet))))