]> Untitled Git - monorepo.git/commitdiff
add blog post
authorPreston Pan <preston@nullring.xyz>
Fri, 26 Jan 2024 21:20:50 +0000 (13:20 -0800)
committerPreston Pan <preston@nullring.xyz>
Fri, 26 Jan 2024 21:20:50 +0000 (13:20 -0800)
blog/stem.org

index a467e8829806834f72e3e566c81527d4ddce1f79..17820cd87aadc872c470784145c7a3afc93d2e5c 100644 (file)
@@ -230,6 +230,7 @@ on the stack back after, with the value at that index on top. There are two more
 #+begin_src stem :exports both
 1 2 swap . .
 1 2 . .
+"hello\n" dup . .
 1 2 5 [ + ] dip . .
 #+end_src
 
@@ -238,10 +239,13 @@ on the stack back after, with the value at that index on top. There are two more
 : 2
 : 2
 : 1
+: hello
+: hello
 : 5
 : 3
 
-~swap~ just swaps the top two numbers on the stack, and ~dip~ is just ~eval~ except it does the operation one layer below. In this example, it adds 1 and 2
+~swap~ just swaps the top two numbers on the stack, ~dup~ just duplicates the top of the stack,
+and ~dip~ is just ~eval~ except it does the operation one layer below. In this example, it adds 1 and 2
 instead of 2 and 5, thus you see a 5 and a 3 printed instead. Note that there are more words, but we won't need them for now. Now, we are ready to investigate
 how to define words in terms of other words, or so-called /compound words/.