x-lang

← Index

x/core/boolean

Short-circuit logical AND and OR operatives.

and

Short-circuit logical AND. Evaluates left to right, returns #f on first falsy value.

Returns: ANY — Last truthy value, or #f if any expression is falsy

Examples:

(and 1 2 3) => 3
(and 1 #f 3) => #f

or

Short-circuit logical OR. Evaluates left to right, returns the first truthy value; when nothing is truthy the last operand passes through unchanged.

Returns: ANY — First truthy value; if none is truthy, the last operand unchanged

Examples:

(or #f 2 3) => 2
(null? (or #f ())) => #t
(list (or () #f) (or #f ())) => (#f ())