diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 19:45:36 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 19:56:28 -0700 |
commit | f918675c8b11adb80a83000a3a984e4ff3bdcf1b (patch) | |
tree | 2472316e3bf536e0bad76751c5f3504d029b8215 /html/065duplex_list.mu.html | |
parent | af7349d50c40e0604c9bb1e9a50aa1c3c0d407d8 (diff) | |
download | mu-f918675c8b11adb80a83000a3a984e4ff3bdcf1b.tar.gz |
3569
Update syntax highlighting to not color numeric locations like literals.
Diffstat (limited to 'html/065duplex_list.mu.html')
-rw-r--r-- | html/065duplex_list.mu.html | 588 |
1 files changed, 294 insertions, 294 deletions
diff --git a/html/065duplex_list.mu.html b/html/065duplex_list.mu.html index af84549a..ce239cde 100644 --- a/html/065duplex_list.mu.html +++ b/html/065duplex_list.mu.html @@ -44,11 +44,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:&: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> + 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 - *in<span class="Special"> <- </span>put *in, <span class="Constant">prev:offset</span>, result + *in <span class="Special"><-</span> put *in, <span class="Constant">prev:offset</span>, result <span class="Delimiter">}</span> <span class="muControl">return</span> result <span class="Comment"># needed explicitly because we need to replace 'in' with 'result'</span> ] @@ -56,22 +56,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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="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:&: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="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:&: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">prev:offset</span> + <span class="muControl">return-unless</span> in,<span class="Constant"> 0</span> + result <span class="Special"><-</span> get *in, <span class="Constant">prev:offset</span> <span class="muControl">return</span> result ] @@ -79,41 +79,41 @@ 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>: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:&: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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>next list2 - <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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>prev 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 + 10:num/<span class="Special">raw</span> <span class="Special"><-</span> copy<span class="Constant"> 34</span> + 11:num/<span class="Special">raw</span> <span class="Special"><-</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:&:duplex-list:char <span class="Special"><-</span> copy list + 20:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 21:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 22:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 30:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list2 + 31:char/<span class="Special">raw</span> <span class="Special"><-</span> first 30:&:duplex-list:char/<span class="Special">raw</span> + 32:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next 30:&:duplex-list:char/<span class="Special">raw</span> + 33:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> prev 30:&:duplex-list:char/<span class="Special">raw</span> + list2 <span class="Special"><-</span> prev list2 + 40:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 41:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 50:bool/<span class="Special">raw</span> <span class="Special"><-</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> - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">34</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">35</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next</span> - <span class="Constant">21</span><span class="Special"> <- </span><span class="Constant">4</span> - <span class="Constant">22</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># null</span> - <span class="Constant">31</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first of null</span> - <span class="Constant">32</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># next of null</span> - <span class="Constant">33</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># prev of null</span> - <span class="Constant">40</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># then start scanning prev</span> - <span class="Constant">41</span><span class="Special"> <- </span><span class="Constant">5</span> - <span class="Constant">50</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># list back at start</span> + <span class="Constant"> 0</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># no modifications to null pointers</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 34</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 35</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># scanning next</span> + <span class="Constant"> 21</span> <span class="Special"><-</span><span class="Constant"> 4</span> + <span class="Constant"> 22</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 30</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># null</span> + <span class="Constant"> 31</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># first of null</span> + <span class="Constant"> 32</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># next of null</span> + <span class="Constant"> 33</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># prev of null</span> + <span class="Constant"> 40</span> <span class="Special"><-</span><span class="Constant"> 4</span> <span class="Comment"># then start scanning prev</span> + <span class="Constant"> 41</span> <span class="Special"><-</span><span class="Constant"> 5</span> + <span class="Constant"> 50</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># list back at start</span> ] ] @@ -121,125 +121,125 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:&: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 + 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:&: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 + 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 <span class="muControl">return-unless</span> next-node - *next-node<span class="Special"> <- </span>put *next-node, <span class="Constant">prev:offset</span>, new-node + *next-node <span class="Special"><-</span> put *next-node, <span class="Constant">prev:offset</span>, new-node ] <span class="muScenario">scenario</span> inserting-into-duplex-list [ <span class="Constant">local-scope</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:&: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 run [ - 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 + 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>next 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>next 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>prev 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>:char/<span class="Special">raw <- </span>first list2 - <span class="Constant">30</span>:bool/<span class="Special">raw <- </span>equal list, list2 + list2 <span class="Special"><-</span> copy list + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 13:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 20:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 21:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 22:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 30:bool/<span class="Special">raw</span> <span class="Special"><-</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> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">4</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># inserted element</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># then prev</span> - <span class="Constant">21</span><span class="Special"> <- </span><span class="Constant">4</span> - <span class="Constant">22</span><span class="Special"> <- </span><span class="Constant">5</span> - <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># list back at start</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># scanning next</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 4</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 6</span> <span class="Comment"># inserted element</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 6</span> <span class="Comment"># then prev</span> + <span class="Constant"> 21</span> <span class="Special"><-</span><span class="Constant"> 4</span> + <span class="Constant"> 22</span> <span class="Special"><-</span><span class="Constant"> 5</span> + <span class="Constant"> 30</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># list back at start</span> ] ] <span class="muScenario">scenario</span> inserting-at-end-of-duplex-list [ <span class="Constant">local-scope</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:&: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 run [ - 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 + 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>next 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>next 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>prev 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>:char/<span class="Special">raw <- </span>first list2 - <span class="Constant">30</span>:bool/<span class="Special">raw <- </span>equal list, list2 + list2 <span class="Special"><-</span> copy list + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 13:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 20:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 21:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 22:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 30:bool/<span class="Special">raw</span> <span class="Special"><-</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> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">4</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># inserted element</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># then prev</span> - <span class="Constant">21</span><span class="Special"> <- </span><span class="Constant">4</span> - <span class="Constant">22</span><span class="Special"> <- </span><span class="Constant">5</span> - <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># list back at start</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># scanning next</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 4</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 6</span> <span class="Comment"># inserted element</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># then prev</span> + <span class="Constant"> 21</span> <span class="Special"><-</span><span class="Constant"> 4</span> + <span class="Constant"> 22</span> <span class="Special"><-</span><span class="Constant"> 5</span> + <span class="Constant"> 30</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># list back at start</span> ] ] <span class="muScenario">scenario</span> inserting-after-start-of-duplex-list [ <span class="Constant">local-scope</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:&: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 run [ - list<span class="Special"> <- </span>insert <span class="Constant">6</span>, list + list <span class="Special"><-</span> insert<span class="Constant"> 6</span>, list <span class="Comment"># check structure like before</span> - 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>next 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>prev 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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </span>prev 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 + list2:&:duplex-list:char <span class="Special"><-</span> copy list + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 13:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 20:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 21:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> prev list2 + 22:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 30:bool/<span class="Special">raw</span> <span class="Special"><-</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> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># inserted element</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">4</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># then prev</span> - <span class="Constant">21</span><span class="Special"> <- </span><span class="Constant">6</span> - <span class="Constant">22</span><span class="Special"> <- </span><span class="Constant">5</span> - <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># list back at start</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># scanning next</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 6</span> <span class="Comment"># inserted element</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 4</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 4</span> <span class="Comment"># then prev</span> + <span class="Constant"> 21</span> <span class="Special"><-</span><span class="Constant"> 6</span> + <span class="Constant"> 22</span> <span class="Special"><-</span><span class="Constant"> 5</span> + <span class="Constant"> 30</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># list back at start</span> ] ] @@ -252,20 +252,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="Comment"># if 'x' is null, return</span> <span class="muControl">return-unless</span> x - 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> + 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> + *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> <span class="Comment"># if next-node is not null, set its prev pointer</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> next-node - *next-node<span class="Special"> <- </span>put *next-node, <span class="Constant">prev:offset</span>, prev-node + *next-node <span class="Special"><-</span> put *next-node, <span class="Constant">prev:offset</span>, 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="muControl">break-unless</span> prev-node - *prev-node<span class="Special"> <- </span>put *prev-node, <span class="Constant">next:offset</span>, next-node + *prev-node <span class="Special"><-</span> put *prev-node, <span class="Constant">next:offset</span>, next-node <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># if prev-node is null, then we removed the head node at 'in'</span> @@ -275,99 +275,99 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> removing-from-duplex-list [ <span class="Constant">local-scope</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:&: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 run [ - 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>:bool/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</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 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </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>:char/<span class="Special">raw <- </span>first list2 - <span class="Constant">40</span>:bool/<span class="Special">raw <- </span>equal list, list2 + list2 <span class="Special"><-</span> copy list + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 20:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list2 + list2 <span class="Special"><-</span> prev list2 + 30:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 40:bool/<span class="Special">raw</span> <span class="Special"><-</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> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next, skipping deleted element</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no more elements</span> - <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># prev of final element</span> - <span class="Constant">40</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># list back at start</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># remove returned non-null</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># scanning next, skipping deleted element</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># no more elements</span> + <span class="Constant"> 30</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># prev of final element</span> + <span class="Constant"> 40</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># list back at start</span> ] ] <span class="muScenario">scenario</span> removing-from-start-of-duplex-list [ <span class="Constant">local-scope</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:&: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 run [ - list<span class="Special"> <- </span>remove list, list + list <span class="Special"><-</span> remove list, list <span class="Comment"># check structure like before</span> - 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>: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>:char/<span class="Special">raw <- </span>first list2 - <span class="Constant">40</span>:bool/<span class="Special">raw <- </span>equal list, list2 + list2:&:duplex-list:char <span class="Special"><-</span> copy list + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 20:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list2 + list2 <span class="Special"><-</span> prev list2 + 30:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 40:bool/<span class="Special">raw</span> <span class="Special"><-</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> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no more elements</span> - <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># prev of final element</span> - <span class="Constant">40</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># list back at start</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 4</span> <span class="Comment"># scanning next, skipping deleted element</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># no more elements</span> + <span class="Constant"> 30</span> <span class="Special"><-</span><span class="Constant"> 4</span> <span class="Comment"># prev of final element</span> + <span class="Constant"> 40</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># list back at start</span> ] ] <span class="muScenario">scenario</span> removing-from-end-of-duplex-list [ <span class="Constant">local-scope</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:&: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 run [ <span class="Comment"># delete last element</span> - 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>:bool/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</span> + 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 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</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>:char/<span class="Special">raw <- </span>first list2 - list2<span class="Special"> <- </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>:char/<span class="Special">raw <- </span>first list2 - <span class="Constant">40</span>:bool/<span class="Special">raw <- </span>equal list, list2 + list2 <span class="Special"><-</span> copy list + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + list2 <span class="Special"><-</span> next list2 + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 20:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list2 + list2 <span class="Special"><-</span> prev list2 + 30:char/<span class="Special">raw</span> <span class="Special"><-</span> first list2 + 40:bool/<span class="Special">raw</span> <span class="Special"><-</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> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next, skipping deleted element</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">4</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no more elements</span> - <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># prev of final element</span> - <span class="Constant">40</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># list back at start</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># remove returned non-null</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># scanning next, skipping deleted element</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 4</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># no more elements</span> + <span class="Constant"> 30</span> <span class="Special"><-</span><span class="Constant"> 5</span> <span class="Comment"># prev of final element</span> + <span class="Constant"> 40</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># list back at start</span> ] ] <span class="muScenario">scenario</span> removing-from-singleton-duplex-list [ <span class="Constant">local-scope</span> - list:&:duplex-list:char<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> run [ - list<span class="Special"> <- </span>remove list, list - <span class="Constant">1</span>:num/<span class="Special">raw <- </span>copy list + list <span class="Special"><-</span> remove list, list + 1:num/<span class="Special">raw</span> <span class="Special"><-</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> + <span class="Constant"> 1</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># back to an empty list</span> ] ] @@ -379,139 +379,139 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:&: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 + 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> <span class="Comment"># start->next = end</span> - *next<span class="Special"> <- </span>put *next, <span class="Constant">prev:offset</span>, <span class="Constant">0</span> - *start<span class="Special"> <- </span>put *start, <span class="Constant">next:offset</span>, end + *next <span class="Special"><-</span> put *next, <span class="Constant">prev:offset</span>,<span class="Constant"> 0</span> + *start <span class="Special"><-</span> put *start, <span class="Constant">next:offset</span>, end <span class="muControl">return-unless</span> end <span class="Comment"># end->prev->next = 0</span> <span class="Comment"># end->prev = start</span> - prev:&: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 + *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 ] <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:&: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 + 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 run [ <span class="Comment"># delete 16 onwards</span> <span class="Comment"># first pointer: to the third element</span> - 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> + 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>: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>: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>: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 + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + list <span class="Special"><-</span> next list + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + list <span class="Special"><-</span> next list + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + 20:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list ] memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">13</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">14</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">15</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 13</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 14</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 15</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] <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:&: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 + 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 run [ <span class="Comment"># delete 15, 16 and 17</span> <span class="Comment"># start pointer: to the second element</span> - list2:&:duplex-list:char<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:&: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 + 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>: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>: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>: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 + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + list <span class="Special"><-</span> next list + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + list <span class="Special"><-</span> next list + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + 20:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list ] memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">13</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">14</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">18</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no more elements</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 13</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 14</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 18</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># no more elements</span> ] ] <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:&: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 + 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 run [ <span class="Comment"># delete between first and second element (i.e. nothing)</span> - list2:&:duplex-list:char<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>: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>: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>: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 + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + list <span class="Special"><-</span> next list + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + list <span class="Special"><-</span> next list + 12:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + 20:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list ] <span class="Comment"># no change</span> memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">13</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">14</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">15</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 13</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 14</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 15</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] <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:&: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 + 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 run [ <span class="Comment"># remove the third element and beyond</span> - list2:&:duplex-list:char<span class="Special"> <- </span>next list - remove-between list2, <span class="Constant">0</span> + 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>: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>: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 + 10:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + list <span class="Special"><-</span> next list + 11:char/<span class="Special">raw</span> <span class="Special"><-</span> get *list, <span class="Constant">value:offset</span> + 20:&:duplex-list:char/<span class="Special">raw</span> <span class="Special"><-</span> next list ] memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">13</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">14</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 13</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 14</span> + <span class="Constant"> 20</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] @@ -521,40 +521,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> in <span class="muControl">return-unless</span> start - end:&:duplex-list:_elem<span class="Special"> <- </span>copy start + end:&:duplex-list:_elem <span class="Special"><-</span> copy start <span class="Delimiter">{</span> - next:&: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 + end <span class="Special"><-</span> copy next <span class="muControl">loop</span> <span class="Delimiter">}</span> - next:&:duplex-list:_elem<span class="Special"> <- </span>next in - *end<span class="Special"> <- </span>put *end, <span class="Constant">next:offset</span>, next + 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 - *next<span class="Special"> <- </span>put *next, <span class="Constant">prev:offset</span>, end + *next <span class="Special"><-</span> put *next, <span class="Constant">prev:offset</span>, end <span class="Delimiter">}</span> - *in<span class="Special"> <- </span>put *in, <span class="Constant">next:offset</span>, start - *start<span class="Special"> <- </span>put *start, <span class="Constant">prev:offset</span>, in + *in <span class="Special"><-</span> put *in, <span class="Constant">next:offset</span>, start + *start <span class="Special"><-</span> put *start, <span class="Constant">prev:offset</span>, in ] <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:&:duplex-list:_elem<span class="Special"> <- </span>last in - *last<span class="Special"> <- </span>put *last, <span class="Constant">next:offset</span>, new + 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 + *new <span class="Special"><-</span> put *new, <span class="Constant">prev:offset</span>, last ] <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 + result <span class="Special"><-</span> copy in <span class="Delimiter">{</span> - next:&: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 + result <span class="Special"><-</span> copy next <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -566,11 +566,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color $print x, <span class="Constant">[: ]</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> x - c:_elem<span class="Special"> <- </span>get *x, <span class="Constant">value:offset</span> + c:_elem <span class="Special"><-</span> get *x, <span class="Constant">value:offset</span> $print c, <span class="Constant">[ ]</span> - x<span class="Special"> <- </span>next x + x <span class="Special"><-</span> next x <span class="Delimiter">{</span> - is-newline?:bool<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> |