diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-12-03 23:25:40 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-12-03 23:25:40 -0800 |
commit | 4a48bedcd1d708a43d43dc6259a4e45c52ea3d00 (patch) | |
tree | 85c1b7310cca932797d727a3de8da96eb175d8da /html/lambda-to-mu.mu.html | |
parent | ef7d834fdd826977cd8d43253052a7b8e1c5aa72 (diff) | |
download | mu-4a48bedcd1d708a43d43dc6259a4e45c52ea3d00.tar.gz |
4134 - 'input' = 'ingredient'
Diffstat (limited to 'html/lambda-to-mu.mu.html')
-rw-r--r-- | html/lambda-to-mu.mu.html | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/html/lambda-to-mu.mu.html b/html/lambda-to-mu.mu.html index 91c9984b..c6502d25 100644 --- a/html/lambda-to-mu.mu.html +++ b/html/lambda-to-mu.mu.html @@ -69,7 +69,7 @@ if ('onhashchange' in window) { <span id="L5" class="LineNr"> 5 </span><span class="Comment"># potential enhancements:</span> <span id="L6" class="LineNr"> 6 </span><span class="Comment"># symbol table</span> <span id="L7" class="LineNr"> 7 </span><span class="Comment"># poor man's macros</span> -<span id="L8" class="LineNr"> 8 </span><span class="Comment"># substitute one instruction with multiple, parameterized by ingredients and products</span> +<span id="L8" class="LineNr"> 8 </span><span class="Comment"># substitute one instruction with multiple, parameterized by inputs and products</span> <span id="L9" class="LineNr"> 9 </span> <span id="L10" class="LineNr"> 10 </span><span class="muScenario">scenario</span> convert-lambda [ <span id="L11" class="LineNr"> 11 </span> run [ @@ -85,7 +85,7 @@ if ('onhashchange' in window) { <span id="L21" class="LineNr"> 21 </span> <span id="L22" class="LineNr"> 22 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L22'>lambda-to-mu</a> in:text<span class="muRecipe"> -> </span>out:text [ <span id="L23" class="LineNr"> 23 </span> <span class="Constant">local-scope</span> -<span id="L24" class="LineNr"> 24 </span> <span class="Constant">load-ingredients</span> +<span id="L24" class="LineNr"> 24 </span> <span class="Constant">load-inputs</span> <span id="L25" class="LineNr"> 25 </span> out <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span id="L26" class="LineNr"> 26 </span> cells:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> <span class="Special"><-</span> parse in <span id="L27" class="LineNr"> 27 </span> out <span class="Special"><-</span> to-mu cells @@ -105,28 +105,28 @@ if ('onhashchange' in window) { <span id="L41" class="LineNr"> 41 </span> <span id="L42" class="LineNr"> 42 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L42'>new-atom</a> name:text<span class="muRecipe"> -> </span>result:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> [ <span id="L43" class="LineNr"> 43 </span> <span class="Constant">local-scope</span> -<span id="L44" class="LineNr"> 44 </span> <span class="Constant">load-ingredients</span> +<span id="L44" class="LineNr"> 44 </span> <span class="Constant">load-inputs</span> <span id="L45" class="LineNr"> 45 </span> result <span class="Special"><-</span> new <span class="Constant"><a href='lambda-to-mu.mu.html#L31'>cell</a>:type</span> <span id="L46" class="LineNr"> 46 </span> *result <span class="Special"><-</span> merge <span class="Constant">0/tag:atom</span>, name <span id="L47" class="LineNr"> 47 </span>] <span id="L48" class="LineNr"> 48 </span> <span id="L49" class="LineNr"> 49 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L49'>new-pair</a> a:&:<a href='lambda-to-mu.mu.html#L31'>cell</a>, b:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>result:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> [ <span id="L50" class="LineNr"> 50 </span> <span class="Constant">local-scope</span> -<span id="L51" class="LineNr"> 51 </span> <span class="Constant">load-ingredients</span> +<span id="L51" class="LineNr"> 51 </span> <span class="Constant">load-inputs</span> <span id="L52" class="LineNr"> 52 </span> result <span class="Special"><-</span> new <span class="Constant"><a href='lambda-to-mu.mu.html#L31'>cell</a>:type</span> <span id="L53" class="LineNr"> 53 </span> *result <span class="Special"><-</span> merge <span class="Constant">1/tag:<a href='lambda-to-mu.mu.html#L37'>pair</a></span>, a/first, b/rest <span id="L54" class="LineNr"> 54 </span>] <span id="L55" class="LineNr"> 55 </span> <span id="L56" class="LineNr"> 56 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L56'>is-atom?</a> x:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>result:bool [ <span id="L57" class="LineNr"> 57 </span> <span class="Constant">local-scope</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Constant">load-ingredients</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Constant">load-inputs</span> <span id="L59" class="LineNr"> 59 </span> <span class="muControl">return-unless</span> x, <span class="Constant">0/false</span> <span id="L60" class="LineNr"> 60 </span> _, result <span class="Special"><-</span> maybe-convert *x, <span class="Constant">atom:variant</span> <span id="L61" class="LineNr"> 61 </span>] <span id="L62" class="LineNr"> 62 </span> <span id="L63" class="LineNr"> 63 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L63'>is-pair?</a> x:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>result:bool [ <span id="L64" class="LineNr"> 64 </span> <span class="Constant">local-scope</span> -<span id="L65" class="LineNr"> 65 </span> <span class="Constant">load-ingredients</span> +<span id="L65" class="LineNr"> 65 </span> <span class="Constant">load-inputs</span> <span id="L66" class="LineNr"> 66 </span> <span class="muControl">return-unless</span> x, <span class="Constant">0/false</span> <span id="L67" class="LineNr"> 67 </span> _, result <span class="Special"><-</span> maybe-convert *x, <span class="Constant"><a href='lambda-to-mu.mu.html#L37'>pair</a>:variant</span> <span id="L68" class="LineNr"> 68 </span>] @@ -159,7 +159,7 @@ if ('onhashchange' in window) { <span id="L95" class="LineNr"> 95 </span> <span id="L96" class="LineNr"> 96 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L96'>atom-match?</a> x:&:<a href='lambda-to-mu.mu.html#L31'>cell</a>, pat:text<span class="muRecipe"> -> </span>result:bool [ <span id="L97" class="LineNr"> 97 </span> <span class="Constant">local-scope</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Constant">load-ingredients</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Constant">load-inputs</span> <span id="L99" class="LineNr"> 99 </span> s:text, <a href='lambda-to-mu.mu.html#L56'>is-atom?</a>:bool <span class="Special"><-</span> maybe-convert *x, <span class="Constant">atom:variant</span> <span id="L100" class="LineNr">100 </span> <span class="muControl">return-unless</span> <a href='lambda-to-mu.mu.html#L56'>is-atom?</a>, <span class="Constant">0/false</span> <span id="L101" class="LineNr">101 </span> result <span class="Special"><-</span> equal pat, s @@ -176,7 +176,7 @@ if ('onhashchange' in window) { <span id="L112" class="LineNr">112 </span> <span id="L113" class="LineNr">113 </span><span class="muRecipe">def</span> first x:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>result:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> [ <span id="L114" class="LineNr">114 </span> <span class="Constant">local-scope</span> -<span id="L115" class="LineNr">115 </span> <span class="Constant">load-ingredients</span> +<span id="L115" class="LineNr">115 </span> <span class="Constant">load-inputs</span> <span id="L116" class="LineNr">116 </span> <a href='lambda-to-mu.mu.html#L37'>pair</a>:<a href='lambda-to-mu.mu.html#L37'>pair</a>, pair?:bool <span class="Special"><-</span> maybe-convert *x, <span class="Constant"><a href='lambda-to-mu.mu.html#L37'>pair</a>:variant</span> <span id="L117" class="LineNr">117 </span> <span class="muControl">return-unless</span> pair?, <span class="Constant">0/nil</span> <span id="L118" class="LineNr">118 </span> result <span class="Special"><-</span> get <a href='lambda-to-mu.mu.html#L37'>pair</a>, <span class="Constant">first:offset</span> @@ -184,7 +184,7 @@ if ('onhashchange' in window) { <span id="L120" class="LineNr">120 </span> <span id="L121" class="LineNr">121 </span><span class="muRecipe">def</span> rest x:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>result:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> [ <span id="L122" class="LineNr">122 </span> <span class="Constant">local-scope</span> -<span id="L123" class="LineNr">123 </span> <span class="Constant">load-ingredients</span> +<span id="L123" class="LineNr">123 </span> <span class="Constant">load-inputs</span> <span id="L124" class="LineNr">124 </span> <a href='lambda-to-mu.mu.html#L37'>pair</a>:<a href='lambda-to-mu.mu.html#L37'>pair</a>, pair?:bool <span class="Special"><-</span> maybe-convert *x, <span class="Constant"><a href='lambda-to-mu.mu.html#L37'>pair</a>:variant</span> <span id="L125" class="LineNr">125 </span> <span class="muControl">return-unless</span> pair?, <span class="Constant">0/nil</span> <span id="L126" class="LineNr">126 </span> result <span class="Special"><-</span> get <a href='lambda-to-mu.mu.html#L37'>pair</a>, <span class="Constant">rest:offset</span> @@ -192,7 +192,7 @@ if ('onhashchange' in window) { <span id="L128" class="LineNr">128 </span> <span id="L129" class="LineNr">129 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L129'>set-first</a> base:&:<a href='lambda-to-mu.mu.html#L31'>cell</a>, new-first:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>base:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> [ <span id="L130" class="LineNr">130 </span> <span class="Constant">local-scope</span> -<span id="L131" class="LineNr">131 </span> <span class="Constant">load-ingredients</span> +<span id="L131" class="LineNr">131 </span> <span class="Constant">load-inputs</span> <span id="L132" class="LineNr">132 </span> <a href='lambda-to-mu.mu.html#L37'>pair</a>:<a href='lambda-to-mu.mu.html#L37'>pair</a>, <a href='lambda-to-mu.mu.html#L63'>is-pair?</a>:bool <span class="Special"><-</span> maybe-convert *base, <span class="Constant"><a href='lambda-to-mu.mu.html#L37'>pair</a>:variant</span> <span id="L133" class="LineNr">133 </span> <span class="muControl">return-unless</span> <a href='lambda-to-mu.mu.html#L63'>is-pair?</a> <span id="L134" class="LineNr">134 </span> <a href='lambda-to-mu.mu.html#L37'>pair</a> <span class="Special"><-</span> put <a href='lambda-to-mu.mu.html#L37'>pair</a>, <span class="Constant">first:offset</span>, new-first @@ -201,7 +201,7 @@ if ('onhashchange' in window) { <span id="L137" class="LineNr">137 </span> <span id="L138" class="LineNr">138 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L138'>set-rest</a> base:&:<a href='lambda-to-mu.mu.html#L31'>cell</a>, new-rest:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>base:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> [ <span id="L139" class="LineNr">139 </span> <span class="Constant">local-scope</span> -<span id="L140" class="LineNr">140 </span> <span class="Constant">load-ingredients</span> +<span id="L140" class="LineNr">140 </span> <span class="Constant">load-inputs</span> <span id="L141" class="LineNr">141 </span> <a href='lambda-to-mu.mu.html#L37'>pair</a>:<a href='lambda-to-mu.mu.html#L37'>pair</a>, <a href='lambda-to-mu.mu.html#L63'>is-pair?</a>:bool <span class="Special"><-</span> maybe-convert *base, <span class="Constant"><a href='lambda-to-mu.mu.html#L37'>pair</a>:variant</span> <span id="L142" class="LineNr">142 </span> <span class="muControl">return-unless</span> <a href='lambda-to-mu.mu.html#L63'>is-pair?</a> <span id="L143" class="LineNr">143 </span> <a href='lambda-to-mu.mu.html#L37'>pair</a> <span class="Special"><-</span> put <a href='lambda-to-mu.mu.html#L37'>pair</a>, <span class="Constant">rest:offset</span>, new-rest @@ -239,7 +239,7 @@ if ('onhashchange' in window) { <span id="L175" class="LineNr">175 </span> <span id="L176" class="LineNr">176 </span><span class="muRecipe">def</span> parse in:text<span class="muRecipe"> -> </span>out:&:<a href='lambda-to-mu.mu.html#L31'>cell</a> [ <span id="L177" class="LineNr">177 </span> <span class="Constant">local-scope</span> -<span id="L178" class="LineNr">178 </span> <span class="Constant">load-ingredients</span> +<span id="L178" class="LineNr">178 </span> <span class="Constant">load-inputs</span> <span id="L179" class="LineNr">179 </span> s:&:<a href='066stream.mu.html#L2'>stream</a>:char <span class="Special"><-</span> <a href='066stream.mu.html#L7'>new-stream</a> in <span id="L180" class="LineNr">180 </span> out, s <span class="Special"><-</span> parse s <span id="L181" class="LineNr">181 </span> trace<span class="Constant"> 2</span>, <span class="Constant">[app/parse]</span>, out @@ -247,7 +247,7 @@ if ('onhashchange' in window) { <span id="L183" class="LineNr">183 </span> <span id="L184" class="LineNr">184 </span><span class="muRecipe">def</span> parse in:&:<a href='066stream.mu.html#L2'>stream</a>:char<span class="muRecipe"> -> </span>out:&:<a href='lambda-to-mu.mu.html#L31'>cell</a>, in:&:<a href='066stream.mu.html#L2'>stream</a>:char [ <span id="L185" class="LineNr">185 </span> <span class="Constant">local-scope</span> -<span id="L186" class="LineNr">186 </span> <span class="Constant">load-ingredients</span> +<span id="L186" class="LineNr">186 </span> <span class="Constant">load-inputs</span> <span id="L187" class="LineNr">187 </span> <span class="Comment"># skip whitespace</span> <span id="L188" class="LineNr">188 </span> in <span class="Special"><-</span> <a href='lambda-to-mu.mu.html#L274'>skip-whitespace</a> in <span id="L189" class="LineNr">189 </span> c:char, eof?:bool <span class="Special"><-</span> <a href='066stream.mu.html#L42'>peek</a> in @@ -337,7 +337,7 @@ if ('onhashchange' in window) { <span id="L273" class="LineNr">273 </span> <span id="L274" class="LineNr">274 </span><span class="muRecipe">def</span> <a href='lambda-to-mu.mu.html#L274'>skip-whitespace</a> in:&:<a href='066stream.mu.html#L2'>stream</a>:char<span class="muRecipe"> -> </span>in:&:<a href='066stream.mu.html#L2'>stream</a>:char [ <span id="L275" class="LineNr">275 </span> <span class="Constant">local-scope</span> -<span id="L276" class="LineNr">276 </span> <span class="Constant">load-ingredients</span> +<span id="L276" class="LineNr">276 </span> <span class="Constant">load-inputs</span> <span id="L277" class="LineNr">277 </span> <span class="Delimiter">{</span> <span id="L278" class="LineNr">278 </span> <span class="Conceal">¦</span> done?:bool <span class="Special"><-</span> <a href='066stream.mu.html#L72'>end-of-stream?</a> in <span id="L279" class="LineNr">279 </span> <span class="Conceal">¦</span> <span class="muControl">return-if</span> done?, <span class="Constant">0/null</span> @@ -351,7 +351,7 @@ if ('onhashchange' in window) { <span id="L287" class="LineNr">287 </span> <span id="L288" class="LineNr">288 </span><span class="muRecipe">def</span> to-text x:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>out:text [ <span id="L289" class="LineNr">289 </span> <span class="Constant">local-scope</span> -<span id="L290" class="LineNr">290 </span> <span class="Constant">load-ingredients</span> +<span id="L290" class="LineNr">290 </span> <span class="Constant">load-inputs</span> <span id="L291" class="LineNr">291 </span> buf:&:<a href='061text.mu.html#L120'>buffer</a>:char <span class="Special"><-</span> <a href='061text.mu.html#L125'>new-buffer</a><span class="Constant"> 30</span> <span id="L292" class="LineNr">292 </span> buf <span class="Special"><-</span> to-buffer x, buf <span id="L293" class="LineNr">293 </span> out <span class="Special"><-</span> <a href='061text.mu.html#L338'>buffer-to-array</a> buf @@ -359,7 +359,7 @@ if ('onhashchange' in window) { <span id="L295" class="LineNr">295 </span> <span id="L296" class="LineNr">296 </span><span class="muRecipe">def</span> to-buffer x:&:<a href='lambda-to-mu.mu.html#L31'>cell</a>, buf:&:<a href='061text.mu.html#L120'>buffer</a>:char<span class="muRecipe"> -> </span>buf:&:<a href='061text.mu.html#L120'>buffer</a>:char [ <span id="L297" class="LineNr">297 </span> <span class="Constant">local-scope</span> -<span id="L298" class="LineNr">298 </span> <span class="Constant">load-ingredients</span> +<span id="L298" class="LineNr">298 </span> <span class="Constant">load-inputs</span> <span id="L299" class="LineNr">299 </span> <span class="Comment"># base case: empty cell</span> <span id="L300" class="LineNr">300 </span> <span class="Delimiter">{</span> <span id="L301" class="LineNr">301 </span> <span class="Conceal">¦</span> <span class="muControl">break-if</span> x @@ -638,7 +638,7 @@ if ('onhashchange' in window) { <span id="L574" class="LineNr">574 </span> <span id="L575" class="LineNr">575 </span><span class="muRecipe">def</span> to-mu in:&:<a href='lambda-to-mu.mu.html#L31'>cell</a><span class="muRecipe"> -> </span>out:text [ <span id="L576" class="LineNr">576 </span> <span class="Constant">local-scope</span> -<span id="L577" class="LineNr">577 </span> <span class="Constant">load-ingredients</span> +<span id="L577" class="LineNr">577 </span> <span class="Constant">load-inputs</span> <span id="L578" class="LineNr">578 </span> buf:&:<a href='061text.mu.html#L120'>buffer</a>:char <span class="Special"><-</span> <a href='061text.mu.html#L125'>new-buffer</a><span class="Constant"> 30</span> <span id="L579" class="LineNr">579 </span> buf <span class="Special"><-</span> to-mu in, buf <span id="L580" class="LineNr">580 </span> out <span class="Special"><-</span> <a href='061text.mu.html#L338'>buffer-to-array</a> buf @@ -646,7 +646,7 @@ if ('onhashchange' in window) { <span id="L582" class="LineNr">582 </span> <span id="L583" class="LineNr">583 </span><span class="muRecipe">def</span> to-mu in:&:<a href='lambda-to-mu.mu.html#L31'>cell</a>, buf:&:<a href='061text.mu.html#L120'>buffer</a>:char<span class="muRecipe"> -> </span>buf:&:<a href='061text.mu.html#L120'>buffer</a>:char, result-name:text [ <span id="L584" class="LineNr">584 </span> <span class="Constant">local-scope</span> -<span id="L585" class="LineNr">585 </span> <span class="Constant">load-ingredients</span> +<span id="L585" class="LineNr">585 </span> <span class="Constant">load-inputs</span> <span id="L586" class="LineNr">586 </span> <span class="Comment"># null cell? no change.</span> <span id="L587" class="LineNr">587 </span> <span class="Comment"># pair with all atoms? gensym a new variable</span> <span id="L588" class="LineNr">588 </span> <span class="Comment"># pair containing other pairs? recurse</span> |