How to read the type charts
Type annotations are written for the ease of the programmer, not for the ease of the stack.
They appear exactly as you would see them when you are writing code.
In define
s case,
define :: (Atom, Any) -> Void
in practice looks like
:meaning_of_life 42 define
even though the 42
is technically at the top of the stack.
List of builtins
define
define :: (Atom, Any) -> Void
Takes two arguments, and defines the Any
as the name of the Atom
.
Can be used to define functions, as well as variables.
Recursion is allowed.
dup
dup :: Any -> (Any, Any)
Takes the first argument, and repushes it to the stack twice
float2int
float2int :: Float -> Int
Takes the first argument, and rounds it down to the nearest whole number
for
for :: (IntList, Atom, TokenList) -> Void
For every item in the IntList
, defines it as the Atom
, then executes the TokenList
.
if
if :: (Float, TokenList) -> Void
If the Float
is 1
run the TokenList
else do nothing.
ifelse
ifelse :: (Float, TokenList, TokenList) -> Void
If the Float
is 1
run the first TokenList
else run the second TokenList
.
print
print :: Any -> Void
Takes one argument, and prints it to the screen.
range
range :: (Int, Int) -> IntList
Generates an IntList
with all the numbers between the first Int
and the second Int
(non-inclusive at the end).
swap
range :: (Any, Any) -> (Any, Any)
This type annotation, while technically correct, does not do this function justice so have an alternative:
range :: (A,B) -> (B,A)
Swaps the two top values on the stack.
while
while :: (TokenList, TokenList) -> Void
While the first TokenList
returns 1, execute the second