You're viewing version 1.2.0 of hash-set. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

hash-set

clojure.core

  • (hash-set)
  • (hash-set & keys)
Returns a new hash set with supplied keys.

1 Example top

  • user=> (hash-set 1 2 1 3 1 4 1 5)
    #{1 2 3 4 5}
    
    user=> (= (hash-set :c :a :b) #{:b :a :c})
    true 
    
    
    user=> (hash-set (seq "Lorem ipsum dolor sit amet"))
    #{(\L \o \r \e \m \space \i \p \s \u \m \space \d \o \l \o \r \space \s \i \t \space \a \m \e \t)} 
    
    user=> (apply hash-set (seq "Lorem ipsum dolor sit amet"))
    #{\space \a \d \e \i \L \l \m \o \p \r \s \t \u} 
    
    
    ;; Caution: hash-set now prevents duplicate keys (Clojure 1.2)
    user=> (hash-set 1 1)
    Duplicate key: 1
      [Thrown class java.lang.IllegalArgumentException]
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:329 top

(defn hash-set
  "Returns a new hash set with supplied keys."
  {:added "1.0"}
  ([] #{})
  ([& keys]
   (clojure.lang.PersistentHashSet/createWithCheck keys)))
Vars in clojure.core/hash-set: defn keys
Used in 1 other vars defalias

Comments top

No comments for hash-set. Log in to add a comment.