String definition: Characters enclosed in quotes like "this is a string"
String access: A string followed by brackets allows 1-based element access like "abcd"[3] is "c"
String slices: A string followed by brackets and intervals slices like "Peter"[2 ... 3] is "et"
Array definition: Values enclosed in square brackets separated by commas like [1,2,3], the square brackets are optional
Array access: An array followed by brackets allows 1-based element access like [4,5,6][2] is 5, [[2,7],[3,8]][2][1] or [[2,7],[3,8]][2,1] is 3
Array slices: An array followed by brackets and intervals slices like [4,5,6,7][2 ... 3] is [5,6], [4,5,6,7][2 ... ] is [5,6,7], [4,5,6,7][... 3] is [4,5,6]
Structure definition: Enclosed by braces with name:value tuples separated by commas like {left:3,right:4}
Structure access: A structure followed by a point and a name allows access to that value like {left:3,right:4}.left is 3, if names are numbers sparse array access is done with brackets like {3:1,7:0}[3] equals 1
Difference: Substract or prefix numbers with a - like 4-3
Multiplication: Multiply numbers with a * like 2*3
Division: Divide numbers with a / like 8/4
Integer division: Use integer division with div like 11 div 3 resulting in 3.
Modulo: Compute remainder with a % or mod like 11%3 or 11 mod 3
Bitwise operations: Compute and, or, xor, not (32 bit) like 12 and 13, 17 or 8, 39 xor 11, not 12.
Use parantheses to group terms like (2+3)*4
Variables and Assignments
Identifiers: Match non-keyword regexp [_a-zA-Z][a-zA-Z0-9_]* such as _Hello2
Variables: Are Identifiers that represent values or compounds
Assignments: Variables can be assigned values from terms like a=3*2
Packed assignments: Variable arrays can be assigned arrays like x,y=[1,2]
Array assignments: Array entry can be assigned values like x[1]=3, A[3,4]=B[6,3]
Comments
Single line comments start with // comment
Multi line comments are enclosed like /* hello comment */
Program control
Conditional statements: Use if with a boolean to conditionally execute the commands after then or optional otherwise else until endif like if true then x=1 else x=0 endif
Chained if statements: Follow if ... then statements with any number of elseif with a condition followed by then and commmands for chained conditions like if false then a=1 elseif true then b=2 else c=3 endif
For loops: y = 0 for x = 1, ..., 3 do y = y + x endfor sums 1+2+3
For-in loops: y = 1 for x in [1,2,3] do y = y * x endfor computes
1*2*3, and y = 1 for i:x in [4,5,6] do y = y * (x+i) endfor
computes (4+1)*(5+2)*(6+3)
While loops: y = 0 while y!=5 do y = y + 1 endwhile counts up to 5
Repeat loops: y = 0 repeat y = y + 1 until y==5 counts up to 5
Swaps: swap x,y swaps x and y like x,y=y,x
Algorithms: Algorithm add(x,y=5) return x+y EndAlgorithm with optional default parameters
Standard library
print(..) printing the argument(s)
round(..), floor(..), ceil(..) compute rounded, rounded down, rounded up values
random(low,high) results in an integer pseudo random number between and including low and high, use seed(..) to switch to seeded version. The function can generate arbitrary long integer numbers but surely is not safe for secure cryptography.
time() returns seconds since 1.1.1970
len(..) results in the length of an array oder a string
codepoint(..), unicode(..) returns the codepoint of a character or the unicode symbol of a codepoint
value(..), value(..,..) returns the value of a number string or with given base
str(...) returns the string representation of given value
hex(..), oct(..), bin(..) returns the hexadecimal, octal or binary of a number
max(..,..), min(..,..), sum(..,..) computes maximum, minimum or sum of several values or arrays
sqrt(..), pow(b,e), pow(b,e,m), exp(..), log(..), log2(..) square root, power (also modulo m), exponential, natural logarithm, dual logarithm