liveBook · Manning

Greater-than-or-equal operator

As explained in Clojure: The Essential Reference

The Clojure numeric comparison operator that returns true when its arguments are monotonically decreasing from left to right, allowing equality.

Clojure’s `>=` predicate tests whether arguments decrease monotonically from left to right, allowing adjacent values to be equal. It returns a Boolean and accepts one or more arguments. section 6.3

Use the operator according to these arity and input rules:

  • With one argument, `>=` returns `true`, regardless of the argument’s type. section 6.3
  • With two or more arguments, every argument must be numeric; the operator returns `true` only when each left-to-right pair satisfies greater-than-or-equal ordering. section 6.3
  • Equality is allowed using the same numeric-equality semantics as `==`; calling `>=` with no arguments throws `clojure.lang.ArityException`, while a nonnumeric multi-argument call throws `java.lang.ClassCastException`. 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]))

The arity listing makes the one-, two-, and variadic argument forms of comparison operators directly browsable. section 6.3

How Clojure: The Essential Reference covers it

How deep it goes
Specifies arities, accepted numeric types, return behavior, equality, and exceptional cases.
Examples
Uses comparison-operator signatures to show single-, pair-, and multiple-argument forms.
What it assumes
Assumes familiarity with Clojure function calls and distinguishes unrestricted unary input from numeric multi-argument input.
What you can do after
Evaluate whether numeric arguments form a nonincreasing sequence, including repeated values.
How it connects
Connects ordering predicates with numeric equality and variadic function arity.

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.