dec is Clojure’s concise way to subtract one from a numeric value. It replaces the longer expression (- x 1), making everyday decrementing clear and composable. section 5.6
Its contract is small but precise:
- Accepts one mandatory argument x, which must satisfy (number? x). section 5.6
- Returns x minus one. section 5.6
- Throws ArithmeticException when decrementing Long/MIN_VALUE would underflow. section 5.6
- Belongs to Clojure’s simple-precision numeric operations; arbitrary-precision operators provide a separate approach for values beyond fixed Long boundaries. section 5.2
Basic decrementing
(dec 1) ;; 0 (dec 10) ;; 9
