The Hylos notebook is not ready for public yet.

This commit is contained in:
Simon Forman 2018-06-08 13:05:59 -07:00
parent f5fe7d9726
commit b98e9f2107
18 changed files with 463 additions and 2825 deletions

View File

@ -157,7 +157,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 6,
"metadata": { "metadata": {
"scrolled": true "scrolled": false
}, },
"outputs": [ "outputs": [
{ {
@ -1113,7 +1113,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython2", "pygments_lexer": "ipython2",
"version": "2.7.13" "version": "2.7.12"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -12526,7 +12526,7 @@ range_sum == [0 &lt;=] [pop 0] [1 - dup] [dip +] genrec</code></pre>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[8]:</div> <div class="prompt input_prompt">In&nbsp;[10]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">defs</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">defs</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span>
@ -12548,7 +12548,7 @@ range_sum == [0 &lt;=] [pop 0] [1 - dup] [dip +] genrec</code></pre>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[9]:</div> <div class="prompt input_prompt">In&nbsp;[11]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 range&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 range&#39;</span><span class="p">)</span>
@ -12579,7 +12579,7 @@ range_sum == [0 &lt;=] [pop 0] [1 - dup] [dip +] genrec</code></pre>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[10]:</div> <div class="prompt input_prompt">In&nbsp;[12]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[9 8 7 6 5 4 3 2 1 0] sum&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[9 8 7 6 5 4 3 2 1 0] sum&#39;</span><span class="p">)</span>
@ -12610,7 +12610,7 @@ range_sum == [0 &lt;=] [pop 0] [1 - dup] [dip +] genrec</code></pre>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[11]:</div> <div class="prompt input_prompt">In&nbsp;[13]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;10 range sum&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;10 range sum&#39;</span><span class="p">)</span>
@ -13127,7 +13127,7 @@ range_sum == [0 &lt;=] [pop 0] [1 - dup] [dip +] genrec</code></pre>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[12]:</div> <div class="prompt input_prompt">In&nbsp;[14]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;10 range_sum&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;10 range_sum&#39;</span><span class="p">)</span>
@ -14390,789 +14390,6 @@ False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] . swaac
</div> </div>
</div> </div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Tree-with-node-and-list-of-trees.">Tree with node and list of trees.<a class="anchor-link" href="#Tree-with-node-and-list-of-trees.">&#182;</a></h1>
<pre><code>tree = [] | [node [tree*]]</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="treestep"><code>treestep</code><a class="anchor-link" href="#treestep">&#182;</a></h3>
<pre><code>tree z [C] [N] treestep
[] z [C] [N] treestep
---------------------------
z
[node [tree*]] z [C] [N] treestep
--------------------------------------- w/ K == z [C] [N] treestep
node N [tree*] [K] map C</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Derive-the-recursive-form.">Derive the recursive form.<a class="anchor-link" href="#Derive-the-recursive-form.">&#182;</a></h3>
<pre><code>K == [not] [pop z] [J] ifte
[node [tree*]] J
------------------------------
node N [tree*] [K] map C
J == .. [N] .. [K] .. [C] ..
[node [tree*]] uncons [N] dip
node [[tree*]] [N] dip
node N [[tree*]]
node N [[tree*]] i [K] map
node N [tree*] [K] map
node N [K.tree*]
J == uncons [N] dip i [K] map [C] i
K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte
K == [not] [pop z] [uncons [N] dip i] [map [C] i] genrec</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Extract-the-givens-to-parameterize-the-program.">Extract the givens to parameterize the program.<a class="anchor-link" href="#Extract-the-givens-to-parameterize-the-program.">&#182;</a></h3>
<pre><code>[not] [pop z] [uncons [N] dip unquote] [map [C] i] genrec
[not] [z] [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
[not] z unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
\............TS0............/
z TS0 [uncons [N] dip unquote] [map [C] i] genrec
z [uncons [N] dip unquote] [TS0] dip [map [C] i] genrec
z [[N] dip unquote] [uncons] swoncat [TS0] dip [map [C] i] genrec
z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec
\...........TS1.................../
z [N] TS1 [TS0] dip [map [C] i] genrec
z [N] [map [C] i] [TS1 [TS0] dip] dip genrec
z [N] [map C ] [TS1 [TS0] dip] dip genrec
z [N] [C] [map] swoncat [TS1 [TS0] dip] dip genrec
z [C] [N] swap [map] swoncat [TS1 [TS0] dip] dip genrec</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<pre><code> TS0 == [not] swap unit [pop] swoncat
TS1 == [dip i] cons [uncons] swoncat
treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<pre><code> [] 0 [C] [N] treestep
---------------------------
0
[n [tree*]] 0 [sum +] [] treestep
--------------------------------------------------
n [tree*] [0 [sum +] [] treestep] map sum +</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[40]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
<span class="s1"> TS0 == [not] swap unit [pop] swoncat</span>
<span class="s1"> TS1 == [dip i] cons [uncons] swoncat</span>
<span class="s1">treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec</span>
<span class="s1">&#39;&#39;&#39;</span><span class="p">,</span> <span class="n">D</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[31]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[] 0 [sum +] [] treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre> . [] 0 [sum +] [] treestep
[] . 0 [sum +] [] treestep
[] 0 . [sum +] [] treestep
[] 0 [sum +] . [] treestep
[] 0 [sum +] [] . treestep
[] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[] 0 [] . TS1 [TS0] dip [map sum +] genrec
[] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i
[] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i
[] [pop 0] . i
[] . pop 0
. 0
0 .
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[32]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[23 []] 0 [sum +] [] treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre> . [23 []] 0 [sum +] [] treestep
[23 []] . 0 [sum +] [] treestep
[23 []] 0 . [sum +] [] treestep
[23 []] 0 [sum +] . [] treestep
[23 []] 0 [sum +] [] . treestep
[23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec
[23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i
[23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
[23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
23 [] . sum +
23 [] . 0 [+] catamorphism +
23 [] 0 . [+] catamorphism +
23 [] 0 [+] . catamorphism +
23 [] 0 [+] . [[] =] roll&gt; [uncons swap] swap hylomorphism +
23 [] 0 [+] [[] =] . roll&gt; [uncons swap] swap hylomorphism +
23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
23 [] [[] =] 0 [uncons swap] [+] . hylomorphism +
23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i +
23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i +
23 [] [pop 0] . i +
23 [] . pop 0 +
23 . 0 +
23 0 . +
23 .
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[33]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[23 [[2 []] [3 []]]] 0 [sum +] [] treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre> . [23 [[2 []] [3 []]]] 0 [sum +] [] treestep
[23 [[2 []] [3 []]]] . 0 [sum +] [] treestep
[23 [[2 []] [3 []]]] 0 . [sum +] [] treestep
[23 [[2 []] [3 []]]] 0 [sum +] . [] treestep
[23 [[2 []] [3 []]]] 0 [sum +] [] . treestep
[23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i
[23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
[23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum +
. [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] . [[] =] roll&gt; [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] [[] =] . roll&gt; [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum +
23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum +
23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum +
23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum +
23 2 [] . sum + [3] swaack first [23] swaack sum +
23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] . [[] =] roll&gt; [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] [[] =] . roll&gt; [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum +
23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum +
23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum +
23 2 [] . pop 0 + [3] swaack first [23] swaack sum +
23 2 . 0 + [3] swaack first [23] swaack sum +
23 2 0 . + [3] swaack first [23] swaack sum +
23 2 . [3] swaack first [23] swaack sum +
23 2 [3] . swaack first [23] swaack sum +
3 [2 23] . first [23] swaack sum +
3 2 . [23] swaack sum +
3 2 [23] . swaack sum +
23 [2 3] . sum +
23 [2 3] . 0 [+] catamorphism +
23 [2 3] 0 . [+] catamorphism +
23 [2 3] 0 [+] . catamorphism +
23 [2 3] 0 [+] . [[] =] roll&gt; [uncons swap] swap hylomorphism +
23 [2 3] 0 [+] [[] =] . roll&gt; [uncons swap] swap hylomorphism +
23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism +
23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i +
23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i +
23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + +
23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + +
23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + +
23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + +
23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + +
23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + +
23 [] [pop 0] . i 3 + 2 + +
23 [] . pop 0 3 + 2 + +
23 . 0 3 + 2 + +
23 0 . 3 + 2 + +
23 0 3 . + 2 + +
23 3 . 2 + +
23 3 2 . + +
23 5 . +
28 .
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[34]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>140
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[35]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [] [unit cons] [23 +] treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>[]
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[36]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 []] [] [unit cons] [23 +] treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>[46 []]
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[37]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>[46 [[25 []] [26 []]]]
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[38]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;treemap == [] [unit cons] roll&lt; treestep&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[39]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [[2 []] [3 []]]] [23 +] treemap&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>[46 [[25 []] [26 []]]]
</pre>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -273,9 +273,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 9,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -642,7 +640,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -660,7 +658,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -677,7 +675,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -694,10 +692,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 13,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -1199,10 +1195,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 14,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -1906,9 +1900,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": 26,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -2008,9 +2000,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": 27,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -2092,9 +2082,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 28,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -2177,9 +2165,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 29, "execution_count": 29,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -2269,698 +2255,6 @@
"\n", "\n",
"\"Too much is always better than not enough.\"" "\"Too much is always better than not enough.\""
] ]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tree with node and list of trees.\n",
"\n",
" tree = [] | [node [tree*]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### `treestep`\n",
"\n",
" tree z [C] [N] treestep\n",
"\n",
"\n",
" [] z [C] [N] treestep\n",
" ---------------------------\n",
" z\n",
"\n",
"\n",
" [node [tree*]] z [C] [N] treestep\n",
" --------------------------------------- w/ K == z [C] [N] treestep\n",
" node N [tree*] [K] map C"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Derive the recursive form.\n",
" K == [not] [pop z] [J] ifte\n",
"\n",
"\n",
" [node [tree*]] J\n",
" ------------------------------\n",
" node N [tree*] [K] map C\n",
"\n",
"\n",
" J == .. [N] .. [K] .. [C] ..\n",
"\n",
" [node [tree*]] uncons [N] dip\n",
" node [[tree*]] [N] dip\n",
" node N [[tree*]]\n",
"\n",
" node N [[tree*]] i [K] map\n",
" node N [tree*] [K] map\n",
" node N [K.tree*]\n",
"\n",
" J == uncons [N] dip i [K] map [C] i\n",
"\n",
" K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte\n",
" K == [not] [pop z] [uncons [N] dip i] [map [C] i] genrec"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Extract the givens to parameterize the program.\n",
" [not] [pop z] [uncons [N] dip unquote] [map [C] i] genrec\n",
" [not] [z] [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec\n",
" [not] z unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec\n",
" z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec\n",
" \\............TS0............/\n",
" z TS0 [uncons [N] dip unquote] [map [C] i] genrec\n",
" z [uncons [N] dip unquote] [TS0] dip [map [C] i] genrec\n",
" z [[N] dip unquote] [uncons] swoncat [TS0] dip [map [C] i] genrec\n",
" z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec\n",
" \\...........TS1.................../\n",
" z [N] TS1 [TS0] dip [map [C] i] genrec\n",
" z [N] [map [C] i] [TS1 [TS0] dip] dip genrec\n",
" z [N] [map C ] [TS1 [TS0] dip] dip genrec\n",
" z [N] [C] [map] swoncat [TS1 [TS0] dip] dip genrec\n",
" z [C] [N] swap [map] swoncat [TS1 [TS0] dip] dip genrec"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" TS0 == [not] swap unit [pop] swoncat\n",
" TS1 == [dip i] cons [uncons] swoncat\n",
" treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" [] 0 [C] [N] treestep\n",
" ---------------------------\n",
" 0\n",
"\n",
"\n",
" [n [tree*]] 0 [sum +] [] treestep\n",
" --------------------------------------------------\n",
" n [tree*] [0 [sum +] [] treestep] map sum +"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"DefinitionWrapper.add_definitions('''\n",
"\n",
" TS0 == [not] swap unit [pop] swoncat\n",
" TS1 == [dip i] cons [uncons] swoncat\n",
"treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec\n",
"\n",
"''', D)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" . [] 0 [sum +] [] treestep\n",
" [] . 0 [sum +] [] treestep\n",
" [] 0 . [sum +] [] treestep\n",
" [] 0 [sum +] . [] treestep\n",
" [] 0 [sum +] [] . treestep\n",
" [] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec\n",
" [] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec\n",
" [] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec\n",
" [] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec\n",
" [] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec\n",
" [] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec\n",
" [] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec\n",
" [] 0 [] . TS1 [TS0] dip [map sum +] genrec\n",
" [] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec\n",
" [] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec\n",
" [] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec\n",
" [] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec\n",
" [] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec\n",
" [] 0 . TS0 [uncons [] dip i] [map sum +] genrec\n",
" [] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec\n",
" [] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec\n",
" [] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec\n",
" [] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec\n",
" [] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte\n",
"[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i\n",
" [] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i\n",
" True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i\n",
" True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i\n",
" [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i\n",
" [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i\n",
" [] [pop 0] . i\n",
" [] . pop 0\n",
" . 0\n",
" 0 . \n"
]
}
],
"source": [
"V('[] 0 [sum +] [] treestep')"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" . [23 []] 0 [sum +] [] treestep\n",
" [23 []] . 0 [sum +] [] treestep\n",
" [23 []] 0 . [sum +] [] treestep\n",
" [23 []] 0 [sum +] . [] treestep\n",
" [23 []] 0 [sum +] [] . treestep\n",
" [23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec\n",
" [23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec\n",
" [23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec\n",
" [23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec\n",
" [23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec\n",
" [23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec\n",
" [23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec\n",
" [23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec\n",
" [23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec\n",
" [23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec\n",
" [23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec\n",
" [23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec\n",
" [23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec\n",
" [23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte\n",
"[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i\n",
" [23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i\n",
" False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i\n",
" False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i\n",
" [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i\n",
" [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i\n",
" [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i\n",
" [23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +\n",
" 23 [] . sum +\n",
" 23 [] . 0 [+] catamorphism +\n",
" 23 [] 0 . [+] catamorphism +\n",
" 23 [] 0 [+] . catamorphism +\n",
" 23 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +\n",
" 23 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +\n",
" 23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism +\n",
" 23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism +\n",
" 23 [] [[] =] 0 [uncons swap] [+] . hylomorphism +\n",
" 23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +\n",
" 23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +\n",
" 23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +\n",
" 23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +\n",
" 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +\n",
" 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +\n",
" 23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +\n",
" 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec +\n",
" 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +\n",
" 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i +\n",
" 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +\n",
" 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +\n",
" 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +\n",
" 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i +\n",
" 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i +\n",
" 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i +\n",
" 23 [] [pop 0] . i +\n",
" 23 [] . pop 0 +\n",
" 23 . 0 +\n",
" 23 0 . +\n",
" 23 . \n"
]
}
],
"source": [
"V('[23 []] 0 [sum +] [] treestep')"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" . [23 [[2 []] [3 []]]] 0 [sum +] [] treestep\n",
" [23 [[2 []] [3 []]]] . 0 [sum +] [] treestep\n",
" [23 [[2 []] [3 []]]] 0 . [sum +] [] treestep\n",
" [23 [[2 []] [3 []]]] 0 [sum +] . [] treestep\n",
" [23 [[2 []] [3 []]]] 0 [sum +] [] . treestep\n",
" [23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec\n",
" [23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec\n",
" [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec\n",
" [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec\n",
" [23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec\n",
" [23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec\n",
" [23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec\n",
" [23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec\n",
" [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec\n",
" [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte\n",
" [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i\n",
" [23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i\n",
" False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i\n",
" False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i\n",
" [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i\n",
" [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i\n",
" [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i\n",
" [23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n",
" 23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +\n",
"23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum +\n",
" . [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" [[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" [3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n",
" 3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum +\n",
" 23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum +\n",
" 23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +\n",
" 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +\n",
" 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum +\n",
" 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum +\n",
" 23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum +\n",
" 23 2 [] . sum + [3] swaack first [23] swaack sum +\n",
" 23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum +\n",
" 23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +\n",
" 23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +\n",
" 23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum +\n",
" 23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum +\n",
" 23 2 [] . pop 0 + [3] swaack first [23] swaack sum +\n",
" 23 2 . 0 + [3] swaack first [23] swaack sum +\n",
" 23 2 0 . + [3] swaack first [23] swaack sum +\n",
" 23 2 . [3] swaack first [23] swaack sum +\n",
" 23 2 [3] . swaack first [23] swaack sum +\n",
" 3 [2 23] . first [23] swaack sum +\n",
" 3 2 . [23] swaack sum +\n",
" 3 2 [23] . swaack sum +\n",
" 23 [2 3] . sum +\n",
" 23 [2 3] . 0 [+] catamorphism +\n",
" 23 [2 3] 0 . [+] catamorphism +\n",
" 23 [2 3] 0 [+] . catamorphism +\n",
" 23 [2 3] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +\n",
" 23 [2 3] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +\n",
" 23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism +\n",
" 23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism +\n",
" 23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism +\n",
" 23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +\n",
" 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +\n",
" 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +\n",
" 23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +\n",
" 23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec +\n",
" 23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +\n",
" 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i +\n",
" 23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +\n",
" 23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +\n",
" 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +\n",
" 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i +\n",
" 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i +\n",
" 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i +\n",
" 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i +\n",
" 23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +\n",
" 23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +\n",
" 23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +\n",
" 23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + +\n",
" 23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + +\n",
" 23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + +\n",
" 23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + +\n",
" 23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + +\n",
" 23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + +\n",
" 23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + +\n",
" 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + +\n",
" 23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +\n",
" 23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +\n",
" 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +\n",
" 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + +\n",
" 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + +\n",
" 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + +\n",
" 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + +\n",
" 23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +\n",
" 23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +\n",
" 23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +\n",
" 23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + +\n",
" 23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +\n",
" 23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +\n",
" 23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + +\n",
" 23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + +\n",
" 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + +\n",
" 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + +\n",
" 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + +\n",
" 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +\n",
" 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +\n",
" 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +\n",
" 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + +\n",
" 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + +\n",
" 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + +\n",
" 23 [] [pop 0] . i 3 + 2 + +\n",
" 23 [] . pop 0 3 + 2 + +\n",
" 23 . 0 3 + 2 + +\n",
" 23 0 . 3 + 2 + +\n",
" 23 0 3 . + 2 + +\n",
" 23 3 . 2 + +\n",
" 23 3 2 . + +\n",
" 23 5 . +\n",
" 28 . \n"
]
}
],
"source": [
"V('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep')"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"140\n"
]
}
],
"source": [
"J('[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"source": [
"J('[] [] [unit cons] [23 +] treestep')"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[46 []]\n"
]
}
],
"source": [
"J('[23 []] [] [unit cons] [23 +] treestep')"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[46 [[25 []] [26 []]]]\n"
]
}
],
"source": [
"J('[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep')"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"define('treemap == [] [unit cons] roll< treestep')"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[46 [[25 []] [26 []]]]\n"
]
}
],
"source": [
"J('[23 [[2 []] [3 []]]] [23 +] treemap')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {

View File

@ -1906,544 +1906,3 @@ V('[2 1] [[] =] [pop c ] [uncons swap] [dip F] genrec')
I think they are having slightly too much fun with the symbols. I think they are having slightly too much fun with the symbols.
"Too much is always better than not enough." "Too much is always better than not enough."
# Tree with node and list of trees.
tree = [] | [node [tree*]]
### `treestep`
tree z [C] [N] treestep
[] z [C] [N] treestep
---------------------------
z
[node [tree*]] z [C] [N] treestep
--------------------------------------- w/ K == z [C] [N] treestep
node N [tree*] [K] map C
### Derive the recursive form.
K == [not] [pop z] [J] ifte
[node [tree*]] J
------------------------------
node N [tree*] [K] map C
J == .. [N] .. [K] .. [C] ..
[node [tree*]] uncons [N] dip
node [[tree*]] [N] dip
node N [[tree*]]
node N [[tree*]] i [K] map
node N [tree*] [K] map
node N [K.tree*]
J == uncons [N] dip i [K] map [C] i
K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte
K == [not] [pop z] [uncons [N] dip i] [map [C] i] genrec
### Extract the givens to parameterize the program.
[not] [pop z] [uncons [N] dip unquote] [map [C] i] genrec
[not] [z] [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
[not] z unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
\............TS0............/
z TS0 [uncons [N] dip unquote] [map [C] i] genrec
z [uncons [N] dip unquote] [TS0] dip [map [C] i] genrec
z [[N] dip unquote] [uncons] swoncat [TS0] dip [map [C] i] genrec
z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec
\...........TS1.................../
z [N] TS1 [TS0] dip [map [C] i] genrec
z [N] [map [C] i] [TS1 [TS0] dip] dip genrec
z [N] [map C ] [TS1 [TS0] dip] dip genrec
z [N] [C] [map] swoncat [TS1 [TS0] dip] dip genrec
z [C] [N] swap [map] swoncat [TS1 [TS0] dip] dip genrec
TS0 == [not] swap unit [pop] swoncat
TS1 == [dip i] cons [uncons] swoncat
treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
[] 0 [C] [N] treestep
---------------------------
0
[n [tree*]] 0 [sum +] [] treestep
--------------------------------------------------
n [tree*] [0 [sum +] [] treestep] map sum +
```python
DefinitionWrapper.add_definitions('''
TS0 == [not] swap unit [pop] swoncat
TS1 == [dip i] cons [uncons] swoncat
treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
''', D)
```
```python
V('[] 0 [sum +] [] treestep')
```
. [] 0 [sum +] [] treestep
[] . 0 [sum +] [] treestep
[] 0 . [sum +] [] treestep
[] 0 [sum +] . [] treestep
[] 0 [sum +] [] . treestep
[] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[] 0 [] . TS1 [TS0] dip [map sum +] genrec
[] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i
[] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i
[] [pop 0] . i
[] . pop 0
. 0
0 .
```python
V('[23 []] 0 [sum +] [] treestep')
```
. [23 []] 0 [sum +] [] treestep
[23 []] . 0 [sum +] [] treestep
[23 []] 0 . [sum +] [] treestep
[23 []] 0 [sum +] . [] treestep
[23 []] 0 [sum +] [] . treestep
[23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec
[23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i
[23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
[23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
23 [] . sum +
23 [] . 0 [+] catamorphism +
23 [] 0 . [+] catamorphism +
23 [] 0 [+] . catamorphism +
23 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +
23 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +
23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
23 [] [[] =] 0 [uncons swap] [+] . hylomorphism +
23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i +
23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i +
23 [] [pop 0] . i +
23 [] . pop 0 +
23 . 0 +
23 0 . +
23 .
```python
V('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep')
```
. [23 [[2 []] [3 []]]] 0 [sum +] [] treestep
[23 [[2 []] [3 []]]] . 0 [sum +] [] treestep
[23 [[2 []] [3 []]]] 0 . [sum +] [] treestep
[23 [[2 []] [3 []]]] 0 [sum +] . [] treestep
[23 [[2 []] [3 []]]] 0 [sum +] [] . treestep
[23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i
[23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
[23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum +
. [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum +
23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum +
23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum +
23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum +
23 2 [] . sum + [3] swaack first [23] swaack sum +
23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum +
23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum +
23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum +
23 2 [] . pop 0 + [3] swaack first [23] swaack sum +
23 2 . 0 + [3] swaack first [23] swaack sum +
23 2 0 . + [3] swaack first [23] swaack sum +
23 2 . [3] swaack first [23] swaack sum +
23 2 [3] . swaack first [23] swaack sum +
3 [2 23] . first [23] swaack sum +
3 2 . [23] swaack sum +
3 2 [23] . swaack sum +
23 [2 3] . sum +
23 [2 3] . 0 [+] catamorphism +
23 [2 3] 0 . [+] catamorphism +
23 [2 3] 0 [+] . catamorphism +
23 [2 3] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +
23 [2 3] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +
23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism +
23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i +
23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i +
23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + +
23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + +
23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + +
23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + +
23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + +
23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + +
23 [] [pop 0] . i 3 + 2 + +
23 [] . pop 0 3 + 2 + +
23 . 0 3 + 2 + +
23 0 . 3 + 2 + +
23 0 3 . + 2 + +
23 3 . 2 + +
23 3 2 . + +
23 5 . +
28 .
```python
J('[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep')
```
140
```python
J('[] [] [unit cons] [23 +] treestep')
```
[]
```python
J('[23 []] [] [unit cons] [23 +] treestep')
```
[46 []]
```python
J('[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep')
```
[46 [[25 []] [26 []]]]
```python
define('treemap == [] [unit cons] roll< treestep')
```
```python
J('[23 [[2 []] [3 []]]] [23 +] treemap')
```
[46 [[25 []] [26 []]]]

View File

@ -2105,576 +2105,3 @@ Wire" <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125>`__
I think they are having slightly too much fun with the symbols. I think they are having slightly too much fun with the symbols.
"Too much is always better than not enough." "Too much is always better than not enough."
Tree with node and list of trees.
=================================
::
tree = [] | [node [tree*]]
``treestep``
~~~~~~~~~~~~
::
tree z [C] [N] treestep
[] z [C] [N] treestep
---------------------------
z
[node [tree*]] z [C] [N] treestep
--------------------------------------- w/ K == z [C] [N] treestep
node N [tree*] [K] map C
Derive the recursive form.
~~~~~~~~~~~~~~~~~~~~~~~~~~
::
K == [not] [pop z] [J] ifte
[node [tree*]] J
------------------------------
node N [tree*] [K] map C
J == .. [N] .. [K] .. [C] ..
[node [tree*]] uncons [N] dip
node [[tree*]] [N] dip
node N [[tree*]]
node N [[tree*]] i [K] map
node N [tree*] [K] map
node N [K.tree*]
J == uncons [N] dip i [K] map [C] i
K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte
K == [not] [pop z] [uncons [N] dip i] [map [C] i] genrec
Extract the givens to parameterize the program.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
[not] [pop z] [uncons [N] dip unquote] [map [C] i] genrec
[not] [z] [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
[not] z unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
\............TS0............/
z TS0 [uncons [N] dip unquote] [map [C] i] genrec
z [uncons [N] dip unquote] [TS0] dip [map [C] i] genrec
z [[N] dip unquote] [uncons] swoncat [TS0] dip [map [C] i] genrec
z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec
\...........TS1.................../
z [N] TS1 [TS0] dip [map [C] i] genrec
z [N] [map [C] i] [TS1 [TS0] dip] dip genrec
z [N] [map C ] [TS1 [TS0] dip] dip genrec
z [N] [C] [map] swoncat [TS1 [TS0] dip] dip genrec
z [C] [N] swap [map] swoncat [TS1 [TS0] dip] dip genrec
::
TS0 == [not] swap unit [pop] swoncat
TS1 == [dip i] cons [uncons] swoncat
treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
::
[] 0 [C] [N] treestep
---------------------------
0
[n [tree*]] 0 [sum +] [] treestep
--------------------------------------------------
n [tree*] [0 [sum +] [] treestep] map sum +
.. code:: ipython2
DefinitionWrapper.add_definitions('''
TS0 == [not] swap unit [pop] swoncat
TS1 == [dip i] cons [uncons] swoncat
treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
''', D)
.. code:: ipython2
V('[] 0 [sum +] [] treestep')
.. parsed-literal::
. [] 0 [sum +] [] treestep
[] . 0 [sum +] [] treestep
[] 0 . [sum +] [] treestep
[] 0 [sum +] . [] treestep
[] 0 [sum +] [] . treestep
[] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[] 0 [] . TS1 [TS0] dip [map sum +] genrec
[] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i
[] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i
[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i
[] [pop 0] . i
[] . pop 0
. 0
0 .
.. code:: ipython2
V('[23 []] 0 [sum +] [] treestep')
.. parsed-literal::
. [23 []] 0 [sum +] [] treestep
[23 []] . 0 [sum +] [] treestep
[23 []] 0 . [sum +] [] treestep
[23 []] 0 [sum +] . [] treestep
[23 []] 0 [sum +] [] . treestep
[23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec
[23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i
[23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
[23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
23 [] . sum +
23 [] . 0 [+] catamorphism +
23 [] 0 . [+] catamorphism +
23 [] 0 [+] . catamorphism +
23 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +
23 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +
23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
23 [] [[] =] 0 [uncons swap] [+] . hylomorphism +
23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i +
23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i +
23 [] [pop 0] . i +
23 [] . pop 0 +
23 . 0 +
23 0 . +
23 .
.. code:: ipython2
V('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep')
.. parsed-literal::
. [23 [[2 []] [3 []]]] 0 [sum +] [] treestep
[23 [[2 []] [3 []]]] . 0 [sum +] [] treestep
[23 [[2 []] [3 []]]] 0 . [sum +] [] treestep
[23 [[2 []] [3 []]]] 0 [sum +] . [] treestep
[23 [[2 []] [3 []]]] 0 [sum +] [] . treestep
[23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
[23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
[23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
[23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
[23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i
[23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
[23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
[23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum +
. [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
[3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum +
23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum +
23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum +
23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum +
23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum +
23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum +
23 2 [] . sum + [3] swaack first [23] swaack sum +
23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum +
23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum +
23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum +
23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum +
23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum +
23 2 [] . pop 0 + [3] swaack first [23] swaack sum +
23 2 . 0 + [3] swaack first [23] swaack sum +
23 2 0 . + [3] swaack first [23] swaack sum +
23 2 . [3] swaack first [23] swaack sum +
23 2 [3] . swaack first [23] swaack sum +
3 [2 23] . first [23] swaack sum +
3 2 . [23] swaack sum +
3 2 [23] . swaack sum +
23 [2 3] . sum +
23 [2 3] . 0 [+] catamorphism +
23 [2 3] 0 . [+] catamorphism +
23 [2 3] 0 [+] . catamorphism +
23 [2 3] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +
23 [2 3] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +
23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism +
23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i +
23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i +
23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i +
23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + +
23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + +
23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + +
23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + +
23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + +
23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + +
23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + +
23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + +
23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + +
23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + +
23 [] [pop 0] . i 3 + 2 + +
23 [] . pop 0 3 + 2 + +
23 . 0 3 + 2 + +
23 0 . 3 + 2 + +
23 0 3 . + 2 + +
23 3 . 2 + +
23 3 2 . + +
23 5 . +
28 .
.. code:: ipython2
J('[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep')
.. parsed-literal::
140
.. code:: ipython2
J('[] [] [unit cons] [23 +] treestep')
.. parsed-literal::
[]
.. code:: ipython2
J('[23 []] [] [unit cons] [23 +] treestep')
.. parsed-literal::
[46 []]
.. code:: ipython2
J('[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep')
.. parsed-literal::
[46 [[25 []] [26 []]]]
.. code:: ipython2
define('treemap == [] [unit cons] roll< treestep')
.. code:: ipython2
J('[23 [[2 []] [3 []]]] [23 +] treemap')
.. parsed-literal::
[46 [[25 []] [26 []]]]

View File

@ -22,7 +22,9 @@ $(docs_md): %.md : %.ipynb
$(docs_rst): %.rst : %.ipynb $(docs_rst): %.rst : %.ipynb
python -m nbconvert --to rst $< python -m nbconvert --to rst $<
move_us = Generator_Programs.rst Ordered_Binary_Trees.rst Quadratic.rst Replacing.rst Treestep.rst Zipper.rst
move_us = Generator_Programs.rst Newton-Raphson.rst Ordered_Binary_Trees.rst Quadratic.rst Replacing.rst Treestep.rst Zipper.rst
mov: $(move_us) mov: $(move_us)
cp -v $? ./sphinx_docs/notebooks/ cp -v $? ./sphinx_docs/notebooks/

View File

@ -11867,21 +11867,6 @@ n+1 2 /
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[2]:</div> <div class="prompt input_prompt">In&nbsp;[2]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;codireco == cons dip rest cons&#39;</span><span class="p">)</span>
<span class="n">define</span><span class="p">(</span><span class="s1">&#39;make_generator == [codireco] ccons&#39;</span><span class="p">)</span>
<span class="n">define</span><span class="p">(</span><span class="s1">&#39;ccons == cons cons&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[3]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator&#39;</span><span class="p">)</span>
@ -11894,7 +11879,7 @@ n+1 2 /
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[4]:</div> <div class="prompt input_prompt">In&nbsp;[3]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra&#39;</span><span class="p">)</span>
@ -11934,7 +11919,7 @@ n+1 2 /
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[5]:</div> <div class="prompt input_prompt">In&nbsp;[4]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra 6 [x popd] times first sqr&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra 6 [x popd] times first sqr&#39;</span><span class="p">)</span>
@ -11967,9 +11952,9 @@ n+1 2 /
</div> </div>
<div class="inner_cell"> <div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html"> <div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Finding-Consecutive-Approximations-within-a-Tolerance">Finding Consecutive Approximations within a Tolerance<a class="anchor-link" href="#Finding-Consecutive-Approximations-within-a-Tolerance">&#182;</a></h2><blockquote><p>The remainder of a square root finder is a function <em>within</em>, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.</p> <h2 id="Finding-Consecutive-Approximations-within-a-Tolerance">Finding Consecutive Approximations within a Tolerance<a class="anchor-link" href="#Finding-Consecutive-Approximations-within-a-Tolerance">&#182;</a></h2><p>From <a href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">"Why Functional Programming Matters" by John Hughes</a>:</p>
<blockquote><p>The remainder of a square root finder is a function <em>within</em>, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.</p>
</blockquote> </blockquote>
<p>From <a href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">"Why Functional Programming Matters" by John Hughes</a></p>
<p>(And note that by “list” he means a lazily-evaluated list.)</p> <p>(And note that by “list” he means a lazily-evaluated list.)</p>
<p>Using the <em>output</em> <code>[a G]</code> of the above generator for square root approximations, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack...</p> <p>Using the <em>output</em> <code>[a G]</code> of the above generator for square root approximations, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack...</p>
@ -12002,7 +11987,7 @@ abs(a-b) ε &lt;=
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[6]:</div> <div class="prompt input_prompt">In&nbsp;[5]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_P == [first - abs] dip &lt;=&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_P == [first - abs] dip &lt;=&#39;</span><span class="p">)</span>
@ -12028,7 +12013,7 @@ abs(a-b) ε &lt;=
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[7]:</div> <div class="prompt input_prompt">In&nbsp;[6]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_B == roll&lt; popop first&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_B == roll&lt; popop first&#39;</span><span class="p">)</span>
@ -12049,8 +12034,8 @@ abs(a-b) ε &lt;=
</code></pre> </code></pre>
<ol> <ol>
<li>Discard a.</li> <li>Discard a.</li>
<li>Use x combinator to generate next term from G.</li> <li>Use <code>x</code> combinator to generate next term from <code>G</code>.</li>
<li>Run within with <code>i</code> (it is a <code>primrec</code> function.)</li> <li>Run <code>within</code> with <code>i</code> (it is a <code>primrec</code> function.)</li>
</ol> </ol>
<p>Pretty straightforward:</p> <p>Pretty straightforward:</p>
@ -12068,7 +12053,7 @@ b [c G] ε within</code></pre>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[8]:</div> <div class="prompt input_prompt">In&nbsp;[7]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_R == [popd x] dip&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_R == [popd x] dip&#39;</span><span class="p">)</span>
@ -12093,7 +12078,7 @@ a [b G] ε ...</code></pre>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[9]:</div> <div class="prompt input_prompt">In&nbsp;[8]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec&#39;</span><span class="p">)</span> <div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec&#39;</span><span class="p">)</span>
@ -12104,6 +12089,46 @@ a [b G] ε ...</code></pre>
</div> </div>
</div> </div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Try it out...</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[9]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;36 sqrt&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>6.0
</pre>
</div>
</div>
</div>
</div>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
@ -12135,6 +12160,15 @@ a [b G] ε ...</code></pre>
</div> </div>
</div> </div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Check it.</p>
</div>
</div>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
@ -12168,6 +12202,41 @@ a [b G] ε ...</code></pre>
</div> </div>
</div> </div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[12]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="n">sqrt</span><span class="p">(</span><span class="mi">23</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[12]:</div>
<div class="output_text output_subarea output_execute_result">
<pre>4.795831523312719</pre>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -87,17 +87,6 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"define('codireco == cons dip rest cons')\n",
"define('make_generator == [codireco] ccons')\n",
"define('ccons == cons cons')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
@ -108,7 +97,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -132,7 +121,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -153,11 +142,11 @@
"source": [ "source": [
"## Finding Consecutive Approximations within a Tolerance\n", "## Finding Consecutive Approximations within a Tolerance\n",
"\n", "\n",
"From [\"Why Functional Programming Matters\" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf):\n",
"\n",
"\n", "\n",
"> The remainder of a square root finder is a function _within_, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.\n", "> The remainder of a square root finder is a function _within_, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.\n",
"\n", "\n",
"From [\"Why Functional Programming Matters\" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf)\n",
"\n",
"(And note that by “list” he means a lazily-evaluated list.)\n", "(And note that by “list” he means a lazily-evaluated list.)\n",
"\n", "\n",
"Using the _output_ `[a G]` of the above generator for square root approximations, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack...\n", "Using the _output_ `[a G]` of the above generator for square root approximations, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack...\n",
@ -189,7 +178,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -210,7 +199,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -226,8 +215,8 @@
" a [b G] ε R0 [within] R1\n", " a [b G] ε R0 [within] R1\n",
"\n", "\n",
"1. Discard a.\n", "1. Discard a.\n",
"2. Use x combinator to generate next term from G.\n", "2. Use `x` combinator to generate next term from `G`.\n",
"3. Run within with `i` (it is a `primrec` function.)\n", "3. Run `within` with `i` (it is a `primrec` function.)\n",
"\n", "\n",
"Pretty straightforward:\n", "Pretty straightforward:\n",
"\n", "\n",
@ -243,7 +232,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -264,7 +253,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -272,6 +261,32 @@
"define('sqrt == gsra within')" "define('sqrt == gsra within')"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Try it out..."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6.0\n"
]
}
],
"source": [
"J('36 sqrt')"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 10,
@ -291,6 +306,13 @@
"J('23 sqrt')" "J('23 sqrt')"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check it."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 11,
@ -312,6 +334,28 @@
"source": [ "source": [
"4.795831523312719**2" "4.795831523312719**2"
] ]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4.795831523312719"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from math import sqrt\n",
"\n",
"sqrt(23)"
]
} }
], ],
"metadata": { "metadata": {

View File

@ -55,13 +55,6 @@ The generator can be written as:
1 [dup 23 over / + 2 /] make_generator 1 [dup 23 over / + 2 /] make_generator
```python
define('codireco == cons dip rest cons')
define('make_generator == [codireco] ccons')
define('ccons == cons cons')
```
```python ```python
define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator') define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator')
``` ```
@ -86,11 +79,11 @@ J('23 gsra 6 [x popd] times first sqr')
## Finding Consecutive Approximations within a Tolerance ## Finding Consecutive Approximations within a Tolerance
From ["Why Functional Programming Matters" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf):
> The remainder of a square root finder is a function _within_, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance. > The remainder of a square root finder is a function _within_, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.
From ["Why Functional Programming Matters" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf)
(And note that by “list” he means a lazily-evaluated list.) (And note that by “list” he means a lazily-evaluated list.)
Using the _output_ `[a G]` of the above generator for square root approximations, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack... Using the _output_ `[a G]` of the above generator for square root approximations, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack...
@ -137,8 +130,8 @@ define('_within_B == roll< popop first')
a [b G] ε R0 [within] R1 a [b G] ε R0 [within] R1
1. Discard a. 1. Discard a.
2. Use x combinator to generate next term from G. 2. Use `x` combinator to generate next term from `G`.
3. Run within with `i` (it is a `primrec` function.) 3. Run `within` with `i` (it is a `primrec` function.)
Pretty straightforward: Pretty straightforward:
@ -169,6 +162,16 @@ define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec')
define('sqrt == gsra within') define('sqrt == gsra within')
``` ```
Try it out...
```python
J('36 sqrt')
```
6.0
```python ```python
J('23 sqrt') J('23 sqrt')
@ -177,6 +180,8 @@ J('23 sqrt')
4.795831523312719 4.795831523312719
Check it.
```python ```python
4.795831523312719**2 4.795831523312719**2
@ -188,3 +193,17 @@ J('23 sqrt')
22.999999999999996 22.999999999999996
```python
from math import sqrt
sqrt(23)
```
4.795831523312719

View File

@ -76,12 +76,6 @@ The generator can be written as:
1 [23 over / + 2 /] [dup] swoncat make_generator 1 [23 over / + 2 /] [dup] swoncat make_generator
1 [dup 23 over / + 2 /] make_generator 1 [dup 23 over / + 2 /] make_generator
.. code:: ipython2
define('codireco == cons dip rest cons')
define('make_generator == [codireco] ccons')
define('ccons == cons cons')
.. code:: ipython2 .. code:: ipython2
define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator') define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator')
@ -112,14 +106,14 @@ square the approximation to see how well it works...
Finding Consecutive Approximations within a Tolerance Finding Consecutive Approximations within a Tolerance
----------------------------------------------------- -----------------------------------------------------
From `"Why Functional Programming Matters" by John
Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__:
The remainder of a square root finder is a function *within*, which The remainder of a square root finder is a function *within*, which
takes a tolerance and a list of approximations and looks down the takes a tolerance and a list of approximations and looks down the
list for two successive approximations that differ by no more than list for two successive approximations that differ by no more than
the given tolerance. the given tolerance.
From `"Why Functional Programming Matters" by John
Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__
(And note that by “list” he means a lazily-evaluated list.) (And note that by “list” he means a lazily-evaluated list.)
Using the *output* ``[a G]`` of the above generator for square root Using the *output* ``[a G]`` of the above generator for square root
@ -175,8 +169,8 @@ Recur
a [b G] ε R0 [within] R1 a [b G] ε R0 [within] R1
1. Discard a. 1. Discard a.
2. Use x combinator to generate next term from G. 2. Use ``x`` combinator to generate next term from ``G``.
3. Run within with ``i`` (it is a ``primrec`` function.) 3. Run ``within`` with ``i`` (it is a ``primrec`` function.)
Pretty straightforward: Pretty straightforward:
@ -211,6 +205,18 @@ The recursive function we have defined so far needs a slight preamble:
define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec') define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec')
define('sqrt == gsra within') define('sqrt == gsra within')
Try it out...
.. code:: ipython2
J('36 sqrt')
.. parsed-literal::
6.0
.. code:: ipython2 .. code:: ipython2
J('23 sqrt') J('23 sqrt')
@ -221,6 +227,8 @@ The recursive function we have defined so far needs a slight preamble:
4.795831523312719 4.795831523312719
Check it.
.. code:: ipython2 .. code:: ipython2
4.795831523312719**2 4.795831523312719**2
@ -233,3 +241,18 @@ The recursive function we have defined so far needs a slight preamble:
22.999999999999996 22.999999999999996
.. code:: ipython2
from math import sqrt
sqrt(23)
.. parsed-literal::
4.795831523312719

View File

@ -157,6 +157,9 @@
<span class="s1">dudipd == dup dipd</span> <span class="s1">dudipd == dup dipd</span>
<span class="s1">primrec == [i] genrec</span> <span class="s1">primrec == [i] genrec</span>
<span class="s1">step_zero == 0 roll&gt; step</span> <span class="s1">step_zero == 0 roll&gt; step</span>
<span class="s1">codireco == cons dip rest cons</span>
<span class="s1">make_generator == [codireco] ccons</span>
<span class="s1">ccons == cons cons</span>
<span class="s1">&#39;&#39;&#39;</span> <span class="s1">&#39;&#39;&#39;</span>
<span class="c1">##Zipper</span> <span class="c1">##Zipper</span>

View File

@ -17,7 +17,7 @@
<link rel="index" title="Index" href="../genindex.html" /> <link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" /> <link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Quadratic formula" href="Quadratic.html" /> <link rel="next" title="Quadratic formula" href="Quadratic.html" />
<link rel="prev" title="Treating Trees" href="Trees.html" /> <link rel="prev" title="Using x to Generate Values" href="Generator_Programs.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" /> <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
@ -34,16 +34,18 @@
<div class="section" id="newton-s-method"> <div class="section" id="newton-s-method">
<h1><a class="reference external" href="https://en.wikipedia.org/wiki/Newton%27s_method">Newtons method</a><a class="headerlink" href="#newton-s-method" title="Permalink to this headline"></a></h1> <h1><a class="reference external" href="https://en.wikipedia.org/wiki/Newton%27s_method">Newtons method</a><a class="headerlink" href="#newton-s-method" title="Permalink to this headline"></a></h1>
<p>Newton-Raphson for finding the root of an equation.</p> <p>Lets use the Newton-Raphson method for finding the root of an equation
to write a function that can compute the square root of a number.</p>
<p>Cf. <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why Functional Programming Matters” by John
Hughes</a></p>
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span> <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
</pre></div> </pre></div>
</div> </div>
<p>Cf. <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why Functional Programming Matters” by John
Hughes</a></p>
<div class="section" id="a-generator-for-approximations"> <div class="section" id="a-generator-for-approximations">
<h2>A Generator for Approximations<a class="headerlink" href="#a-generator-for-approximations" title="Permalink to this headline"></a></h2> <h2>A Generator for Approximations<a class="headerlink" href="#a-generator-for-approximations" title="Permalink to this headline"></a></h2>
<p>In <a class="reference internal" href="Generator Programs.html"><span class="doc">Using x to Generate Values</span></a> we derive a function (called <code class="docutils literal notranslate"><span class="pre">make_generator</span></code> in the dictionary) that accepts an initial value and a quoted program and returns a new quoted program that, when driven by the <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator (<a class="reference internal" href="../library.html#joy.library.x" title="joy.library.x"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.library.x()</span></code></a>), acts like a lazy stream.</p> <p>To make a generator that generates successive approximations lets start
<p>To make a generator that generates successive approximations lets start by assuming an initial approximation and then derive the function that computes the next approximation:</p> by assuming an initial approximation and then derive the function that
computes the next approximation:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">a</span> <span class="n">F</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">a</span> <span class="n">F</span>
<span class="o">---------</span> <span class="o">---------</span>
<span class="n">a</span><span class="s1">&#39;</span> <span class="n">a</span><span class="s1">&#39;</span>
@ -51,7 +53,8 @@ Hughes</a></p>
</div> </div>
<div class="section" id="a-function-to-compute-the-next-approximation"> <div class="section" id="a-function-to-compute-the-next-approximation">
<h3>A Function to Compute the Next Approximation<a class="headerlink" href="#a-function-to-compute-the-next-approximation" title="Permalink to this headline"></a></h3> <h3>A Function to Compute the Next Approximation<a class="headerlink" href="#a-function-to-compute-the-next-approximation" title="Permalink to this headline"></a></h3>
<p>Looking at the equation again:</p> <p>This is the equation for computing the next approximate value of the
square root:</p>
<p><span class="math notranslate nohighlight">\(a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}\)</span></p> <p><span class="math notranslate nohighlight">\(a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}\)</span></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="n">n</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="n">n</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
<span class="n">a</span> <span class="n">n</span> <span class="n">a</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span> <span class="n">a</span> <span class="n">n</span> <span class="n">a</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
@ -71,7 +74,8 @@ Hughes</a></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">dup</span> <span class="n">F</span><span class="p">]</span> <span class="n">make_generator</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">dup</span> <span class="n">F</span><span class="p">]</span> <span class="n">make_generator</span>
</pre></div> </pre></div>
</div> </div>
<p>With <code class="docutils literal notranslate"><span class="pre">n</span></code> as part of the function <code class="docutils literal notranslate"><span class="pre">F</span></code>, but <code class="docutils literal notranslate"><span class="pre">n</span></code> is the input to the <code class="docutils literal notranslate"><span class="pre">sqrt</span></code> function were writing. If we let 1 be the initial approximation:</p> <p>With n as part of the function F, but n is the input to the sqrt
function were writing. If we let 1 be the initial approximation:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="n">n</span> <span class="mi">1</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="n">n</span> <span class="mi">1</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
<span class="mi">1</span> <span class="n">n</span><span class="o">/</span><span class="mi">1</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span> <span class="mi">1</span> <span class="n">n</span><span class="o">/</span><span class="mi">1</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
<span class="mi">1</span> <span class="n">n</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span> <span class="mi">1</span> <span class="n">n</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
@ -80,48 +84,51 @@ Hughes</a></p>
</pre></div> </pre></div>
</div> </div>
<p>The generator can be written as:</p> <p>The generator can be written as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
</pre></div>
</div>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span> <span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span> <span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
<span class="mi">1</span> <span class="mi">23</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span> <span class="mi">1</span> <span class="mi">23</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
<span class="mi">1</span> <span class="p">[</span><span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span> <span class="mi">1</span> <span class="p">[</span><span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
<span class="mi">1</span> <span class="p">[</span><span class="n">dup</span> <span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">make_generator</span> <span class="mi">1</span> <span class="p">[</span><span class="n">dup</span> <span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">make_generator</span>
<span class="o">.</span>
<span class="o">.</span>
<span class="o">.</span>
<span class="p">[</span><span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
</pre></div> </pre></div>
</div> </div>
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator&#39;</span><span class="p">)</span>
</pre></div>
</div> </div>
<div class="section" id="a-generator-of-square-root-approximations"> <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra&#39;</span><span class="p">)</span>
<h3>A Generator of Square Root Approximations<a class="headerlink" href="#a-generator-of-square-root-approximations" title="Permalink to this headline"></a></h3> </pre></div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">gsra</span> <span class="o">==</span> <span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span> </div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="n">dup</span> <span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">codireco</span><span class="p">]</span>
</pre></div>
</div>
<p>Lets drive the generator a few time (with the <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator) and
square the approximation to see how well it works…</p>
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra 6 [x popd] times first sqr&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">23.0000000001585</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
</div> </div>
<div class="section" id="finding-consecutive-approximations-within-a-tolerance"> <div class="section" id="finding-consecutive-approximations-within-a-tolerance">
<h2>Finding Consecutive Approximations <code class="docutils literal notranslate"><span class="pre">within</span></code> a Tolerance<a class="headerlink" href="#finding-consecutive-approximations-within-a-tolerance" title="Permalink to this headline"></a></h2> <h2>Finding Consecutive Approximations within a Tolerance<a class="headerlink" href="#finding-consecutive-approximations-within-a-tolerance" title="Permalink to this headline"></a></h2>
<blockquote>
<div>The remainder of a square root finder is a function <em>within</em>, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.</div></blockquote>
<p>From <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why Functional Programming Matters” by John <p>From <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why Functional Programming Matters” by John
Hughes</a></p> Hughes</a>:</p>
<blockquote>
<div>The remainder of a square root finder is a function <em>within</em>, which
takes a tolerance and a list of approximations and looks down the
list for two successive approximations that differ by no more than
the given tolerance.</div></blockquote>
<p>(And note that by “list” he means a lazily-evaluated list.)</p> <p>(And note that by “list” he means a lazily-evaluated list.)</p>
<p>Using the <em>output</em> <code class="docutils literal notranslate"><span class="pre">[a</span> <span class="pre">G]</span></code> of the above <a class="reference internal" href="Generator Programs.html"><span class="doc">generator</span></a> for square root approximations, and further assuming that the first term <code class="docutils literal notranslate"><span class="pre">a</span></code> has been generated already and epsilon <code class="docutils literal notranslate"><span class="pre">ε</span></code> is handy on the stack…</p> <p>Using the <em>output</em> <code class="docutils literal notranslate"><span class="pre">[a</span> <span class="pre">G]</span></code> of the above generator for square root
approximations, and further assuming that the first term a has been
generated already and epsilon ε is handy on the stack…</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
<span class="o">----------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&lt;=</span> <span class="o">----------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&lt;=</span>
<span class="n">b</span> <span class="n">b</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span> <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
<span class="o">----------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&gt;</span> <span class="o">----------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&gt;</span>
<span class="o">.</span>
<span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">x</span> <span class="n">ε</span> <span class="o">...</span>
<span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="o">...</span>
<span class="o">.</span>
<span class="o">----------------------</span>
<span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span> <span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
</pre></div> </pre></div>
</div> </div>
@ -135,7 +142,7 @@ Hughes</a></p>
<span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">a</span><span class="o">-</span><span class="n">b</span><span class="p">)</span><span class="o">&lt;=</span><span class="n">ε</span><span class="p">)</span> <span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">a</span><span class="o">-</span><span class="n">b</span><span class="p">)</span><span class="o">&lt;=</span><span class="n">ε</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">P</span> <span class="o">==</span> <span class="p">[</span><span class="n">first</span> <span class="o">-</span> <span class="nb">abs</span><span class="p">]</span> <span class="n">dip</span> <span class="o">&lt;=</span> <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_P == [first - abs] dip &lt;=&#39;</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@ -147,7 +154,7 @@ Hughes</a></p>
<span class="n">b</span> <span class="n">b</span>
</pre></div> </pre></div>
</div> </div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">B</span> <span class="o">==</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="n">popop</span> <span class="n">first</span> <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_B == roll&lt; popop first&#39;</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@ -157,10 +164,11 @@ Hughes</a></p>
</pre></div> </pre></div>
</div> </div>
<ol class="arabic simple"> <ol class="arabic simple">
<li>Discard <code class="docutils literal notranslate"><span class="pre">a</span></code>.</li> <li>Discard a.</li>
<li>Use <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator to generate next term from <code class="docutils literal notranslate"><span class="pre">G</span></code>.</li> <li>Use <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator to generate next term from <code class="docutils literal notranslate"><span class="pre">G</span></code>.</li>
<li>Run <code class="docutils literal notranslate"><span class="pre">within</span></code> with <code class="docutils literal notranslate"><span class="pre">i</span></code> (it is a <code class="docutils literal notranslate"><span class="pre">primrec</span></code> function.)</li> <li>Run <code class="docutils literal notranslate"><span class="pre">within</span></code> with <code class="docutils literal notranslate"><span class="pre">i</span></code> (it is a <code class="docutils literal notranslate"><span class="pre">primrec</span></code> function.)</li>
</ol> </ol>
<p>Pretty straightforward:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">R0</span> <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">R1</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">R0</span> <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">R1</span>
<span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="p">[</span><span class="n">popd</span> <span class="n">x</span><span class="p">]</span> <span class="n">dip</span> <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">i</span> <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="p">[</span><span class="n">popd</span> <span class="n">x</span><span class="p">]</span> <span class="n">dip</span> <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">i</span>
<span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">popd</span> <span class="n">x</span> <span class="n">ε</span> <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">i</span> <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">popd</span> <span class="n">x</span> <span class="n">ε</span> <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">i</span>
@ -171,34 +179,51 @@ Hughes</a></p>
<span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span> <span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
</pre></div> </pre></div>
</div> </div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">R0</span> <span class="o">==</span> <span class="p">[</span><span class="n">popd</span> <span class="n">x</span><span class="p">]</span> <span class="n">dip</span> <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_R == [popd x] dip&#39;</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="setting-up"> <div class="section" id="setting-up">
<h3>Setting up<a class="headerlink" href="#setting-up" title="Permalink to this headline"></a></h3> <h3>Setting up<a class="headerlink" href="#setting-up" title="Permalink to this headline"></a></h3>
<p>The recursive function we have defined so far needs a slight preamble: <code class="docutils literal notranslate"><span class="pre">x</span></code> to prime the generator and the epsilon value to use:</p> <p>The recursive function we have defined so far needs a slight preamble:
<code class="docutils literal notranslate"><span class="pre">x</span></code> to prime the generator and the epsilon value to use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">a</span> <span class="n">G</span><span class="p">]</span> <span class="n">x</span> <span class="n">ε</span> <span class="o">...</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">a</span> <span class="n">G</span><span class="p">]</span> <span class="n">x</span> <span class="n">ε</span> <span class="o">...</span>
<span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="o">...</span> <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="o">...</span>
</pre></div> </pre></div>
</div> </div>
</div> <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec&#39;</span><span class="p">)</span>
<div class="section" id="within"> <span class="n">define</span><span class="p">(</span><span class="s1">&#39;sqrt == gsra within&#39;</span><span class="p">)</span>
<h3><code class="docutils literal notranslate"><span class="pre">within</span></code><a class="headerlink" href="#within" title="Permalink to this headline"></a></h3>
<p>Giving us the following definitions:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">_within_P</span> <span class="o">==</span> <span class="p">[</span><span class="n">first</span> <span class="o">-</span> <span class="nb">abs</span><span class="p">]</span> <span class="n">dip</span> <span class="o">&lt;=</span>
<span class="n">_within_B</span> <span class="o">==</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="n">popop</span> <span class="n">first</span>
<span class="n">_within_R</span> <span class="o">==</span> <span class="p">[</span><span class="n">popd</span> <span class="n">x</span><span class="p">]</span> <span class="n">dip</span>
<span class="n">within</span> <span class="o">==</span> <span class="n">x</span> <span class="n">ε</span> <span class="p">[</span><span class="n">_within_P</span><span class="p">]</span> <span class="p">[</span><span class="n">_within_B</span><span class="p">]</span> <span class="p">[</span><span class="n">_within_R</span><span class="p">]</span> <span class="n">primrec</span>
</pre></div> </pre></div>
</div> </div>
</div> <p>Try it out…</p>
</div> <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;36 sqrt&#39;</span><span class="p">)</span>
<div class="section" id="finding-square-roots">
<h2>Finding Square Roots<a class="headerlink" href="#finding-square-roots" title="Permalink to this headline"></a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sqrt</span> <span class="o">==</span> <span class="n">gsra</span> <span class="n">within</span>
</pre></div> </pre></div>
</div> </div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">6.0</span>
</pre></div>
</div>
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 sqrt&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span>
</pre></div>
</div>
<p>Check it.</p>
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span><span class="o">**</span><span class="mi">2</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">22.999999999999996</span>
</pre></div>
</div>
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">math</span> <span class="k">import</span> <span class="n">sqrt</span>
<span class="n">sqrt</span><span class="p">(</span><span class="mi">23</span><span class="p">)</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span>
</pre></div>
</div>
</div>
</div> </div>
</div> </div>
@ -214,18 +239,15 @@ Hughes</a></p>
<li><a class="reference internal" href="#a-generator-for-approximations">A Generator for Approximations</a><ul> <li><a class="reference internal" href="#a-generator-for-approximations">A Generator for Approximations</a><ul>
<li><a class="reference internal" href="#a-function-to-compute-the-next-approximation">A Function to Compute the Next Approximation</a></li> <li><a class="reference internal" href="#a-function-to-compute-the-next-approximation">A Function to Compute the Next Approximation</a></li>
<li><a class="reference internal" href="#make-it-into-a-generator">Make it into a Generator</a></li> <li><a class="reference internal" href="#make-it-into-a-generator">Make it into a Generator</a></li>
<li><a class="reference internal" href="#a-generator-of-square-root-approximations">A Generator of Square Root Approximations</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference internal" href="#finding-consecutive-approximations-within-a-tolerance">Finding Consecutive Approximations <code class="docutils literal notranslate"><span class="pre">within</span></code> a Tolerance</a><ul> <li><a class="reference internal" href="#finding-consecutive-approximations-within-a-tolerance">Finding Consecutive Approximations within a Tolerance</a><ul>
<li><a class="reference internal" href="#predicate">Predicate</a></li> <li><a class="reference internal" href="#predicate">Predicate</a></li>
<li><a class="reference internal" href="#base-case">Base-Case</a></li> <li><a class="reference internal" href="#base-case">Base-Case</a></li>
<li><a class="reference internal" href="#recur">Recur</a></li> <li><a class="reference internal" href="#recur">Recur</a></li>
<li><a class="reference internal" href="#setting-up">Setting up</a></li> <li><a class="reference internal" href="#setting-up">Setting up</a></li>
<li><a class="reference internal" href="#within"><code class="docutils literal notranslate"><span class="pre">within</span></code></a></li>
</ul> </ul>
</li> </li>
<li><a class="reference internal" href="#finding-square-roots">Finding Square Roots</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -234,7 +256,7 @@ Hughes</a></p>
<ul> <ul>
<li><a href="../index.html">Documentation overview</a><ul> <li><a href="../index.html">Documentation overview</a><ul>
<li><a href="index.html">Essays about Programming in Joy</a><ul> <li><a href="index.html">Essays about Programming in Joy</a><ul>
<li>Previous: <a href="Trees.html" title="previous chapter">Treating Trees</a></li> <li>Previous: <a href="Generator_Programs.html" title="previous chapter">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
<li>Next: <a href="Quadratic.html" title="next chapter">Quadratic formula</a></li> <li>Next: <a href="Quadratic.html" title="next chapter">Quadratic formula</a></li>
</ul></li> </ul></li>
</ul></li> </ul></li>

View File

@ -16,7 +16,7 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="../genindex.html" /> <link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" /> <link rel="search" title="Search" href="../search.html" />
<link rel="next" title="No Updates" href="NoUpdates.html" /> <link rel="next" title="Traversing Datastructures with Zippers" href="Zipper.html" />
<link rel="prev" title="Newtons method" href="Newton-Raphson.html" /> <link rel="prev" title="Newtons method" href="Newton-Raphson.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" /> <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
@ -213,7 +213,7 @@ already.)</p>
<li><a href="../index.html">Documentation overview</a><ul> <li><a href="../index.html">Documentation overview</a><ul>
<li><a href="index.html">Essays about Programming in Joy</a><ul> <li><a href="index.html">Essays about Programming in Joy</a><ul>
<li>Previous: <a href="Newton-Raphson.html" title="previous chapter">Newtons method</a></li> <li>Previous: <a href="Newton-Raphson.html" title="previous chapter">Newtons method</a></li>
<li>Next: <a href="NoUpdates.html" title="next chapter">No Updates</a></li> <li>Next: <a href="Zipper.html" title="next chapter">Traversing Datastructures with Zippers</a></li>
</ul></li> </ul></li>
</ul></li> </ul></li>
</ul> </ul>

View File

@ -16,6 +16,8 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="../genindex.html" /> <link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" /> <link rel="search" title="Search" href="../search.html" />
<link rel="next" title="No Updates" href="NoUpdates.html" />
<link rel="prev" title="Quadratic formula" href="Quadratic.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" /> <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
@ -323,6 +325,10 @@ i d i d i d d Bingo!
<h3>Related Topics</h3> <h3>Related Topics</h3>
<ul> <ul>
<li><a href="../index.html">Documentation overview</a><ul> <li><a href="../index.html">Documentation overview</a><ul>
<li><a href="index.html">Essays about Programming in Joy</a><ul>
<li>Previous: <a href="Quadratic.html" title="previous chapter">Quadratic formula</a></li>
<li>Next: <a href="NoUpdates.html" title="next chapter">No Updates</a></li>
</ul></li>
</ul></li> </ul></li>
</ul> </ul>
</div> </div>

View File

@ -86,8 +86,7 @@
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="Newton-Raphson.html">Newtons method</a><ul> <li class="toctree-l1"><a class="reference internal" href="Newton-Raphson.html">Newtons method</a><ul>
<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html#a-generator-for-approximations">A Generator for Approximations</a></li> <li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html#a-generator-for-approximations">A Generator for Approximations</a></li>
<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html#finding-consecutive-approximations-within-a-tolerance">Finding Consecutive Approximations <code class="docutils literal notranslate"><span class="pre">within</span></code> a Tolerance</a></li> <li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html#finding-consecutive-approximations-within-a-tolerance">Finding Consecutive Approximations within a Tolerance</a></li>
<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html#finding-square-roots">Finding Square Roots</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="Quadratic.html">Quadratic formula</a><ul> <li class="toctree-l1"><a class="reference internal" href="Quadratic.html">Quadratic formula</a><ul>

File diff suppressed because one or more lines are too long

View File

@ -1,33 +1,35 @@
*********************************************************************
`Newton's method <https://en.wikipedia.org/wiki/Newton%27s_method>`__
*********************************************************************
Newton-Raphson for finding the root of an equation. `Newton's method <https://en.wikipedia.org/wiki/Newton%27s_method>`__
=====================================================================
Let's use the Newton-Raphson method for finding the root of an equation
to write a function that can compute the square root of a number.
Cf. `"Why Functional Programming Matters" by John
Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__
.. code:: ipython2 .. code:: ipython2
from notebook_preamble import J, V, define from notebook_preamble import J, V, define
Cf. `"Why Functional Programming Matters" by John
Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__
A Generator for Approximations A Generator for Approximations
============================== ------------------------------
In :doc:`Generator Programs` we derive a function (called ``make_generator`` in the dictionary) that accepts an initial value and a quoted program and returns a new quoted program that, when driven by the ``x`` combinator (:py:func:`joy.library.x`), acts like a lazy stream. To make a generator that generates successive approximations lets start
by assuming an initial approximation and then derive the function that
computes the next approximation:
To make a generator that generates successive approximations let's start by assuming an initial approximation and then derive the function that computes the next approximation:: ::
a F a F
--------- ---------
a' a'
A Function to Compute the Next Approximation A Function to Compute the Next Approximation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Looking at the equation again: This is the equation for computing the next approximate value of the
square root:
:math:`a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}` :math:`a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}`
@ -39,19 +41,25 @@ Looking at the equation again:
a+n/a 2 / a+n/a 2 /
(a+n/a)/2 (a+n/a)/2
The function we want has the argument ``n`` in it:: The function we want has the argument ``n`` in it:
::
F == n over / + 2 / F == n over / + 2 /
Make it into a Generator Make it into a Generator
^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~
Our generator would be created by:: Our generator would be created by:
::
a [dup F] make_generator a [dup F] make_generator
With ``n`` as part of the function ``F``, but ``n`` is the input to the ``sqrt`` function we're writing. If we let 1 be the initial approximation:: With n as part of the function F, but n is the input to the sqrt
function were writing. If we let 1 be the initial approximation:
::
1 n 1 / + 2 / 1 n 1 / + 2 /
1 n/1 + 2 / 1 n/1 + 2 /
@ -59,41 +67,58 @@ With ``n`` as part of the function ``F``, but ``n`` is the input to the ``sqrt``
n+1 2 / n+1 2 /
(n+1)/2 (n+1)/2
The generator can be written as:: The generator can be written as:
1 swap [over / + 2 /] cons [dup] swoncat make_generator ::
Example::
23 1 swap [over / + 2 /] cons [dup] swoncat make_generator 23 1 swap [over / + 2 /] cons [dup] swoncat make_generator
1 23 [over / + 2 /] cons [dup] swoncat make_generator 1 23 [over / + 2 /] cons [dup] swoncat make_generator
1 [23 over / + 2 /] [dup] swoncat make_generator 1 [23 over / + 2 /] [dup] swoncat make_generator
1 [dup 23 over / + 2 /] make_generator 1 [dup 23 over / + 2 /] make_generator
.
. .. code:: ipython2
.
[1 swap [dup 23 over / + 2 /] direco] define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator')
.. code:: ipython2
J('23 gsra')
A Generator of Square Root Approximations .. parsed-literal::
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:: [1 [dup 23 over / + 2 /] codireco]
gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator
Finding Consecutive Approximations ``within`` a Tolerance Let's drive the generator a few time (with the ``x`` combinator) and
========================================================= square the approximation to see how well it works...
The remainder of a square root finder is a function *within*, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance. .. code:: ipython2
J('23 gsra 6 [x popd] times first sqr')
.. parsed-literal::
23.0000000001585
Finding Consecutive Approximations within a Tolerance
-----------------------------------------------------
From `"Why Functional Programming Matters" by John From `"Why Functional Programming Matters" by John
Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__ Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__:
(And note that by "list" he means a lazily-evaluated list.) The remainder of a square root finder is a function *within*, which
takes a tolerance and a list of approximations and looks down the
list for two successive approximations that differ by no more than
the given tolerance.
Using the *output* ``[a G]`` of the above :doc:`generator <Generator Programs>` for square root approximations, and further assuming that the first term ``a`` has been generated already and epsilon ``ε`` is handy on the stack... (And note that by “list” he means a lazily-evaluated list.)
Using the *output* ``[a G]`` of the above generator for square root
approximations, and further assuming that the first term a has been
generated already and epsilon ε is handy on the stack...
:: ::
@ -101,21 +126,13 @@ Using the *output* ``[a G]`` of the above :doc:`generator <Generator Programs>`
---------------------- a b - abs ε <= ---------------------- a b - abs ε <=
b b
::
a [b G] ε within a [b G] ε within
---------------------- a b - abs ε > ---------------------- a b - abs ε >
.
[b G] x ε ...
b [c G] ε ...
.
----------------------
b [c G] ε within b [c G] ε within
Predicate Predicate
^^^^^^^^^^^^^ ~~~~~~~~~
:: ::
@ -126,14 +143,12 @@ Predicate
abs(a-b) ε <= abs(a-b) ε <=
(abs(a-b)<=ε) (abs(a-b)<=ε)
.. code:: ipython2
:: define('_within_P == [first - abs] dip <=')
P == [first - abs] dip <=
Base-Case Base-Case
^^^^^^^^^^^^^ ~~~~~~~~~
:: ::
@ -142,23 +157,23 @@ Base-Case
[b G] first [b G] first
b b
:: .. code:: ipython2
B == roll< popop first
define('_within_B == roll< popop first')
Recur Recur
^^^^^^^^^^^^^ ~~~~~
:: ::
a [b G] ε R0 [within] R1 a [b G] ε R0 [within] R1
1. Discard a.
1. Discard ``a``.
2. Use ``x`` combinator to generate next term from ``G``. 2. Use ``x`` combinator to generate next term from ``G``.
3. Run ``within`` with ``i`` (it is a ``primrec`` function.) 3. Run ``within`` with ``i`` (it is a ``primrec`` function.)
Pretty straightforward:
:: ::
a [b G] ε R0 [within] R1 a [b G] ε R0 [within] R1
@ -170,35 +185,74 @@ Recur
b [c G] ε within b [c G] ε within
:: .. code:: ipython2
R0 == [popd x] dip
define('_within_R == [popd x] dip')
Setting up Setting up
^^^^^^^^^^ ~~~~~~~~~~
The recursive function we have defined so far needs a slight preamble: ``x`` to prime the generator and the epsilon value to use:: The recursive function we have defined so far needs a slight preamble:
``x`` to prime the generator and the epsilon value to use:
::
[a G] x ε ... [a G] x ε ...
a [b G] ε ... a [b G] ε ...
.. code:: ipython2
``within`` define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec')
^^^^^^^^^^ define('sqrt == gsra within')
Giving us the following definitions:: Try it out...
_within_P == [first - abs] dip <= .. code:: ipython2
_within_B == roll< popop first
_within_R == [popd x] dip J('36 sqrt')
within == x ε [_within_P] [_within_B] [_within_R] primrec
Finding Square Roots .. parsed-literal::
====================
:: 6.0
.. code:: ipython2
J('23 sqrt')
.. parsed-literal::
4.795831523312719
Check it.
.. code:: ipython2
4.795831523312719**2
.. parsed-literal::
22.999999999999996
.. code:: ipython2
from math import sqrt
sqrt(23)
.. parsed-literal::
4.795831523312719
sqrt == gsra within