summaryrefslogtreecommitdiffhomepage
path: root/forth.html.markdown
diff options
context:
space:
mode:
authorHorseMD <alightedness@gmail.com>2014-11-13 00:13:54 +0000
committerHorseMD <alightedness@gmail.com>2014-11-13 00:13:54 +0000
commite5fbd94af0455cfcac15e398c41a0686b69d38ec (patch)
treeb220b3fd733a0b301fb8c308cf8b7d650c303148 /forth.html.markdown
parentae2728d58009abfd7d50c2fbc346e46a58e0c2fc (diff)
Refactor section Stack Manipulation.
Diffstat (limited to 'forth.html.markdown')
-rw-r--r--forth.html.markdown16
1 files changed, 4 insertions, 12 deletions
diff --git a/forth.html.markdown b/forth.html.markdown
index 7b805057..91591ac9 100644
--- a/forth.html.markdown
+++ b/forth.html.markdown
@@ -56,17 +56,10 @@ of what is written here should work elsewhere.
\ Naturally, as we do so much work with the stack, we'll want some useful methods.
-drop \ drop (remove) the item at the top of the stack (note the difference between this and `.`)
-dup \ duplicate the item on top the stack
-rot \ rotate the top three items (third -> first, first -> second, second -> third)
-swap \ swaps the top item with the second item
-
-\ Examples:
-
-dup * \ square the top item
-2 5 dup * swap / \ half the top item squared
-6 4 5 rot * - \ sometimes we just want to reorganize
-4 0 drop 2 / \ add 4 and 0, remove 0 and divide the top by 2
+3 dup - \ duplicate the top item (1st now equals 2nd): 3 - 3
+2 5 swap / \ swap the top with the second element: 5 / 2
+6 4 5 rot .s \ rotate the top 3 elements: 4 5 6 ok
+4 0 drop 2 / \ remove the top item (dont print to screen): 4 / 2
\ ------------------------------ More Advanced Stack Manipulation ------------------------------
@@ -173,7 +166,6 @@ mynumbers 3 cells erase
\ them to 0 we just use `erase`).
\ or we can just skip all the above and initialize with specific values:
-
create mynumbers 64 , 9001 , 1337 , \ the last `,` is important!
\ ...which is equivalent to: