# 1.06 Expressions

## Definition

At its simplest an expression is a stream of values that can be reduced to a single value, either as a string, a numeric value or a logical value.

Strictly speaking an array expression does not fit this definition unless you consider an array to be a single value.

## String Expressions

String expressions are constructed from string variables, string literals, and function references joined using concatenation operators. The concatenation operators are the space character ( ) and the colon (:). The arithmetic plus (+) and minus (-) may also be used. See 1.03 Language Overview for details.

#### Example:

```string = "An" "example":'!' "Plus" + " " +
"and minus " - " may also be used"
put string

An example! Plus and minus - may also be used```

## Arithmetic Expressions

Arithmetic expressions are constructed from numeric literals, variables, and functions using the arithmetic operators for addition (+), substraction (-), multiplication (*), division (/) and exponentiation (^).

The minus sign (-) can be used either to indicate subtraction or as a unary minus.

The normal hierarchy for evaluating a numeric expression is:

1. exponentiation
2. multiplication and division
3. addition and subtraction

However, any part of a numeric expression that is enclosed in parenthesis is evaluated first.

As with most programming languages, LynPlex supports a range of operators. See Appendix D. Operators and Special Characters.

## Relational Expressions

Relational expressions are most often used in a conditional statement, but may be used anywhere that numeric expressions are allowed. A relational expression has a value of 1 if it is true and a value of 0 if it is false. Relational operations are performed from left to right, after all arithmetic operations are completed. The most usual relational operators are:

• Equal to (=)
• Not equal to (<>)
• Less than (<)
• Less than or equal to (<=)
• Greater than (>)
• Greater than or equal to (>=)

## Boolean or Logical Expressions

Logical expressions are used for testing conditions. The logical operators and (&&), or (||) and not are used in combination with relational expressions to create logical expressions.

An expression is evaluated and the result is then considered true (1) or false (0). If an aritmethic expression evaluates to a zero value it is considered false. Similarly, if a string expression evaluates to a null string (or only whitespace?) it is considered false. All other values are considered true.

A logical expression using and is true if both its left and right clauses are true.

A logical expression using or is true if either its left or its right, or both, clauses are true.

A logical expression using not is true if the following clause it is not true.

## Array Expressions

To be added

lynplex/lp0106.txt · Last modified: 2012/09/08 12:33 (external edit)