Vikari Language Documentation


Available since:  v0.8.0.

Logical Operators

Vikari supports the following boolean logic operators:

Operator NameSymbolFunction
And^Binary operator that applies the AND operation.
Or"Binary operator that applies the OR operation.
Not'Unary operator that applies the NOT operation.

Rather than using ' and " for quotation purposes, Vikari uses them as logical operators. Backtick tokens with a pattern of ` and `` etc. are used instead for quotations of character and string literals, respectively.

Logical operator expressions require operands with the Boolean type, and also have a return type of Boolean. This means they can have operands that are a Boolean variable, a literal value of true or false, another logical expression, or a comparison operator expression.

Examples

The following demonstrates usage of the logical operators.

~:Usage of the AND operator.:~
foo:Boolean << true ^ true ~:Assigns "true" to foo:~
:[foo ^ false]: ~:Prints "false":~

~:Usage of the OR operator.:~
bar:Boolean << true " false ~:Assigns "true" to bar:~
:[bar " false]: ~:Prints "true":~

~:Usage of the NOT operator.:~
baz:Boolean << 'true ~:Assigns "false" to baz:~
:['baz]: ~:Prints "true":~
:'[true " false]: ~:Prints "false":~

~:Usage with the comparison operators.:~
:[foo = true] ^ [bar '= null]: ~:Prints "true":~

~:Chaining all logical operators together.:~
:'[foo ^ bar] " ['baz ^ foo]: ~:Prints "true":~