In this guide, we will discuss Clojure Predicates some. Returns the first logical true value for any predicate value of x in the collection of values.
Syntax
Following is the syntax.
(some p1 col)
Parameters − ‘p1’ is the predicate which needs to be tested. ‘col’ is the collection of values which needs to be tested.
Return Value − Returns true if the predicate is true for every value, else false.
Example
Following is an example of some in Clojure.
(ns clojure.examples.example (:gen-class)) (defn Example [] (println (some even? '(1 2 3 4)))) (Example)
Output
The above program produces the following output.
true
Note that in the above program, once the predicate reaches the value 2, which is even, the function will exit and the values of 3 and 4 will not be tested.
Next Topic : Click Here
Pingback: Clojure - Predicates every? | Adglob Infosystem Pvt Ltd
Pingback: Clojure - Predicates | Adglob Infosystem Pvt Ltd