Clojure – Predicates every?

Clojure predicates every?

In this guide, we will discuss 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

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply