liveBook · Manning

Dec

As explained in Clojure: The Essential Reference

dec is a Clojure function that decrements a numeric value by one.

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

How Clojure: The Essential Reference covers it

How deep it goes
Defines the one-argument contract, result, shortcut equivalence, and Long underflow behavior without descending into implementation internals.
Examples
Uses direct evaluations such as (dec 1) returning 0 and presents dec beside inc in a compact signature listing.
What it assumes
Assumes basic Clojure function calls and numeric values while stating the number? requirement explicitly.
What you can do after
Apply dec to numeric values and recognize its fixed-precision underflow boundary.
How it connects
Relates dec to inc, subtraction, numeric types, update functions, and arbitrary-precision arithmetic.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.