about summary refs log tree commit diff stats
path: root/html/074list.mu.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-21 17:44:53 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-21 17:44:53 -0700
commit2f02189ddcdeb7d25b0ca9bd5b955b764d41a1a7 (patch)
tree7c2e8b6e37ae3201dc01e90bcb390ee60b7f4a77 /html/074list.mu.html
parent61c025b11ed4ddd002f09f061fd77c75d8b6d0ba (diff)
downloadmu-2f02189ddcdeb7d25b0ca9bd5b955b764d41a1a7.tar.gz
2996
Diffstat (limited to 'html/074list.mu.html')
-rw-r--r--html/074list.mu.html14
1 files changed, 11 insertions, 3 deletions
diff --git a/html/074list.mu.html b/html/074list.mu.html
index bb619f3e..be4c153f 100644
--- a/html/074list.mu.html
+++ b/html/074list.mu.html
@@ -42,12 +42,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   next:address:list:_elem
 ]
 
-<span class="muRecipe">def</span> push x:_elem, in:address:list:_elem<span class="muRecipe"> -&gt; </span>in:address:list:_elem [
+<span class="muRecipe">def</span> push x:_elem, in:address:list:_elem<span class="muRecipe"> -&gt; </span>result:address:list:_elem [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  result:address:list:_elem<span class="Special"> &lt;- </span>new <span class="Delimiter">{</span>(list _elem): type<span class="Delimiter">}</span>
+  result<span class="Special"> &lt;- </span>new <span class="Delimiter">{</span>(list _elem): type<span class="Delimiter">}</span>
   *result<span class="Special"> &lt;- </span>merge x, in
-  <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:list:_elem<span class="muRecipe"> -&gt; </span>result:_elem [
@@ -82,6 +81,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   ]
 ]
 
+<span class="muRecipe">def</span> length l:address:list:_elem<span class="muRecipe"> -&gt; </span>result:number [
+  <span class="Constant">local-scope</span>
+  <span class="Constant">load-ingredients</span>
+  <span class="muControl">return-unless</span> l, <span class="Constant">0</span>
+  rest:address:list:_elem<span class="Special"> &lt;- </span>rest l
+  length-of-rest:number<span class="Special"> &lt;- </span>length rest
+  result<span class="Special"> &lt;- </span>add length-of-rest, <span class="Constant">1</span>
+]
+
 <span class="muRecipe">def</span> to-text in:address:list:_elem<span class="muRecipe"> -&gt; </span>result:address:array:character [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>