summaryrefslogtreecommitdiffhomepage
path: root/forth.html.markdown
diff options
context:
space:
mode:
authorHorseMD <alightedness@gmail.com>2014-11-14 11:23:14 +0000
committerHorseMD <alightedness@gmail.com>2014-11-14 11:23:14 +0000
commit6b5c06d45a8ee067fcb62bb6e02b6dd95c634292 (patch)
tree58395e3a7a73ec0863a79eab35532ded9e35ad09 /forth.html.markdown
parenta49ab049a54f3961f3e491d48678b421c7662ee1 (diff)
Remove unnecessary swap, give array helper word a better name.
Diffstat (limited to 'forth.html.markdown')
-rw-r--r--forth.html.markdown10
1 files changed, 5 insertions, 5 deletions
diff --git a/forth.html.markdown b/forth.html.markdown
index 847895c3..0521a3ab 100644
--- a/forth.html.markdown
+++ b/forth.html.markdown
@@ -161,13 +161,13 @@ create mynumbers 64 , 9001 , 1337 , \ ok (the last `,` is important!)
0 cells mynumbers + ? \ 64 ok
1 cells mynumbers + ? \ 9001 ok
-\ We can simplify it by making a helper word for manipulating arrays:
-: arr ( n n -- n ) cells swap + ;
-mynumbers 2 arr ? \ 1337 ok
+\ We can simplify it a little by making a helper word for manipulating arrays:
+: of-arr ( n n -- n ) cells + ; \ ok
+mynumbers 2 of-arr ? \ 1337 ok
\ Which we can use for writing too:
-20 mynumbers 1 arr ! \ ok
-mynumbers 1 arr ? \ 20 ok
+20 mynumbers 1 of-arr ! \ ok
+mynumbers 1 of-arr ? \ 20 ok
\ ------------------------------ The Return Stack ------------------------------