Next: Logical operators, Previous: Arithmetic operators, Up: Operators [Contents][Index]

### 7.3 Relational operators

Operator: < ¶
Operator: <= ¶
Operator: >= ¶
Operator: > ¶

  The symbols `<` `<=` `>=` and `>` represent less than, less than or equal, greater than or equal, and greater than, respectively. The names of these operators are `"<"` `"<="` `">="` and `">"`, which may appear where the name of a function or operator is required.

  These relational operators are all binary operators; constructs such as `a < b < c` are not recognized by Maxima.

  Relational expressions are evaluated to Boolean values by the functions `is` and `maybe`, and the programming constructs `if`, `while`, and `unless`. Relational expressions are not otherwise evaluated or simplified to Boolean values, although the arguments of relational expressions are evaluated (when evaluation is not otherwise prevented by quotation).

  When a relational expression cannot be evaluated to `true` or `false`, the behavior of `is` and `if` are governed by the global flag `prederror`. When `prederror` is `true`, `is` and `if` trigger an error. When `prederror` is `false`, `is` returns `unknown`, and `if` returns a partially-evaluated conditional expression.

  `maybe` always behaves as if `prederror` were `false`, and `while` and `unless` always behave as if `prederror` were `true`.

  Relational operators do not distribute over lists or other aggregates.

  See also `=`, `#`, `equal`, and `notequal`.

  Examples:

  Relational expressions are evaluated to Boolean values by some functions and programming constructs.

      (%i1) [x, y, z] : [123, 456, 789];
      (%o1)                    [123, 456, 789]
      (%i2) is (x < y);
      (%o2)                         true
      (%i3) maybe (y > z);
      (%o3)                         false
      (%i4) if x >= z then 1 else 0;
      (%o4)                           0
      (%i5) block ([S], S : 0, for i:1 while i <= 100 do S : S + i,
                   return (S));
      (%o5)                         5050

  Relational expressions are not otherwise evaluated or simplified to Boolean values, although the arguments of relational expressions are evaluated.

      (%o1)                    [123, 456, 789]
      (%i2) [x < y, y <= z, z >= y, y > z];
      (%o2)    [123 < 456, 456 <= 789, 789 >= 456, 456 > 789]
      (%i3) map (is, %);
      (%o3)               [true, true, true, false]

  Categories: Operators ·

Next: Logical operators, Previous: Arithmetic operators, Up: Operators [Contents][Index]