aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/for-next.frt
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/common/lib/for-next.frt')
-rw-r--r--amforth-6.5/common/lib/for-next.frt18
1 files changed, 18 insertions, 0 deletions
diff --git a/amforth-6.5/common/lib/for-next.frt b/amforth-6.5/common/lib/for-next.frt
new file mode 100644
index 0000000..8a29ebf
--- /dev/null
+++ b/amforth-6.5/common/lib/for-next.frt
@@ -0,0 +1,18 @@
+\ for/next is from colorforth
+\ note that 0 and -1 are executable words, not numbers!
+\
+: for postpone 0
+ postpone swap
+ postpone do
+; immediate
+
+: next
+ postpone -1
+ postpone +loop
+; immediate
+
+\ test case
+\ : test 10 for i . next ;
+\ prints
+\ 10 9 8 7 6 5 4 3 2 1 0
+\ \ No newline at end of file