Clojure - Predicates every?



Returns true if the predicate is true for every value, else false.

Syntax

Following is the syntax.

(every? p1 col)

Parameters − ‘p1’ is the predicate which need 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 every? in Clojure.

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

Output

The above program produces the following output.

true
false
clojure_predicates.htm
Advertisements