1.1. Booleans

Orc supports Boolean values, true and false.

1.1.1. Syntax

[53]BooleanLiteral::= truefalse  

1.1.2. Operations

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.

1.1.3. Type

A Boolean value has type Boolean.

1.1.4. Java calls

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.

1.1.5. Examples

Boolean XOR
{- Define exclusive or -}

def xor(a,b) = (a || b) && ~(a && b)

xor(true, true) | xor(false, false)

{-
OUTPUT:
false
false
-}

1.1.6. Related Links

Related Reference Topics

Related Tutorial Sections