The Lambda Lab
/
projects
/
forth.jl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eaec011
)
Working on ROLL, redefined SPACES
author
Tim Vaughan
<tgvaughan@gmail.com>
Tue, 26 Apr 2016 19:38:43 +0000
(07:38 +1200)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Tue, 26 Apr 2016 19:38:43 +0000
(07:38 +1200)
src/lib.4th
patch
|
blob
|
history
diff --git
a/src/lib.4th
b/src/lib.4th
index
51f0b97
..
1f97d20
100644
(file)
--- a/
src/lib.4th
+++ b/
src/lib.4th
@@
-170,16
+170,15
@@
@ ( and fetch )
;
+: ROLL ( x_u x_u-1... x_0 u -- x_u-1 ... x_0 x_u )
+ 1+ DUP PICK SWAP ( x_u x_u-1 ... x_0 x_u u+1 )
+;
( With the looping constructs, we can now write SPACES, which writes n spaces to stdout. )
: SPACES ( n -- )
- BEGIN
- DUP 0> ( while n > 0 )
- WHILE
- SPACE ( print a space )
- 1- ( until we count down to 0 )
- REPEAT
- DROP
+ 0 DO
+ SPACE
+ LOOP
;
( Standard words for manipulating BASE. )