Boolean operations

Booleans

Arc provides basic Boolean operations.
Only nil and empty list are false; any other value, including 0 and empty string, is true. The operations provide short-circuit evaluation, so only the necessary arguments are evaluated, left-to-right.

The and boolean operator tests if all the arguments are true. It evaluates its arguments in turn until a false argument is found.
If all arguments are true, the last argument is returned. If all arguments are false, nil is returned. The and operator performs 'short-circuit' evaluation, and doesn't evaluate arguments that follow a false one.

>(and 1 t 0 "x")
"x"

>(and nil t)
nil

>(and nil (/ 1 0))
nil

or[arg ...]

The or boolean operator tests if any of the arguments are true. It evaluates its arguments in turn until a true argument is found. If any argument is true, the first true argument is returned. If all arguments are false, nil is returned. The or operator performs 'short-circuit' evaluation, and doesn't evaluate arguments that follow a true one.

>(or nil 42 '() (/ 1 0))
42

>(or nil '())
nil

nor[arg ...]

The nor boolean operator tests if all of the arguments are false. It returns t if all arguments are false, and nil if any arguments are true. It performs 'short-circuit' evaluation, and doesn't evaluate arguments that follow a true one.