Expressions - pwdlugosz/Rye GitHub Wiki
#Scalar Expressions
-
- : traditional addition for doubles and integers, concatenates strings and blobs, adds ticks to dates, and returns null for bool.
-
- : traditional subtraction for doubles and integers, calculates the difference in ticks for dates, returns null otherwise.
-
- : traditional multiplication for doubles and integers, returns null otherwise.
- / : traditional division for doubles and integers, returns null otherwise.
- /? : traditional division, but returns 0 if the denominator is 0 rather than null.
- % : traditional modular arithmetic for integers and doubles, returns null otherwise.
- ^ : raises a number to a power.
-
, <, >=, <= : traditional comparisons.
- == , != : equals and not equals
- AND, OR, XOR : traditional Boolean operations.
- !, -, + : unary operators, where '!' is the 'not' operator.
- X IS NULL : true if X is null, false otherwise.
- X ?? Y : returns X if X is not null, returns Y otherwise.
- X ? Y : Z : C/C++/C# style 'if', returns Y if Z is true and Y otherwise.
- X -> type : casts the variable X to a new type.
- CASE WHEN ... THEN ... WHEN ... THEN ... ELSE : traditional SQL style case statement; optimized better than nested ifs.
- X[a] and X[a,b] : returns either the (a,0) or (a,b) element in a cell matrix.
- Standard function library (coming soon ...)
Note about 'IF': the action 'IF', which is a control statement, uses the syntax 'IF-THEN-ELSE'. The expression 'IF' uses the '?' and ':' operators. You cannot interchange them, meaning 'IF-THEN-ELSE' tells the compiler you want to do something, where '?-:' tells the compiler you want to return something.
#Matrix Operations
-
- : Adds two matrices.
-
- : Subtracts two matrices.
-
- : Akin to adding, multiplies each element in A with the corresponding element in B. Not true matrix multiplication.
- / : Divides each element in a matrix with the corresponding element in another matrix.
- /? : Performs the check divide (described above) for each element in both matrices.
- ** : True matrix multiplication.
- ! : Inverts a matrix (unary operation)
- ~ : Transposes a matrix (unary operation)
-
- : Negates each element in a matrix (unary operation)
- For +, -, *, /, and /?, the user can operate on scalar x matrix or matrix x scalar, and the operation will be performed on each matrix element.
- The function IDENTITY(type, X) returns an identity matrix with diagonal equal to X.