The simplest operator which has an operand of mode
BOOL
is NOT. If its operand
is TRUE
, it yields FALSE
. Conversely, if
its operand is FALSE
, it yields TRUE
. The
operator ODD yields TRUE
if
its operand is an odd integer and FALSE
if it is even.
The operators can be combined, so
NOT ODD 2
yields TRUE
.
ABS converts its operand of mode
BOOL
and yields an integer: ABS TRUE
yields
1
, ABS FALSE
yields 0
.
Boolean dyadic operators come in two kinds:
those that take operands of mode BOOL
, yielding
TRUE
or FALSE
, and those that operate on
operands of other modes.
Two dyadic operators are declared in the standard
prelude which take operands of mode
BOOL
. The operator AND
(alternative representation &
) yields
TRUE
if, and only if, both its operands yield
TRUE
, so that
t AND f
yields FALSE
(t
and f
were
declared earlier). Both the operands are elaborated before the
operator (but see the section later on pseudo-operators). The
priority of AND
is 3.
The operator OR yields
TRUE
if at least one of its operands yields
TRUE
. Thus
t OR f
yields TRUE
. It has no alternative representation.
Again, both operands are elaborated before the operator. The priority
of OR
is 2.
You will learn in chapter 6 how to define new operators if you need them.
Sian Mountbatten 2012-01-19