Clojure – Predicates every-pred

Clojure predicates every-pred

In this guide, we will discuss Clojure Predicates every-pred. Takes a set of predicates and returns a function ‘f’ that returns true if all of its composing predicates return a logical true value against all of its arguments, else it returns false.

Syntax

Following is the syntax.

(every-pred p1 p2 .. pn)

Parameters − ‘p1 p2…pn’ is the list of all predicates which need to be tested.

Return Value − Returns true if all of its composing predicates return a logical true value against all of its arguments, else it returns false.

Example

Following is an example of every-pred in Clojure.

(ns clojure.examples.example
   (:gen-class))
(defn Example []
   (println ((every-pred number? even?) 2 4 6))
   (println ((every-pred number? odd?) 2 4 6)))
(Example)

Output

The above program produces the following output.

true
false

Next Topic : Click Here

This Post Has One Comment

Leave a Reply