Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

communitycreator
clojure

What is the not-any predicate function in Clojure?

Chinweuba Elijah Azubuike

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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)
not-any syntax

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)
Example of the not-any function

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.

RELATED TAGS

communitycreator
clojure

CONTRIBUTOR

Chinweuba Elijah Azubuike

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring