Clojure - Maps dissoc


Advertisements


Dissociates a key value entry from the map.

Syntax

Following is the syntax.

(dissoc hmap key)

Parameters − ‘hmap’ is the map of hash keys and values. ‘key’ is the key which needs to be dissociated from the HashMap.

Return Value − Returns a map with the dissociated key.

Example

Following is an example of dissoc in Clojure.

Live Demo
(ns clojure.examples.example
   (:gen-class))
(defn example []
   (def demokeys (hash-map "z" "1" "b" "2" "a" "3"))
   (println (dissoc demokeys "b")))
(example)

Output

The above code produces the following output.

{z 1, a 3}

clojure_maps.htm

Advertisements