Generic Expressions
Generic Expressions¶
This section details the HS\({}^3\) generic expression language. Expressions can be use to specify generic functions and generic distributions. The implementations that support generic expression must support:
- Literal integer (format
1234), boolean (formatTRUEandFALSE) and floating point (format123.4,1.234e2and1.234E2) values. - Literal values for \(\pi\) (
PI) and Euler's number (EULER). - The arithmetic operators addition (
x + y), subtraction (x - y), multiplication (x * y), division (x / y) and exponentiation (x^y). - The comparison operators approximately-equal (
x == y), exactly-equal (x === y), not-approximately-equal (x != y), not-exactly-equal (x !== y), less-than (x < y), less-or-equal (x <= y), greater-than (x >= y) and greater-or-equal (x >= y). - The logical operators logical-inverse (
!a), logical-and (a && b), logical-or (a || b), less-or-equal (a <= b), greater-than (a >= b) and greater-or-equal (a >= b). - Round brackets to specify the order of operations.
- The ternary operator
condition ? result_if_true : result_if_false - The functions
exp(x): Euler's number raised to the power ofxlog(x): Natural logarithm ofxsqrt(x): The square root ofxabs(x): The absolute value ofxpow(x, y):xraised to the power ofypow(x, y):xraised to the power ofymin(x, y): minimum ofxandymax(x, y): maximum ofxandysin(x): The sine ofxcos(x): The cosine ofxtan(x): The tangent ofxasin(x): The inverse sin ofxacos(x): The inverse cosine ofxatan(x): The inverse tangent ofx
Symbols not defined here refer to variables in the HS\({}^3\) model.
The operator precedence and associativity is acorrding to the common conventions.
Spaces between operators and operands are optional. There must be no space between a function name and the function arguments, spaces between function arguments are optional (f(a, b) and f(a,b) are correct but f (a, b) is not allowed).
Division must be treated as floating-point division (i.e. 2/3 should be equivalent to 2.0/3.0).
The approximately-equal (a == b) and the not-approximately-equal operator (a != b), should compare floating-point numbers to within a small multiple of the unit of least precision.
The behavior of any functions and operators not listed above is not defined, they are reserved for future versions of this standard. Implementations may support additional functions and operators as experimental features, but their use is considered non-standard and results in non-portable and potentially non-forward-compatible HS\({}^3\) documents.