dissoc

clojure.core

  • (dissoc map)
  • (dissoc map key)
  • (dissoc map key & ks)
dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
that does not contain a mapping for key(s).

1 Example top

  • user=> (dissoc {:a 1 :b 2 :c 3}) ; dissoc nothing 
    {:a 1, :b 2, :c 3} 
    
    user=> (dissoc {:a 1 :b 2 :c 3} :b) ; dissoc key :b
    {:a 1, :c 3} 
    
    user=> (dissoc {:a 1 :b 2 :c 3} :d) ; dissoc not existed key
    {:a 1, :b 2, :c 3} 
    
    user=> (dissoc {:a 1 :b 2 :c 3} :c :b) ; several keys at once
    {:a 1} 
    
    
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:1397 top

(defn dissoc
  "dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
  that does not contain a mapping for key(s)."
  {:added "1.0"
   :static true}
  ([map] map)
  ([map key]
   (. clojure.lang.RT (dissoc map key)))
  ([map key & ks]
   (let [ret (dissoc map key)]
     (if ks
       (recur ret (first ks) (next ks))
       ret))))
Vars in clojure.core/dissoc:
Used in 0 other vars

Comments top

No comments for dissoc. Log in to add a comment.