convention | since v0.0-927 | in clojure | Edit |
A naming convention for functions returning true or false (unenforced). Examples:
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.
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)