Next: , Previous: Interpreter, Up: Top


3 Booleans

The boolean data type consists of two values, which are called true and false, and have respectively external representations #t and #f. There are no possible mutations of either of these two values, and the boolean type is encapsulated.

— Applicative: boolean? (boolean? . objects)

The primitive type predicate for type boolean. boolean? returns true iff all the objects in objects are of type boolean.

— Applicative: not? (not? boolean)

Applicative not? is a predicate that returns the logical negation of its argument.

— Applicative: and? (and? . booleans)

Applicative and? is a predicate that returns true unless one or more of its arguments are false.

— Applicative: or? (or? . booleans)

Applicative or? is a predicate that returns false unless one or more of its arguments are true.

— Operative: $and? ($and? . <list>)

The $and? operative performs a “short-circuit and” of its operands. It evaluates them from left to right, until either an operand evaluates to false, or the end of the list is reached. If the end of the list is reached (which is immediate if <list> is nil), the operative returns true. If an operand evaluates to false, no further operand evaluations are performed, and the operative returns false. If <list> is acyclic, and the last operand is evaluated, it is evaluated in a special type of tail context that checks that the passed value is a boolean. If <list> is cyclic, an unbounded number of operand evaluations may be performed. If any of the operands evaluates to a non-boolean value, an error is signaled (even if it's the last one).

— Operative: $or? ($or? . <list>)

The $or? operative performs a “short-circuit or” of its operands. It evaluates them from left to right, until either an operand evaluates to true, or the end of the list is reached. If the end of the list is reached (which is immediate if <list> is nil), the operative returns false. If an operand evaluates to true, no further operand evaluations are performed, and the operative returns true. If <list> is acyclic, and the last operand is evaluated, it is evaluated in a special type of tail context that checks that the passed value is a boolean. If <list> is cyclic, an unbounded number of operand evaluations may be performed. If any of the operands evaluates to a non-boolean value, an error is signaled (even if it's the last one).