? predicate

conventionsince v0.0-927 in clojureEdit

A naming convention for functions returning true or false (unenforced). Examples:


Details:

Predicate functions are presumably pure (not having any side-effects on state).

It is sometimes used to name boolean values as well, not just predicate functions.


Examples:

Create a divisible? predicate:

(defn divisible? [n factor]
  (zero? (mod n factor)))

(divisible? 15 3)
;;=> true

(divisible? 15 2)
;;=> false

(filter #(divisible? 15 %) (range 15))
;;=> (1 3 5)

See Also: