Like LISP, a 'list' is the fundamental datatype, and every expression evaluates to a list.

<expr1> indicates the parameter passed in will be the final element from the evaluated list.

<exprList> is a list of expressions (each of which can evaluate to a list), which will be passed as a flattened list to the function.

Arithmetical Operations

add

(add <exprList>)

Adds together the numbers evaluated in the expression list.

Example:

(add 1 2 3 (list 4 5 6) (list 7 "eight" 9))

returns 37.

divide

(divide <expr1> <expr2>

Divides expr1 by expr2 using integer division.

Example:

(div 15 5)

returns 3.

mult

(add <exprList>)

Multiplies together the numbers evaluated in the expression list.

Example:

(mult 1 2 3 (list 4 5 6) (list 7 "eight" 9))

returns 45360.

sub

(sub <expr1> <expr2>)

Subtracts expr2 from expr1.

Example:

(sub 42 (list 3 5))

returns 37.

Logical Operations

The empty list is considered false, and everything else is true.

To define constants for true and false, put (setg true "true") and (setg false (list)) at the start of the program ((list) defines an empty list).

Since false is the empty list, (print (equals 1 0)) will print nothing to the screen.

and

(and <exprList>)

Evaluates to true if every element evaluates to "true".

It is a short-cutting boolean operation.

Example:

(and (equals 1 1) (lt 1 2) (list "true" "true"))

returns true.

not

(not <expr>)

Evaluates to true if expr is false, and false if expr is true.

For example:

(not (equals 1 1))

returns false.

or

(or <exprList>)

Evaluates to true if any element evaluates to "true".

It is a short-cutting boolean operation.

Example:

(or (equals 0 1) (lt 1 2) (list (list) (list)))

returns true.

Control Flow

when

(when <condition> <exprList>)

Evaluates <exprList> if <condition> evaluates to true.

Example:

(when (equals 1 1) (print "Hello") (print "World"))

returns:

Hello

World

if

(if <condition> <expr1> <expr2>)

Evaluate <expr1> if <condition> evaluates to true, otherwise <expr2>.

<expr2> is optional.

For example:

(if (equals 1 0) "It does!" "It doesn't!")

returns "It doesn't!".

while

(while <expr> <exprList>)

Repeatedly evaluates <exprList> for as long as <expr> is true.

Example:

(setg n 0)

(while (lt n 3) n (setg n (add 1 n)))

returns:

0

1

2