donotturnoff

builtin

Rex has some builtin functions which aren't supplied by external libraries and are therefore available to all programs.


Miscellaneous operations

exit

& exit -> null
exit = exit()

This halts the current program at its current position using Python's exit subroutine.

out

& out str -> null
out s = print(s)

This prints a string to the screen using Python's print subroutine.

in

& in str -> str
in s = input(s)

This prints a string prompt to the screen and accepts input following it, returning it as a string. It does this using Python's input function.

error

& error str str -> err
error eType message = message

This throws an error message containing the text in the message argument.

Arithmetic operations

+

& + num num -> num
+ x y = x + y

This returns the first argument add the second argument, using Python's + operator.

-

& - num num -> num
- x y = x - y

This returns the first argument minus the second argument, using Python's - operator.

*

& * num num -> num
* x y = x * y

This returns the first argument multiplied by the second argument, using Python's * operator.

/

& / num num -> num
/ x y = x / y

This returns the first argument divided by the second argument, using Python's / operator. If division by zero is attempted, a zeroDivisionErr is thrown.

%

& % num num -> num
% x y = x % y

This returns the first argument modulo the second argument (the remainder when the first argument is divided by the first argument), using Python's % operator.

Comparators

==

& == num num -> bool
== x y = x == y

This returns True if the first argument is equal to the second argument and False otherwise, using Python's == operator.

!=

& != num num -> bool
!= x y = x != y

This returns True if the first argument is not equal to the second argument and False otherwise, using Python's != operator.

<

& < num num -> bool
< x y = x < y

This returns True if the first argument is less than the second argument and False otherwise, using Python's < operator.

>

& > num num -> bool
> x y = x > y

This returns True if the first argument is greater than the second argument and False otherwise, using Python's > operator.

<=

& <= num num -> bool
<= x y = x <= y

This returns True if the first argument is less than or equal to the second argument and False otherwise, using Python's <= operator.

>=

& >= num num -> bool
>= x y = x >= y

This returns True if the first argument is greater than or equal to the second argument and False otherwise, using Python's >= operator.

Boolean operations

&&

& && bool bool -> bool
&& x y = x and y

This performs a Boolean AND operation on two Boolean values using Python's and operator.

||

& || bool bool -> bool
|| x y = x or y

This performs a Boolean OR operation on two Boolean values using Python's or operator.

!

!

& ! bool -> bool
! x = not x

This negates a Boolean value (i.e. ! True == False and ! False == True) using Python's not operator.

String operations

.

& . str str -> str
. s1 s2 = s1 + s2

This concatenates two strings to produce one string, using Python's concatenation operator.