summaryrefslogtreecommitdiffhomepage
path: root/forth.html.markdown
diff options
context:
space:
mode:
authorHorseMD <alightedness@gmail.com>2014-11-14 00:14:38 +0000
committerHorseMD <alightedness@gmail.com>2014-11-14 00:14:38 +0000
commitf1688b8000eeb39bc1e89b06c6a55eb74a081b96 (patch)
tree6068a65da2d672d7c7825c97fd431a1d5961d749 /forth.html.markdown
parent601f06e72d48ce0d16f9d34dc1f74418eddae654 (diff)
Illustrate parameters via loops.
Diffstat (limited to 'forth.html.markdown')
-rw-r--r--forth.html.markdown8
1 files changed, 4 insertions, 4 deletions
diff --git a/forth.html.markdown b/forth.html.markdown
index e799655b..a6b17a5d 100644
--- a/forth.html.markdown
+++ b/forth.html.markdown
@@ -108,12 +108,12 @@ myloop
\ We can get the value of the index as we loop with `i`:
: one-to-12 ( -- ) 12 0 do i . loop ; \ ok
one-to-12 \ 0 1 2 3 4 5 6 7 8 9 10 11 12 ok
-: squares ( -- ) 10 0 do i dup * . loop ; \ ok
-squares \ 0 1 4 9 16 25 36 49 64 81 ok
+: squares ( -- ) 0 do i dup * . loop ; \ ok
+10 squares \ 0 1 4 9 16 25 36 49 64 81 ok
\ Change the "step" with `+loop`:
-: threes ( -- ) 15 0 do i . 3 +loop ; \ ok
-threes \ 0 3 6 9 12 ok
+: threes ( -- ) do i . 3 +loop ; \ ok
+15 0 threes \ 0 3 6 9 12 ok
\ Finally, while loops with `begin` <stuff to do> <flag> `unil`:
: death ( -- ) begin ." Are we there yet?" 0 until ; \ ok