Clojure - Maps find


Advertisements

Returns the map entry for the key.

Syntax

Following is the syntax.

(find hmap key)

Parameters − ‘hmap’ is the map of hash keys and values. ‘key’ is the key which needs to be searched in the map.

Return Value − Returns the key value pair for the desired key, else returns nil.

Example

Following is an example of find in Clojure.

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

Output

The above code produces the following output.

{z 1, a 3, b 2}
[b 2]
nil
clojure_maps.htm
Advertisements