Orc supports Boolean values, true
and false
.
Notable Boolean operations include:
Logical negation (not): ~
Logical and: &&
Logical or: ||
as well as the comparison operators, which yield Boolean results:
Less than: <:
Greater than: :>
Less than or equal to: <=
Greater than or equal to: >=
Equal to: =
Not equal to: /=
Note: Unlike the typical symbols <
and >
for arithmetic relations, Orc uses <:
and :>
respectively. This usage avoids ambiguity with the
sequential combinator
and the pruning combinator.
Orc Boolean values are passed in calls to and returns
from Java code as java.lang.Boolean
, which is boxed and
unboxed per The Java Language Specification as boolean
.
{- Define exclusive or -} def xor(a,b) = (a || b) && ~(a && b) xor(true, true) | xor(false, false) {- OUTPUT: false false -}
Related Reference Topics
Related Tutorial Sections