This page provides a quick reference for built‑in operators. Note: only #f is false; the empty list () is truthy. Boolean results are written as #t and #f.
Arithmetic Operators
These operators perform standard mathematical calculations.
+ (Add)
Sums two or more numbers.
- With no arguments, returns
0. - With one argument, returns the argument itself.
(+ 10 20 5) ;; Result: 35
(+ 10) ;; Result: 10
(+) ;; Result: 0
- (Subtract)
With one argument, negates the number. With two or more, subtracts the subsequent numbers from the first.
(- 100 20 10) ;; Result: 70
(- 10) ;; Result: -10
* (Multiply)
Multiplies two or more numbers.
- With no arguments, returns
1. - With one argument, returns the argument itself.
(* 5 10 2) ;; Result: 100
(* 7) ;; Result: 7
(*) ;; Result: 1
/ (Divide)
Divides the first number by the subsequent numbers. Throws an error on division by zero.
(/ 100 5 2) ;; Result: 10
modulo (Remainder)
Returns the remainder of the division of the first number by the second. Requires exactly two arguments.
Alias: % (discouraged; prefer modulo, warn W330).
(modulo 10 3) ;; Result: 1
Comparison Operators
These operators compare values and return #t or #f.
=, == (Equal)
Checks if two values are equal. For lists, it performs a deep, recursive comparison of their elements. == is an alias for =.
(= 10 10) ;; Result: #t
(= "hello" "world") ;; Result: #f
(= (list 1 2) (list 1 2)) ;; Result: #t
!= (Not Equal)
Checks if two values are not equal. It's the opposite of =.
(!= 10 5) ;; Result: #t
(!= (list 1 2) (list 1 2)) ;; Result: #f
> (Greater Than)
Checks if the first number is greater than the second.
(> 10 5) ;; Result: #t
< (Less Than)
Checks if the first number is less than the second.
(< 10 5) ;; Result: #f
>= (Greater Than or Equal To)
Checks if the first number is greater than or equal to the second.
(>= 10 10) ;; Result: #t
<= (Less Than or Equal To)
Checks if the first number is less than or equal to the second.
(<= 10 5) ;; Result: #f
Logical Operators
These operators work with boolean logic and feature short-circuit evaluation.
and
Returns #f as soon as it encounters #f. If all values are truthy (anything other than #f), returns the value of the last expression.
(and #t #t) ;; Result: #t
(and #t #f 10) ;; Result: #f (stops at #f)
or
Returns the first truthy value it encounters. If all values are #f, it returns #f.
(or #f 10 #t) ;; Result: 10 (stops at 10)
(or #f #f) ;; Result: #f
not
Returns the opposite boolean. It returns #t for #f and #f for any other value.
(not #t) ;; Result: #f
(not #f) ;; Result: #t
(not 0) ;; Result: #f (0 is truthy)