about summary refs log tree commit diff stats
path: root/html/075channel.mu.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-22 04:04:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-22 04:04:46 -0700
commitbeea7ce25cfe42c363259705a6b5741ad47484ab (patch)
treed30b44a935bad1cb6c88083c57caabdf062ed513 /html/075channel.mu.html
parent98e3a41bf96b37d94f6b0a0e98a4635a174e9903 (diff)
downloadmu-beea7ce25cfe42c363259705a6b5741ad47484ab.tar.gz
3543
Diffstat (limited to 'html/075channel.mu.html')
-rw-r--r--html/075channel.mu.html16
1 files changed, 15 insertions, 1 deletions
diff --git a/html/075channel.mu.html b/html/075channel.mu.html
index 862329f8..eda9e8da 100644
--- a/html/075channel.mu.html
+++ b/html/075channel.mu.html
@@ -412,7 +412,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   result<span class="Special"> &lt;- </span>length *q
 ]
 
-<span class="Comment"># helper for channels of characters in particular</span>
+<span class="SalientComment">## helpers for channels of characters in particular</span>
+
 <span class="muRecipe">def</span> buffer-lines in:&amp;:source:char, buffered-out:&amp;:sink:char<span class="muRecipe"> -&gt; </span>buffered-out:&amp;:sink:char, in:&amp;:source:char [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
@@ -511,6 +512,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
     test: reached end
   ]
 ]
+
+<span class="muRecipe">def</span> drain source:&amp;:source:char<span class="muRecipe"> -&gt; </span>result:text, source:&amp;:source:char [
+  <span class="Constant">local-scope</span>
+  <span class="Constant">load-ingredients</span>
+  buf:&amp;:buffer<span class="Special"> &lt;- </span>new-buffer <span class="Constant">30</span>
+  <span class="Delimiter">{</span>
+    c:char, done?:bool<span class="Special"> &lt;- </span>read source
+    <span class="muControl">break-if</span> done?
+    buf<span class="Special"> &lt;- </span>append buf, c
+    <span class="muControl">loop</span>
+  <span class="Delimiter">}</span>
+  result<span class="Special"> &lt;- </span>buffer-to-array buf
+]
 </pre>
 </body>
 </html>