Trelis 16.4 User Documentation
The operators recognized by APREPRO are listed below.
In the following table, the letters a and b can represent variables, numbers, functions, or expressions unless otherwise noted. The tables below also list the precedence and associativity of the operators. Precedence defines the order in which operations should be performed. For example, in the expression:
3 * 4 + 6 / 2
the multiplications and divisions are performed first, followed by the addition because multiplication and division have higher precedence than addition. The precedence is listed from 1 to 14 with 1 being the lowest precedence and 14 being the highest.
Associativity defines which side of the expressions should be simplified first. For example the expression: 3 + 4 + 5 would be evaluated as (3 + 4) + 5 for left associativity, the expression a = b / c would be evaluated as a = (b / c) for right associativity.
Note: Operators must not be separated from operands by white space. For example, the expressions x_coord1 and x_coord 1 will parse correctly, while the expressions x_coord  1 and x_coord 1 will not parse correctly.
Arithmetic operators combine two or more algebraic expressions into a single algebraic expression. These have obvious meanings except for the pre and post increment and decrement operators. The preincrement and predecrement operators first increment or decrement the value of the variable and then return the value. For example, if a = 1, then b=++a will set both b and a equal to 2. The postincrement and postdecrement operators first return the value of the variable and then increment or decrement the variable. For example, if a = 1, then b=a++ will set b equal to 1 and a equal to 2. The modulus operator % calculates the integer remainder. That is both expressions are truncated an integer value and then the remainder calculated. See the fmod function in Mathematical Functions, for the calculation of the floating point remainder. The tilde character ~ is used as a synonym for multiplication to improve the aesthetics of the APREPRO unit conversion system (however, the unit conversions system is not supported in Trelis). It is more natural for some users to type 12~metre than 12*metre
Table 1. Arithmetic Operators
Syntax 
Description 
Precedence 
Associativity 

a+b 
Addition 
9 
left 

ab 
Subtraction 
9 
left 

a*b, a~b 
Multiplication 
10 
left 

a/b 
Division 
10 
left 

a^b, a**b 
Exponentiation 
12 
right 

a%b 
Modulus (remainder) 
10 
left 

++a, a++ 
Pre, postincrement 
13 
left 

a, a 
Pre, postdecrement 
13 
left 
Assignment operators combine a variable and an algebraic expression into a single algebraic expression, and also set the variable equal to the algebraic expression. Only variables can be specified on the lefthandside of the equal sign.
Table 2. Assignment Operators
Syntax 
Description 
Precedence 
Associativity 

a=b 
The value of 'a' is set equal to 'b' 
1 
right 

a+=b 
The value of 'a' is set equal to a + b 
2 
right 

a=b 
The value of 'a' is set equal to a  b 
2 
right 

a*=b 
The value of 'a' is set equal to a * b 
3 
right 

a/=b 
The value of 'a' is set equal to a / b 
3 
right 

a^=b 
The value of 'a' is set equal to a ^{b} 
4 
right 

a**=b 
The value of 'a' is set equal to a ^{b} 
4 
right 
Relational operators combine two algebraic expressions into a single relational expression. Relational expressions and operators can only be used before the question mark (?) in a conditional expression.
Table 3. Relational Operators
Syntax 
Description 
Precedence 
Associativity 

a<b 
true if 'a' is less than 'b' 
8 
left 

a>b 
true if 'a' is greater than 'b' 
8 
left 

a<=b 
true if 'a' is less than or equal to 'b' 
8 
left 

a>=b 
true if 'a' is greater than or equal to 'b' 
8 
left 

a==b 
true if 'a' is equal to 'b' 
8 
left 

a!=b 
true if 'a' is not equal to 'b' 
8 
left 
Boolean operators combine one or more relational expressions into a single relational expression. If la and lb are two relational expressions, then:
Table 4. Boolean Operators
Syntax 
Description 
Precedence 
Associativity 

1a  1b 
true if either 'la' or 'lb' are true. 
6 
left 

1a && 1b 
true if both 'la' and 'lb' are true. 
7 
left 

!1a 
true if 'la' is false. 
11 
left 
The only supported string operator at this time is string concatenation, which is denoted by //. If a = "Hello" and b = "World", then:
c = a // " " // b
sets c equal to "Hello World". Concatenation has precedence 14 and left associativity. Also see String Functions