about summary refs log tree commit diff stats
path: root/html/059to_text.mu.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-16 16:04:11 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-16 16:04:11 -0700
commitced133e40290c30809e6d632cdf1e6f749ea9dd5 (patch)
tree8e217620ee5016db6d1be429d2724bd9adfd0881 /html/059to_text.mu.html
parentaa2fd725c0e5129bd4a750261f97ababa8af9a12 (diff)
downloadmu-ced133e40290c30809e6d632cdf1e6f749ea9dd5.tar.gz
3371
Diffstat (limited to 'html/059to_text.mu.html')
-rw-r--r--html/059to_text.mu.html17
1 files changed, 17 insertions, 0 deletions
diff --git a/html/059to_text.mu.html b/html/059to_text.mu.html
index deaacdf7..b050f5e9 100644
--- a/html/059to_text.mu.html
+++ b/html/059to_text.mu.html
@@ -60,6 +60,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   x:text<span class="Special"> &lt;- </span>array-to-text-line n
   <span class="Comment"># just ensure there were no errors</span>
 ]
+
+<span class="Comment"># finally, a specialization for single characters</span>
+<span class="muRecipe">def</span> to-text c:character<span class="muRecipe"> -&gt; </span>y:text [
+  <span class="Constant">local-scope</span>
+  <span class="Constant">load-ingredients</span>
+  y<span class="Special"> &lt;- </span>new <span class="Constant">character:type</span>, <span class="Constant">1/capacity</span>
+  *y<span class="Special"> &lt;- </span>put-index *y, <span class="Constant">0</span>, c
+]
+
+<span class="muScenario">scenario</span> character-to-text [
+  <span class="Constant">1</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">111/o</span>
+  <span class="Constant">2</span>:text<span class="Special"> &lt;- </span>to-text <span class="Constant">1</span>:character
+  <span class="Constant">3</span>:array:character<span class="Special"> &lt;- </span>copy *<span class="Constant">2</span>:text
+  memory-should-contain [
+    <span class="Constant">3</span>:array:character<span class="Special"> &lt;- </span><span class="Constant">[o]</span>
+  ]
+]
 </pre>
 </body>
 </html>