A comparison predicate tests an ordering relationship and returns a Boolean. In Clojure, <, >, <=, and >= accept one or more arguments and verify the relationship across the entire sequence. section 6.3
Use the arity and input contract carefully:
- A single argument of any type returns true. section 6.3
- Two or more arguments must be numeric; nonnumeric values raise ClassCastException. section 6.3
- Calling a predicate without arguments raises ArityException. section 6.3
- < and > require strict increase or decrease, while <= and >= permit equal adjacent values. section 6.3
Checking an ordered sequence
(< 0 (byte 1) 2 2.1 3N 2M 21/2) ;; false (apply < [2.1 4 5.2 8 124 9012 1e4]) ;; true section 6.3
Listing 6.3. → Comparison Operators, Ordering
(< ([x]) ([x y]) ([x y & more])) (> ([x]) ([x y]) ([x y & more])) (<= ([x]) ([x y]) ([x y & more])) (>= ([x]) ([x y]) ([x y & more]))
Browse the supported arities for all four ordering predicates. section 6.3
