Contents Previous Next Subchapters

Logical Operators
Syntax left and right 
left or right 
not 
value
See Also xor , ordered , any , all

Description
Computes the element-by-element result for expressions that use the and, or and not operators. The values left, right, and value are logical operands.

The and, and or operators combine two logical values, whereas the not operator negates a single logical value.

Combining Logical Expressions
If both values joined by the and operator are true, the combined expression is true. If you enter
     x = 1 < 2
     y = 3 > 4
     print x and y
O-Matrix will respond
     F
because, although x is true, y is false.

If at least one of the values joined by the or operator is true, the combined expression is true. If you enter
     x = 1 < 2
     y = 3 > 4
     x or y
O-Matrix will respond
     T
because, although y is false, x is true.

Negating Logical Expressions
The not operator negates the logical value it precedes. If you enter
     x = [1, 2]
     y = [4, 2]
     z = x == y
     not z
O-Matrix will respond
     [ T , F ]
because the first element of z is false and the second element of z is true.

Combining Logical Matrices
Logical operators act on matrices in an element-by-element manner. If you enter
     x = {[true, false], [true, false]}
     y = {[true, true], [false, false]}
     x and y
O-Matrix will respond
     {
     [ T , F ]
     [ F , F ]
     }
If you continue by entering
     x and true
O-Matrix will respond
     {
     [ T , F ]
     [ T , F ]
     }