|
Contents | Previous | Next | Subchapters |
| Syntax |
left value == right valueleft value <> right value
|
(equal)
(not equal)
|
| See Also | ordered , equal , all , any , and string == |
Comparisons using the equal (==) and not equal (<>)
operators return logical matrices with dimensions equal to the
matrices being compared.
An element of the result is true
(which O-Matrix prints as T)
if the condition is true for the corresponding elements of the two matrices,
or false
(which O-Matrix prints as F)
if it is not.
If a matrix is compared with a scalar,
O-Matrix compares the scalar value with the value of each
individual element of the matrix.
x = 4
y = 8
print y == x
O-Matrix will respond
F
O-Matrix does not consider matrix type when testing equality
(because it performs coercion
before making the test).
If you enter
x = 1
y = 1.
print y == x
O-Matrix will respond
T
even though x is an integer and y is a real number.
z = 2 <> 3
z
O-Matrix will respond
T
Variables can also be directly assigned the logical values true or false.
Entering
x = true
x
results in
T
u = { 4, 3, 2, 1, 9 }
v = { 9, 2, 2, 2, 9 }
u == v
O-Matrix will respond
{
F
F
T
F
T
}
If you enter
x = {[1, 2], [2, 1]}
y = {[2, 1], [2, 1]}
x == y
O-Matrix will respond
{
[ F , F ]
[ T , T ]
}
x = {[1, 2], [3, 4]}
x == 2
O-Matrix will respond
{
[ F , T ]
[ F , F ]
}