In this guide, we will discuss Clojure contains? Finds out whether the set contains a certain element or not.
Syntax
Following is the syntax.
(contains? setofelements searchelement)
Parameters ā āsetofelementsā is the set of elements. āSearchelementā is the element which needs to be searched for in the list.
Return Value ā Returns true if the element exists in the set or false if it dosenāt.
Example
Following is an example of contains? in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (println (contains? (set '(3 2 1)) 2)) (println (contains? (set '(3 2 1)) 5))) (example)
Output
The above code produces the following output.
true false
Next Topic : Click Here
Pingback: Clojure - get | Adglob Infosystem Pvt Ltd
Pingback: Clojure - Sets | Adglob Infosystem Pvt Ltd