Next: Operators for Equations, Previous: Relational operators, Up: Operators [Contents][Index]

### 7.4 Logical operators

Operator: and ¶

  The logical conjunction operator. `and` is an n-ary infix operator; its operands are Boolean expressions, and its result is a Boolean value.

  `and` forces evaluation (like `is`) of one or more operands, and may force evaluation of all operands.

  Operands are evaluated in the order in which they appear. `and` evaluates only as many of its operands as necessary to determine the result. If any operand is `false`, the result is `false` and no further operands are evaluated.

  The global flag `prederror` governs the behavior of `and` when an evaluated operand cannot be determined to be `true` or `false`. `and` prints an error message when `prederror` is `true`. Otherwise, operands which do not evaluate to `true` or `false` are accepted, and the result is a Boolean expression.

  `and` is not commutative: `a and b` might not be equal to `b and a` due to the treatment of indeterminate operands.

  Categories: Operators ·

Operator: not ¶

  The logical negation operator. `not` is a prefix operator; its operand is a Boolean expression, and its result is a Boolean value.

  `not` forces evaluation (like `is`) of its operand.

  The global flag `prederror` governs the behavior of `not` when its operand cannot be determined to be `true` or `false`. `not` prints an error message when `prederror` is `true`. Otherwise, operands which do not evaluate to `true` or `false` are accepted, and the result is a Boolean expression.

  Categories: Operators ·

Operator: or ¶

  The logical disjunction operator. `or` is an n-ary infix operator; its operands are Boolean expressions, and its result is a Boolean value.

  `or` forces evaluation (like `is`) of one or more operands, and may force evaluation of all operands.

  Operands are evaluated in the order in which they appear. `or` evaluates only as many of its operands as necessary to determine the result. If any operand is `true`, the result is `true` and no further operands are evaluated.

  The global flag `prederror` governs the behavior of `or` when an evaluated operand cannot be determined to be `true` or `false`. `or` prints an error message when `prederror` is `true`. Otherwise, operands which do not evaluate to `true` or `false` are accepted, and the result is a Boolean expression.

  `or` is not commutative: `a or b` might not be equal to `b or a` due to the treatment of indeterminate operands.

  Categories: Operators ·

Next: Operators for Equations, Previous: Relational operators, Up: Operators [Contents][Index]