What is the not-any predicate function in Clojure?
What are predicates?
Predicates are functions that examine a condition and send a boolean value (true or false).
What is the not-any function?
The not-any function takes a predicate method to evaluate the parameter passed. If any of these parameters are evaluated to be true by the predicate method, the not-any method returns false. If all of them are evaluated to be false the parameter evaluates true.
Syntax
(not-any? p1 params)
Where p1 is the predicate function and params are the parameters to be tested.
Parameter
The not-any function receives a predicate function to evaluate the passed parameter.
Return value
The not-any returns either true or false.
Example
(ns clojure.examples.example(:gen-class))(defn func [](println (not-any? zero? '(2 4 6))))(func)
Explanation
Line 3: We define a function, func.
Line 4: We use zero alongside thenot-any function to evaluate the passed parameter, 2 4 6. Next, we print the output. Notice that the output is true because all the values passed in the parameter are not 0, so the not-any will return true.
Line 5: We call the func function.