liveBook · Manning

Less-than operator

As explained in Clojure: The Essential Reference

The Clojure numeric comparison operator that returns true when its arguments are strictly increasing from left to right.

The less-than operator, <, returns true when its arguments form a strictly increasing sequence from left to right. One argument always returns true; two or more arguments must be numeric and satisfy every adjacent comparison. section 6.3

Its contract includes these practical cases:

  • Accepts integers, decimals, ratios, big integers, big decimals, and other Java numeric types when given multiple arguments. section 6.3
  • Returns false when any required comparison fails; equal adjacent values fail because the ordering is strict. section 6.3
  • Throws ArityException with no arguments and ClassCastException when a multi-argument call contains a non-number. section 6.3

Checking a numeric sequence

(< 0 (byte 1) 2 2.1 3N 4M 21/2) ; true (< 0 (byte 1) 2 2.1 3N 2M 21/2) ; false Use apply when the values already reside in a collection: (apply < [2.1 4 5.2 8 124 9012 1e4]) ; true

How Clojure: The Essential Reference covers it

How deep it goes
Defines arities, accepted numeric types, return values, exceptions, and adjacent ordering, but defers broader implementation details.
Examples
Uses mixed numeric sequences, collection application, sorting, filtering, and operator implementation listings.
What you can do after
Apply it via Clojure to validate strictly increasing numeric sequences and compose it with collection operations.
How it connects
Connects comparison operators with ordering predicates, numeric equality, apply, sort, and partial.

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.