In this guide, we will discuss Clojure Maps select-keys. Returns a map containing only those entries in map whose key is in keys.
Syntax
Following is the syntax.
(select-keys hmap keys)
Parameters − ‘hmap’ is the map of hash keys and values. ‘keys’ is the list of keys which need to be selected from the HashMap.
Return Value − Returns the keys from the map as per the select clause of keys.
Example
Following is an example of select-keys in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (def demokeys (hash-map "z" 1 "b" 2 "a" 3)) (println (select-keys demokeys ["z" "a"]))) (example)
Output
The above code produces the following output.
{z 1, a 3}
Next Topic : Click Here
Pingback: Clojure - Maps merge-with | Adglob Infosystem Pvt Ltd
Pingback: Clojure - Maps | Adglob Infosystem Pvt Ltd