Skip to content

Basic Functions and Operators

Before going in note that any time VARNAME or FUNCNAME is written, it means a variable or function in the form Collection@Variableor a literal. Types are annotated in the parenthesis, for example (num) is a number, and (_) is any type.

call

Syntax:

call FUNCNAME(fn)
Calls the function named FUNCNAME.

if

Syntax:

if VARNAME1(_) == VARNAME2(_) FUNCNAME(fn)
Uses the operator in the middle to compare VARNAME1 and VARNAME2, and if the result is true, calls FUNCNAME. Operators include: ==, !=, <, >, <=, >=.

print

Syntax:

print(VARNAME1(_))

Prints the value of VARNAME to the console.

input

Syntax:

VARNAME1(str) = input(VARNAME2(str))

Gets user input from the console with prompt VARNAME2 and stores the result in VARNAME1.

timeit

Syntax:

timeit FUNCNAME(fn)
Measures the time taken to execute FUNCNAME and prints the result to the console.

loop

Syntax:

loop FUNCNAME(fn), VARNAME1(num), VARNAME2(num)

Loops from VARNAME1 to VARNAME2 (end value exclusive) and calls FUNCNAME in each iteration.

until_break

Syntax:

until_break FUNCNAME(fn)

Loops until breaking and calls FUNCNAME in each iteration.

break

Syntax:

break

Exits the current loop immediately.

Variable Cloning

Syntax:

VARNAME1(_) <- VARNAME2(_)

Clones the value of VARNAME2 into VARNAME1. This used when needing to temporarily store a value before modifying it, such as with a counter.

exec

Syntax:

VARNAME1 = exec(VARNAME2(str))

Executes the commandline command in the string VARNAME2, outputs result to VARNAME1

Types

Syntax:

1
2
3
4
5
6
7
8
NUM num: 1.0
STR str: "Hello, World!"
BOOL bool: true
ARR arr: [1, 2, 3]
TUP tuple: ("HELLO WORLD", 123)
MAP map: {test: "HELLO WORLD"}
FN l: |print(?@str)|
(_) unknown: ""

All variables are typed, if the type (_) is used the type is inferred, otherwise its explicit.

wait

Syntax:

wait(VARNAME(num))

Pauses execution for the number of seconds specified in VARNAME.

Legacy Shorthand Operator

Syntax:

?@VARNAME = 1+1

The shorthand ? is used for the current collection instead of writing out the full name. This has been replaced by just typing the variable name without collection name or @, this feature is depreceated but has been left in for backwards compatibility.

free

Syntax:

free(VARNAME(str))

Frees the variable VARNAME from memory, allowing it to be reused. Useful for memory management.

exit

Syntax:

exit

Exits the program forcefully

fwrite

Syntax:

fwrite(VARNAME1(str), VARNAME2(str))

Writes the contents of the string VARNAME2 to the file at path VARNAME1, replacing the files contents and creating the file if it does not exist

fread

Syntax:

VARNAME1(str) = fread(VARNAME2(str))

Reads the contents of the file at path VARNAME2, returning the result to VARNAME1

t_spawn

Syntax:

VARNAME1(num) = t_spawn(VARNAME2(fn))

Spawns the function VARNAME2 in a thread, returning the thread ID to VARNAME1

t_join

Syntax:

VARNAME1(bool) = t_join(VARNAME2(num))

Waits for the thread with id VARNAME2 to end, returning a bool for success

parse

Syntax:

VARNAME1(_) = parse(VARNAME2(str))

Parses the string representation of a variable of a different type to that type. For example "100" becomes the number 100.