diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
commit | f344b250f6f062a1a1902bf69b23ebf9b565de0e (patch) | |
tree | 199bd32a9aee198d5028b1c21b83d2cf0944b2b6 /html/065duplex_list.mu.html | |
parent | 897ae8c1855f830d8819759ea327d147f28a09bf (diff) | |
download | mu-f344b250f6f062a1a1902bf69b23ebf9b565de0e.tar.gz |
3395
Diffstat (limited to 'html/065duplex_list.mu.html')
-rw-r--r-- | html/065duplex_list.mu.html | 256 |
1 files changed, 128 insertions, 128 deletions
diff --git a/html/065duplex_list.mu.html b/html/065duplex_list.mu.html index 8dad9fc4..7cefee4d 100644 --- a/html/065duplex_list.mu.html +++ b/html/065duplex_list.mu.html @@ -36,15 +36,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muData">container</span> duplex-list:_elem [ value:_elem - next:address:duplex-list:_elem - prev:address:duplex-list:_elem + next:&:duplex-list:_elem + prev:&:duplex-list:_elem ] <span class="Comment"># should I say in/contained-in:result, allow ingredients to refer to products?</span> -<span class="muRecipe">def</span> push x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">def</span> push x:_elem, in:&:duplex-list:_elem<span class="muRecipe"> -> </span>in:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:address:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> + result:&:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> *result<span class="Special"> <- </span>merge x, in, <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> in @@ -53,21 +53,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> result <span class="Comment"># needed explicitly because we need to replace 'in' with 'result'</span> ] -<span class="muRecipe">def</span> first in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:_elem [ +<span class="muRecipe">def</span> first in:&:duplex-list:_elem<span class="muRecipe"> -> </span>result:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> in, <span class="Constant">0</span> result<span class="Special"> <- </span>get *in, <span class="Constant">value:offset</span> ] -<span class="muRecipe">def</span> next in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:duplex-list:_elem/contained-in:in [ +<span class="muRecipe">def</span> next in:&:duplex-list:_elem<span class="muRecipe"> -> </span>result:&:duplex-list:_elem/contained-in:in [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> in, <span class="Constant">0</span> result<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> ] -<span class="muRecipe">def</span> prev in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:duplex-list:_elem/contained-in:in [ +<span class="muRecipe">def</span> prev in:&:duplex-list:_elem<span class="muRecipe"> -> </span>result:&:duplex-list:_elem/contained-in:in [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> in, <span class="Constant">0</span> @@ -79,26 +79,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ <span class="Constant">local-scope</span> <span class="Comment"># reserve locations 0-9 to check for missing null check</span> - <span class="Constant">10</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">34</span> - <span class="Constant">11</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">35</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">10</span>:num/<span class="Special">raw <- </span>copy <span class="Constant">34</span> + <span class="Constant">11</span>:num/<span class="Special">raw <- </span>copy <span class="Constant">35</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">4</span>, list list<span class="Special"> <- </span>push <span class="Constant">5</span>, list - list2:address:duplex-list:character<span class="Special"> <- </span>copy list - <span class="Constant">20</span>:character/<span class="Special">raw <- </span>first list2 + list2:&:duplex-list:char<span class="Special"> <- </span>copy list + <span class="Constant">20</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">21</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">21</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">22</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">30</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list2 - <span class="Constant">31</span>:character/<span class="Special">raw <- </span>first <span class="Constant">30</span>:address:duplex-list:character/<span class="Special">raw</span> - <span class="Constant">32</span>:address:duplex-list:character/<span class="Special">raw <- </span>next <span class="Constant">30</span>:address:duplex-list:character/<span class="Special">raw</span> - <span class="Constant">33</span>:address:duplex-list:character/<span class="Special">raw <- </span>prev <span class="Constant">30</span>:address:duplex-list:character/<span class="Special">raw</span> + <span class="Constant">22</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">30</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list2 + <span class="Constant">31</span>:char/<span class="Special">raw <- </span>first <span class="Constant">30</span>:&:duplex-list:char/<span class="Special">raw</span> + <span class="Constant">32</span>:&:duplex-list:char/<span class="Special">raw <- </span>next <span class="Constant">30</span>:&:duplex-list:char/<span class="Special">raw</span> + <span class="Constant">33</span>:&:duplex-list:char/<span class="Special">raw <- </span>prev <span class="Constant">30</span>:&:duplex-list:char/<span class="Special">raw</span> list2<span class="Special"> <- </span>prev list2 - <span class="Constant">40</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">40</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">41</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">50</span>:boolean/<span class="Special">raw <- </span>equal list, list2 + <span class="Constant">41</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">50</span>:bool/<span class="Special">raw <- </span>equal list, list2 ] memory-should-contain [ <span class="Constant">0</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no modifications to null pointers</span> @@ -118,13 +118,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># insert 'x' after 'in'</span> -<span class="muRecipe">def</span> insert x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">def</span> insert x:_elem, in:&:duplex-list:_elem<span class="muRecipe"> -> </span>in:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - new-node:address:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> + new-node:&:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> *new-node<span class="Special"> <- </span>put *new-node, <span class="Constant">value:offset</span>, x <span class="Comment"># save old next before changing it</span> - next-node:address:duplex-list:_elem<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> + next-node:&:duplex-list:_elem<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> *in<span class="Special"> <- </span>put *in, <span class="Constant">next:offset</span>, new-node *new-node<span class="Special"> <- </span>put *new-node, <span class="Constant">prev:offset</span>, in *new-node<span class="Special"> <- </span>put *new-node, <span class="Constant">next:offset</span>, next-node @@ -135,27 +135,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> inserting-into-duplex-list [ run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">4</span>, list list<span class="Special"> <- </span>push <span class="Constant">5</span>, list - list2:address:duplex-list:character<span class="Special"> <- </span>next list <span class="Comment"># inside list</span> + list2:&:duplex-list:char<span class="Special"> <- </span>next list <span class="Comment"># inside list</span> list2<span class="Special"> <- </span>insert <span class="Constant">6</span>, list2 <span class="Comment"># check structure like before</span> list2<span class="Special"> <- </span>copy list - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">13</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">13</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">20</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">20</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">21</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">21</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">22</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">30</span>:boolean/<span class="Special">raw <- </span>equal list, list2 + <span class="Constant">22</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">30</span>:bool/<span class="Special">raw <- </span>equal list, list2 ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next</span> @@ -172,28 +172,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> inserting-at-end-of-duplex-list [ run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">4</span>, list list<span class="Special"> <- </span>push <span class="Constant">5</span>, list - list2:address:duplex-list:character<span class="Special"> <- </span>next list <span class="Comment"># inside list</span> + list2:&:duplex-list:char<span class="Special"> <- </span>next list <span class="Comment"># inside list</span> list2<span class="Special"> <- </span>next list2 <span class="Comment"># now at end of list</span> list2<span class="Special"> <- </span>insert <span class="Constant">6</span>, list2 <span class="Comment"># check structure like before</span> list2<span class="Special"> <- </span>copy list - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">13</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">13</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">20</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">20</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">21</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">21</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">22</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">30</span>:boolean/<span class="Special">raw <- </span>equal list, list2 + <span class="Constant">22</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">30</span>:bool/<span class="Special">raw <- </span>equal list, list2 ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next</span> @@ -210,26 +210,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> inserting-after-start-of-duplex-list [ run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">4</span>, list list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list<span class="Special"> <- </span>insert <span class="Constant">6</span>, list <span class="Comment"># check structure like before</span> - list2:address:duplex-list:character<span class="Special"> <- </span>copy list - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>first list2 + list2:&:duplex-list:char<span class="Special"> <- </span>copy list + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">13</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">13</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">20</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">20</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">21</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">21</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">22</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">30</span>:boolean/<span class="Special">raw <- </span>equal list, list2 + <span class="Constant">22</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">30</span>:bool/<span class="Special">raw <- </span>equal list, list2 ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next</span> @@ -247,13 +247,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment">#</span> <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">def</span> remove x:address:duplex-list:_elem/contained-in:in, in:address:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">def</span> remove x:&:duplex-list:_elem/contained-in:in, in:&:duplex-list:_elem<span class="muRecipe"> -> </span>in:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if 'x' is null, return</span> <span class="muControl">return-unless</span> x - next-node:address:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">next:offset</span> - prev-node:address:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">prev:offset</span> + next-node:&:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">next:offset</span> + prev-node:&:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">prev:offset</span> <span class="Comment"># null x's pointers</span> *x<span class="Special"> <- </span>put *x, <span class="Constant">next:offset</span>, <span class="Constant">0</span> *x<span class="Special"> <- </span>put *x, <span class="Constant">prev:offset</span>, <span class="Constant">0</span> @@ -276,21 +276,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> removing-from-duplex-list [ run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">4</span>, list list<span class="Special"> <- </span>push <span class="Constant">5</span>, list - list2:address:duplex-list:character<span class="Special"> <- </span>next list <span class="Comment"># second element</span> + list2:&:duplex-list:char<span class="Special"> <- </span>next list <span class="Comment"># second element</span> list<span class="Special"> <- </span>remove list2, list - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</span> + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</span> <span class="Comment"># check structure like before</span> list2<span class="Special"> <- </span>copy list - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">20</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list2 + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">20</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">30</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">40</span>:boolean/<span class="Special">raw <- </span>equal list, list2 + <span class="Constant">30</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">40</span>:bool/<span class="Special">raw <- </span>equal list, list2 ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># remove returned non-null</span> @@ -305,19 +305,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> removing-from-start-of-duplex-list [ run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">4</span>, list list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list<span class="Special"> <- </span>remove list, list <span class="Comment"># check structure like before</span> - list2:address:duplex-list:character<span class="Special"> <- </span>copy list - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>first list2 + list2:&:duplex-list:char<span class="Special"> <- </span>copy list + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">20</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list2 + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">20</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">30</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">40</span>:boolean/<span class="Special">raw <- </span>equal list, list2 + <span class="Constant">30</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">40</span>:bool/<span class="Special">raw <- </span>equal list, list2 ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># scanning next, skipping deleted element</span> @@ -331,23 +331,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> removing-from-end-of-duplex-list [ run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">4</span>, list list<span class="Special"> <- </span>push <span class="Constant">5</span>, list <span class="Comment"># delete last element</span> - list2:address:duplex-list:character<span class="Special"> <- </span>next list + list2:&:duplex-list:char<span class="Special"> <- </span>next list list2<span class="Special"> <- </span>next list2 list<span class="Special"> <- </span>remove list2, list - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</span> + <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</span> <span class="Comment"># check structure like before</span> list2<span class="Special"> <- </span>copy list - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>first list2 + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>first list2 list2<span class="Special"> <- </span>next list2 - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">20</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list2 + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">20</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list2 list2<span class="Special"> <- </span>prev list2 - <span class="Constant">30</span>:character/<span class="Special">raw <- </span>first list2 - <span class="Constant">40</span>:boolean/<span class="Special">raw <- </span>equal list, list2 + <span class="Constant">30</span>:char/<span class="Special">raw <- </span>first list2 + <span class="Constant">40</span>:bool/<span class="Special">raw <- </span>equal list, list2 ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># remove returned non-null</span> @@ -362,9 +362,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> removing-from-singleton-duplex-list [ run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>remove list, list - <span class="Constant">1</span>:number/<span class="Special">raw <- </span>copy list + <span class="Constant">1</span>:num/<span class="Special">raw <- </span>copy list ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># back to an empty list</span> @@ -376,11 +376,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># set end to 0 to delete everything past start.</span> <span class="Comment"># can't set start to 0 to delete everything before end, because there's no</span> <span class="Comment"># clean way to return the new head pointer.</span> -<span class="muRecipe">def</span> remove-between start:address:duplex-list:_elem, end:address:duplex-list:_elem/contained-in:start<span class="muRecipe"> -> </span>start:address:duplex-list:_elem [ +<span class="muRecipe">def</span> remove-between start:&:duplex-list:_elem, end:&:duplex-list:_elem/contained-in:start<span class="muRecipe"> -> </span>start:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - next:address:duplex-list:_elem<span class="Special"> <- </span>get *start, <span class="Constant">next:offset</span> - nothing-to-delete?:boolean<span class="Special"> <- </span>equal next, end + next:&:duplex-list:_elem<span class="Special"> <- </span>get *start, <span class="Constant">next:offset</span> + nothing-to-delete?:bool<span class="Special"> <- </span>equal next, end <span class="muControl">return-if</span> nothing-to-delete? assert next, <span class="Constant">[malformed duplex list]</span> <span class="Comment"># start->next->prev = 0</span> @@ -390,7 +390,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return-unless</span> end <span class="Comment"># end->prev->next = 0</span> <span class="Comment"># end->prev = start</span> - prev:address:duplex-list:_elem<span class="Special"> <- </span>get *end, <span class="Constant">prev:offset</span> + prev:&:duplex-list:_elem<span class="Special"> <- </span>get *end, <span class="Constant">prev:offset</span> assert prev, <span class="Constant">[malformed duplex list - 2]</span> *prev<span class="Special"> <- </span>put *prev, <span class="Constant">next:offset</span>, <span class="Constant">0</span> *end<span class="Special"> <- </span>put *end, <span class="Constant">prev:offset</span>, start @@ -399,28 +399,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> remove-range [ <span class="Comment"># construct a duplex list with six elements [13, 14, 15, 16, 17, 18]</span> <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">17</span>, list list<span class="Special"> <- </span>push <span class="Constant">16</span>, list list<span class="Special"> <- </span>push <span class="Constant">15</span>, list list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> + <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw</span> <span class="Comment"># restore list</span> + list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># delete 16 onwards</span> <span class="Comment"># first pointer: to the third element</span> - list2:address:duplex-list:character<span class="Special"> <- </span>next list + list2:&:duplex-list:char<span class="Special"> <- </span>next list list2<span class="Special"> <- </span>next list2 list2<span class="Special"> <- </span>remove-between list2, <span class="Constant">0</span> <span class="Comment"># now check the list</span> - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> list<span class="Special"> <- </span>next list - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> list<span class="Special"> <- </span>next list - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> - <span class="Constant">20</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">20</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">13</span> @@ -433,32 +433,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> remove-range-to-final [ <span class="Constant">local-scope</span> <span class="Comment"># construct a duplex list with six elements [13, 14, 15, 16, 17, 18]</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">17</span>, list list<span class="Special"> <- </span>push <span class="Constant">16</span>, list list<span class="Special"> <- </span>push <span class="Constant">15</span>, list list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> + <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw</span> <span class="Comment"># restore list</span> + list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># delete 15, 16 and 17</span> <span class="Comment"># start pointer: to the second element</span> - list2:address:duplex-list:character<span class="Special"> <- </span>next list + list2:&:duplex-list:char<span class="Special"> <- </span>next list <span class="Comment"># end pointer: to the last (sixth) element</span> - end:address:duplex-list:character<span class="Special"> <- </span>next list2 + end:&:duplex-list:char<span class="Special"> <- </span>next list2 end<span class="Special"> <- </span>next end end<span class="Special"> <- </span>next end end<span class="Special"> <- </span>next end remove-between list2, end <span class="Comment"># now check the list</span> - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> list<span class="Special"> <- </span>next list - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> list<span class="Special"> <- </span>next list - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> - <span class="Constant">20</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">20</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">13</span> @@ -471,23 +471,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> remove-range-empty [ <span class="Constant">local-scope</span> <span class="Comment"># construct a duplex list with three elements [13, 14, 15]</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">15</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">15</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> + <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw</span> <span class="Comment"># restore list</span> + list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># delete between first and second element (i.e. nothing)</span> - list2:address:duplex-list:character<span class="Special"> <- </span>next list + list2:&:duplex-list:char<span class="Special"> <- </span>next list remove-between list, list2 <span class="Comment"># now check the list</span> - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> list<span class="Special"> <- </span>next list - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> list<span class="Special"> <- </span>next list - <span class="Constant">12</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> - <span class="Constant">20</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">20</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list ] <span class="Comment"># no change</span> memory-should-contain [ @@ -501,24 +501,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> remove-range-to-end [ <span class="Constant">local-scope</span> <span class="Comment"># construct a duplex list with six elements [13, 14, 15, 16, 17, 18]</span> - list:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">17</span>, list list<span class="Special"> <- </span>push <span class="Constant">16</span>, list list<span class="Special"> <- </span>push <span class="Constant">15</span>, list list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> + <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ <span class="Constant">local-scope</span> - list:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character/<span class="Special">raw</span> <span class="Comment"># restore list</span> + list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># remove the third element and beyond</span> - list2:address:duplex-list:character<span class="Special"> <- </span>next list + list2:&:duplex-list:char<span class="Special"> <- </span>next list remove-between list2, <span class="Constant">0</span> <span class="Comment"># now check the list</span> - <span class="Constant">10</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">10</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> list<span class="Special"> <- </span>next list - <span class="Constant">11</span>:character/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> - <span class="Constant">20</span>:address:duplex-list:character/<span class="Special">raw <- </span>next list + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>get *list, <span class="Constant">value:offset</span> + <span class="Constant">20</span>:&:duplex-list:char/<span class="Special">raw <- </span>next list ] memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">13</span> @@ -528,19 +528,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># insert list beginning at 'new' after 'in'</span> -<span class="muRecipe">def</span> insert-range in:address:duplex-list:_elem, start:address:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">def</span> insert-range in:&:duplex-list:_elem, start:&:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> in <span class="muControl">return-unless</span> start - end:address:duplex-list:_elem<span class="Special"> <- </span>copy start + end:&:duplex-list:_elem<span class="Special"> <- </span>copy start <span class="Delimiter">{</span> - next:address:duplex-list:_elem<span class="Special"> <- </span>next end/insert-range + next:&:duplex-list:_elem<span class="Special"> <- </span>next end/insert-range <span class="muControl">break-unless</span> next end<span class="Special"> <- </span>copy next <span class="muControl">loop</span> <span class="Delimiter">}</span> - next:address:duplex-list:_elem<span class="Special"> <- </span>next in + next:&:duplex-list:_elem<span class="Special"> <- </span>next in *end<span class="Special"> <- </span>put *end, <span class="Constant">next:offset</span>, next <span class="Delimiter">{</span> <span class="muControl">break-unless</span> next @@ -550,21 +550,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *start<span class="Special"> <- </span>put *start, <span class="Constant">prev:offset</span>, in ] -<span class="muRecipe">def</span> append in:address:duplex-list:_elem, new:address:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">def</span> append in:&:duplex-list:_elem, new:&:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - last:address:duplex-list:_elem<span class="Special"> <- </span>last in + last:&:duplex-list:_elem<span class="Special"> <- </span>last in *last<span class="Special"> <- </span>put *last, <span class="Constant">next:offset</span>, new <span class="muControl">return-unless</span> new *new<span class="Special"> <- </span>put *new, <span class="Constant">prev:offset</span>, last ] -<span class="muRecipe">def</span> last in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:duplex-list:_elem [ +<span class="muRecipe">def</span> last in:&:duplex-list:_elem<span class="muRecipe"> -> </span>result:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>copy in <span class="Delimiter">{</span> - next:address:duplex-list:_elem<span class="Special"> <- </span>next result + next:&:duplex-list:_elem<span class="Special"> <- </span>next result <span class="muControl">break-unless</span> next result<span class="Special"> <- </span>copy next <span class="muControl">loop</span> @@ -572,7 +572,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># helper for debugging</span> -<span class="muRecipe">def</span> dump-from x:address:duplex-list:_elem [ +<span class="muRecipe">def</span> dump-from x:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> $print x, <span class="Constant">[: ]</span> @@ -582,7 +582,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color $print c, <span class="Constant">[ ]</span> x<span class="Special"> <- </span>next x <span class="Delimiter">{</span> - is-newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + is-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> is-newline? $print <span class="Constant">10/newline</span> $print x, <span class="Constant">[: ]</span> |