about summary refs log tree commit diff stats
path: root/html/075duplex_list.mu.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-12-15 14:32:47 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-12-15 14:32:47 -0800
commit67db19a05335c7fbea3ad6737303c8848fd39e74 (patch)
tree00d9585bf4de231254867d8c7515386934bb3d3f /html/075duplex_list.mu.html
parent62a390ca0a27daa80ce4b6b17934d8d067db8631 (diff)
downloadmu-67db19a05335c7fbea3ad6737303c8848fd39e74.tar.gz
2545
update html
Diffstat (limited to 'html/075duplex_list.mu.html')
-rw-r--r--html/075duplex_list.mu.html97
1 files changed, 47 insertions, 50 deletions
diff --git a/html/075duplex_list.mu.html b/html/075duplex_list.mu.html
index f2094cde..4a0abcbb 100644
--- a/html/075duplex_list.mu.html
+++ b/html/075duplex_list.mu.html
@@ -40,17 +40,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   prev:address:duplex-list:_elem
 ]
 
-<span class="muRecipe">recipe</span> push x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>result:address:duplex-list:_elem [
+<span class="Comment"># should I say in/contained-in:result, allow ingredients to refer to products?</span>
+<span class="muRecipe">recipe</span> push x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>in:address:duplex-list:_elem [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  result<span class="Special"> &lt;- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span>
+  result:address:duplex-list:_elem<span class="Special"> &lt;- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span>
   val:address:_elem<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">value:offset</span>
   *val<span class="Special"> &lt;- </span>copy x
   next:address:address:duplex-list:_elem<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">next:offset</span>
   *next<span class="Special"> &lt;- </span>copy in
-  <span class="muControl">reply-unless</span> in
-  prev:address:address:duplex-list:_elem<span class="Special"> &lt;- </span>get-address *in, <span class="Constant">prev:offset</span>
-  *prev<span class="Special"> &lt;- </span>copy result
+  <span class="Delimiter">{</span>
+    <span class="muControl">break-unless</span> in
+    prev:address:address:duplex-list:_elem<span class="Special"> &lt;- </span>get-address *in, <span class="Constant">prev:offset</span>
+    *prev<span class="Special"> &lt;- </span>copy result
+  <span class="Delimiter">}</span>
+  <span class="muControl">reply</span> result  <span class="Comment"># needed explicitly because we need to replace 'in' with 'result'</span>
 ]
 
 <span class="muRecipe">recipe</span> first in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>result:_elem [
@@ -60,14 +64,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   result<span class="Special"> &lt;- </span>get *in, <span class="Constant">value:offset</span>
 ]
 
-<span class="muRecipe">recipe</span> next in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>result:address:duplex-list:_elem [
+<span class="muRecipe">recipe</span> next in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>result:address:duplex-list:_elem/contained-in:in [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="muControl">reply-unless</span> in, <span class="Constant">0</span>
   result<span class="Special"> &lt;- </span>get *in, <span class="Constant">next:offset</span>
 ]
 
-<span class="muRecipe">recipe</span> prev in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>result:address:duplex-list:_elem [
+<span class="muRecipe">recipe</span> prev in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>result:address:duplex-list:_elem/contained-in:in [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="muControl">reply-unless</span> in, <span class="Constant">0</span>
@@ -116,11 +120,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   ]
 ]
 
-<span class="Comment"># Inserts 'x' after 'in'. Returns some pointer into the list.</span>
-<span class="muRecipe">recipe</span> insert x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>new-node:address:duplex-list:_elem [
+<span class="Comment"># insert 'x' after 'in'</span>
+<span class="muRecipe">recipe</span> insert x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>in:address:duplex-list:_elem [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  new-node<span class="Special"> &lt;- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span>
+  new-node:address:duplex-list:_elem<span class="Special"> &lt;- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span>
   val:address:_elem<span class="Special"> &lt;- </span>get-address *new-node, <span class="Constant">value:offset</span>
   *val<span class="Special"> &lt;- </span>copy x
   next-node:address:duplex-list:_elem<span class="Special"> &lt;- </span>get *in, <span class="Constant">next:offset</span>
@@ -134,11 +138,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   y<span class="Special"> &lt;- </span>get-address *new-node, <span class="Constant">next:offset</span>
   *y<span class="Special"> &lt;- </span>copy next-node
   <span class="Comment"># if next-node is not null</span>
-  <span class="muControl">reply-unless</span> next-node, new-node
+  <span class="muControl">reply-unless</span> next-node
   <span class="Comment"># next-node.prev = new-node</span>
   y<span class="Special"> &lt;- </span>get-address *next-node, <span class="Constant">prev:offset</span>
   *y<span class="Special"> &lt;- </span>copy new-node
-  <span class="muControl">reply</span> new-node  <span class="Comment"># just signalling something changed; don't rely on the result</span>
 ]
 
 <span class="muScenario">scenario</span> inserting-into-duplex-list [
@@ -219,7 +222,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">3</span>, <span class="Constant">0</span>
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character
-    <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>insert <span class="Constant">6</span>, <span class="Constant">1</span>:address:duplex-list:character
+    <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>insert <span class="Constant">6</span>, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Comment"># check structure like before</span>
     <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">3</span>:character<span class="Special"> &lt;- </span>first <span class="Constant">2</span>:address:duplex-list:character
@@ -249,38 +252,37 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   ]
 ]
 
-<span class="Comment"># Removes 'in' from its surrounding list. Returns some valid pointer into the</span>
-<span class="Comment"># rest of the list.</span>
+<span class="Comment"># remove 'x' from its surrounding list 'in'</span>
 <span class="Comment">#</span>
-<span class="Comment"># Returns null if and only if list is empty. Beware: in that case any pointers</span>
-<span class="Comment"># to the head are now invalid.</span>
-<span class="muRecipe">recipe</span> remove in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>next-node:address:duplex-list:_elem [
+<span class="Comment"># Returns null if and only if list is empty. Beware: in that case any other</span>
+<span class="Comment"># pointers to the head are now invalid.</span>
+<span class="muRecipe">recipe</span> remove x:address:duplex-list:_elem/contained-in:in, in:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>in:address:duplex-list:_elem [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  <span class="Comment"># if 'in' is null, return</span>
-  <span class="muControl">reply-unless</span> in, in
-  next-node:address:duplex-list:_elem<span class="Special"> &lt;- </span>get *in, <span class="Constant">next:offset</span>
-  prev-node:address:duplex-list:_elem<span class="Special"> &lt;- </span>get *in, <span class="Constant">prev:offset</span>
-  <span class="Comment"># null in's pointers</span>
-  x:address:address:duplex-list:_elem<span class="Special"> &lt;- </span>get-address *in, <span class="Constant">next:offset</span>
-  *x<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
-  x<span class="Special"> &lt;- </span>get-address *in, <span class="Constant">prev:offset</span>
-  *x<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  <span class="Comment"># if 'x' is null, return</span>
+  <span class="muControl">reply-unless</span> x
+  next-node:address:duplex-list:_elem<span class="Special"> &lt;- </span>get *x, <span class="Constant">next:offset</span>
+  prev-node:address:duplex-list:_elem<span class="Special"> &lt;- </span>get *x, <span class="Constant">prev:offset</span>
+  <span class="Comment"># null x's pointers</span>
+  tmp:address:address:duplex-list:_elem<span class="Special"> &lt;- </span>get-address *x, <span class="Constant">next:offset</span>
+  *tmp<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  tmp<span class="Special"> &lt;- </span>get-address *x, <span class="Constant">prev:offset</span>
+  *tmp<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  <span class="Comment"># if next-node is not null, set its prev pointer</span>
   <span class="Delimiter">{</span>
-    <span class="Comment"># if next-node is not null</span>
     <span class="muControl">break-unless</span> next-node
-    <span class="Comment"># next-node.prev = prev-node</span>
-    x<span class="Special"> &lt;- </span>get-address *next-node, <span class="Constant">prev:offset</span>
-    *x<span class="Special"> &lt;- </span>copy prev-node
+    tmp<span class="Special"> &lt;- </span>get-address *next-node, <span class="Constant">prev:offset</span>
+    *tmp<span class="Special"> &lt;- </span>copy prev-node
   <span class="Delimiter">}</span>
+  <span class="Comment"># if prev-node is not null, set its next pointer and return</span>
   <span class="Delimiter">{</span>
-    <span class="Comment"># if prev-node is not null</span>
     <span class="muControl">break-unless</span> prev-node
-    <span class="Comment"># prev-node.next = next-node</span>
-    x<span class="Special"> &lt;- </span>get-address *prev-node, <span class="Constant">next:offset</span>
-    *x<span class="Special"> &lt;- </span>copy next-node
-    <span class="muControl">reply</span> prev-node
+    tmp<span class="Special"> &lt;- </span>get-address *prev-node, <span class="Constant">next:offset</span>
+    *tmp<span class="Special"> &lt;- </span>copy next-node
+    <span class="muControl">reply</span>
   <span class="Delimiter">}</span>
+  <span class="Comment"># if prev-node is null, then we removed the node at 'in'</span>
+  <span class="Comment"># return the new head rather than the old 'in'</span>
   <span class="muControl">reply</span> next-node
 ]
 
@@ -290,7 +292,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>next <span class="Constant">1</span>:address:duplex-list:character  <span class="Comment"># 2 points at second element</span>
-    <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">2</span>:address:duplex-list:character
+    <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">3</span>:boolean<span class="Special"> &lt;- </span>equal <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">0</span>
     <span class="Comment"># check structure like before</span>
     <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>:address:duplex-list:character
@@ -317,8 +319,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">3</span>, <span class="Constant">0</span>
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character
-    <span class="Comment"># removing from head? return value matters.</span>
-    <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">1</span>:address:duplex-list:character
+    <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Comment"># check structure like before</span>
     <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">3</span>:character<span class="Special"> &lt;- </span>first <span class="Constant">2</span>:address:duplex-list:character
@@ -346,7 +347,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     <span class="Comment"># delete last element</span>
     <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>next <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>next <span class="Constant">2</span>:address:duplex-list:character
-    <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">2</span>:address:duplex-list:character
+    <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character
     <span class="Constant">3</span>:boolean<span class="Special"> &lt;- </span>equal <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">0</span>
     <span class="Comment"># check structure like before</span>
     <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>:address:duplex-list:character
@@ -371,20 +372,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 <span class="muScenario">scenario</span> removing-from-singleton-list [
   run [
     <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>push <span class="Constant">3</span>, <span class="Constant">0</span>
-    <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">1</span>:address:duplex-list:character
-    <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> &lt;- </span>get *<span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">next:offset</span>
-    <span class="Constant">4</span>:address:duplex-list:character<span class="Special"> &lt;- </span>get *<span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">prev:offset</span>
+    <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> &lt;- </span>remove <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character
   ]
   memory-should-contain [
-    <span class="Constant">2</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># remove returned null</span>
-    <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># removed node is also detached</span>
-    <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
+    <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># back to an empty list</span>
   ]
 ]
 
 <span class="Comment"># remove values between 'start' and 'end' (both exclusive)</span>
 <span class="Comment"># also clear pointers back out from start/end for hygiene</span>
-<span class="muRecipe">recipe</span> remove-between start:address:duplex-list:_elem, end:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>start:address:duplex-list:_elem [
+<span class="muRecipe">recipe</span> remove-between start:address:duplex-list:_elem, end:address:duplex-list:_elem/contained-in:start<span class="muRecipe"> -&gt; </span>start:address:duplex-list:_elem [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="muControl">reply-unless</span> start
@@ -491,8 +488,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   ]
 ]
 
-<span class="Comment"># Inserts list beginning at 'new' after 'in'. Returns some pointer into the list.</span>
-<span class="muRecipe">recipe</span> insert-range in:address:duplex-list:_elem, start:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>in:address:duplex-list:_elem [
+<span class="Comment"># insert list beginning at 'new' after 'in'</span>
+<span class="muRecipe">recipe</span> insert-range in:address:duplex-list:_elem, start:address:duplex-list:_elem/contained-in:in<span class="muRecipe"> -&gt; </span>in:address:duplex-list:_elem [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="muControl">reply-unless</span> in
@@ -518,7 +515,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   *dest<span class="Special"> &lt;- </span>copy in
 ]
 
-<span class="muRecipe">recipe</span> append in:address:duplex-list:_elem, new:address:duplex-list:_elem<span class="muRecipe"> -&gt; </span>in:address:duplex-list:_elem [
+<span class="muRecipe">recipe</span> append in:address:duplex-list:_elem, new:address:duplex-list:_elem/contained-in:in<span class="muRecipe"> -&gt; </span>in:address:duplex-list:_elem [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   last:address:duplex-list:_elem<span class="Special"> &lt;- </span>last in