Next: , Previous: Conditions, Up: The Language


6.6 The Operators not, and, and or

Conditions can be combined logically:

not cond
This is true if condition cond is false.
cond1 and cond2 and cond3 and ...
This is true if all conditions cond1, cond2, cond3, ... are true. The conditions are tested one by one from left to right until one of them is false. This is called short-cut evaluation.
cond1 or cond2 or cond3 or ...
This is true if at least one of the conditions cond1, cond2, cond3, ... is true. The conditions are tested one by one from left to right until one of them is true. This is also a form of short-cut evaluation.

The operator not takes exactly one argument. If its argument contains another logical operator, put it in parentheses ‘()’, as in not (cond1 or cond2).

The operators and and or may not be mixed as in cond1 and cond2 or cond3; here the order of evaluation would be ambiguous. Use parentheses ‘()’ to indicate in wich order the condition is to be evaluated, as in (cond1 and cond2) or cond3.