/usr/share/freemat/help/text/logicalops.mdc is in freemat-help 4.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | LOGICALOPS LOGICALOPS Logical Array Operators
Usage
There are three Boolean operators available in FreeMat. The syntax for their use is:
y = ~x
y = a & b
y = a | b
where x, a and b are logical arrays. The operators are
- NOT (~) - output y is true if the corresponding element of x is false, and ouput y is false if the corresponding element of x is true.
- OR (|) - output y is true if corresponding element of a is true or if corresponding element of b is true (or if both are true).
- AND (\&) - output y is true only if both the corresponding elements of a and b are both true.
The binary operators AND and OR can take scalar arguments as well as vector arguments, in which case, the scalar is operated on with each element of the vector.
As of version 1.10, FreeMat supports shortcut evaluation. This means that
if we have two expressions
if (expr1 & expr2)
then if expr1 evaluates to false, then expr2 is not evaluated at all.
Similarly, for the expression
if (expr1 | expr2)
then if expr1 evaluates to true, then expr2 is not evaluated at all.
Shortcut evaluation is useful for doing a sequence of tests, each of which is
not valid unless the prior test is successful. For example,
if isa(p,'string') & strcmp(p,'fro')
is not valid without shortcut evaluation (if p is an integer, for example,
the first test returns false, and an attempt to evaluate the second expression
would lead to an error). Note that shortcut evaluation only works with scalar
expressions.
|