Symbol | Stack diagram |
error |
s error! [machine halts with an error]
|
add |
x y add! (x+y)
|
sub |
x y sub! (x-y)
|
mul |
x y mul! (x*y)
|
div |
x y div! (x/y)
|
neg |
x neg! (-x)
|
inv |
x inv! (1/x)
|
truncate |
x truncate! y
where
y = (truncate x) in Haskell
|
todouble |
x todouble! y
where
y represents the integer x as a double
|
inc |
x inc! (x+1)
|
dec |
x dec! (x-1)
|
pop |
x pop!
|
dup |
x dup! x x
|
dup2 |
x y dup2! x y x y
|
swap |
y x swap! x y
|
not |
b not! (!b)
|
and |
a b and! (a&&b)
|
or |
a b or! (a||b)
|
eq |
x y eq! (x==y)
|
ne |
x y ne! (x/=y)
|
lt |
x y lt! (x<y)
|
le |
x y le! (x<=y)
|
gt |
x y gt! (x>y)
|
ge |
x y ge! (x>=y)
|
iszero |
x iszero! (x==0)
|
if |
p t f if! (p ? t : f)
|
cons |
x y cons! (x,y)
|
car |
(x,y) car! x
|
cdr |
(x,y) cdr! y
|
isempty |
[] isempty! true
[a1, ...] isempty! false
|
prepend |
[] x prepend! [x]
[a1, ..., an] x prepend! [x, a1, ..., an]
|
repeat |
f n repeat! r
where
f! f! f! r
\________/
n times
|
append |
[] x append! [x]
[a_1, ..., a_n] x append! [a_1, ..., a_n, x]
|
map |
[a_1, ..., a_n] f map! [b_1, ..., b_n]
where
a_i f! b_i
|
foldr |
[] f b foldr! b
[a_1, ..., a_n] f b foldr! r_1
where
a_n b f! r_n
a_(n-1) r_n f! r_(n-1)
...
a_1 r_2 f! r_1
|
list |
a_1 ... a_n n list! [a_1, ..., a_n]
|
unlist |
[a_1, ..., a_n] unlist! a_1 ... a_n
|
length |
[a_1, ..., a_n] length! n
|
seq |
s f seq! [s, s+1, ..., f-1, f]
|
reverse |
[a_1, ..., a_n] reverse! [a_n, ..., a_1]
|