Basic expressions

The basic expressions are the fundamental building blocks of all programs and include the following:

  • constant literals and tuples
  • arithmetic, relational, and logical operations
  • string concatenation, comparison, and pattern matching
  • set operations
  • object comparisons
  • variables

Constant literals

Constant literals represent values of the basic types string, integer, real, and Boolean and values of the type regexp.

These expressions simply evaluate to their corresponding values.

Strings

Strings are enclosed in quotation marks ("). . Examples:

"abc"
"a\"bc\tdef\n"

Integer examples

2
100

Real examples

-2.0
3.4

Boolean

This constant can be either true or false.

Regexp

For the syntax of regular expressions, see Lexical elements. Regular expressions are enclosed in back quotes (`), as in this example:

`[a-zA-Z]+`

Tuples

Tuples represent ordered collections of values. These expressions take the form of a parenthesized list of components separated by commas, as in these examples:

(1, true)
("abc", true, -2.0)
Note: To change the form of the display from a paragraph to a column, use the \n to insert a new line and make other changes to a replace_all command. See the replace_all command instructions in the Catalog of built-in functions section.

Arithmetic operations

Arithmetic operations on primitive values are basic expressions. The arithmetic operators +, -, *, and / have the typical meanings over integers and reals. The arguments to an arithmetic operator must be of the same type, either integer or real.

Relational operations

Relational operations on primitive values are basic expressions. The relational operators =, <>, <, <=, >, and >= have the typical meanings over integers and reals, with <> representing the inequality operator. The arguments to a relational operator must agree in type.

Logical operations

Logical operations on primitive values are basic expressions over Boolean. The logical operators are as follows:

not
and
οr
implies (p implies q  ≡ not p or q)

String operations

String concatenation, comparison, and pattern matching are basic expressions in the form of an infix operator.

String concatenation

The operator + concatenates two strings, as in this example:

"abc" + "def" ⇒ abcdef

String comparison

The relational operators (=,<> ,<, <=, >, >=) implement lexicographical comparisons of strings, as in these examples:

"abc" = "abd" ⇒ false
"abc" <> "abd" ⇒ true
"abc" < "abd" ⇒ true

String pattern matching

The operators ~= and ~<> compare a string on the left side against a regular expression on the right side for a match or a mismatch. The right side argument to ~= and ~<> must be a string literal rather than a regular expression literal, as in these examples:

"abc" ~= "a*" ⇒ true
"abc" ~<> "a*" ⇒ false
"10111010110101" ~= "[01]+" ⇒ true
"abcdefghijkl" ~= "[^01]+" ⇒ true

Feedback