From 6b5c06d45a8ee067fcb62bb6e02b6dd95c634292 Mon Sep 17 00:00:00 2001 From: HorseMD Date: Fri, 14 Nov 2014 11:23:14 +0000 Subject: [PATCH] Remove unnecessary swap, give array helper word a better name. --- forth.html.markdown | 10 +++++----- 1 file 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 ------------------------------