The Lambda Lab
/
projects
/
forth.jl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Still messing around with vocabs.
[forth.jl.git]
/
src
/
lib_10_misc.4th
1
\ Miscellaneous core words
2
3
: ROLL ( x_u x_u-1... x_0 u -- x_u-1 ... x_0 x_u )
4
1+ DUP PICK SWAP ( x_u x_u-1 ... x_0 x_u u+1 )
5
PSP@ 1- SWAP - PSP@ 2- SWAP
6
DO
7
i 1+ @ i !
8
LOOP
9
SWAP DROP
10
;
11
12
( Compute absolute value. )
13
: ABS ( n -- |n| )
14
dup 0< if
15
negate
16
then
17
;
18
19
: MAX ( n m -- max )
20
2dup - 0< if
21
swap drop
22
else
23
drop
24
then
25
;
26
27
: MIN ( n m -- max )
28
2dup - 0> if
29
swap drop
30
else
31
drop
32
then
33
;
34
35
: UNUSED ( -- cells )
36
MEMSIZE HERE - ;