OSDN Git Service

Cleaning up docs.
authorSimon Forman <sforman@hushmail.com>
Thu, 7 Jun 2018 19:37:32 +0000 (12:37 -0700)
committerSimon Forman <sforman@hushmail.com>
Thu, 7 Jun 2018 19:37:32 +0000 (12:37 -0700)
19 files changed:
docs/Newton-Raphson.html
docs/Newton-Raphson.ipynb
docs/Newton-Raphson.md
docs/Newton-Raphson.rst
docs/Quadratic.html
docs/Quadratic.ipynb
docs/Quadratic.md
docs/Quadratic.rst
docs/sphinx_docs/_build/html/index.html
docs/sphinx_docs/_build/html/notebooks/Quadratic.html
docs/sphinx_docs/_build/html/notebooks/Zipper.html
docs/sphinx_docs/_build/html/notebooks/index.html
docs/sphinx_docs/_build/html/objects.inv
docs/sphinx_docs/_build/html/searchindex.js
docs/sphinx_docs/notebooks/Generator_Programs.rst [moved from docs/sphinx_docs/notebooks/Generator Programs.rst with 98% similarity]
docs/sphinx_docs/notebooks/Quadratic.rst
docs/sphinx_docs/notebooks/Zipper.rst
docs/sphinx_docs/notebooks/index.rst
joy/library.py

index 643821f..1288221 100644 (file)
@@ -11775,7 +11775,9 @@ div#notebook {
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<h1 id="Newton's-method"><a href="https://en.wikipedia.org/wiki/Newton%27s_method">Newton's method</a><a class="anchor-link" href="#Newton's-method">&#182;</a></h1>
+<h1 id="Newton's-method"><a href="https://en.wikipedia.org/wiki/Newton%27s_method">Newton's method</a><a class="anchor-link" href="#Newton's-method">&#182;</a></h1><p>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.</p>
+<p>Cf. <a href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">"Why Functional Programming Matters" by John Hughes</a></p>
+
 </div>
 </div>
 </div>
@@ -11796,7 +11798,11 @@ div#notebook {
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<p>Cf. <a href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">"Why Functional Programming Matters" by John Hughes</a></p>
+<h2 id="A-Generator-for-Approximations">A Generator for Approximations<a class="anchor-link" href="#A-Generator-for-Approximations">&#182;</a></h2><p>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:</p>
+
+<pre><code>   a F
+---------
+    a'</code></pre>
 
 </div>
 </div>
@@ -11805,6 +11811,7 @@ div#notebook {
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
+<h3 id="A-Function-to-Compute-the-Next-Approximation">A Function to Compute the Next Approximation<a class="anchor-link" href="#A-Function-to-Compute-the-Next-Approximation">&#182;</a></h3><p>This is the equation for computing the next approximate value of the square root:</p>
 <p>$a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}$</p>
 
 </div>
@@ -11814,62 +11821,57 @@ div#notebook {
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<p>Let's define a function that computes the above equation:</p>
 
-<pre><code>     n a Q
----------------
-   (a+n/a)/2
-
-n a tuck / + 2 /
+<pre><code>a n over / + 2 /
 a n a    / + 2 /
 a n/a      + 2 /
 a+n/a        2 /
 (a+n/a)/2
 
 </code></pre>
-<p>We want it to leave n but replace a, so we execute it with <code>unary</code>:</p>
-
-<pre><code>Q == [tuck / + 2 /] unary</code></pre>
+<p>The function we want has the argument <code>n</code> in it:</p>
 
-</div>
-</div>
-</div>
-<div class="cell border-box-sizing code_cell rendered">
-<div class="input">
-<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;Q == [tuck / + 2 /] unary&#39;</span><span class="p">)</span>
-</pre></div>
+<pre><code>F == n over / + 2 /</code></pre>
 
 </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>And a function to compute the error:</p>
+<h3 id="Make-it-into-a-Generator">Make it into a Generator<a class="anchor-link" href="#Make-it-into-a-Generator">&#182;</a></h3><p>Our generator would be created by:</p>
+
+<pre><code>a [dup F] make_generator
+
+</code></pre>
+<p>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:</p>
 
-<pre><code>n a sqr - abs
-|n-a**2|
+<pre><code>1 n 1 / + 2 /
+1 n/1   + 2 /
+1 n     + 2 /
+n+1       2 /
+(n+1)/2
 
 </code></pre>
-<p>This should be <code>nullary</code> so as to leave both n and a on the stack below the error.</p>
+<p>The generator can be written as:</p>
 
-<pre><code>err == [sqr - abs] nullary</code></pre>
+<pre><code>23 1 swap  [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   [dup 23 over / + 2 /]                    make_generator</code></pre>
 
 </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="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;err == [sqr - abs] nullary&#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;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>
@@ -11877,60 +11879,12 @@ a+n/a        2 /
 </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>Now we can define a recursive program that expects a number <code>n</code>, an initial estimate <code>a</code>, and an epsilon value <code>ε</code>, and that leaves on the stack the square root of <code>n</code> to within the precision of the epsilon value.  (Later on we'll refine it to generate the initial estimate and hard-code an epsilon value.)</p>
-
-<pre><code>n a ε square-root
------------------
-      √n
-
-
-</code></pre>
-<p>If we apply the two functions <code>Q</code> and <code>err</code> defined above we get the next approximation and the error on the stack below the epsilon.</p>
-
-<pre><code>n a ε [Q err] dip
-n a Q err ε 
-n a'  err ε 
-n a' e    ε
-
-</code></pre>
-<p>Let's define the recursive function from here.  Start with <code>ifte</code>; the predicate and the base case behavior are obvious:</p>
-
-<pre><code>n a' e ε [&lt;] [popop popd] [J] ifte
-
-</code></pre>
-<p>Base-case</p>
-
-<pre><code>n a' e ε popop popd
-n a'           popd
-  a'
-
-</code></pre>
-<p>The recursive branch is pretty easy.  Discard the error and recur.</p>
-
-<pre><code>w/ K == [&lt;] [popop popd] [J] ifte
-
-n a' e ε J
-n a' e ε popd [Q err] dip [K] i
-n a'   ε      [Q err] dip [K] i
-n a' Q err ε              [K] i
-n a''  e   ε               K
-
-</code></pre>
-<p>This fragment alone is pretty useful.</p>
-
-</div>
-</div>
-</div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
-<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;K == [&lt;] [popop popd] [popd [Q err] dip] 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;gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator&#39;</span><span class="p">)</span>
 </pre></div>
 
 </div>
@@ -11940,10 +11894,10 @@ n a''  e   ε               K
 </div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
-<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;25 10 0.001 dup K&#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>
 </pre></div>
 
 </div>
@@ -11960,7 +11914,7 @@ n a''  e   ε               K
 
 
 <div class="output_subarea output_stream output_stdout output_text">
-<pre>5.000000232305737
+<pre>[1 [dup 23 over / + 2 /] codireco]
 </pre>
 </div>
 </div>
@@ -11969,12 +11923,21 @@ n a''  e   ε               K
 </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>Let's drive the generator a few time (with the <code>x</code> combinator) and square the approximation to see how well it works...</p>
+
+</div>
+</div>
+</div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
-<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;25 10 0.000001 dup K&#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>
 </pre></div>
 
 </div>
@@ -11991,7 +11954,7 @@ n a''  e   ε               K
 
 
 <div class="output_subarea output_stream output_stdout output_text">
-<pre>5.000000000000005
+<pre>23.0000000001585
 </pre>
 </div>
 </div>
@@ -12004,19 +11967,45 @@ n a''  e   ε               K
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<p>So now all we need is a way to generate an initial approximation and an epsilon value:</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><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>
+<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>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>
+
+<pre><code>   a [b G] ε within
+---------------------- a b - abs ε &lt;=
+      b
 
-<pre><code>square-root == dup 3 / 0.000001 dup K</code></pre>
+
+   a [b G] ε within
+---------------------- a b - abs ε &gt;
+   b [c G] ε within</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="Predicate">Predicate<a class="anchor-link" href="#Predicate">&#182;</a></h3>
+<pre><code>a [b G]             ε [first - abs] dip &lt;=
+a [b G] first - abs ε                   &lt;=
+a b           - abs ε                   &lt;=
+a-b             abs ε                   &lt;=
+abs(a-b)            ε                   &lt;=
+(abs(a-b)&lt;=ε)</code></pre>
 
 </div>
 </div>
 </div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
-<div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;square-root == dup 3 / 0.000001 dup K&#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>
 </pre></div>
 
 </div>
@@ -12024,43 +12013,104 @@ n a''  e   ε               K
 </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="Base-Case">Base-Case<a class="anchor-link" href="#Base-Case">&#182;</a></h3>
+<pre><code>a [b G] ε roll&lt; popop first
+  [b G] ε a     popop first
+  [b G]               first
+   b</code></pre>
+
+</div>
+</div>
+</div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
-<div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;36 square-root&#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>
 </pre></div>
 
 </div>
 </div>
 </div>
 
-<div class="output_wrapper">
-<div class="output">
+</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="Recur">Recur<a class="anchor-link" href="#Recur">&#182;</a></h3>
+<pre><code>a [b G] ε R0 [within] R1
 
+</code></pre>
+<ol>
+<li>Discard a.</li>
+<li>Use x combinator to generate next term from G.</li>
+<li>Run within with <code>i</code> (it is a <code>primrec</code> function.)</li>
+</ol>
+<p>Pretty straightforward:</p>
 
-<div class="output_area">
+<pre><code>a [b G]        ε R0           [within] R1
+a [b G]        ε [popd x] dip [within] i
+a [b G] popd x ε              [within] i
+  [b G]      x ε              [within] i
+b [c G]        ε              [within] i
+b [c G]        ε               within
 
-<div class="prompt"></div>
+b [c G] ε within</code></pre>
 
+</div>
+</div>
+</div>
+<div class="cell border-box-sizing code_cell rendered">
+<div class="input">
+<div class="prompt input_prompt">In&nbsp;[8]:</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;_within_R == [popd x] dip&#39;</span><span class="p">)</span>
+</pre></div>
 
-<div class="output_subarea output_stream output_stdout output_text">
-<pre>6.000000000000007
-</pre>
+</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">
+<h3 id="Setting-up">Setting up<a class="anchor-link" href="#Setting-up">&#182;</a></h3><p>The recursive function we have defined so far needs a slight preamble: <code>x</code> to prime the generator and the epsilon value to use:</p>
+
+<pre><code>[a G] x ε ...
+a [b G] ε ...</code></pre>
 
 </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;4895048365636 square-root&#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>
+<span class="n">define</span><span class="p">(</span><span class="s1">&#39;sqrt == gsra within&#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;[10]:</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 sqrt&#39;</span><span class="p">)</span>
 </pre></div>
 
 </div>
@@ -12077,7 +12127,7 @@ n a''  e   ε               K
 
 
 <div class="output_subarea output_stream output_stdout output_text">
-<pre>2212475.6192184356
+<pre>4.795831523312719
 </pre>
 </div>
 </div>
@@ -12088,10 +12138,10 @@ n a''  e   ε               K
 </div>
 <div class="cell border-box-sizing code_cell rendered">
 <div class="input">
-<div class="prompt input_prompt">In&nbsp;[10]:</div>
+<div class="prompt input_prompt">In&nbsp;[11]:</div>
 <div class="inner_cell">
     <div class="input_area">
-<div class=" highlight hl-ipython2"><pre><span></span><span class="mf">2212475.6192184356</span> <span class="o">*</span> <span class="mf">2212475.6192184356</span>
+<div class=" highlight hl-ipython2"><pre><span></span><span class="mf">4.795831523312719</span><span class="o">**</span><span class="mi">2</span>
 </pre></div>
 
 </div>
@@ -12104,13 +12154,13 @@ n a''  e   ε               K
 
 <div class="output_area">
 
-<div class="prompt output_prompt">Out[10]:</div>
+<div class="prompt output_prompt">Out[11]:</div>
 
 
 
 
 <div class="output_text output_subarea output_execute_result">
-<pre>4895048365636.0</pre>
+<pre>22.999999999999996</pre>
 </div>
 
 </div>
index 302dc3f..99897a3 100644 (file)
@@ -4,7 +4,10 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "# [Newton's method](https://en.wikipedia.org/wiki/Newton%27s_method)"
+    "# [Newton's method](https://en.wikipedia.org/wiki/Newton%27s_method)\n",
+    "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.\n",
+    "\n",
+    "Cf. [\"Why Functional Programming Matters\" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf)"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Cf. [\"Why Functional Programming Matters\" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf)"
+    "## A Generator for Approximations\n",
+    "\n",
+    "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:\n",
+    "\n",
+    "       a F\n",
+    "    ---------\n",
+    "        a'"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
+    "### A Function to Compute the Next Approximation\n",
+    "\n",
+    "This is the equation for computing the next approximate value of the square root:\n",
+    "\n",
     "$a_{i+1} = \\frac{(a_i+\\frac{n}{a_i})}{2}$"
    ]
   },
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Let's define a function that computes the above equation:\n",
-    "\n",
-    "         n a Q\n",
-    "    ---------------\n",
-    "       (a+n/a)/2\n",
-    "\n",
-    "    n a tuck / + 2 /\n",
+    "    a n over / + 2 /\n",
     "    a n a    / + 2 /\n",
     "    a n/a      + 2 /\n",
     "    a+n/a        2 /\n",
     "    (a+n/a)/2\n",
     "\n",
-    "We want it to leave n but replace a, so we execute it with `unary`:\n",
+    "The function we want has the argument `n` in it:\n",
     "\n",
-    "    Q == [tuck / + 2 /] unary"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "define('Q == [tuck / + 2 /] unary')"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "And a function to compute the error:\n",
-    "\n",
-    "    n a sqr - abs\n",
-    "    |n-a**2|\n",
-    "\n",
-    "This should be `nullary` so as to leave both n and a on the stack below the error.\n",
-    "\n",
-    "    err == [sqr - abs] nullary"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 3,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "define('err == [sqr - abs] nullary')"
+    "    F == n over / + 2 /"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Now we can define a recursive program that expects a number `n`, an initial estimate `a`, and an epsilon value `ε`, and that leaves on the stack the square root of `n` to within the precision of the epsilon value.  (Later on we'll refine it to generate the initial estimate and hard-code an epsilon value.)\n",
-    "\n",
-    "    n a ε square-root\n",
-    "    -----------------\n",
-    "          √n\n",
-    "\n",
-    "\n",
-    "If we apply the two functions `Q` and `err` defined above we get the next approximation and the error on the stack below the epsilon.\n",
-    "\n",
-    "    n a ε [Q err] dip\n",
-    "    n a Q err ε \n",
-    "    n a'  err ε \n",
-    "    n a' e    ε\n",
+    "### Make it into a Generator\n",
     "\n",
-    "Let's define the recursive function from here.  Start with `ifte`; the predicate and the base case behavior are obvious:\n",
+    "Our generator would be created by:\n",
     "\n",
-    "    n a' e ε [<] [popop popd] [J] ifte\n",
+    "    a [dup F] make_generator\n",
     "\n",
-    "Base-case\n",
+    "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:\n",
     "\n",
-    "    n a' e ε popop popd\n",
-    "    n a'           popd\n",
-    "      a'\n",
+    "    1 n 1 / + 2 /\n",
+    "    1 n/1   + 2 /\n",
+    "    1 n     + 2 /\n",
+    "    n+1       2 /\n",
+    "    (n+1)/2\n",
     "\n",
-    "The recursive branch is pretty easy.  Discard the error and recur.\n",
+    "The generator can be written as:\n",
     "\n",
-    "    w/ K == [<] [popop popd] [J] ifte\n",
-    "\n",
-    "    n a' e ε J\n",
-    "    n a' e ε popd [Q err] dip [K] i\n",
-    "    n a'   ε      [Q err] dip [K] i\n",
-    "    n a' Q err ε              [K] i\n",
-    "    n a''  e   ε               K\n",
-    "\n",
-    "This fragment alone is pretty useful."
+    "    23 1 swap  [over / + 2 /] cons [dup] swoncat make_generator\n",
+    "    1 23       [over / + 2 /] cons [dup] swoncat make_generator\n",
+    "    1       [23 over / + 2 /]      [dup] swoncat make_generator\n",
+    "    1   [dup 23 over / + 2 /]                    make_generator"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [],
    "source": [
-    "define('K == [<] [popop popd] [popd [Q err] dip] primrec')"
+    "define('codireco == cons dip rest cons')\n",
+    "define('make_generator == [codireco] ccons')\n",
+    "define('ccons == cons cons')"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 3,
    "metadata": {
     "scrolled": true
    },
+   "outputs": [],
+   "source": [
+    "define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "5.000000232305737\n"
+      "[1 [dup 23 over / + 2 /] codireco]\n"
      ]
     }
    ],
    "source": [
-    "J('25 10 0.001 dup K')"
+    "J('23 gsra')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Let's drive the generator a few time (with the `x` combinator) and square the approximation to see how well it works..."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "5.000000000000005\n"
+      "23.0000000001585\n"
      ]
     }
    ],
    "source": [
-    "J('25 10 0.000001 dup K')"
+    "J('23 gsra 6 [x popd] times first sqr')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Finding Consecutive Approximations within a Tolerance\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",
+    "\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",
+    "\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",
+    "\n",
+    "       a [b G] ε within\n",
+    "    ---------------------- a b - abs ε <=\n",
+    "          b\n",
+    "\n",
+    "\n",
+    "       a [b G] ε within\n",
+    "    ---------------------- a b - abs ε >\n",
+    "       b [c G] ε within\n",
+    "\n"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "So now all we need is a way to generate an initial approximation and an epsilon value:\n",
+    "### Predicate\n",
     "\n",
-    "    square-root == dup 3 / 0.000001 dup K"
+    "    a [b G]             ε [first - abs] dip <=\n",
+    "    a [b G] first - abs ε                   <=\n",
+    "    a b           - abs ε                   <=\n",
+    "    a-b             abs ε                   <=\n",
+    "    abs(a-b)            ε                   <=\n",
+    "    (abs(a-b)<=ε)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "define('_within_P == [first - abs] dip <=')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Base-Case\n",
+    "\n",
+    "    a [b G] ε roll< popop first\n",
+    "      [b G] ε a     popop first\n",
+    "      [b G]               first\n",
+    "       b"
    ]
   },
   {
    "metadata": {},
    "outputs": [],
    "source": [
-    "define('square-root == dup 3 / 0.000001 dup K')"
+    "define('_within_B == roll< popop first')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Recur\n",
+    "\n",
+    "    a [b G] ε R0 [within] R1\n",
+    "\n",
+    "1. Discard a.\n",
+    "2. Use x combinator to generate next term from G.\n",
+    "3. Run within with `i` (it is a `primrec` function.)\n",
+    "\n",
+    "Pretty straightforward:\n",
+    "\n",
+    "    a [b G]        ε R0           [within] R1\n",
+    "    a [b G]        ε [popd x] dip [within] i\n",
+    "    a [b G] popd x ε              [within] i\n",
+    "      [b G]      x ε              [within] i\n",
+    "    b [c G]        ε              [within] i\n",
+    "    b [c G]        ε               within\n",
+    "\n",
+    "    b [c G] ε within"
    ]
   },
   {
    "cell_type": "code",
    "execution_count": 8,
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "6.000000000000007\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
-    "J('36 square-root')"
+    "define('_within_R == [popd x] dip')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Setting up\n",
+    "\n",
+    "The recursive function we have defined so far needs a slight preamble: `x` to prime the generator and the epsilon value to use:\n",
+    "\n",
+    "    [a G] x ε ...\n",
+    "    a [b G] ε ..."
    ]
   },
   {
    "cell_type": "code",
    "execution_count": 9,
    "metadata": {},
+   "outputs": [],
+   "source": [
+    "define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec')\n",
+    "define('sqrt == gsra within')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {
+    "scrolled": true
+   },
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "2212475.6192184356\n"
+      "4.795831523312719\n"
      ]
     }
    ],
    "source": [
-    "J('4895048365636 square-root')"
+    "J('23 sqrt')"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
-   "metadata": {},
+   "execution_count": 11,
+   "metadata": {
+    "scrolled": true
+   },
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "4895048365636.0"
+       "22.999999999999996"
       ]
      },
-     "execution_count": 10,
+     "execution_count": 11,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "2212475.6192184356 * 2212475.6192184356"
+    "4.795831523312719**2"
    ]
   }
  ],
index 148afab..3f0735f 100644 (file)
 
 # [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)
 
 
 ```python
 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_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}$
+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:
 
-Let's define a function that computes the above equation:
+       a F
+    ---------
+        a'
 
-         n a Q
-    ---------------
-       (a+n/a)/2
+### A Function to Compute the Next Approximation
 
-    n a tuck / + 2 /
+This is the equation for computing the next approximate value of the square root:
+
+$a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}$
+
+    a n over / + 2 /
     a n a    / + 2 /
     a n/a      + 2 /
     a+n/a        2 /
     (a+n/a)/2
 
-We want it to leave n but replace a, so we execute it with `unary`:
+The function we want has the argument `n` in it:
+
+    F == n over / + 2 /
+
+### Make it into a Generator
+
+Our generator would be created by:
+
+    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:
+
+    1 n 1 / + 2 /
+    1 n/1   + 2 /
+    1 n     + 2 /
+    n+1       2 /
+    (n+1)/2
+
+The generator can be written as:
+
+    23 1 swap  [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   [dup 23 over / + 2 /]                    make_generator
 
-    Q == [tuck / + 2 /] unary
+
+```python
+define('codireco == cons dip rest cons')
+define('make_generator == [codireco] ccons')
+define('ccons == cons cons')
+```
 
 
 ```python
-define('Q == [tuck / + 2 /] unary')
+define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator')
 ```
 
-And a function to compute the error:
 
-    n a sqr - abs
-    |n-a**2|
+```python
+J('23 gsra')
+```
+
+    [1 [dup 23 over / + 2 /] codireco]
 
-This should be `nullary` so as to leave both n and a on the stack below the error.
 
-    err == [sqr - abs] nullary
+Let's drive the generator a few time (with the `x` combinator) and square the approximation to see how well it works...
 
 
 ```python
-define('err == [sqr - abs] nullary')
+J('23 gsra 6 [x popd] times first sqr')
 ```
 
-Now we can define a recursive program that expects a number `n`, an initial estimate `a`, and an epsilon value `ε`, and that leaves on the stack the square root of `n` to within the precision of the epsilon value.  (Later on we'll refine it to generate the initial estimate and hard-code an epsilon value.)
+    23.0000000001585
 
-    n a ε square-root
-    -----------------
-          √n
 
+## Finding Consecutive Approximations within a Tolerance
 
-If we apply the two functions `Q` and `err` defined above we get the next approximation and the error on the stack below the epsilon.
 
-    n a ε [Q err] dip
-    n a Q err ε 
-    n a'  err ε 
-    n a' e    ε
+> 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.
 
-Let's define the recursive function from here.  Start with `ifte`; the predicate and the base case behavior are obvious:
+From ["Why Functional Programming Matters" by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf)
 
-    n a' e ε [<] [popop popd] [J] ifte
+(And note that by “list” he means a lazily-evaluated list.)
 
-Base-case
+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 a' e ε popop popd
-    n a'           popd
-      a'
+       a [b G] ε within
+    ---------------------- a b - abs ε <=
+          b
 
-The recursive branch is pretty easy.  Discard the error and recur.
 
-    w/ K == [<] [popop popd] [J] ifte
+       a [b G] ε within
+    ---------------------- a b - abs ε >
+       b [c G] ε within
 
-    n a' e ε J
-    n a' e ε popd [Q err] dip [K] i
-    n a'   ε      [Q err] dip [K] i
-    n a' Q err ε              [K] i
-    n a''  e   ε               K
 
-This fragment alone is pretty useful.
 
+### Predicate
 
-```python
-define('K == [<] [popop popd] [popd [Q err] dip] primrec')
-```
+    a [b G]             ε [first - abs] dip <=
+    a [b G] first - abs ε                   <=
+    a b           - abs ε                   <=
+    a-b             abs ε                   <=
+    abs(a-b)            ε                   <=
+    (abs(a-b)<=ε)
 
 
 ```python
-J('25 10 0.001 dup K')
+define('_within_P == [first - abs] dip <=')
 ```
 
-    5.000000232305737
+### Base-Case
 
+    a [b G] ε roll< popop first
+      [b G] ε a     popop first
+      [b G]               first
+       b
 
 
 ```python
-J('25 10 0.000001 dup K')
+define('_within_B == roll< popop first')
 ```
 
-    5.000000000000005
+### Recur
 
+    a [b G] ε R0 [within] R1
 
-So now all we need is a way to generate an initial approximation and an epsilon value:
+1. Discard a.
+2. Use x combinator to generate next term from G.
+3. Run within with `i` (it is a `primrec` function.)
 
-    square-root == dup 3 / 0.000001 dup K
+Pretty straightforward:
 
+    a [b G]        ε R0           [within] R1
+    a [b G]        ε [popd x] dip [within] i
+    a [b G] popd x ε              [within] i
+      [b G]      x ε              [within] i
+    b [c G]        ε              [within] i
+    b [c G]        ε               within
 
-```python
-define('square-root == dup 3 / 0.000001 dup K')
-```
+    b [c G] ε within
 
 
 ```python
-J('36 square-root')
+define('_within_R == [popd x] dip')
 ```
 
-    6.000000000000007
+### 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:
+
+    [a G] x ε ...
+    a [b G] ε ...
 
 
+```python
+define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec')
+define('sqrt == gsra within')
+```
+
 
 ```python
-J('4895048365636 square-root')
+J('23 sqrt')
 ```
 
-    2212475.6192184356
+    4.795831523312719
 
 
 
 ```python
-2212475.6192184356 * 2212475.6192184356
+4.795831523312719**2
 ```
 
 
 
 
-    4895048365636.0
+    22.999999999999996
 
 
index 7cc23e3..829ad63 100644 (file)
 `Newton's method <https://en.wikipedia.org/wiki/Newton%27s_method>`__
 =====================================================================
 
-.. code:: ipython2
-
-    from notebook_preamble import J, V, define
+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>`__
 
-:math:`a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}`
+.. code:: ipython2
+
+    from notebook_preamble import J, V, define
+
+A Generator for Approximations
+------------------------------
 
-Let's define a function that computes the above equation:
+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:
 
 ::
 
-         n a Q
-    ---------------
-       (a+n/a)/2
+       a F
+    ---------
+        a'
+
+A Function to Compute the Next Approximation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+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}`
+
+::
 
-    n a tuck / + 2 /
+    a n over / + 2 /
     a n a    / + 2 /
     a n/a      + 2 /
     a+n/a        2 /
     (a+n/a)/2
 
-We want it to leave n but replace a, so we execute it with ``unary``:
+The function we want has the argument ``n`` in it:
 
 ::
 
-    Q == [tuck / + 2 /] unary
+    F == n over / + 2 /
 
-.. code:: ipython2
+Make it into a Generator
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Our generator would be created by:
+
+::
 
-    define('Q == [tuck / + 2 /] unary')
+    a [dup F] make_generator
 
-And a function to compute the error:
+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:
 
 ::
 
-    n a sqr - abs
-    |n-a**2|
+    1 n 1 / + 2 /
+    1 n/1   + 2 /
+    1 n     + 2 /
+    n+1       2 /
+    (n+1)/2
 
-This should be ``nullary`` so as to leave both n and a on the stack
-below the error.
+The generator can be written as:
 
 ::
 
-    err == [sqr - abs] nullary
+    23 1 swap  [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   [dup 23 over / + 2 /]                    make_generator
 
 .. code:: ipython2
 
-    define('err == [sqr - abs] nullary')
+    define('codireco == cons dip rest cons')
+    define('make_generator == [codireco] ccons')
+    define('ccons == cons cons')
 
-Now we can define a recursive program that expects a number ``n``, an
-initial estimate ``a``, and an epsilon value ``ε``, and that leaves on
-the stack the square root of ``n`` to within the precision of the
-epsilon value. (Later on we'll refine it to generate the initial
-estimate and hard-code an epsilon value.)
+.. code:: ipython2
 
-::
+    define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator')
 
-    n a ε square-root
-    -----------------
-          √n
+.. code:: ipython2
 
-If we apply the two functions ``Q`` and ``err`` defined above we get the
-next approximation and the error on the stack below the epsilon.
+    J('23 gsra')
 
-::
 
-    n a ε [Q err] dip
-    n a Q err ε 
-    n a'  err ε 
-    n a' e    ε
+.. parsed-literal::
 
-Let's define the recursive function from here. Start with ``ifte``; the
-predicate and the base case behavior are obvious:
+    [1 [dup 23 over / + 2 /] codireco]
 
-::
 
-    n a' e ε [<] [popop popd] [J] ifte
+Let's drive the generator a few time (with the ``x`` combinator) and
+square the approximation to see how well it works...
 
-Base-case
+.. code:: ipython2
 
-::
+    J('23 gsra 6 [x popd] times first sqr')
+
+
+.. parsed-literal::
+
+    23.0000000001585
 
-    n a' e ε popop popd
-    n a'           popd
-      a'
 
-The recursive branch is pretty easy. Discard the error and recur.
+Finding Consecutive Approximations within a 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.)
+
+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...
 
 ::
 
-    w/ K == [<] [popop popd] [J] ifte
+       a [b G] ε within
+    ---------------------- a b - abs ε <=
+          b
 
-    n a' e ε J
-    n a' e ε popd [Q err] dip [K] i
-    n a'   ε      [Q err] dip [K] i
-    n a' Q err ε              [K] i
-    n a''  e   ε               K
 
-This fragment alone is pretty useful.
+       a [b G] ε within
+    ---------------------- a b - abs ε >
+       b [c G] ε within
 
-.. code:: ipython2
+Predicate
+~~~~~~~~~
 
-    define('K == [<] [popop popd] [popd [Q err] dip] primrec')
+::
 
-.. code:: ipython2
+    a [b G]             ε [first - abs] dip <=
+    a [b G] first - abs ε                   <=
+    a b           - abs ε                   <=
+    a-b             abs ε                   <=
+    abs(a-b)            ε                   <=
+    (abs(a-b)<=ε)
 
-    J('25 10 0.001 dup K')
+.. code:: ipython2
 
+    define('_within_P == [first - abs] dip <=')
 
-.. parsed-literal::
+Base-Case
+~~~~~~~~~
 
-    5.000000232305737
+::
 
+    a [b G] ε roll< popop first
+      [b G] ε a     popop first
+      [b G]               first
+       b
 
 .. code:: ipython2
 
-    J('25 10 0.000001 dup K')
+    define('_within_B == roll< popop first')
 
+Recur
+~~~~~
 
-.. parsed-literal::
+::
 
-    5.000000000000005
+    a [b G] ε R0 [within] R1
 
+1. Discard a.
+2. Use x combinator to generate next term from G.
+3. Run within with ``i`` (it is a ``primrec`` function.)
 
-So now all we need is a way to generate an initial approximation and an
-epsilon value:
+Pretty straightforward:
 
 ::
 
-    square-root == dup 3 / 0.000001 dup K
+    a [b G]        ε R0           [within] R1
+    a [b G]        ε [popd x] dip [within] i
+    a [b G] popd x ε              [within] i
+      [b G]      x ε              [within] i
+    b [c G]        ε              [within] i
+    b [c G]        ε               within
+
+    b [c G] ε within
 
 .. code:: ipython2
 
-    define('square-root == dup 3 / 0.000001 dup K')
+    define('_within_R == [popd x] dip')
 
-.. code:: ipython2
+Setting up
+~~~~~~~~~~
 
-    J('36 square-root')
+The recursive function we have defined so far needs a slight preamble:
+``x`` to prime the generator and the epsilon value to use:
 
+::
 
-.. parsed-literal::
+    [a G] x ε ...
+    a [b G] ε ...
 
-    6.000000000000007
+.. code:: ipython2
 
+    define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec')
+    define('sqrt == gsra within')
 
 .. code:: ipython2
 
-    J('4895048365636 square-root')
+    J('23 sqrt')
 
 
 .. parsed-literal::
 
-    2212475.6192184356
+    4.795831523312719
 
 
 .. code:: ipython2
 
-    2212475.6192184356 * 2212475.6192184356
+    4.795831523312719**2
 
 
 
 
 .. parsed-literal::
 
-    4895048365636.0
+    22.999999999999996
 
 
index f524c57..8df05d1 100644 (file)
@@ -11826,11 +11826,21 @@ div#notebook {
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<h1 id="Write-a-straightforward-program-with-variable-names.">Write a straightforward program with variable names.<a class="anchor-link" href="#Write-a-straightforward-program-with-variable-names.">&#182;</a></h1>
+<h2 id="Write-a-straightforward-program-with-variable-names.">Write a straightforward program with variable names.<a class="anchor-link" href="#Write-a-straightforward-program-with-variable-names.">&#182;</a></h2>
 <pre><code>b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
 
 </code></pre>
-<h3 id="Check-it.">Check it.<a class="anchor-link" href="#Check-it.">&#182;</a></h3>
+<p>We use <code>cleave</code> to compute the sum and difference and then <code>app2</code> to finish computing both roots using a quoted program <code>[2a truediv]</code> built with <code>cons</code>.</p>
+
+</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="Check-it.">Check it.<a class="anchor-link" href="#Check-it.">&#182;</a></h3><p>Evaluating by hand:</p>
+
 <pre><code> b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
 -b     b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
 -b     b^2   4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
@@ -11842,8 +11852,18 @@ div#notebook {
 -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    2a    [truediv] cons app2
 -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    [2a truediv]         app2
 -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a
+
 </code></pre>
-<h3 id="Codicil">Codicil<a class="anchor-link" href="#Codicil">&#182;</a></h3>
+<p>(Eventually we’ll be able to use e.g. Sympy versions of the Joy commands to do this sort of thing symbolically. This is part of what is meant by a “categorical” language.)</p>
+
+</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="Cleanup">Cleanup<a class="anchor-link" href="#Cleanup">&#182;</a></h3>
 <pre><code>-b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a                          roll&lt; pop
    -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a -b                             pop
    -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a</code></pre>
@@ -11855,7 +11875,7 @@ div#notebook {
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<h1 id="Derive-a-definition.">Derive a definition.<a class="anchor-link" href="#Derive-a-definition.">&#182;</a></h1>
+<h2 id="Derive-a-definition.">Derive a definition.<a class="anchor-link" href="#Derive-a-definition.">&#182;</a></h2>
 <pre><code>b neg b           sqr 4 a c        * * - sqrt [+] [-] cleave a       2 * [truediv] cons app2 roll&lt; pop
 b    [neg] dupdip sqr 4 a c        * * - sqrt [+] [-] cleave a       2 * [truediv] cons app2 roll&lt; pop
 b a c    [[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave a       2 * [truediv] cons app2 roll&lt; pop
@@ -11913,24 +11933,21 @@ b a c over [[[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave] dip 2 * [truedi
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<h3 id="Simplify">Simplify<a class="anchor-link" href="#Simplify">&#182;</a></h3><p>We can define a <code>pm</code> plus-or-minus function:</p>
+<h2 id="Simplify">Simplify<a class="anchor-link" href="#Simplify">&#182;</a></h2><p>We can define a <code>pm</code> plus-or-minus function:</p>
 
 </div>
 </div>
 </div>
-<div class="cell border-box-sizing code_cell rendered">
-<div class="input">
-<div class="prompt input_prompt">In&nbsp;[4]:</div>
+<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
+</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;pm == [+] [-] cleave popdd&#39;</span><span class="p">)</span>
-</pre></div>
+<div class="text_cell_render border-box-sizing rendered_html">
+
+<pre><code>pm == [+] [-] cleave popdd</code></pre>
 
 </div>
 </div>
 </div>
-
-</div>
 <div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
 </div>
 <div class="inner_cell">
@@ -11942,7 +11959,7 @@ b a c over [[[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave] dip 2 * [truedi
 </div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
 <div class=" highlight hl-ipython2"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [truediv] cons app2&#39;</span><span class="p">)</span>
@@ -11955,7 +11972,7 @@ b a c over [[[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave] dip 2 * [truedi
 </div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
 <div class=" highlight hl-ipython2"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 1 1 quadratic&#39;</span><span class="p">)</span>
@@ -11988,28 +12005,20 @@ b a c over [[[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave] dip 2 * [truedi
 </div>
 <div class="inner_cell">
 <div class="text_cell_render border-box-sizing rendered_html">
-<h3 id="Define-a-&quot;native&quot;-pm-function.">Define a "native" <code>pm</code> function.<a class="anchor-link" href="#Define-a-&quot;native&quot;-pm-function.">&#182;</a></h3><p>The definition of <code>pm</code> above is pretty elegant, but the implementation takes a lot of steps relative to what it's accomplishing.  Since we are likely to use <code>pm</code> more than once in the future, let's write a primitive in Python and add it to the dictionary.</p>
+<h3 id="Define-a-&quot;native&quot;-pm-function.">Define a "native" <code>pm</code> function.<a class="anchor-link" href="#Define-a-&quot;native&quot;-pm-function.">&#182;</a></h3><p>The definition of <code>pm</code> above is pretty elegant, but the implementation takes a lot of steps relative to what it's accomplishing.  Since we are likely to use <code>pm</code> more than once in the future, let's write a primitive in Python and add it to the dictionary.  (This has been done already.)</p>
 
 </div>
 </div>
 </div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
-<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">from</span> <span class="nn">joy.library</span> <span class="kn">import</span> <span class="n">SimpleFunctionWrapper</span>
-<span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">D</span>
-
-
-<span class="nd">@SimpleFunctionWrapper</span>
-<span class="k">def</span> <span class="nf">pm</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+<div class=" highlight hl-ipython2"><pre><span></span><span class="k">def</span> <span class="nf">pm</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
     <span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="n">p</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="o">=</span> <span class="n">b</span> <span class="o">+</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">-</span> <span class="n">a</span>
     <span class="k">return</span> <span class="n">m</span><span class="p">,</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
-
-
-<span class="n">D</span><span class="p">[</span><span class="s1">&#39;pm&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pm</span>
 </pre></div>
 
 </div>
@@ -12028,7 +12037,7 @@ b a c over [[[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave] dip 2 * [truedi
 </div>
 <div class="cell border-box-sizing code_cell rendered">
 <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="input_area">
 <div class=" highlight hl-ipython2"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;3 1 1 quadratic&#39;</span><span class="p">)</span>
index 89029f1..d736d60 100644 (file)
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "# Write a straightforward program with variable names.\n",
+    "## Write a straightforward program with variable names.\n",
+    "\n",
     "    b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2\n",
     "\n",
+    "We use `cleave` to compute the sum and difference and then `app2` to finish computing both roots using a quoted program `[2a truediv]` built with `cons`."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
     "### Check it.\n",
+    "Evaluating by hand:\n",
     "\n",
     "     b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2\n",
     "    -b     b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2\n",
     "    -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    2a    [truediv] cons app2\n",
     "    -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    [2a truediv]         app2\n",
     "    -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a\n",
-    "### Codicil\n",
+    "\n",
+    "(Eventually we’ll be able to use e.g. Sympy versions of the Joy commands to do this sort of thing symbolically. This is part of what is meant by a “categorical” language.)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Cleanup\n",
     "    -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a                          roll< pop\n",
     "       -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a -b                             pop\n",
     "       -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a"
@@ -69,7 +86,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "# Derive a definition.\n",
+    "## Derive a definition.\n",
     "\n",
     "    b neg b           sqr 4 a c        * * - sqrt [+] [-] cleave a       2 * [truediv] cons app2 roll< pop\n",
     "    b    [neg] dupdip sqr 4 a c        * * - sqrt [+] [-] cleave a       2 * [truediv] cons app2 roll< pop\n",
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "### Simplify\n",
+    "## Simplify\n",
     "We can define a `pm` plus-or-minus function:"
    ]
   },
   {
-   "cell_type": "code",
-   "execution_count": 4,
+   "cell_type": "markdown",
    "metadata": {},
-   "outputs": [],
    "source": [
-    "define('pm == [+] [-] cleave popdd')"
+    "    pm == [+] [-] cleave popdd"
    ]
   },
   {
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
    "metadata": {},
    "source": [
     "### Define a \"native\" `pm` function.\n",
-    "The definition of `pm` above is pretty elegant, but the implementation takes a lot of steps relative to what it's accomplishing.  Since we are likely to use `pm` more than once in the future, let's write a primitive in Python and add it to the dictionary."
+    "The definition of `pm` above is pretty elegant, but the implementation takes a lot of steps relative to what it's accomplishing.  Since we are likely to use `pm` more than once in the future, let's write a primitive in Python and add it to the dictionary.  (This has been done already.)"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [],
    "source": [
-    "from joy.library import SimpleFunctionWrapper\n",
-    "from notebook_preamble import D\n",
-    "\n",
-    "\n",
-    "@SimpleFunctionWrapper\n",
     "def pm(stack):\n",
     "    a, (b, stack) = stack\n",
     "    p, m, = b + a, b - a\n",
-    "    return m, (p, stack)\n",
-    "\n",
-    "\n",
-    "D['pm'] = pm"
+    "    return m, (p, stack)"
    ]
   },
   {
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
index b8dfb54..c55abe5 100644 (file)
@@ -14,10 +14,14 @@ Cf. [jp-quadratic.html](http://www.kevinalbrecht.com/code/joy-mirror/jp-quadrati
 
 $\frac{-b  \pm \sqrt{b^2 - 4ac}}{2a}$
 
-# Write a straightforward program with variable names.
+## Write a straightforward program with variable names.
+
     b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
 
+We use `cleave` to compute the sum and difference and then `app2` to finish computing both roots using a quoted program `[2a truediv]` built with `cons`.
+
 ### Check it.
+Evaluating by hand:
 
      b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
     -b     b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
@@ -30,12 +34,15 @@ $\frac{-b  \pm \sqrt{b^2 - 4ac}}{2a}$
     -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    2a    [truediv] cons app2
     -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    [2a truediv]         app2
     -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a
-### Codicil
+
+(Eventually we’ll be able to use e.g. Sympy versions of the Joy commands to do this sort of thing symbolically. This is part of what is meant by a “categorical” language.)
+
+### Cleanup
     -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a                          roll< pop
        -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a -b                             pop
        -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a
 
-# Derive a definition.
+## Derive a definition.
 
     b neg b           sqr 4 a c        * * - sqrt [+] [-] cleave a       2 * [truediv] cons app2 roll< pop
     b    [neg] dupdip sqr 4 a c        * * - sqrt [+] [-] cleave a       2 * [truediv] cons app2 roll< pop
@@ -56,13 +63,10 @@ J('3 1 1 quadratic')
     -0.3819660112501051 -2.618033988749895
 
 
-### Simplify
+## Simplify
 We can define a `pm` plus-or-minus function:
 
-
-```python
-define('pm == [+] [-] cleave popdd')
-```
+    pm == [+] [-] cleave popdd
 
 Then `quadratic` becomes:
 
@@ -80,22 +84,14 @@ J('3 1 1 quadratic')
 
 
 ### Define a "native" `pm` function.
-The definition of `pm` above is pretty elegant, but the implementation takes a lot of steps relative to what it's accomplishing.  Since we are likely to use `pm` more than once in the future, let's write a primitive in Python and add it to the dictionary.
+The definition of `pm` above is pretty elegant, but the implementation takes a lot of steps relative to what it's accomplishing.  Since we are likely to use `pm` more than once in the future, let's write a primitive in Python and add it to the dictionary.  (This has been done already.)
 
 
 ```python
-from joy.library import SimpleFunctionWrapper
-from notebook_preamble import D
-
-
-@SimpleFunctionWrapper
 def pm(stack):
     a, (b, stack) = stack
     p, m, = b + a, b - a
     return m, (p, stack)
-
-
-D['pm'] = pm
 ```
 
 The resulting trace is short enough to fit on a page.
index 1c8b0d5..9975abb 100644 (file)
@@ -18,15 +18,21 @@ Cf.
 :math:`\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}`
 
 Write a straightforward program with variable names.
-====================================================
+----------------------------------------------------
 
 ::
 
     b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
 
+We use ``cleave`` to compute the sum and difference and then ``app2`` to
+finish computing both roots using a quoted program ``[2a truediv]``
+built with ``cons``.
+
 Check it.
 ~~~~~~~~~
 
+Evaluating by hand:
+
 ::
 
      b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
@@ -41,7 +47,11 @@ Check it.
     -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    [2a truediv]         app2
     -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a
 
-Codicil
+(Eventually we’ll be able to use e.g. Sympy versions of the Joy commands
+to do this sort of thing symbolically. This is part of what is meant by
+a “categorical” language.)
+
+Cleanup
 ~~~~~~~
 
 ::
@@ -51,7 +61,7 @@ Codicil
        -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a
 
 Derive a definition.
-====================
+--------------------
 
 ::
 
@@ -76,13 +86,13 @@ Derive a definition.
 
 
 Simplify
-~~~~~~~~
+--------
 
 We can define a ``pm`` plus-or-minus function:
 
-.. code:: ipython2
+::
 
-    define('pm == [+] [-] cleave popdd')
+    pm == [+] [-] cleave popdd
 
 Then ``quadratic`` becomes:
 
@@ -106,22 +116,15 @@ Define a "native" ``pm`` function.
 The definition of ``pm`` above is pretty elegant, but the implementation
 takes a lot of steps relative to what it's accomplishing. Since we are
 likely to use ``pm`` more than once in the future, let's write a
-primitive in Python and add it to the dictionary.
+primitive in Python and add it to the dictionary. (This has been done
+already.)
 
 .. code:: ipython2
 
-    from joy.library import SimpleFunctionWrapper
-    from notebook_preamble import D
-    
-    
-    @SimpleFunctionWrapper
     def pm(stack):
         a, (b, stack) = stack
         p, m, = b + a, b - a
         return m, (p, stack)
-    
-    
-    D['pm'] = pm
 
 The resulting trace is short enough to fit on a page.
 
index f8fe488..be7dcc6 100644 (file)
@@ -135,9 +135,10 @@ interesting aspects.  It’s quite a treasure trove.</p>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Replacing.html">Replacing Functions in the Dictionary</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
-<li class="toctree-l2"><a class="reference internal" href="notebooks/Generator Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="notebooks/Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Newton-Raphson.html">Newton’s method</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="notebooks/Zipper.html">Traversing Datastructures with Zippers</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/NoUpdates.html">No Updates</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Categorical.html">Categorical Programming</a></li>
 </ul>
index cc8aaf7..68867b3 100644 (file)
             
   <div class="section" id="quadratic-formula">
 <h1><a class="reference external" href="https://en.wikipedia.org/wiki/Quadratic_formula">Quadratic formula</a><a class="headerlink" href="#quadratic-formula" title="Permalink to this headline">¶</a></h1>
-<p><a class="reference external" href="https://en.wikipedia.org/wiki/Quadratic_formula">The Quadratic formula</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>
+</pre></div>
+</div>
+<p>Cf.
+<a class="reference external" href="http://www.kevinalbrecht.com/code/joy-mirror/jp-quadratic.html">jp-quadratic.html</a></p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="n">b</span>  <span class="o">+/-</span> <span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span> <span class="o">*</span> <span class="n">a</span> <span class="o">*</span> <span class="n">c</span><span class="p">)</span>
+<span class="o">-----------------------------</span>
+           <span class="mi">2</span> <span class="o">*</span> <span class="n">a</span>
+</pre></div>
+</div>
 <p><span class="math notranslate nohighlight">\(\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\)</span></p>
-<p>In
-<a class="reference external" href="http://www.kevinalbrecht.com/code/joy-mirror/jp-quadratic.html">jp-quadratic.html</a>
-a Joy function for the Quadratic formula is derived (along with one of my favorite combinators <code class="docutils literal notranslate"><span class="pre">[i]</span> <span class="pre">map</span></code>,
-which I like to call <code class="docutils literal notranslate"><span class="pre">pam</span></code>) starting with a version written in Scheme.  Here we investigate a different approach.</p>
-<div class="section" id="write-a-program-with-variable-names">
-<h2>Write a program with variable names.<a class="headerlink" href="#write-a-program-with-variable-names" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="write-a-straightforward-program-with-variable-names">
+<h2>Write a straightforward program with variable names.<a class="headerlink" href="#write-a-straightforward-program-with-variable-names" title="Permalink to this headline">¶</a></h2>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="n">neg</span> <span class="n">b</span> <span class="n">sqr</span> <span class="mi">4</span> <span class="n">a</span> <span class="n">c</span> <span class="o">*</span> <span class="o">*</span> <span class="o">-</span> <span class="n">sqrt</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="p">]</span> <span class="n">cleave</span> <span class="n">a</span> <span class="mi">2</span> <span class="o">*</span> <span class="p">[</span><span class="n">truediv</span><span class="p">]</span> <span class="n">cons</span> <span class="n">app2</span>
 </pre></div>
 </div>
-<p>We use <code class="docutils literal notranslate"><span class="pre">cleave</span></code> to compute the sum and difference (“plus-or-minus”) and then <code class="docutils literal notranslate"><span class="pre">app2</span></code> to finish computing both roots using a quoted program <code class="docutils literal notranslate"><span class="pre">[2a</span> <span class="pre">truediv]</span></code> built with <code class="docutils literal notranslate"><span class="pre">cons</span></code>.</p>
+<p>We use <code class="docutils literal notranslate"><span class="pre">cleave</span></code> to compute the sum and difference and then <code class="docutils literal notranslate"><span class="pre">app2</span></code> to
+finish computing both roots using a quoted program <code class="docutils literal notranslate"><span class="pre">[2a</span> <span class="pre">truediv]</span></code>
+built with <code class="docutils literal notranslate"><span class="pre">cons</span></code>.</p>
 <div class="section" id="check-it">
 <h3>Check it.<a class="headerlink" href="#check-it" title="Permalink to this headline">¶</a></h3>
 <p>Evaluating by hand:</p>
@@ -62,12 +69,14 @@ which I like to call <code class="docutils literal notranslate"><span class="pre
 <span class="o">-</span><span class="n">b</span> <span class="o">-</span><span class="n">b</span><span class="o">+</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span>
 </pre></div>
 </div>
-<p>(Eventually we’ll be able to use e.g. Sympy versions of the Joy commands to do this sort of thing symbolically.  This is part of what is meant by a “categorical” language.)</p>
+<p>(Eventually we’ll be able to use e.g. Sympy versions of the Joy commands
+to do this sort of thing symbolically. This is part of what is meant by
+a “categorical” language.)</p>
 </div>
 <div class="section" id="cleanup">
 <h3>Cleanup<a class="headerlink" href="#cleanup" title="Permalink to this headline">¶</a></h3>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="n">b</span> <span class="o">-</span><span class="n">b</span><span class="o">+</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span>    <span class="n">roll</span><span class="o">&lt;</span> <span class="n">pop</span>
-   <span class="o">-</span><span class="n">b</span><span class="o">+</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span>       <span class="n">pop</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="n">b</span> <span class="o">-</span><span class="n">b</span><span class="o">+</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span>                          <span class="n">roll</span><span class="o">&lt;</span> <span class="n">pop</span>
+   <span class="o">-</span><span class="n">b</span><span class="o">+</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span>                             <span class="n">pop</span>
    <span class="o">-</span><span class="n">b</span><span class="o">+</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span> <span class="o">-</span><span class="n">b</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span><span class="o">^</span><span class="mi">2</span><span class="o">-</span><span class="mi">4</span><span class="n">ac</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="n">a</span>
 </pre></div>
 </div>
@@ -82,9 +91,6 @@ which I like to call <code class="docutils literal notranslate"><span class="pre
 <span class="n">b</span> <span class="n">a</span> <span class="n">c</span> <span class="n">over</span> <span class="p">[[[</span><span class="n">neg</span><span class="p">]</span> <span class="n">dupdip</span> <span class="n">sqr</span> <span class="mi">4</span><span class="p">]</span> <span class="n">dipd</span> <span class="o">*</span> <span class="o">*</span> <span class="o">-</span> <span class="n">sqrt</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="p">]</span> <span class="n">cleave</span><span class="p">]</span> <span class="n">dip</span> <span class="mi">2</span> <span class="o">*</span> <span class="p">[</span><span class="n">truediv</span><span class="p">]</span> <span class="n">cons</span> <span class="n">app2</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="n">pop</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">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>
-</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;quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave] dip 2 * [truediv] cons app2 roll&lt; pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -94,10 +100,11 @@ which I like to call <code class="docutils literal notranslate"><span class="pre
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="mf">0.3819660112501051</span> <span class="o">-</span><span class="mf">2.618033988749895</span>
 </pre></div>
 </div>
+</div>
 <div class="section" id="simplify">
-<h3>Simplify<a class="headerlink" href="#simplify" title="Permalink to this headline">¶</a></h3>
+<h2>Simplify<a class="headerlink" href="#simplify" title="Permalink to this headline">¶</a></h2>
 <p>We can define a <code class="docutils literal notranslate"><span class="pre">pm</span></code> plus-or-minus function:</p>
-<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;pm == [+] [-] cleave popdd&#39;</span><span class="p">)</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pm</span> <span class="o">==</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="p">]</span> <span class="n">cleave</span> <span class="n">popdd</span>
 </pre></div>
 </div>
 <p>Then <code class="docutils literal notranslate"><span class="pre">quadratic</span></code> becomes:</p>
@@ -110,25 +117,17 @@ which I like to call <code class="docutils literal notranslate"><span class="pre
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="mf">0.3819660112501051</span> <span class="o">-</span><span class="mf">2.618033988749895</span>
 </pre></div>
 </div>
-</div>
 <div class="section" id="define-a-native-pm-function">
 <h3>Define a “native” <code class="docutils literal notranslate"><span class="pre">pm</span></code> function.<a class="headerlink" href="#define-a-native-pm-function" title="Permalink to this headline">¶</a></h3>
 <p>The definition of <code class="docutils literal notranslate"><span class="pre">pm</span></code> above is pretty elegant, but the implementation
 takes a lot of steps relative to what it’s accomplishing. Since we are
 likely to use <code class="docutils literal notranslate"><span class="pre">pm</span></code> more than once in the future, let’s write a
-primitive in Python and add it to the dictionary.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.library</span> <span class="k">import</span> <span class="n">SimpleFunctionWrapper</span>
-<span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">D</span>
-
-
-<span class="nd">@SimpleFunctionWrapper</span>
-<span class="k">def</span> <span class="nf">pm</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+primitive in Python and add it to the dictionary. (This has been done
+already.)</p>
+<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">pm</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
     <span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="n">p</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="o">=</span> <span class="n">b</span> <span class="o">+</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">-</span> <span class="n">a</span>
     <span class="k">return</span> <span class="n">m</span><span class="p">,</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
-
-
-<span class="n">D</span><span class="p">[</span><span class="s1">&#39;pm&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pm</span>
 </pre></div>
 </div>
 <p>The resulting trace is short enough to fit on a page.</p>
@@ -195,13 +194,13 @@ primitive in Python and add it to the dictionary.</p>
   <h3><a href="../index.html">Table Of Contents</a></h3>
   <ul>
 <li><a class="reference internal" href="#">Quadratic formula</a><ul>
-<li><a class="reference internal" href="#write-a-program-with-variable-names">Write a program with variable names.</a><ul>
+<li><a class="reference internal" href="#write-a-straightforward-program-with-variable-names">Write a straightforward program with variable names.</a><ul>
 <li><a class="reference internal" href="#check-it">Check it.</a></li>
 <li><a class="reference internal" href="#cleanup">Cleanup</a></li>
 </ul>
 </li>
-<li><a class="reference internal" href="#derive-a-definition">Derive a definition.</a><ul>
-<li><a class="reference internal" href="#simplify">Simplify</a></li>
+<li><a class="reference internal" href="#derive-a-definition">Derive a definition.</a></li>
+<li><a class="reference internal" href="#simplify">Simplify</a><ul>
 <li><a class="reference internal" href="#define-a-native-pm-function">Define a “native” <code class="docutils literal notranslate"><span class="pre">pm</span></code> function.</a></li>
 </ul>
 </li>
index 775b613..d64edb6 100644 (file)
@@ -6,7 +6,7 @@
   <head>
     <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <title>Preamble &#8212; Thun 0.2.0 documentation</title>
+    <title>Traversing Datastructures with Zippers &#8212; Thun 0.2.0 documentation</title>
     <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
     <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
     <script type="text/javascript" src="../_static/documentation_options.js"></script>
         <div class="bodywrapper">
           <div class="body" role="main">
             
-  <p>This notebook is about using the “zipper” with joy datastructures. See
+  <div class="section" id="traversing-datastructures-with-zippers">
+<h1>Traversing Datastructures with Zippers<a class="headerlink" href="#traversing-datastructures-with-zippers" title="Permalink to this headline">¶</a></h1>
+<p>This notebook is about using the “zipper” with joy datastructures. See
 the <a class="reference external" href="https://en.wikipedia.org/wiki/Zipper_%28data_structure%29">Zipper wikipedia
 entry</a> or
 the original paper: <a class="reference external" href="https://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/huet-zipper.pdf">“FUNCTIONAL PEARL The Zipper” by Gérard
 Huet</a></p>
 <p>Given a datastructure on the stack we can navigate through it, modify
 it, and rebuild it using the “zipper” technique.</p>
-<div class="section" id="preamble">
-<h1>Preamble<a class="headerlink" href="#preamble" title="Permalink to this headline">¶</a></h1>
 <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>
 </div>
@@ -309,7 +309,7 @@ i d i d i d d Bingo!
         <div class="sphinxsidebarwrapper">
   <h3><a href="../index.html">Table Of Contents</a></h3>
   <ul>
-<li><a class="reference internal" href="#">Preamble</a><ul>
+<li><a class="reference internal" href="#">Traversing Datastructures with Zippers</a><ul>
 <li><a class="reference internal" href="#trees">Trees</a></li>
 <li><a class="reference internal" href="#zipper-in-joy">Zipper in Joy</a></li>
 <li><a class="reference internal" href="#dip-and-infra"><code class="docutils literal notranslate"><span class="pre">dip</span></code> and <code class="docutils literal notranslate"><span class="pre">infra</span></code></a></li>
index 84eb4f1..7cde03d 100644 (file)
 <li class="toctree-l2"><a class="reference internal" href="Treestep.html#putting-it-together">Putting it together</a></li>
 </ul>
 </li>
-<li class="toctree-l1"><a class="reference internal" href="Generator Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a><ul>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#direco"><code class="docutils literal notranslate"><span class="pre">direco</span></code></a></li>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#making-generators">Making Generators</a></li>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#generating-multiples-of-three-and-five">Generating Multiples of Three and Five</a></li>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#project-euler-problem-one">Project Euler Problem One</a></li>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#a-generator-for-the-fibonacci-sequence">A generator for the Fibonacci Sequence.</a></li>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#project-euler-problem-two">Project Euler Problem Two</a></li>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#how-to-compile-these">How to compile these?</a></li>
-<li class="toctree-l2"><a class="reference internal" href="Generator Programs.html#an-interesting-variation">An Interesting Variation</a></li>
+<li class="toctree-l1"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#direco"><code class="docutils literal notranslate"><span class="pre">direco</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#making-generators">Making Generators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#generating-multiples-of-three-and-five">Generating Multiples of Three and Five</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#project-euler-problem-one">Project Euler Problem One</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#a-generator-for-the-fibonacci-sequence">A generator for the Fibonacci Sequence.</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#project-euler-problem-two">Project Euler Problem Two</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#how-to-compile-these">How to compile these?</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html#an-interesting-variation">An Interesting Variation</a></li>
 </ul>
 </li>
 <li class="toctree-l1"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a><ul>
 </ul>
 </li>
 <li class="toctree-l1"><a class="reference internal" href="Quadratic.html">Quadratic formula</a><ul>
-<li class="toctree-l2"><a class="reference internal" href="Quadratic.html#write-a-program-with-variable-names">Write a program with variable names.</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html#write-a-straightforward-program-with-variable-names">Write a straightforward program with variable names.</a></li>
 <li class="toctree-l2"><a class="reference internal" href="Quadratic.html#derive-a-definition">Derive a definition.</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html#simplify">Simplify</a></li>
+</ul>
+</li>
+<li class="toctree-l1"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html#trees">Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html#zipper-in-joy">Zipper in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html#dip-and-infra"><code class="docutils literal notranslate"><span class="pre">dip</span></code> and <code class="docutils literal notranslate"><span class="pre">infra</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html#z"><code class="docutils literal notranslate"><span class="pre">Z</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html#addressing">Addressing</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html#determining-the-right-path-for-an-item-in-a-tree">Determining the right “path” for an item in a tree.</a></li>
 </ul>
 </li>
 <li class="toctree-l1"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
index 27ec52e..9d8e390 100644 (file)
Binary files a/docs/sphinx_docs/_build/html/objects.inv and b/docs/sphinx_docs/_build/html/objects.inv differ
index f42664a..89d91be 100644 (file)
@@ -1 +1 @@
-Search.setIndex({docnames:["index","joy","lib","library","notebooks/Advent of Code 2017 December 1st","notebooks/Advent of Code 2017 December 2nd","notebooks/Advent of Code 2017 December 3rd","notebooks/Advent of Code 2017 December 4th","notebooks/Advent of Code 2017 December 5th","notebooks/Advent of Code 2017 December 6th","notebooks/Categorical","notebooks/Developing","notebooks/Generator Programs","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Replacing","notebooks/Trees","notebooks/Treestep","notebooks/Zipper","notebooks/index","parser","pretty","stack"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Advent of Code 2017 December 1st.rst","notebooks/Advent of Code 2017 December 2nd.rst","notebooks/Advent of Code 2017 December 3rd.rst","notebooks/Advent of Code 2017 December 4th.rst","notebooks/Advent of Code 2017 December 5th.rst","notebooks/Advent of Code 2017 December 6th.rst","notebooks/Categorical.rst","notebooks/Developing.rst","notebooks/Generator Programs.rst","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Replacing.rst","notebooks/Trees.rst","notebooks/Treestep.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst"],objects:{"joy.joy":{joy:[1,1,1,""],repl:[1,1,1,""],run:[1,1,1,""]},"joy.library":{"void":[3,1,1,""],BinaryBuiltinWrapper:[3,1,1,""],DefinitionWrapper:[3,2,1,""],FunctionWrapper:[3,1,1,""],SimpleFunctionWrapper:[3,1,1,""],UnaryBuiltinWrapper:[3,1,1,""],add_aliases:[3,1,1,""],app1:[3,1,1,""],app2:[3,1,1,""],app3:[3,1,1,""],b:[3,1,1,""],branch:[3,1,1,""],choice:[3,1,1,""],clear:[3,1,1,""],cmp_:[3,1,1,""],concat:[3,1,1,""],cond:[3,1,1,""],cons:[3,1,1,""],dip:[3,1,1,""],dipd:[3,1,1,""],dipdd:[3,1,1,""],divmod_:[3,1,1,""],drop:[3,1,1,""],dup:[3,1,1,""],dupd:[3,1,1,""],dupdip:[3,1,1,""],first:[3,1,1,""],floor:[3,1,1,""],genrec:[3,1,1,""],getitem:[3,1,1,""],help_:[3,1,1,""],i:[3,1,1,""],id_:[3,1,1,""],ifte:[3,1,1,""],infra:[3,1,1,""],initialize:[3,1,1,""],inscribe:[3,1,1,""],loop:[3,1,1,""],map_:[3,1,1,""],max_:[3,1,1,""],min_:[3,1,1,""],over:[3,1,1,""],parse:[3,1,1,""],pm:[3,1,1,""],pop:[3,1,1,""],popd:[3,1,1,""],popdd:[3,1,1,""],popop:[3,1,1,""],pred:[3,1,1,""],remove:[3,1,1,""],rest:[3,1,1,""],reverse:[3,1,1,""],rolldown:[3,1,1,""],rollup:[3,1,1,""],select:[3,1,1,""],sharing:[3,1,1,""],shunt:[3,1,1,""],sort_:[3,1,1,""],sqrt:[3,1,1,""],stack_:[3,1,1,""],step:[3,1,1,""],succ:[3,1,1,""],sum_:[3,1,1,""],swaack:[3,1,1,""],swap:[3,1,1,""],take:[3,1,1,""],times:[3,1,1,""],tuck:[3,1,1,""],uncons:[3,1,1,""],unique:[3,1,1,""],unstack:[3,1,1,""],warranty:[3,1,1,""],words:[3,1,1,""],x:[3,1,1,""],zip_:[3,1,1,""]},"joy.library.DefinitionWrapper":{add_def:[3,3,1,""],add_definitions:[3,3,1,""],parse_definition:[3,3,1,""]},"joy.parser":{ParseError:[24,4,1,""],Symbol:[24,2,1,""],text_to_expression:[24,1,1,""]},"joy.utils":{pretty_print:[25,0,0,"-"],stack:[26,0,0,"-"]},"joy.utils.pretty_print":{TracePrinter:[25,2,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[25,5,1,""],viewer:[25,5,1,""]},"joy.utils.stack":{expression_to_string:[26,1,1,""],iter_stack:[26,1,1,""],list_to_stack:[26,1,1,""],pick:[26,1,1,""],pushback:[26,1,1,""],stack_to_string:[26,1,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[24,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","classmethod","Python class method"],"4":["py","exception","Python exception"],"5":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:classmethod","4":"py:exception","5":"py:method"},terms:{"0b11100111011011":11,"10m":13,"10n":13,"4ac":18,"5bkei":[17,20],"\u03b5":15,"abstract":[14,17,20],"boolean":[2,3,14,17,20],"break":[9,14],"byte":11,"case":[2,3,5,9,13,21,26],"class":[3,14,24,25,26],"default":[3,8,12,17,26],"export":[3,24],"final":[2,6,13,17],"float":[3,14,22,24],"function":[0,1,4,5,6,7,8,10,11,12,16,22,23,24,25,26],"g\u00e9rard":22,"import":[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],"int":[6,12,13,14,22,24,26],"long":[17,23],"new":[2,3,6,12,13,14,15,16,19,20],"public":16,"return":[1,3,5,6,8,9,11,13,14,15,17,18,19,20,21,24,25,26],"short":18,"static":[2,16],"switch":2,"throw":17,"true":[2,3,5,6,11,13,20],"try":[6,12,13,21],"void":[0,3],"while":[3,6,8,9,14,17,20,24,26],Adding:[14,23],And:[4,6,11,12,13,15,17,20,22,26],But:[0,5,10,11,12,13,14,17,19,20],CPS:14,For:[2,3,4,5,6,7,8,13,17,20,23,26],Going:5,Has:3,Its:3,Not:6,One:[2,14,23],RHS:20,TOS:[2,3,13],That:[11,13,17,20],The:[0,1,2,3,4,5,6,7,8,10,12,15,16,18,22,23,24,26],Then:[2,3,5,8,17,18,20],There:[6,8,13,20,21,26],These:[23,26],Use:[3,13,15],Using:[0,6,13,15,17,20,23],With:[4,13,15,23],__str__:25,_tree_add_:17,_tree_add_e:17,_tree_add_p:17,_tree_add_r:17,_tree_add_t:17,_tree_delete_:17,_tree_delete_clear_stuff:17,_tree_delete_del:17,_tree_delete_r0:17,_tree_delete_r1:17,_tree_delete_rightmost:17,_tree_delete_w:17,_tree_get_:17,_tree_get_p:17,_tree_get_r:17,_tree_get_t:17,_tree_iter_order_curr:17,_tree_iter_order_left:17,_tree_iter_order_r:17,_tree_iter_order_right:17,_tree_t:17,_treestep_0:21,_treestep_1:21,_within_b:15,_within_p:15,_within_r:15,aaa:7,abbrevi:[20,21],abl:18,about:[0,6,8,14,17,20,22,26],abov:[0,6,11,15,17,18,20],abs:[6,15],absolut:[6,14],accept:[1,2,3,11,12,13,14,15,17,20,21,22],access:[6,8],accomplish:18,accordingli:[17,20],accumul:11,across:[6,8],act:15,action:[14,22],actual:[2,6,11,14,17,20],adapt:23,add:[3,4,5,6,11,12,14,18,25],add_alias:3,add_def:3,add_definit:[3,8,13,17,20,21],add_if_match:4,add_valu:8,added:[10,17,20],adding:[6,16],addit:[0,2,3,8,11,13,14,20,21],adjust:17,admit:6,advantag:13,after:[4,6,8,11,12,14],afterward:14,again:[2,3,6,8,11,14,15,17,20],against:[5,6],aggreg:[3,22],aka:[14,22],albrecht:0,algebra:20,algorithm:14,alia:3,alias:[3,14],align:[14,25],all:[3,4,5,11,12,13,14,17,20,21,25],alloc:6,allow:[13,16,17,20],almost:[17,20],along:[13,14,18],alphabet:3,alreadi:[6,15,19,22],also:[0,11,13,14,17,20,26],altern:[10,20],although:[4,10,17,20],altogeth:12,alwai:[6,11,13,16],amort:[17,20],amount:6,analysi:[10,23],anamorph:14,ani:[8,10,11,14,16,17,20,22,24],annual:14,anonym:[17,20],anoth:[4,13,17,20,26],answer:6,anyth:[2,3,14],aoc20017:5,aoc20173:6,aoc2017:[4,5,6,7,8,9],api:16,app1:3,app2:[3,5,14,18,19],app3:3,app:14,appear:[2,7,10,11,17,20],append:8,appendix:23,appli:[2,3,5,11,12,17,20],applic:12,approach:[11,18],approxim:23,archiv:0,aren:22,arg:[2,3],argument:[2,3,13,14,15,25,26],arithmet:2,ariti:2,around:[11,26],arrai:8,arrang:[8,21],arriv:[12,20,21],articl:[0,10,12],ask:[6,10,12],aspect:[0,6],assembl:8,assert:[6,9],assign:26,associ:[17,20],assum:[4,5,7,8,15],asterisk:[20,21],attack:14,attempt:[0,1],attribut:3,automat:[10,13],auxiliari:21,avail:[0,7],averag:[14,19],avoid:[17,20],awai:17,awar:2,awkward:[17,20],azur:23,back:[6,8,17,20],backward:[16,17,20,21],bag:14,banana:[13,20],bank:9,barb:13,base:[0,2,3,5,9,13,16,21],basic:[1,2,3,4,6,14,17,20],bear:8,beat:8,becaus:[2,3,4,5,6,8,13,14,17,20,21,22,26],becom:[4,17,18,20,21,26],been:[13,15,16,17,20,22],befor:[5,8,12,13,14,17,20],begin:[6,13,17,20,21],behavior:[16,20,21],behaviour:[0,1],behind:8,being:0,belong:8,below:[2,3,6,11,12,17,20,22],bespok:14,best:0,better:[6,11,17,20],between:[0,5,6,11],beyond:12,biannual:14,big:[6,8,20],binari:[0,12,14,20,23],binary_search_tre:[17,20],binarybuiltinwrapp:3,bind:14,bingo:22,bit:[6,11,12,17,20],block:[9,11],bodi:[2,14,17,20],body_text:3,bool:[5,13],borrow:14,both:[2,6,8,11,13,14,18,19,20,26],bottom:12,boundari:6,bracket:[6,14,24],branch:[3,4,5,8,11,12,20],breakpoint:14,bring:[11,14],btree:[17,21],buck:[17,20],bug:[0,14],build:[12,13,14,20,22,26],built:[13,18],bundl:[2,3],burgeon:14,calcul:6,calculu:10,call:[2,13,14,15,16,17,18,20,25,26],caller:[17,20],came:[8,20],can:[0,2,3,4,5,6,10,11,12,13,14,15,16,18,19,21,22,23,26],candid:5,captur:14,card:14,care:[6,11,26],carefulli:[20,22],carri:[4,6,12,13,17],cartesian:10,categor:[0,18,23],categori:10,ccc:10,ccon:[17,20],ceil:6,certain:[14,26],certainli:[17,20],chain:3,chang:[2,6,8,16,17,20,22],charact:22,chat:14,chatter:0,cheat:9,check:[5,12,13],checksum:5,child0:20,child:21,childn:20,children:20,choic:[3,13],choos:[16,20],cinf:17,circuit:10,circular:[4,20],cite_not:[17,20],classmethod:3,claus:3,clear:[3,6,11,14],clear_stuff:17,cleav:[4,5,7,14,18,19],close:[0,1,10],clunki:11,cmp:[3,21,23],cmp_:[3,20],code:[0,1,10,13,20,23],codireco:12,collaps:13,collect:[10,12,14],column:6,combin:[0,3,7,11,12,14,15,18,21,22,23],come:[6,8,14,17],command:[4,14,17,18,20],common:[2,11,13],compar:[3,6,10],comparison:[0,17],compel:10,compil:[2,8,10,13,14,17,19,23],complet:10,complex:[3,22],compos:13,compound:[17,20],comput:[2,5,6,8,10,11,14,18],con:[3,5,8,9,11,12,13,14,15,17,18,21,22,26],conal:10,concat:[3,4,12,13,14,20,21],concaten:0,concatin:[0,3,26],concis:6,concret:13,concurr:2,cond:[3,17],condit:[3,8,14],condition:5,confid:6,conflict:[17,20],cons2:20,consecut:23,consid:[8,11,12,13,17,20,21,22],consist:[2,6,12,14,20,21],constant:[17,20],constitu:13,consum:[5,13],contain:[0,2,3,6,7,12,13,14],context:2,conting:17,continu:[0,5,13,22],control:14,conveni:10,convert:[13,19,20,21,24,26],cook:13,cool:[17,20],copi:[2,3,4,11,13,17,20,21,23],copyright:14,corner:6,correct:6,correctli:20,correspond:10,could:[2,6,8,10,11,13,14,16,17,20,22],count:[3,6,7],count_stat:9,counter:11,coupl:21,cours:[6,8,11,13,17,20],cover:6,cpu:6,crack:[17,20],crap:[],crash:[17,20],creat:[0,2,3,4,11,13,15,17,20],crude:[17,20,24],current:[2,3,8,13,14,21,22,25],custom:16,cycl:[11,12],cython:14,dai:[13,14],data:[2,3,6],datastructur:[0,2,13,22,23,24,26],datatyp:26,ddididi:22,deal:[0,4,17,20],debugg:13,decid:[17,20],decor:3,decoupl:13,decreas:6,decrement:3,deduc:11,deeper:0,deepli:10,def:[3,6,8,9,13,14,18,19,20,26],defi:3,defin:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23],definit:[2,3,7,8,11,12,13,14,15,16,17,20,21,23],definitionwrapp:[3,8,13,17,20,21],deleg:14,delet:23,demonstr:[10,13],depend:[3,13,17,20],deposit:[20,21],dequot:[4,13],der:17,deriv:[2,3,4,5,11,14,15,17,23],descend:5,describ:[3,10,13,17,20,21,24],descript:[11,14,20],design:[2,3,5,17,20],desir:[6,14,20,21],destruct:[17,20],detail:[6,14,17,20],detect:[5,12,13,17,20],determin:[5,6],develop:[0,12,14,23],diagram:11,dialect:1,dict:[1,3],dictionari:[0,1,3,14,15,18,20,23],did:6,didn:13,differ:[0,5,7,10,11,13,15,17,18,20,26],differenti:10,dig:[17,22],digit:[4,11],dimension:6,dinfrirst:14,dip:[3,5,6,8,9,11,12,13,14,15,17,18,19,20,21],dipd:[3,8,12,13,14,17,18,20,22],dipdd:[3,17,20],direco:[9,15,23],direct:14,directli:[6,11,20,21,26],disappear:2,discard:[3,12,13,15,17,20],disciplin:17,discov:5,disenstacken:[14,20],disk:14,displac:2,distanc:6,distribut:9,ditch:[17,20],div:[3,14],dive:[20,21],divid:5,divis:[5,17,20],divisor:5,divmod:[3,5],divmod_:3,doc:[2,3,14],document:[23,24,26],doe:[0,1,5,6,8,10,12,13,14,23,25],doesn:[4,8,11,13,16,17,20,21,26],dog:20,doing:[6,10,11,13,14,22],domain:[6,10],don:[5,6,8,11,14,17,20],done:[2,11,14,16],doodl:6,door:14,dot:25,doubl:[11,14],down:[2,3,6,8,15,22],down_to_zero:14,downward:8,dozen:14,draft:[9,10,16],dream:14,drive:12,driven:[11,15],driver:12,drop:[3,4,17,20],dudipd:14,due:4,dummi:5,dup:[3,4,5,6,8,9,11,12,13,14,15,17,18,20,22,26],dupd:3,dupdip:[3,5,6,11,13,17,18,20],duplic:[3,7,13,17,20],durat:2,dure:[2,13],each:[2,3,4,5,6,8,10,11,13,14,19,20,21,25],easi:[0,6,17,20,21,22],easier:[3,4,17,20],easili:10,edit:23,effect:[2,3,14,22],effici:[6,8,12,19,22],either:[1,2,3,5,13,17,20],eleg:[8,14,17,18,20],element:[2,3],elliott:10,els:[2,3,4,5,8,9,13],embed:[10,17,20,22],empti:[3,5,14,21,26],encapsul:14,enclos:14,encod:[8,12],encount:8,end:[6,8,11,13,17,21,26],endless:12,enforc:[2,14],engend:14,enlarg:6,enough:[6,13,14,18,25],enstacken:[12,14],ensur:7,enter:14,entir:26,entri:[3,22,25],epsilon:15,equal:[11,21,26],equat:[6,14,15],ergo:[6,13,17,20],err:[17,20],error:[6,14,24],escap:8,essai:0,etc:[3,6,21,22,24],euler:23,eval:0,evalu:[1,2,3,4,13,14,15,17,18,19,20,21],even:8,evenli:5,eventu:[6,18],everi:12,everyth:[3,17,20],evolv:16,exactli:13,exampl:[0,3,4,5,6,7,8,11,13,15,20,23,24,26],exce:12,except:[14,17,20,24],execut:[0,1,2,3,5,14,19,21,22,26],exercis:17,exist:[10,17],exit:8,expand:17,expect:[2,3,5,13,20,21,26],experi:[14,21],experiment:6,explan:14,explor:14,express:[0,1,2,3,10,13,17,19,20,22,25,26],expression_to_str:26,extend:6,extra:[4,5,11,12],extract:[17,23],extrem:14,extrememli:14,facet:0,facil:14,fact:[20,24],factor:[2,11,14,17],fail:[2,3,5,17,20,24],fals:[2,3,5,9,11,13],far:[8,13,15,17,20],fascin:0,fast:6,faster:6,favorit:18,fear:[17,20],feel:6,few:[6,11,14],fewer:[3,14],fib:12,fib_gen:12,fibonacci:23,figur:[2,3,6,17,20],filter:[17,20],fin:11,find:[2,3,4,5,11,12,20,21,23],finder:15,fine:[0,11,17,20],finish:18,first:[3,4,5,6,8,9,12,13,14,15,17,18,19,20,21,22,23],first_two:17,fit:[11,14,18],five:[11,13,14,23],fix:[2,3],flag:5,flatten:[14,20,21],flexibl:[20,23],floor:[3,6],floordiv:11,flow:14,follow:[0,2,3,5,8,13,14,15,16,21,22],foo:[14,16,17,20],foo_ii:16,form:[2,3,5,7,10,11,12,21,26],forman:14,format:[23,25],formula:[0,6,11,23],forth:[4,8,14,20],fortun:8,forum:0,forward:[5,8],found:[8,9,14,20],four:[2,3,6,8,11,12,14,17,20],fourteen:11,fourth:[2,3,4,17,20],fractal:14,fraction0:14,fraction:[2,14],framework:14,free:[10,14,17,20],freeli:[2,6],from:[0,1,2,3,4,5,6,7,8,9,11,12,14,15,17,18,19,20,21,22,23,26],front:[2,3],full:[7,11],fun:6,functionwrapp:[3,20],funtion:[17,20],further:[15,23],futur:18,garbag:14,gari:[17,20],gcd:14,gen:9,gener:[0,2,3,6,8,10,23,26],genrec:[3,5,8,13,14,17,20,21],geometr:11,geometri:20,get:[2,5,6,10,11,12,13,14,23],get_valu:8,getitem:3,getrecursionlimit:26,getsourc:14,ghc:10,give:[6,10,11,13,15,17,21,26],given:[2,3,4,5,6,8,9,11,12,15,17,22,23],glue:14,goal:8,going:[5,6,8,17,20,21,22],good:[8,11,17,20],grab:3,grammar:24,grand:14,graph:6,great:[0,4,6,14,23],greater:[6,26],grid:6,group:[0,6],gsra:15,guard:[5,6,17],had:[11,22],haiku:14,half:[11,22],half_of_s:4,halfwai:4,hand:[14,18,19,20,23],handi:15,handl:[17,26],happen:[6,14,20],hard:22,hardli:13,hardwar:10,has:[0,2,5,6,8,12,13,14,15,16,17,20,22,26],haskel:10,have:[2,3,4,5,6,8,9,11,12,13,14,15,16,20,22,23,26],head:[5,13,26],help:[7,13,14,17,20],help_:3,helper:[3,5],herd:14,here:[6,11,12,13,17,18,20,21,22],heterogen:20,heurist:[4,8],hide:[17,20],higher:[14,17,20],highest:[5,20],highli:[14,20],hindsight:5,histori:25,hmm:[17,20],hog:20,hoist:3,hold:11,hood:[8,17],hope:[0,11,14,23],host:23,how:[0,6,7,8,10,13,17,20,22,23],html:[2,3,12,18,23],http:[17,20],huet:22,huge:17,hugh:[15,20,21],human:14,hypothet:2,id_:3,idea:[10,11,14,20],ident:[3,13],identifi:6,if_not_empti:17,ift:[3,4,5,8,13,17,20,21],ignor:[3,17,20],illustr:13,imagin:22,imit:21,immedi:[8,13],immut:[14,17,20],imper:13,implement:[0,1,2,3,6,9,10,13,14,16,17,18,20],impli:5,implicit:14,includ:[7,10,17,21],inclus:11,incom:26,incompat:16,incr_at:8,incr_step_count:8,incr_valu:8,increas:[6,8,11],increment:[3,10,11,16],index:[0,6,9,14,26],index_of:9,indexerror:26,indic:[20,21],infil:20,infinit:6,inform:3,infra:[3,12,13,14,17,18,19,21],infrastructur:3,init:8,init_print:6,initi:[2,3,5,6,7,8,14,15,17,20],inlin:[17,20],inner:5,input:[1,4,5,6,7,13,15],inscrib:3,inspect:14,instal:0,instanti:[10,25],instead:[6,11,12,13,17,20,22,26],instruct:8,integ:[2,3,4,5,6,7,8,13,14,21],integr:3,intend:[0,14],interact:[14,23],interest:[0,6,11,17,20,23],interlock:6,interlud:23,intermedi:13,intern:[0,25,26],interpret:[0,10,13,16,24,25],interrupt:14,interv:[10,11],introduc:16,introduct:0,invari:3,invers:3,investig:18,ipf:14,ipynb:12,isn:[13,17,22],item:[2,3,4,5,9,13,14,17,20,21,26],iter:[1,3,6,13,14,21,23,26],iter_stack:[9,19,26],its:[0,2,3,5,6,10,11,13,14,17,20,21,26],itself:[0,2,8,14,17,20],j05cmp:[2,3],jenni:20,job:[8,23],john:[15,20,21],joi:[2,4,5,7,8,9,10,15,16,17,18,19,20],joypi:[8,9,13,14,20,22],jump:8,jupyt:23,just:[0,2,3,4,5,6,8,12,13,14,16,17,21,22],keep:[17,22],kei:[21,23],kevin:0,key_n:[17,20],keyerror:[17,20],kind:[2,6,8,10,13,14,17,20,21],kleen:[20,21],know:[6,11,13,17,20],known:10,l_kei:17,l_left:17,l_right:17,l_valu:17,labda:[],lambda:[10,13],lambdifi:6,languag:[10,14,16,17,18,20],larg:6,larger:[6,26],largest:[3,5,8],last:[4,8,11,13,17],lastli:[12,13],later:[8,14,21],law:2,lazi:15,lazili:15,lcm:11,lead:[8,14],leaf:[17,20],lean:14,learn:[0,9],least:[2,6,8,11,13,26],least_fract:14,leav:[5,6,8,11,20],left:[6,13,14,21,22,25,26],leftov:13,legendari:8,legibl:8,len:9,length:[3,11,26],lens:13,less:[11,12,13,14,26],lesser:6,let:[4,5,6,8,12,13,15,17,18,20,21,22],level:[10,17,20],librari:[0,6,8,9,15,18,19,20],lieu:20,like:[2,3,5,6,9,11,13,14,15,18,21,23,24],line:[3,5,8,13,14,17,20,25],linear:26,link:0,linux:0,list:[0,3,4,5,7,8,9,11,14,15,17,21,22,25],list_to_stack:[8,9,26],liter:[1,17,20,21,22,24],littl:[6,8,12,17,20,23],live:23,lkei:[20,21],load:[11,14],locat:[2,6],locu:25,log_2:[17,20],logic:[0,11],longer:[17,20],look:[6,12,14,15,17,20],lookup:[14,20],loop:[0,1,3,11],lot:[14,17,18,20,22],love:11,low:10,lower:[11,20],lowest:[5,17,20],machin:[0,20],machineri:[17,20],macro:14,made:[0,5,14,20,22],mai:[2,8,13,20],mail:0,main:[0,3,4,14,22],mainloop:16,maintain:22,major:16,make:[2,3,4,10,11,13,14,17,19,21,22,23],make_distributor:9,make_gener:15,manfr:[0,2,3,10],manhattan:6,mani:[0,6,7,8,13,14],manipul:6,manual:[6,13],map:[1,3,11,13,14,16,18,20,21],map_:3,mark:[6,8],marker:14,mask:[11,12],match:[0,1,4],materi:0,math:[0,6,8,14,17,20],mathemat:[6,14],matter:[4,11,13,15,17,20,21],max:[5,6,9],max_:3,maximum:[3,20],maxmin:5,mayb:[13,17,20],maze:8,mean:[5,10,11,13,14,15,17,20,21,26],meant:[13,14,17,18,20,21],meantim:8,mem:8,member:[2,3,6],memori:6,mental:14,mention:2,mercuri:0,merg:20,meta:[14,17,20],methink:20,method:[0,3,6,14,23,25],mfloor:6,midpoint:11,might:[4,10,12,13,17,20],mike:17,million:12,min:5,min_:3,mind:8,minimum:3,minor:17,minu:[3,18],mirror:0,miscellan:0,mistak:9,mix:14,mnemon:4,mod:3,model:[10,14],modern:0,modif:12,modifi:[8,14,17,22],modul:[0,1,3,14,24],modulu:14,monkei:6,month:14,more:[0,3,7,8,10,11,12,13,14,15,18,19,20,21,24,26],most:20,mostli:0,move:[4,6,8,17],movement:2,mrank_of:6,much:[6,8,11,12,13,17,20],muck:[17,20],mul:[14,18,22,25],multi:3,multipl:[13,23],must:[2,3,5,6,7,11,13,16,21],mutabl:8,n_rang:[],nail:8,name:[1,3,4,14,16,17,22,23,24,26],natur:[11,12,17,20],navig:22,neat:17,need:[2,3,4,5,6,8,9,11,12,13,15,16,17,20],neg:[3,8,18],nest:[3,14,17,20,22],network:14,never:16,new_kei:17,new_valu:17,newton:[0,23],next:[4,5,6,8,11,13,20,21],nice:[0,4,6,13,26],niether:2,node:[21,23],node_kei:[17,20],node_valu:[17,20],non:[5,20,21],none:[1,3],nope:21,normal:[7,13],notat:[14,17,20],note:[2,6,11,15,17,20,26],notebook:[11,14,22,23],notebook_preambl:[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],noth:[2,17,20],notic:11,now:[4,5,6,11,12,13,14,19,21,23],nth:[3,26],nullari:[5,8,9,14,17,20],number:[1,2,3,5,11,12,26],object:24,observ:11,obviou:12,obvious:[5,7,8],occur:[17,20],odd:[11,12],off:[2,3,6,11,12,22],offset:8,offset_of:6,old:[2,19],old_k:17,old_kei:17,old_valu:17,omit:13,onc:[3,7,16,17,18,20],one:[2,3,4,5,6,7,8,11,12,13,17,18,20,21,25,26],ones:12,onli:[2,3,4,5,6,8,11,13,17,20,22,26],onto:[1,2,3,14,26],open:[7,14],oper:[3,5,13,14,17,20,26],oppos:4,optim:17,option:[1,14,17,20,26],order:[0,2,3,4,5,13,14,23,26],org:[0,17,20],origin:[0,1,2,3,4,17,20,22],other:[0,2,3,5,6,10,13,14,17,20,21,26],otherwis:[3,5,11,12,17,20,21],our:[4,5,6,11,12,13,14,15,21],ourselv:13,out:[2,3,6,10,11,12,13,14,17,20,22],outcom:[20,21],output:[6,13,15],outsid:[8,10],outward:6,over:[3,4,6,10,11,12,14,15,17,18,20,21,23],overhead:6,overkil:13,overshadow:6,own:[6,17,20],pack:[20,26],packag:[0,14],page:[0,17,18,20,26],pair:[2,3,4,5,11,12,17],pair_up:4,palidrom:11,palindrom:11,pam:[14,18],paper:[6,10,13,14,20,22],parallel:2,paramet:[1,2,3,8,13,24,25,26],parameter:23,paranthes:20,parenthes:[8,17,20,26],pariti:12,pars:[0,3,14,20],parse_definit:3,parseerror:24,parser:0,part:[2,3,5,8,13,15,18,20,21],partial:[6,13],particular:22,particularli:8,pass:[0,17,20,25],passphras:7,path:6,pattern:[6,11,20,21],payoff:13,pe1:[11,12],pe2:12,pearl:22,pend:[3,13,14,22,25],peopl:23,per:[6,14,21],perform:8,perhap:12,period:14,permit:[8,26],persist:[17,20],phase:2,pick:[11,12,26],pickl:14,pictur:[17,20],piec:13,pip:0,pita:9,place:[3,6,8,11,13,14],plai:0,plain:8,plane:6,plu:[3,6,18],plug:[12,13,20,21],point:[6,10,13,14,17,20],pointless:2,pop:[3,4,5,8,9,11,12,13,14,17,18,19,20,21,26],popd:[3,8,14,15,17,19],popdd:[3,5,12,18],popop:[3,4,5,8,9,11,12,13,14,15,17,20,21],port:6,posit:[3,8,11,13,14],possibilit:[17,20],possibl:[5,17,20,21,23],post:[14,20],potenti:3,power:14,pragmat:11,pre:[8,13,20],preambl:15,precis:[0,1],pred:3,predic:[2,3,5,12,13],prefer:13,prefix:[13,25],prep:[5,20],prepar:[8,13],preprocessor:13,present:20,preserv:[10,21],pretti:[6,17,18,20,21,25,26],pretty_print:0,prevent:13,previou:[6,8,14],prime:[5,15],primit:[2,3,8,18],primrec:[3,5,8,9,12,13,14,15],print:[0,1,2,3,6,13,25,26],probabl:[4,12,14,17,20],problem:[6,14,23],proc_curr:[17,20],proc_left:[17,20],proc_right:[17,20],proce:[4,11],process:[8,13,14,21,25],processor:20,produc:[4,11,13,17,20,21],product:[12,14],program:[0,2,3,4,5,6,8,12,14,15,17,22],project:23,prompt:14,proper:[2,3],properli:8,properti:0,provid:[0,3,10,14],prune:20,pun:[0,14],pure:[0,20],puriti:14,purpos:14,push:[2,3,13,14,22,26],pushback:[14,20,26],put:[1,2,12,14,23,26],puzzl:[4,5,6,7],pypi:0,pyramid:6,python:[0,2,3,6,8,13,17,18,20,22,23,24,26],quadrat:[0,6,23],queri:[17,20,21],query_kei:21,queu:13,quit:[0,1,6,21],quot:[0,3,12,13,14,15,17,18,20,21,22,25],quotat:[2,3],quotient:3,r_kei:17,r_left:17,r_right:17,r_valu:17,rais:[17,20,24,26],random:8,rang:[6,13,14],range_sum:13,range_to_zero:14,rank_and_offset:6,rank_of:6,raphson:15,rather:[11,13,14,20,21],ratio:14,reach:[8,11,12,13],read:[0,1,11,12,17,20,22],readabl:19,reader:17,real:[17,20],realiz:[4,8,10,17,20],realli:6,rearrang:[2,13,17],reason:[6,11,14],rebuild:[21,22],rec1:[2,3],rec2:[2,3],recogn:24,record:[14,25],recur:13,recurs:[2,3,5,8,9,12,14,15,23,26],recus:14,recusr:20,redefin:23,redistribut:[3,14],reduc:2,redund:26,reexamin:20,refactor:[13,14,16],refer:[0,2],regist:2,regular:24,reimplement:23,rel:[8,18],releas:16,relev:6,remain:[2,3,14,16],remaind:[3,15],remind:13,remov:[3,6,17,20,26],renam:20,render:[20,23],repeat:[4,6,11],repeatedli:11,repl:[0,1],replac:[0,2,3,12,13,20,21,22,23,26],repositori:0,repres:[2,14,17,20,24,25],represent:26,reprod:12,request:6,requir:[6,26],resembl:14,reset:[],respect:11,rest:[3,5,9,11,12,14,17,20,22,23,26],rest_two:17,restor:2,result:[1,2,3,5,11,13,17,18,20,21,22],resum:14,retir:2,retri:14,reus:[17,20],revers:[3,4,5,11,12,13,22,26],rewrit:[3,8,14],rewritten:14,richard:20,rid:[17,20],right:[6,12,13,14,21,25,26],rightest:17,rightmost:11,rkei:[20,21],role:20,roll:[3,5,7,8,13,15,17,18,20,21],rolldown:3,rollup:3,root:[3,6,18,23],rotate_seq:4,round:4,row:[5,6],row_valu:6,run:[0,1,3,6,11,13,14,15,17,20,21,22],runtim:6,runtimeerror:26,sai:[12,17,20,21],same:[2,10,11,13,17,20,26],sandwich:[2,3],save:[2,11,14],scan:3,scanner:[14,24],scenario:22,scheme:[18,20],scope:[4,12,17,20],search:[0,6,17,20],second:[3,4,5,13,14,17,20,21,26],secur:7,see:[0,6,12,13,14,16,19,20,22,25],seem:[0,9,11,14,20,21],seen:22,select:[3,6],semant:[2,3,14,16,17,20],semi:14,send:14,sens:[0,2,11,22],separ:14,sequenc:[0,1,2,3,4,5,7,8,9,11,14,17,19,20,22,23,24],seri:[6,11,12,13,17,20,22],serv:13,set:[2,3,13,23],seven:[11,12],sever:[0,10,14],share:[3,6,14],shelf:2,shift:[11,12],shine:8,shorter:23,shortest:6,shorthand:17,should:[2,3,5,11,13,17,20],shouldn:14,show:[6,10,20,22],shunt:[3,22],side:[17,20],sign:6,signal:5,signifi:[14,17,20],silli:20,similar:[17,20,21],simon:14,simpl:[6,13,14,26],simplefunctionwrapp:[3,8,9,18,19],simpler:21,simplest:23,simpli:10,simplifi:[6,11,17,20,22],sinc:[2,6,11,17,18,20],singl:[3,12,14,19,24],situ:[17,20],situat:[17,20],six:[11,12,14],sixti:[11,12],size:[4,7,8,9,14,23],skeptic:14,skip:[6,8],slight:15,slightli:[13,17,20],small:[4,20],smallest:[3,5],smart:[8,13,17],sneaki:6,softwar:14,solei:2,solut:[6,11,12],solv:6,solvabl:14,some:[2,3,5,6,8,12,13,14,17,20,21,23,26],somehow:[17,20],someth:[2,4,8,16,17],sometim:[17,20],somewher:[13,17,20,23],sophist:6,sort:[3,5,13,17,18,20],sort_:3,sourc:[0,1,3,23,24,25,26],space:[6,11,25],span:11,special:[12,13,17,20],specif:[0,10],specifi:17,speed:[6,8,19],spell:21,sphinx:[23,26],spiral:6,spirit:[0,1,20,21],split_at:4,spreadsheet:5,sqr:[14,18,22],sqrt:[3,6,15,18],squar:[3,6,23,24],stack:[0,1,3,5,8,9,11,12,13,15,17,18,19,20,21,22,24,25],stack_:3,stack_to_str:26,stage:[20,21],stai:[0,1],stand:10,standard:[14,17],star:[20,21],stare:[17,20],start:[5,6,8,9,11,12,13,14,15,17,18,20,21],state:[5,8,14],statement:3,step:[3,4,5,6,7,11,14,17,18,19,20,22,23],step_zero:[4,5,7],still:[6,8,13,17],stop:[17,20],storag:[11,13,17,20],store:[6,11,13],stori:13,str:[1,24,25,26],straightforward:[1,4,6,12],strang:8,stream:[11,15],stretch:17,string:[1,2,3,4,14,22,24,25,26],strip:6,structur:[13,14,20,21,22,23,26],stuff:[17,20],style:[0,10],sub:[16,20],subclass:14,subject:22,subract:6,substitut:[6,13,17],subtract:[5,6,11],succ:3,success:15,suffici:[8,13,17],suggest:[5,10,17,20],suitabl:[3,10,11],sum:[3,4,5,12,13,14,18,19,20,21],sum_:3,summand:11,sumtre:21,suppli:[13,17,20,24],support:[6,14,25,26],sure:[6,13],suspect:2,swaack:[3,13,18,19,20,22],swap:[3,4,5,6,7,9,11,12,13,14,15,17,19,20,21,22],swon:[3,9,12,13,14,20,21,22],swoncat:[8,9,12,13,14,15,20,21],symbol:[2,3,6,18,22,24],symmetr:[11,17,20],sympi:18,syntact:14,syntax:[14,26],sys:[6,26],system:[6,7,14,17,20],tail:[5,17,20,26],take:[3,4,6,8,11,14,15,17,18,20,26],taken:8,talk:[14,17,20,26],target:[6,22],task:6,tast:10,tbd:14,technic:2,techniqu:[10,22],technolog:2,teh:20,temporari:22,ten:11,term:[1,2,5,8,9,13,14,15,23,24,26],termin:[2,3,5],ternari:14,test:[2,3],text:[0,1,3],text_to_express:[14,24],textual:14,than:[0,3,6,7,11,12,14,15,18,21,26],thei:[2,5,6,11,12,13,14,17,20,22,24,26],them:[2,3,5,6,11,12,13,17,20,22,23],theori:[2,3],therefor:[12,20],thi:[0,1,2,3,4,5,6,8,9,10,11,12,13,14,18,21,22,23,24,25,26],thing:[2,5,6,8,12,13,17,18,20,22,24,26],think:[2,8,11,13,14,17,20,21],third:[3,4,5,12,14,17,20],thirti:11,those:[2,3,5,6,8,13,17,20,23],though:[11,20],thought:14,thousand:11,thread:2,three:[2,3,8,11,14,17,20,21,23],through:[1,11,14,21,22,26],thu:4,thun:[2,3,10,16],thunder:14,tied:20,tile:6,time:[3,6,8,9,11,13,14,17,20,22],tini:20,to_set:[17,20],todai:14,todo:[14,24],togeth:[12,14,23],token:24,toler:23,tommi:20,too:[13,20],took:6,tool:14,top:[2,3,14,25,26],total:[4,6,11],total_match:4,trace:[0,14,18,22,23,26],traceprint:25,track:22,tracker:0,trade:6,transform:[10,13],translat:[6,10,13],travers:[22,23],treasur:0,treat:[0,2,3,23],treatment:12,tree:[0,14,23],treegrind:23,treemap:13,treestep:[0,23],tri:11,trick:[11,20],tricki:[6,8],trivial:[5,8,20],trobe:0,trove:0,truediv:18,truthi:[3,14],ts0:[13,20],ts1:[13,20],tuck:[3,5,14,20],tupl:[3,14,26],turn:[2,3,6],twice:[6,13,17,20],two:[2,3,5,6,11,13,14,15,17,20,21,22,23,26],type:[1,10,13,14,17,24,25,26],typic:[2,3],unari:[8,13,14],unarybuiltinwrapp:3,unbalanc:[17,20,24],unchang:17,uncon:[3,4,5,12,13,14,17,20,21,22],under:[2,3,8,14,17],understand:[0,6,17,20],undistinguish:17,undocu:14,unfortun:26,uniqu:[3,7,17,20],unit:[4,13,14,20],univers:[0,14],unless:[6,13],unlik:13,unnecessari:23,unpack:[2,3,17,26],unpair:11,unquot:[13,14,20,21],unstack:3,untangl:13,until:[5,6,8,12],unus:11,unusu:[17,20],updat:[0,23],upward:8,usag:14,use:[0,2,3,6,8,10,11,12,14,15,16,17,18,19,20,21,22,26],used:[3,10,13,14,17,20,22,24,26],useful:0,user:[6,21],uses:[2,5,11,13],using:[3,5,6,12,13,17,18,20,21,22],usual:[0,2],util:[0,8,9,19,20],valid:7,valu:[0,2,3,5,6,11,13,14,15,19,21,23,26],value_n:[17,20],valueerror:26,vanilla:8,variabl:[13,23],variant:17,variat:[13,23],varient:20,varieti:[10,14],variou:0,vener:26,verbos:10,veri:[0,1,6,10,14,17,20,26],versa:2,version:[0,1,2,12,16,18,21,22,23],via:14,vice:2,view:[17,23],viewer:[1,14,16,25],von:[0,2,3,10],wai:[0,2,3,4,6,8,10,11,13,14,20],walk:20,wall:6,want:[2,6,8,11,12,15,17,20],warranti:[3,14],wash:14,wast:14,web:26,websit:[0,11],welcom:14,well:[0,4,5,6,10,14,17,20,24],were:[6,8,13,14,22],what:[2,3,5,8,9,10,13,14,17,18,20,21,25],whatev:[2,3,20,21,26],when:[11,12,13,14,15,17,20,22,24,26],where:[2,3,4,5,8,13,14,17,20,23,26],whether:13,which:[0,1,3,5,6,8,11,13,14,15,17,18,20,21,22,26],whole:[2,3,5,11,20,21],whose:12,why:[6,15,20,21],wiki:[17,20],wikipedia:[0,17,20,22],wildli:14,wind:14,winner:6,wire:13,wit:8,within:[14,17,20,23],without:[2,14,17,20],won:[17,20,26],word:[0,3,4,5,7,11,14,20,22],work:[0,3,4,5,6,8,11,12,13,14,17,20,21,22,26],worth:[6,11],would:[2,5,6,7,8,9,11,12,13,14,15,17,20,22,26],wouldn:8,wrap:[3,6,14],write:[4,6,8,10,13,15,17,20,21,22,23,26],written:[0,1,8,15,17,18,19,26],wrong:2,wtf:13,wtfmorphism:13,year:14,yet:[8,13,17,20,22],yield:[2,3,26],you:[0,2,3,5,6,8,11,12,13,14,16,17,19,20,21,22,25,26],your:[2,3,4,5,6,7,14],yourself:[14,17,20],zero:[3,5,6,8,13,17,20,21,24,26],zip:[4,11],zip_:3,zstr:22},titles:["Thun 0.2.0 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Categorical Programming","Developing a Program in Joy","Using <code class=\"docutils literal notranslate\"><span class=\"pre\">x</span></code> to Generate Values","Hylomorphism","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Replacing Functions in the Dictionary","Treating Trees","Treating Trees II: <code class=\"docutils literal notranslate\"><span class=\"pre\">treestep</span></code>","Preamble","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026"],titleterms:{"1st":4,"2nd":5,"3rd":6,"4th":7,"5th":8,"6th":9,"case":[15,17,20],"final":5,"function":[2,3,9,13,14,15,17,18,19,20,21],"long":19,"new":17,"void":2,"while":2,Adding:[17,20],One:[12,17],The:[11,13,14,17,20,21],There:14,Use:20,Using:12,With:21,about:23,abov:13,add:[2,8,17,20],adding:[17,20],address:22,advent:[4,5,6,7,8,9],all:[6,8],altern:21,ana:13,analysi:[6,11],anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[13,17],approxim:15,automat:20,averag:2,base:[15,17,20],befor:9,better:13,binari:[2,17,21],block:5,both:17,branch:[2,17],breakdown:8,btree:20,can:[17,20],cata:13,catamorph:13,categor:10,chatter:2,check:18,child:[17,20],choic:2,cleanup:18,clear:2,cleav:2,cmp:[17,20],code:[4,5,6,7,8,9,14,17],combin:[2,13,17,20],compar:[17,20],comparison:2,compil:12,comput:15,con:[2,20],concat:2,consecut:15,continu:14,count:[8,9],crap:20,current:[17,20],data:20,datastructur:[14,17,20],decemb:[4,5,6,7,8,9],defin:[17,18,20,21],definit:18,delet:[17,20],deriv:[13,18,20,21],determin:22,develop:11,dialect:0,dictionari:19,dip:[2,22],dipd:2,dipdd:2,direco:12,disenstacken:2,div:2,document:0,doe:[17,20],down:5,down_to_zero:2,drive:9,drop:2,dup:2,dupd:2,dupdip:2,els:[17,20],empti:[17,20],enstacken:2,equal:[17,20],essai:23,euler:[11,12],eval:14,even:12,exampl:[2,14,17,21],execut:25,express:[14,24],extract:[13,20,21],factor:[13,20],factori:13,fibonacci:12,filter:11,find:[6,13,15,17],first:[2,11],five:12,flatten:2,flexibl:21,floordiv:2,form:[13,20],formula:18,found:17,four:13,from:13,ftw:4,fun:13,further:11,fusion:13,gcd:2,gener:[9,11,12,13,15,20],genrec:2,get:[8,17,20,21],getitem:2,given:[13,20,21],gotten:8,greater:[17,20],group:2,have:[17,21],help:2,highest:17,host:0,how:[9,11,12],hylo:13,hylomorph:13,ift:2,increment:8,index:8,indic:0,inform:0,infra:[2,20,22],integ:11,interest:12,interlud:[17,20],intern:24,interpret:[1,14],isn:20,item:22,iter:[11,17,20],joi:[0,1,3,6,11,13,14,22,23,24,25,26],just:[11,20],kei:[17,20],languag:0,law:13,least_fract:2,left:[17,20],less:[17,20],let:11,librari:[3,14],like:[17,20],list:[2,13,20,26],literari:14,littl:11,logic:2,loop:[2,5,14],lower:17,lshift:2,make:[12,15,20],mani:[9,11],map:2,math:2,method:15,min:2,miscellan:[2,20],mod:2,modif:20,modulu:2,more:17,most:17,mul:2,multipl:[11,12],must:[17,20],name:[18,20],nativ:18,neg:2,newton:15,next:15,node:[13,17,20],non:17,now:[8,17,20],nullari:2,number:[6,13],offset:6,one:14,onli:14,order:[17,20,21],osdn:0,our:[17,20],out:5,over:2,pack:11,pam:2,paper:5,para:13,paramet:20,parameter:[13,17,20,21],paramorph:13,pars:[2,24],parser:[14,24],pass:14,path:22,pattern:13,per:[17,20],piec:5,pop:2,popd:2,popop:2,pow:2,power:12,preambl:[8,13,22],pred:2,predic:[8,11,15,17,20,21],pretty_print:25,primrec:2,print:14,problem:[11,12],process:[17,20],product:2,program:[9,10,11,13,18,20,21,23],project:[0,11,12],pure:14,put:[6,17,20,21],python:[14,19],quadrat:18,quick:0,quot:[2,26],rang:[2,11],range_to_zero:2,rank:6,read:14,recal:9,recur:[15,17,20],recurs:[13,17,20,21],redefin:[17,20,21],refactor:[4,11,17,20],refer:3,regular:14,reimplement:21,rem:2,remaind:2,remov:2,render:11,repeat:9,repl:14,replac:[17,19],rescu:6,reset:12,rest:[2,13],revers:2,right:[17,20,22],rightmost:17,roll:2,rolldown:2,rollup:2,root:15,rshift:2,run:[2,12],sat:5,second:2,select:2,sequenc:[12,26],set:[8,15,17,20],shorter:19,should:14,shunt:2,simplest:11,simplifi:18,size:[2,19],slight:20,sourc:17,sqr:2,sqrt:2,squar:15,stack:[2,14,26],start:0,state:9,step:[2,8,13,21],structur:17,style:14,sub:[2,17],succ:2,sum:[2,11],swaack:2,swap:2,swon:2,swoncat:2,symbol:[13,14],sympi:6,tabl:0,tail:13,take:2,term:[11,12,20,21],ternari:2,text:24,than:[13,17,20],thi:[17,20],think:5,third:2,three:12,thun:[0,14],time:[2,12],todo:20,togeth:[6,8,17,20,21],toi:20,token:14,toler:15,trace:[19,25],traceprint:14,travers:[17,20,21],treat:[17,20,21],tree:[13,17,20,21,22],treegrind:21,treestep:[13,20,21],triangular:13,tricki:5,truediv:2,truthi:2,tuck:2,two:12,type:20,unari:2,uncon:2,unfinish:13,unit:2,unnecessari:11,unquot:2,unstack:2,updat:16,use:13,usual:13,util:[25,26],valu:[8,12,17,20],variabl:18,variat:12,version:[6,11,17,19,20],view:14,want:5,within:15,word:2,write:18,xor:2,zero:12,zip:2,zipper:22}})
\ No newline at end of file
+Search.setIndex({docnames:["index","joy","lib","library","notebooks/Advent of Code 2017 December 1st","notebooks/Advent of Code 2017 December 2nd","notebooks/Advent of Code 2017 December 3rd","notebooks/Advent of Code 2017 December 4th","notebooks/Advent of Code 2017 December 5th","notebooks/Advent of Code 2017 December 6th","notebooks/Categorical","notebooks/Developing","notebooks/Generator_Programs","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Replacing","notebooks/Trees","notebooks/Treestep","notebooks/Zipper","notebooks/index","parser","pretty","stack"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Advent of Code 2017 December 1st.rst","notebooks/Advent of Code 2017 December 2nd.rst","notebooks/Advent of Code 2017 December 3rd.rst","notebooks/Advent of Code 2017 December 4th.rst","notebooks/Advent of Code 2017 December 5th.rst","notebooks/Advent of Code 2017 December 6th.rst","notebooks/Categorical.rst","notebooks/Developing.rst","notebooks/Generator_Programs.rst","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Replacing.rst","notebooks/Trees.rst","notebooks/Treestep.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst"],objects:{"joy.joy":{joy:[1,1,1,""],repl:[1,1,1,""],run:[1,1,1,""]},"joy.library":{"void":[3,1,1,""],BinaryBuiltinWrapper:[3,1,1,""],DefinitionWrapper:[3,2,1,""],FunctionWrapper:[3,1,1,""],SimpleFunctionWrapper:[3,1,1,""],UnaryBuiltinWrapper:[3,1,1,""],add_aliases:[3,1,1,""],app1:[3,1,1,""],app2:[3,1,1,""],app3:[3,1,1,""],b:[3,1,1,""],branch:[3,1,1,""],choice:[3,1,1,""],clear:[3,1,1,""],cmp_:[3,1,1,""],concat:[3,1,1,""],cond:[3,1,1,""],cons:[3,1,1,""],dip:[3,1,1,""],dipd:[3,1,1,""],dipdd:[3,1,1,""],divmod_:[3,1,1,""],drop:[3,1,1,""],dup:[3,1,1,""],dupd:[3,1,1,""],dupdip:[3,1,1,""],first:[3,1,1,""],floor:[3,1,1,""],genrec:[3,1,1,""],getitem:[3,1,1,""],help_:[3,1,1,""],i:[3,1,1,""],id_:[3,1,1,""],ifte:[3,1,1,""],infra:[3,1,1,""],initialize:[3,1,1,""],inscribe:[3,1,1,""],loop:[3,1,1,""],map_:[3,1,1,""],max_:[3,1,1,""],min_:[3,1,1,""],over:[3,1,1,""],parse:[3,1,1,""],pm:[3,1,1,""],pop:[3,1,1,""],popd:[3,1,1,""],popdd:[3,1,1,""],popop:[3,1,1,""],pred:[3,1,1,""],remove:[3,1,1,""],rest:[3,1,1,""],reverse:[3,1,1,""],rolldown:[3,1,1,""],rollup:[3,1,1,""],select:[3,1,1,""],sharing:[3,1,1,""],shunt:[3,1,1,""],sort_:[3,1,1,""],sqrt:[3,1,1,""],stack_:[3,1,1,""],step:[3,1,1,""],succ:[3,1,1,""],sum_:[3,1,1,""],swaack:[3,1,1,""],swap:[3,1,1,""],take:[3,1,1,""],times:[3,1,1,""],tuck:[3,1,1,""],uncons:[3,1,1,""],unique:[3,1,1,""],unstack:[3,1,1,""],warranty:[3,1,1,""],words:[3,1,1,""],x:[3,1,1,""],zip_:[3,1,1,""]},"joy.library.DefinitionWrapper":{add_def:[3,3,1,""],add_definitions:[3,3,1,""],parse_definition:[3,3,1,""]},"joy.parser":{ParseError:[24,4,1,""],Symbol:[24,2,1,""],text_to_expression:[24,1,1,""]},"joy.utils":{pretty_print:[25,0,0,"-"],stack:[26,0,0,"-"]},"joy.utils.pretty_print":{TracePrinter:[25,2,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[25,5,1,""],viewer:[25,5,1,""]},"joy.utils.stack":{expression_to_string:[26,1,1,""],iter_stack:[26,1,1,""],list_to_stack:[26,1,1,""],pick:[26,1,1,""],pushback:[26,1,1,""],stack_to_string:[26,1,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[24,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","classmethod","Python class method"],"4":["py","exception","Python exception"],"5":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:classmethod","4":"py:exception","5":"py:method"},terms:{"0b11100111011011":11,"10m":13,"10n":13,"4ac":18,"5bkei":[17,20],"\u03b5":15,"abstract":[14,17,20],"boolean":[2,3,14,17,20],"break":[9,14],"byte":11,"case":[2,3,5,9,13,21,26],"class":[3,14,24,25,26],"default":[3,8,12,17,26],"export":[3,24],"final":[2,6,13,17],"float":[3,14,22,24],"function":[0,1,4,5,6,7,8,10,11,12,16,22,23,24,25,26],"g\u00e9rard":22,"import":[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],"int":[6,12,13,14,22,24,26],"long":[17,23],"new":[2,3,6,12,13,14,15,16,19,20],"public":16,"return":[1,3,5,6,8,9,11,13,14,15,17,18,19,20,21,24,25,26],"short":18,"static":[2,16],"switch":2,"throw":17,"true":[2,3,5,6,11,13,20],"try":[6,12,13,21],"void":[0,3],"while":[3,6,8,9,14,17,20,24,26],Adding:[14,23],And:[4,6,11,12,13,15,17,20,22,26],But:[0,5,10,11,12,13,14,17,19,20],CPS:14,For:[2,3,4,5,6,7,8,13,17,20,23,26],Going:5,Has:3,Its:3,Not:6,One:[2,14,23],RHS:20,TOS:[2,3,13],That:[11,13,17,20],The:[0,1,2,3,4,5,6,7,8,10,12,15,16,18,22,23,24,26],Then:[2,3,5,8,17,18,20],There:[6,8,13,20,21,26],These:[23,26],Use:[3,13,15],Using:[0,6,13,15,17,20,23],With:[4,13,15,23],__str__:25,_tree_add_:17,_tree_add_e:17,_tree_add_p:17,_tree_add_r:17,_tree_add_t:17,_tree_delete_:17,_tree_delete_clear_stuff:17,_tree_delete_del:17,_tree_delete_r0:17,_tree_delete_r1:17,_tree_delete_rightmost:17,_tree_delete_w:17,_tree_get_:17,_tree_get_p:17,_tree_get_r:17,_tree_get_t:17,_tree_iter_order_curr:17,_tree_iter_order_left:17,_tree_iter_order_r:17,_tree_iter_order_right:17,_tree_t:17,_treestep_0:21,_treestep_1:21,_within_b:15,_within_p:15,_within_r:15,aaa:7,abbrevi:[20,21],abl:18,about:[0,6,8,14,17,20,22,26],abov:[0,6,11,15,17,18,20],abs:[6,15],absolut:[6,14],accept:[1,2,3,11,12,13,14,15,17,20,21,22],access:[6,8],accomplish:18,accordingli:[17,20],accumul:11,across:[6,8],act:15,action:[14,22],actual:[2,6,11,14,17,20],adapt:23,add:[3,4,5,6,11,12,14,18,25],add_alias:3,add_def:3,add_definit:[3,8,13,17,20,21],add_if_match:4,add_valu:8,added:[10,17,20],adding:[6,16],addit:[0,2,3,8,11,13,14,20,21],address:23,adjust:17,admit:6,advantag:13,after:[4,6,8,11,12,14],afterward:14,again:[2,3,6,8,11,14,15,17,20],against:[5,6],aggreg:[3,22],aka:[14,22],albrecht:0,algebra:20,algorithm:14,alia:3,alias:[3,14],align:[14,25],all:[3,4,5,11,12,13,14,17,20,21,25],alloc:6,allow:[13,16,17,20],almost:[17,20],along:[13,14],alphabet:3,alreadi:[6,15,18,19,22],also:[0,11,13,14,17,20,26],altern:[10,20],although:[4,10,17,20],altogeth:12,alwai:[6,11,13,16],amort:[17,20],amount:6,analysi:[10,23],anamorph:14,ani:[8,10,11,14,16,17,20,22,24],annual:14,anonym:[17,20],anoth:[4,13,17,20,26],answer:6,anyth:[2,3,14],aoc20017:5,aoc20173:6,aoc2017:[4,5,6,7,8,9],api:16,app1:3,app2:[3,5,14,18,19],app3:3,app:14,appear:[2,7,10,11,17,20],append:8,appendix:23,appli:[2,3,5,11,12,17,20],applic:12,approach:11,approxim:23,archiv:0,aren:22,arg:[2,3],argument:[2,3,13,14,15,25,26],arithmet:2,ariti:2,around:[11,26],arrai:8,arrang:[8,21],arriv:[12,20,21],articl:[0,10,12],ask:[6,10,12],aspect:[0,6],assembl:8,assert:[6,9],assign:26,associ:[17,20],assum:[4,5,7,8,15],asterisk:[20,21],attack:14,attempt:[0,1],attribut:3,automat:[10,13],auxiliari:21,avail:[0,7],averag:[14,19],avoid:[17,20],awai:17,awar:2,awkward:[17,20],azur:23,back:[6,8,17,20],backward:[16,17,20,21],bag:14,banana:[13,20],bank:9,barb:13,base:[0,2,3,5,9,13,16,21],basic:[1,2,3,4,6,14,17,20],bear:8,beat:8,becaus:[2,3,4,5,6,8,13,14,17,20,21,22,26],becom:[4,17,18,20,21,26],been:[13,15,16,17,18,20,22],befor:[5,8,12,13,14,17,20],begin:[6,13,17,20,21],behavior:[16,20,21],behaviour:[0,1],behind:8,being:0,belong:8,below:[2,3,6,11,12,17,20,22],bespok:14,best:0,better:[6,11,17,20],between:[0,5,6,11],beyond:12,biannual:14,big:[6,8,20],binari:[0,12,14,20,23],binary_search_tre:[17,20],binarybuiltinwrapp:3,bind:14,bingo:22,bit:[6,11,12,17,20],block:[9,11],bodi:[2,14,17,20],body_text:3,bool:[5,13],borrow:14,both:[2,6,8,11,13,14,18,19,20,26],bottom:12,boundari:6,bracket:[6,14,24],branch:[3,4,5,8,11,12,20],breakpoint:14,bring:[11,14],btree:[17,21],buck:[17,20],bug:[0,14],build:[12,13,14,20,22,26],built:[13,18],bundl:[2,3],burgeon:14,calcul:6,calculu:10,call:[2,13,14,15,16,17,20,25,26],caller:[17,20],came:[8,20],can:[0,2,3,4,5,6,10,11,12,13,14,15,16,18,19,21,22,23,26],candid:5,captur:14,card:14,care:[6,11,26],carefulli:[20,22],carri:[4,6,12,13,17],cartesian:10,categor:[0,18,23],categori:10,ccc:10,ccon:[17,20],ceil:6,certain:[14,26],certainli:[17,20],chain:3,chang:[2,6,8,16,17,20,22],charact:22,chat:14,chatter:0,cheat:9,check:[5,12,13],checksum:5,child0:20,child:21,childn:20,children:20,choic:[3,13],choos:[16,20],cinf:17,circuit:10,circular:[4,20],cite_not:[17,20],classmethod:3,claus:3,clear:[3,6,11,14],clear_stuff:17,cleav:[4,5,7,14,18,19],close:[0,1,10],clunki:11,cmp:[3,21,23],cmp_:[3,20],code:[0,1,10,13,20,23],codireco:12,collaps:13,collect:[10,12,14],column:6,combin:[0,3,7,11,12,14,15,21,22,23],come:[6,8,14,17],command:[4,14,17,18,20],common:[2,11,13],compar:[3,6,10],comparison:[0,17],compel:10,compil:[2,8,10,13,14,17,19,23],complet:10,complex:[3,22],compos:13,compound:[17,20],comput:[2,5,6,8,10,11,14,18],con:[3,5,8,9,11,12,13,14,15,17,18,21,22,26],conal:10,concat:[3,4,12,13,14,20,21],concaten:0,concatin:[0,3,26],concis:6,concret:13,concurr:2,cond:[3,17],condit:[3,8,14],condition:5,confid:6,conflict:[17,20],cons2:20,consecut:23,consid:[8,11,12,13,17,20,21,22],consist:[2,6,12,14,20,21],constant:[17,20],constitu:13,consum:[5,13],contain:[0,2,3,6,7,12,13,14],context:2,conting:17,continu:[0,5,13,22],control:14,conveni:10,convert:[13,19,20,21,24,26],cook:13,cool:[17,20],copi:[2,3,4,11,13,17,20,21,23],copyright:14,corner:6,correct:6,correctli:20,correspond:10,could:[2,6,8,10,11,13,14,16,17,20,22],count:[3,6,7],count_stat:9,counter:11,coupl:21,cours:[6,8,11,13,17,20],cover:6,cpu:6,crack:[17,20],crap:[],crash:[17,20],creat:[0,2,3,4,11,13,15,17,20],crude:[17,20,24],current:[2,3,8,13,14,21,22,25],custom:16,cycl:[11,12],cython:14,dai:[13,14],data:[2,3,6],datastructur:[0,2,13,23,24,26],datatyp:26,ddididi:22,deal:[0,4,17,20],debugg:13,decid:[17,20],decor:3,decoupl:13,decreas:6,decrement:3,deduc:11,deeper:0,deepli:10,def:[3,6,8,9,13,14,18,19,20,26],defi:3,defin:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23],definit:[2,3,7,8,11,12,13,14,15,16,17,20,21,23],definitionwrapp:[3,8,13,17,20,21],deleg:14,delet:23,demonstr:[10,13],depend:[3,13,17,20],deposit:[20,21],dequot:[4,13],der:17,deriv:[2,3,4,5,11,14,15,17,23],descend:5,describ:[3,10,13,17,20,21,24],descript:[11,14,20],design:[2,3,5,17,20],desir:[6,14,20,21],destruct:[17,20],detail:[6,14,17,20],detect:[5,12,13,17,20],determin:[5,6,23],develop:[0,12,14,23],diagram:11,dialect:1,dict:[1,3],dictionari:[0,1,3,14,15,18,20,23],did:6,didn:13,differ:[0,5,7,10,11,13,15,17,18,20,26],differenti:10,dig:[17,22],digit:[4,11],dimension:6,dinfrirst:14,dip:[3,5,6,8,9,11,12,13,14,15,17,18,19,20,21,23],dipd:[3,8,12,13,14,17,18,20,22],dipdd:[3,17,20],direco:[9,15,23],direct:14,directli:[6,11,20,21,26],disappear:2,discard:[3,12,13,15,17,20],disciplin:17,discov:5,disenstacken:[14,20],disk:14,displac:2,distanc:6,distribut:9,ditch:[17,20],div:[3,14],dive:[20,21],divid:5,divis:[5,17,20],divisor:5,divmod:[3,5],divmod_:3,doc:[2,3,14],document:[23,24,26],doe:[0,1,5,6,8,10,12,13,14,23,25],doesn:[4,8,11,13,16,17,20,21,26],dog:20,doing:[6,10,11,13,14,22],domain:[6,10],don:[5,6,8,11,14,17,20],done:[2,11,14,16,18],doodl:6,door:14,dot:25,doubl:[11,14],down:[2,3,6,8,15,22],down_to_zero:14,downward:8,dozen:14,draft:[9,10,16],dream:14,drive:12,driven:[11,15],driver:12,drop:[3,4,17,20],dudipd:14,due:4,dummi:5,dup:[3,4,5,6,8,9,11,12,13,14,15,17,18,20,22,26],dupd:3,dupdip:[3,5,6,11,13,17,18,20],duplic:[3,7,13,17,20],durat:2,dure:[2,13],each:[2,3,4,5,6,8,10,11,13,14,19,20,21,25],easi:[0,6,17,20,21,22],easier:[3,4,17,20],easili:10,edit:23,effect:[2,3,14,22],effici:[6,8,12,19,22],either:[1,2,3,5,13,17,20],eleg:[8,14,17,18,20],element:[2,3],elliott:10,els:[2,3,4,5,8,9,13],embed:[10,17,20,22],empti:[3,5,14,21,26],encapsul:14,enclos:14,encod:[8,12],encount:8,end:[6,8,11,13,17,21,26],endless:12,enforc:[2,14],engend:14,enlarg:6,enough:[6,13,14,18,25],enstacken:[12,14],ensur:7,enter:14,entir:26,entri:[3,22,25],epsilon:15,equal:[11,21,26],equat:[6,14,15],ergo:[6,13,17,20],err:[17,20],error:[6,14,24],escap:8,essai:0,etc:[3,6,21,22,24],euler:23,eval:0,evalu:[1,2,3,4,13,14,15,17,18,19,20,21],even:8,evenli:5,eventu:[6,18],everi:12,everyth:[3,17,20],evolv:16,exactli:13,exampl:[0,3,4,5,6,7,8,11,13,15,20,23,24,26],exce:12,except:[14,17,20,24],execut:[0,1,2,3,5,14,19,21,22,26],exercis:17,exist:[10,17],exit:8,expand:17,expect:[2,3,5,13,20,21,26],experi:[14,21],experiment:6,explan:14,explor:14,express:[0,1,2,3,10,13,17,19,20,22,25,26],expression_to_str:26,extend:6,extra:[4,5,11,12],extract:[17,23],extrem:14,extrememli:14,facet:0,facil:14,fact:[20,24],factor:[2,11,14,17],fail:[2,3,5,17,20,24],fals:[2,3,5,9,11,13],far:[8,13,15,17,20],fascin:0,fast:6,faster:6,favorit:[],fear:[17,20],feel:6,few:[6,11,14],fewer:[3,14],fib:12,fib_gen:12,fibonacci:23,figur:[2,3,6,17,20],filter:[17,20],fin:11,find:[2,3,4,5,11,12,20,21,23],finder:15,fine:[0,11,17,20],finish:18,first:[3,4,5,6,8,9,12,13,14,15,17,18,19,20,21,22,23],first_two:17,fit:[11,14,18],five:[11,13,14,23],fix:[2,3],flag:5,flatten:[14,20,21],flexibl:[20,23],floor:[3,6],floordiv:11,flow:14,follow:[0,2,3,5,8,13,14,15,16,21,22],foo:[14,16,17,20],foo_ii:16,form:[2,3,5,7,10,11,12,21,26],forman:14,format:[23,25],formula:[0,6,11,23],forth:[4,8,14,20],fortun:8,forum:0,forward:[5,8],found:[8,9,14,20],four:[2,3,6,8,11,12,14,17,20],fourteen:11,fourth:[2,3,4,17,20],fractal:14,fraction0:14,fraction:[2,14],framework:14,free:[10,14,17,20],freeli:[2,6],from:[0,1,2,3,4,5,6,7,8,9,11,12,14,15,17,18,19,20,21,22,23,26],front:[2,3],full:[7,11],fun:6,functionwrapp:[3,20],funtion:[17,20],further:[15,23],futur:18,garbag:14,gari:[17,20],gcd:14,gen:9,gener:[0,2,3,6,8,10,23,26],genrec:[3,5,8,13,14,17,20,21],geometr:11,geometri:20,get:[2,5,6,10,11,12,13,14,23],get_valu:8,getitem:3,getrecursionlimit:26,getsourc:14,ghc:10,give:[6,10,11,13,15,17,21,26],given:[2,3,4,5,6,8,9,11,12,15,17,22,23],glue:14,goal:8,going:[5,6,8,17,20,21,22],good:[8,11,17,20],grab:3,grammar:24,grand:14,graph:6,great:[0,4,6,14,23],greater:[6,26],grid:6,group:[0,6],gsra:15,guard:[5,6,17],had:[11,22],haiku:14,half:[11,22],half_of_s:4,halfwai:4,hand:[14,18,19,20,23],handi:15,handl:[17,26],happen:[6,14,20],hard:22,hardli:13,hardwar:10,has:[0,2,5,6,8,12,13,14,15,16,17,18,20,22,26],haskel:10,have:[2,3,4,5,6,8,9,11,12,13,14,15,16,20,22,23,26],head:[5,13,26],help:[7,13,14,17,20],help_:3,helper:[3,5],herd:14,here:[6,11,12,13,17,20,21,22],heterogen:20,heurist:[4,8],hide:[17,20],higher:[14,17,20],highest:[5,20],highli:[14,20],hindsight:5,histori:25,hmm:[17,20],hog:20,hoist:3,hold:11,hood:[8,17],hope:[0,11,14,23],host:23,how:[0,6,7,8,10,13,17,20,22,23],html:[2,3,12,18,23],http:[17,20],huet:22,huge:17,hugh:[15,20,21],human:14,hypothet:2,id_:3,idea:[10,11,14,20],ident:[3,13],identifi:6,if_not_empti:17,ift:[3,4,5,8,13,17,20,21],ignor:[3,17,20],illustr:13,imagin:22,imit:21,immedi:[8,13],immut:[14,17,20],imper:13,implement:[0,1,2,3,6,9,10,13,14,16,17,18,20],impli:5,implicit:14,includ:[7,10,17,21],inclus:11,incom:26,incompat:16,incr_at:8,incr_step_count:8,incr_valu:8,increas:[6,8,11],increment:[3,10,11,16],index:[0,6,9,14,26],index_of:9,indexerror:26,indic:[20,21],infil:20,infinit:6,inform:3,infra:[3,12,13,14,17,18,19,21,23],infrastructur:3,init:8,init_print:6,initi:[2,3,5,6,7,8,14,15,17,20],inlin:[17,20],inner:5,input:[1,4,5,6,7,13,15],inscrib:3,inspect:14,instal:0,instanti:[10,25],instead:[6,11,12,13,17,20,22,26],instruct:8,integ:[2,3,4,5,6,7,8,13,14,21],integr:3,intend:[0,14],interact:[14,23],interest:[0,6,11,17,20,23],interlock:6,interlud:23,intermedi:13,intern:[0,25,26],interpret:[0,10,13,16,24,25],interrupt:14,interv:[10,11],introduc:16,introduct:0,invari:3,invers:3,investig:[],ipf:14,ipynb:[],isn:[13,17,22],item:[2,3,4,5,9,13,14,17,20,21,23,26],iter:[1,3,6,13,14,21,23,26],iter_stack:[9,19,26],its:[0,2,3,5,6,10,11,13,14,17,20,21,26],itself:[0,2,8,14,17,20],j05cmp:[2,3],jenni:20,job:[8,23],john:[15,20,21],joi:[2,4,5,7,8,9,10,15,16,17,18,19,20],joypi:[8,9,13,14,20,22],jump:8,jupyt:23,just:[0,2,3,4,5,6,8,12,13,14,16,17,21,22],keep:[17,22],kei:[21,23],kevin:0,key_n:[17,20],keyerror:[17,20],kind:[2,6,8,10,13,14,17,20,21],kleen:[20,21],know:[6,11,13,17,20],known:10,l_kei:17,l_left:17,l_right:17,l_valu:17,labda:[],lambda:[10,13],lambdifi:6,languag:[10,14,16,17,18,20],larg:6,larger:[6,26],largest:[3,5,8],last:[4,8,11,13,17],lastli:[12,13],later:[8,14,21],law:2,lazi:15,lazili:15,lcm:11,lead:[8,14],leaf:[17,20],lean:14,learn:[0,9],least:[2,6,8,11,13,26],least_fract:14,leav:[5,6,8,11,20],left:[6,13,14,21,22,25,26],leftov:13,legendari:8,legibl:8,len:9,length:[3,11,26],lens:13,less:[11,12,13,14,26],lesser:6,let:[4,5,6,8,12,13,15,17,18,20,21,22],level:[10,17,20],librari:[0,6,8,9,15,19,20],lieu:20,like:[2,3,5,6,9,11,13,14,15,18,21,23,24],line:[3,5,8,13,14,17,20,25],linear:26,link:0,linux:0,list:[0,3,4,5,7,8,9,11,14,15,17,21,22,25],list_to_stack:[8,9,26],liter:[1,17,20,21,22,24],littl:[6,8,12,17,20,23],live:23,lkei:[20,21],load:[11,14],locat:[2,6],locu:25,log_2:[17,20],logic:[0,11],longer:[17,20],look:[6,12,14,15,17,20],lookup:[14,20],loop:[0,1,3,11],lot:[14,17,18,20,22],love:11,low:10,lower:[11,20],lowest:[5,17,20],machin:[0,20],machineri:[17,20],macro:14,made:[0,5,14,20,22],mai:[2,8,13,20],mail:0,main:[0,3,4,14,22],mainloop:16,maintain:22,major:16,make:[2,3,4,10,11,13,14,17,19,21,22,23],make_distributor:9,make_gener:15,manfr:[0,2,3,10],manhattan:6,mani:[0,6,7,8,13,14],manipul:6,manual:[6,13],map:[1,3,11,13,14,16,20,21],map_:3,mark:[6,8],marker:14,mask:[11,12],match:[0,1,4],materi:0,math:[0,6,8,14,17,20],mathemat:[6,14],matter:[4,11,13,15,17,20,21],max:[5,6,9],max_:3,maximum:[3,20],maxmin:5,mayb:[13,17,20],maze:8,mean:[5,10,11,13,14,15,17,20,21,26],meant:[13,14,17,18,20,21],meantim:8,mem:8,member:[2,3,6],memori:6,mental:14,mention:2,mercuri:0,merg:20,meta:[14,17,20],methink:20,method:[0,3,6,14,23,25],mfloor:6,midpoint:11,might:[4,10,12,13,17,20],mike:17,million:12,min:5,min_:3,mind:8,minimum:3,minor:17,minu:[3,18],mirror:0,miscellan:0,mistak:9,mix:14,mnemon:4,mod:3,model:[10,14],modern:0,modif:12,modifi:[8,14,17,22],modul:[0,1,3,14,24],modulu:14,monkei:6,month:14,more:[0,3,7,8,10,11,12,13,14,15,18,19,20,21,24,26],most:20,mostli:0,move:[4,6,8,17],movement:2,mrank_of:6,much:[6,8,11,12,13,17,20],muck:[17,20],mul:[14,18,22,25],multi:3,multipl:[13,23],must:[2,3,5,6,7,11,13,16,21],mutabl:8,n_rang:[],nail:8,name:[1,3,4,14,16,17,22,23,24,26],natur:[11,12,17,20],navig:22,neat:17,need:[2,3,4,5,6,8,9,11,12,13,15,16,17,20],neg:[3,8,18],nest:[3,14,17,20,22],network:14,never:16,new_kei:17,new_valu:17,newton:[0,23],next:[4,5,6,8,11,13,20,21],nice:[0,4,6,13,26],niether:2,node:[21,23],node_kei:[17,20],node_valu:[17,20],non:[5,20,21],none:[1,3],nope:21,normal:[7,13],notat:[14,17,20],note:[2,6,11,15,17,20,26],notebook:[11,12,14,22,23],notebook_preambl:[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],noth:[2,17,20],notic:11,now:[4,5,6,11,12,13,14,19,21,23],nth:[3,26],nullari:[5,8,9,14,17,20],number:[1,2,3,5,11,12,26],object:24,observ:11,obviou:12,obvious:[5,7,8],occur:[17,20],odd:[11,12],off:[2,3,6,11,12,22],offset:8,offset_of:6,old:[2,19],old_k:17,old_kei:17,old_valu:17,omit:13,onc:[3,7,16,17,18,20],one:[2,3,4,5,6,7,8,11,12,13,17,20,21,25,26],ones:12,onli:[2,3,4,5,6,8,11,13,17,20,22,26],onto:[1,2,3,14,26],open:[7,14],oper:[3,5,13,14,17,20,26],oppos:4,optim:17,option:[1,14,17,20,26],order:[0,2,3,4,5,13,14,23,26],org:[0,17,20],origin:[0,1,2,3,4,17,20,22],other:[0,2,3,5,6,10,13,14,17,20,21,26],otherwis:[3,5,11,12,17,20,21],our:[4,5,6,11,12,13,14,15,21],ourselv:13,out:[2,3,6,10,11,12,13,14,17,20,22],outcom:[20,21],output:[6,13,15],outsid:[8,10],outward:6,over:[3,4,6,10,11,12,14,15,17,18,20,21,23],overhead:6,overkil:13,overshadow:6,own:[6,17,20],pack:[20,26],packag:[0,14],page:[0,17,18,20,26],pair:[2,3,4,5,11,12,17],pair_up:4,palidrom:11,palindrom:11,pam:14,paper:[6,10,13,14,20,22],parallel:2,paramet:[1,2,3,8,13,24,25,26],parameter:23,paranthes:20,parenthes:[8,17,20,26],pariti:12,pars:[0,3,14,20],parse_definit:3,parseerror:24,parser:0,part:[2,3,5,8,13,15,18,20,21],partial:[6,13],particular:22,particularli:8,pass:[0,17,20,25],passphras:7,path:[6,23],pattern:[6,11,20,21],payoff:13,pe1:[11,12],pe2:12,pearl:22,pend:[3,13,14,22,25],peopl:23,per:[6,14,21],perform:8,perhap:12,period:14,permit:[8,26],persist:[17,20],phase:2,pick:[11,12,26],pickl:14,pictur:[17,20],piec:13,pip:0,pita:9,place:[3,6,8,11,13,14],plai:0,plain:8,plane:6,plu:[3,6,18],plug:[12,13,20,21],point:[6,10,13,14,17,20],pointless:2,pop:[3,4,5,8,9,11,12,13,14,17,18,19,20,21,26],popd:[3,8,14,15,17,19],popdd:[3,5,12,18],popop:[3,4,5,8,9,11,12,13,14,15,17,20,21],port:6,posit:[3,8,11,13,14],possibilit:[17,20],possibl:[5,17,20,21,23],post:[14,20],potenti:3,power:14,pragmat:11,pre:[8,13,20],preambl:15,precis:[0,1],pred:3,predic:[2,3,5,12,13],prefer:13,prefix:[13,25],prep:[5,20],prepar:[8,13],preprocessor:13,present:20,preserv:[10,21],pretti:[6,17,18,20,21,25,26],pretty_print:0,prevent:13,previou:[6,8,14],prime:[5,15],primit:[2,3,8,18],primrec:[3,5,8,9,12,13,14,15],print:[0,1,2,3,6,13,25,26],probabl:[4,12,14,17,20],problem:[6,14,23],proc_curr:[17,20],proc_left:[17,20],proc_right:[17,20],proce:[4,11],process:[8,13,14,21,25],processor:20,produc:[4,11,13,17,20,21],product:[12,14],program:[0,2,3,4,5,6,8,12,14,15,17,22],project:23,prompt:14,proper:[2,3],properli:8,properti:0,provid:[0,3,10,14],prune:20,pun:[0,14],pure:[0,20],puriti:14,purpos:14,push:[2,3,13,14,22,26],pushback:[14,20,26],put:[1,2,12,14,23,26],puzzl:[4,5,6,7],pypi:0,pyramid:6,python:[0,2,3,6,8,13,17,18,20,22,23,24,26],quadrat:[0,6,23],queri:[17,20,21],query_kei:21,queu:13,quit:[0,1,6,21],quot:[0,3,12,13,14,15,17,18,20,21,22,25],quotat:[2,3],quotient:3,r_kei:17,r_left:17,r_right:17,r_valu:17,rais:[17,20,24,26],random:8,rang:[6,13,14],range_sum:13,range_to_zero:14,rank_and_offset:6,rank_of:6,raphson:15,rather:[11,13,14,20,21],ratio:14,reach:[8,11,12,13],read:[0,1,11,12,17,20,22],readabl:19,reader:17,real:[17,20],realiz:[4,8,10,17,20],realli:6,rearrang:[2,13,17],reason:[6,11,14],rebuild:[21,22],rec1:[2,3],rec2:[2,3],recogn:24,record:[14,25],recur:13,recurs:[2,3,5,8,9,12,14,15,23,26],recus:14,recusr:20,redefin:23,redistribut:[3,14],reduc:2,redund:26,reexamin:20,refactor:[13,14,16],refer:[0,2],regist:2,regular:24,reimplement:23,rel:[8,18],releas:16,relev:6,remain:[2,3,14,16],remaind:[3,15],remind:13,remov:[3,6,17,20,26],renam:20,render:[20,23],repeat:[4,6,11],repeatedli:11,repl:[0,1],replac:[0,2,3,12,13,20,21,22,23,26],repositori:0,repres:[2,14,17,20,24,25],represent:26,reprod:12,request:6,requir:[6,26],resembl:14,reset:[],respect:11,rest:[3,5,9,11,12,14,17,20,22,23,26],rest_two:17,restor:2,result:[1,2,3,5,11,13,17,18,20,21,22],resum:14,retir:2,retri:14,reus:[17,20],revers:[3,4,5,11,12,13,22,26],rewrit:[3,8,14],rewritten:14,richard:20,rid:[17,20],right:[6,12,13,14,21,23,25,26],rightest:17,rightmost:11,rkei:[20,21],role:20,roll:[3,5,7,8,13,15,17,18,20,21],rolldown:3,rollup:3,root:[3,6,18,23],rotate_seq:4,round:4,row:[5,6],row_valu:6,run:[0,1,3,6,11,13,14,15,17,20,21,22],runtim:6,runtimeerror:26,sai:[12,17,20,21],same:[2,10,11,13,17,20,26],sandwich:[2,3],save:[2,11,14],scan:3,scanner:[14,24],scenario:22,scheme:20,scope:[4,12,17,20],search:[0,6,17,20],second:[3,4,5,13,14,17,20,21,26],secur:7,see:[0,6,12,13,14,16,19,20,22,25],seem:[0,9,11,14,20,21],seen:22,select:[3,6],semant:[2,3,14,16,17,20],semi:14,send:14,sens:[0,2,11,22],separ:14,sequenc:[0,1,2,3,4,5,7,8,9,11,14,17,19,20,22,23,24],seri:[6,11,12,13,17,20,22],serv:13,set:[2,3,13,23],seven:[11,12],sever:[0,10,14],share:[3,6,14],shelf:2,shift:[11,12],shine:8,shorter:23,shortest:6,shorthand:17,should:[2,3,5,11,13,17,20],shouldn:14,show:[6,10,20,22],shunt:[3,22],side:[17,20],sign:6,signal:5,signifi:[14,17,20],silli:20,similar:[17,20,21],simon:14,simpl:[6,13,14,26],simplefunctionwrapp:[3,8,9,19],simpler:21,simplest:23,simpli:10,simplifi:[6,11,17,20,22,23],sinc:[2,6,11,17,18,20],singl:[3,12,14,19,24],situ:[17,20],situat:[17,20],six:[11,12,14],sixti:[11,12],size:[4,7,8,9,14,23],skeptic:14,skip:[6,8],slight:15,slightli:[13,17,20],small:[4,20],smallest:[3,5],smart:[8,13,17],sneaki:6,softwar:14,solei:2,solut:[6,11,12],solv:6,solvabl:14,some:[2,3,5,6,8,12,13,14,17,20,21,23,26],somehow:[17,20],someth:[2,4,8,16,17],sometim:[17,20],somewher:[13,17,20,23],sophist:6,sort:[3,5,13,17,18,20],sort_:3,sourc:[0,1,3,23,24,25,26],space:[6,11,25],span:11,special:[12,13,17,20],specif:[0,10],specifi:17,speed:[6,8,19],spell:21,sphinx:[23,26],spiral:6,spirit:[0,1,20,21],split_at:4,spreadsheet:5,sqr:[14,18,22],sqrt:[3,6,15,18],squar:[3,6,23,24],stack:[0,1,3,5,8,9,11,12,13,15,17,18,19,20,21,22,24,25],stack_:3,stack_to_str:26,stage:[20,21],stai:[0,1],stand:10,standard:[14,17],star:[20,21],stare:[17,20],start:[5,6,8,9,11,12,13,14,15,17,20,21],state:[5,8,14],statement:3,step:[3,4,5,6,7,11,14,17,18,19,20,22,23],step_zero:[4,5,7],still:[6,8,13,17],stop:[17,20],storag:[11,13,17,20],store:[6,11,13],stori:13,str:[1,24,25,26],straightforward:[1,4,6,12,23],strang:8,stream:[11,15],stretch:17,string:[1,2,3,4,14,22,24,25,26],strip:6,structur:[13,14,20,21,22,23,26],stuff:[17,20],style:[0,10],sub:[16,20],subclass:14,subject:22,subract:6,substitut:[6,13,17],subtract:[5,6,11],succ:3,success:15,suffici:[8,13,17],suggest:[5,10,17,20],suitabl:[3,10,11],sum:[3,4,5,12,13,14,18,19,20,21],sum_:3,summand:11,sumtre:21,suppli:[13,17,20,24],support:[6,14,25,26],sure:[6,13],suspect:2,swaack:[3,13,18,19,20,22],swap:[3,4,5,6,7,9,11,12,13,14,15,17,19,20,21,22],swon:[3,9,12,13,14,20,21,22],swoncat:[8,9,12,13,14,15,20,21],symbol:[2,3,6,18,22,24],symmetr:[11,17,20],sympi:18,syntact:14,syntax:[14,26],sys:[6,26],system:[6,7,14,17,20],tail:[5,17,20,26],take:[3,4,6,8,11,14,15,17,18,20,26],taken:8,talk:[14,17,20,26],target:[6,22],task:6,tast:10,tbd:14,technic:2,techniqu:[10,22],technolog:2,teh:20,temporari:22,ten:11,term:[1,2,5,8,9,13,14,15,23,24,26],termin:[2,3,5],ternari:14,test:[2,3],text:[0,1,3],text_to_express:[14,24],textual:14,than:[0,3,6,7,11,12,14,15,18,21,26],thei:[2,5,6,11,12,13,14,17,20,22,24,26],them:[2,3,5,6,11,12,13,17,20,22,23],theori:[2,3],therefor:[12,20],thi:[0,1,2,3,4,5,6,8,9,10,11,12,13,14,18,21,22,23,24,25,26],thing:[2,5,6,8,12,13,17,18,20,22,24,26],think:[2,8,11,13,14,17,20,21],third:[3,4,5,12,14,17,20],thirti:11,those:[2,3,5,6,8,13,17,20,23],though:[11,20],thought:14,thousand:11,thread:2,three:[2,3,8,11,14,17,20,21,23],through:[1,11,14,21,22,26],thu:4,thun:[2,3,10,16],thunder:14,tied:20,tile:6,time:[3,6,8,9,11,13,14,17,20,22],tini:20,to_set:[17,20],todai:14,todo:[14,24],togeth:[12,14,23],token:24,toler:23,tommi:20,too:[13,20],took:6,tool:14,top:[2,3,14,25,26],total:[4,6,11],total_match:4,trace:[0,14,18,22,23,26],traceprint:25,track:22,tracker:0,trade:6,transform:[10,13],translat:[6,10,13],travers:[0,23],treasur:0,treat:[0,2,3,23],treatment:12,tree:[0,14,23],treegrind:23,treemap:13,treestep:[0,23],tri:11,trick:[11,20],tricki:[6,8],trivial:[5,8,20],trobe:0,trove:0,truediv:18,truthi:[3,14],ts0:[13,20],ts1:[13,20],tuck:[3,5,14,20],tupl:[3,14,26],turn:[2,3,6],twice:[6,13,17,20],two:[2,3,5,6,11,13,14,15,17,20,21,22,23,26],type:[1,10,13,14,17,24,25,26],typic:[2,3],unari:[8,13,14],unarybuiltinwrapp:3,unbalanc:[17,20,24],unchang:17,uncon:[3,4,5,12,13,14,17,20,21,22],under:[2,3,8,14,17],understand:[0,6,17,20],undistinguish:17,undocu:14,unfortun:26,uniqu:[3,7,17,20],unit:[4,13,14,20],univers:[0,14],unless:[6,13],unlik:13,unnecessari:23,unpack:[2,3,17,26],unpair:11,unquot:[13,14,20,21],unstack:3,untangl:13,until:[5,6,8,12],unus:11,unusu:[17,20],updat:[0,23],upward:8,usag:14,use:[0,2,3,6,8,10,11,12,14,15,16,17,18,19,20,21,22,26],used:[3,10,13,14,17,20,22,24,26],useful:0,user:[6,21],uses:[2,5,11,13],using:[3,5,6,12,13,17,18,20,21,22],usual:[0,2],util:[0,8,9,19,20],valid:7,valu:[0,2,3,5,6,11,13,14,15,19,21,23,26],value_n:[17,20],valueerror:26,vanilla:8,variabl:[13,23],variant:17,variat:[13,23],varient:20,varieti:[10,14],variou:0,vener:26,verbos:10,veri:[0,1,6,10,14,17,20,26],versa:2,version:[0,1,2,12,16,18,21,22,23],via:14,vice:2,view:[17,23],viewer:[1,14,16,25],von:[0,2,3,10],wai:[0,2,3,4,6,8,10,11,13,14,20],walk:20,wall:6,want:[2,6,8,11,12,15,17,20],warranti:[3,14],wash:14,wast:14,web:26,websit:[0,11],welcom:14,well:[0,4,5,6,10,14,17,20,24],were:[6,8,13,14,22],what:[2,3,5,8,9,10,13,14,17,18,20,21,25],whatev:[2,3,20,21,26],when:[11,12,13,14,15,17,20,22,24,26],where:[2,3,4,5,8,13,14,17,20,23,26],whether:13,which:[0,1,3,5,6,8,11,13,14,15,17,20,21,22,26],whole:[2,3,5,11,20,21],whose:12,why:[6,15,20,21],wiki:[17,20],wikipedia:[0,17,20,22],wildli:14,wind:14,winner:6,wire:13,wit:8,within:[14,17,20,23],without:[2,14,17,20],won:[17,20,26],word:[0,3,4,5,7,11,14,20,22],work:[0,3,4,5,6,8,11,12,13,14,17,20,21,22,26],worth:[6,11],would:[2,5,6,7,8,9,11,12,13,14,15,17,20,22,26],wouldn:8,wrap:[3,6,14],write:[4,6,8,10,13,15,17,20,21,22,23,26],written:[0,1,8,15,17,19,26],wrong:2,wtf:13,wtfmorphism:13,year:14,yet:[8,13,17,20,22],yield:[2,3,26],you:[0,2,3,5,6,8,11,12,13,14,16,17,19,20,21,22,25,26],your:[2,3,4,5,6,7,14],yourself:[14,17,20],zero:[3,5,6,8,13,17,20,21,24,26],zip:[4,11],zip_:3,zipper:[0,23],zstr:22},titles:["Thun 0.2.0 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Categorical Programming","Developing a Program in Joy","Using <code class=\"docutils literal notranslate\"><span class=\"pre\">x</span></code> to Generate Values","Hylomorphism","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Replacing Functions in the Dictionary","Treating Trees","Treating Trees II: <code class=\"docutils literal notranslate\"><span class=\"pre\">treestep</span></code>","Traversing Datastructures with Zippers","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026"],titleterms:{"1st":4,"2nd":5,"3rd":6,"4th":7,"5th":8,"6th":9,"case":[15,17,20],"final":5,"function":[2,3,9,13,14,15,17,18,19,20,21],"long":19,"new":17,"void":2,"while":2,Adding:[17,20],One:[12,17],The:[11,13,14,17,20,21],There:14,Use:20,Using:12,With:21,about:23,abov:13,add:[2,8,17,20],adding:[17,20],address:22,advent:[4,5,6,7,8,9],all:[6,8],altern:21,ana:13,analysi:[6,11],anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[13,17],approxim:15,automat:20,averag:2,base:[15,17,20],befor:9,better:13,binari:[2,17,21],block:5,both:17,branch:[2,17],breakdown:8,btree:20,can:[17,20],cata:13,catamorph:13,categor:10,chatter:2,check:18,child:[17,20],choic:2,cleanup:18,clear:2,cleav:2,cmp:[17,20],code:[4,5,6,7,8,9,14,17],combin:[2,13,17,20],compar:[17,20],comparison:2,compil:12,comput:15,con:[2,20],concat:2,consecut:15,continu:14,count:[8,9],crap:20,current:[17,20],data:20,datastructur:[14,17,20,22],decemb:[4,5,6,7,8,9],defin:[17,18,20,21],definit:18,delet:[17,20],deriv:[13,18,20,21],determin:22,develop:11,dialect:0,dictionari:19,dip:[2,22],dipd:2,dipdd:2,direco:12,disenstacken:2,div:2,document:0,doe:[17,20],down:5,down_to_zero:2,drive:9,drop:2,dup:2,dupd:2,dupdip:2,els:[17,20],empti:[17,20],enstacken:2,equal:[17,20],essai:23,euler:[11,12],eval:14,even:12,exampl:[2,14,17,21],execut:25,express:[14,24],extract:[13,20,21],factor:[13,20],factori:13,fibonacci:12,filter:11,find:[6,13,15,17],first:[2,11],five:12,flatten:2,flexibl:21,floordiv:2,form:[13,20],formula:18,found:17,four:13,from:13,ftw:4,fun:13,further:11,fusion:13,gcd:2,gener:[9,11,12,13,15,20],genrec:2,get:[8,17,20,21],getitem:2,given:[13,20,21],gotten:8,greater:[17,20],group:2,have:[17,21],help:2,highest:17,host:0,how:[9,11,12],hylo:13,hylomorph:13,ift:2,increment:8,index:8,indic:0,inform:0,infra:[2,20,22],integ:11,interest:12,interlud:[17,20],intern:24,interpret:[1,14],isn:20,item:22,iter:[11,17,20],joi:[0,1,3,6,11,13,14,22,23,24,25,26],just:[11,20],kei:[17,20],languag:0,law:13,least_fract:2,left:[17,20],less:[17,20],let:11,librari:[3,14],like:[17,20],list:[2,13,20,26],literari:14,littl:11,logic:2,loop:[2,5,14],lower:17,lshift:2,make:[12,15,20],mani:[9,11],map:2,math:2,method:15,min:2,miscellan:[2,20],mod:2,modif:20,modulu:2,more:17,most:17,mul:2,multipl:[11,12],must:[17,20],name:[18,20],nativ:18,neg:2,newton:15,next:15,node:[13,17,20],non:17,now:[8,17,20],nullari:2,number:[6,13],offset:6,one:14,onli:14,order:[17,20,21],osdn:0,our:[17,20],out:5,over:2,pack:11,pam:2,paper:5,para:13,paramet:20,parameter:[13,17,20,21],paramorph:13,pars:[2,24],parser:[14,24],pass:14,path:22,pattern:13,per:[17,20],piec:5,pop:2,popd:2,popop:2,pow:2,power:12,preambl:[8,13],pred:2,predic:[8,11,15,17,20,21],pretty_print:25,primrec:2,print:14,problem:[11,12],process:[17,20],product:2,program:[9,10,11,13,18,20,21,23],project:[0,11,12],pure:14,put:[6,17,20,21],python:[14,19],quadrat:18,quick:0,quot:[2,26],rang:[2,11],range_to_zero:2,rank:6,read:14,recal:9,recur:[15,17,20],recurs:[13,17,20,21],redefin:[17,20,21],refactor:[4,11,17,20],refer:3,regular:14,reimplement:21,rem:2,remaind:2,remov:2,render:11,repeat:9,repl:14,replac:[17,19],rescu:6,reset:12,rest:[2,13],revers:2,right:[17,20,22],rightmost:17,roll:2,rolldown:2,rollup:2,root:15,rshift:2,run:[2,12],sat:5,second:2,select:2,sequenc:[12,26],set:[8,15,17,20],shorter:19,should:14,shunt:2,simplest:11,simplifi:18,size:[2,19],slight:20,sourc:17,sqr:2,sqrt:2,squar:15,stack:[2,14,26],start:0,state:9,step:[2,8,13,21],straightforward:18,structur:17,style:14,sub:[2,17],succ:2,sum:[2,11],swaack:2,swap:2,swon:2,swoncat:2,symbol:[13,14],sympi:6,tabl:0,tail:13,take:2,term:[11,12,20,21],ternari:2,text:24,than:[13,17,20],thi:[17,20],think:5,third:2,three:12,thun:[0,14],time:[2,12],todo:20,togeth:[6,8,17,20,21],toi:20,token:14,toler:15,trace:[19,25],traceprint:14,travers:[17,20,21,22],treat:[17,20,21],tree:[13,17,20,21,22],treegrind:21,treestep:[13,20,21],triangular:13,tricki:5,truediv:2,truthi:2,tuck:2,two:12,type:20,unari:2,uncon:2,unfinish:13,unit:2,unnecessari:11,unquot:2,unstack:2,updat:16,use:13,usual:13,util:[25,26],valu:[8,12,17,20],variabl:18,variat:12,version:[6,11,17,19,20],view:14,want:5,within:15,word:2,write:18,xor:2,zero:12,zip:2,zipper:22}})
\ No newline at end of file
@@ -208,9 +208,9 @@ with the ``x`` combinator.
 Generating Multiples of Three and Five
 --------------------------------------
 
-Look at the treatment of the Project Euler Problem One in `Developing a
-Program.ipynb <./Developing%20a%20Program.ipynb>`__ and you'll see that
-we might be interested in generating an endless cycle of:
+Look at the treatment of the Project Euler Problem One in the
+"Developing a Program" notebook and you'll see that we might be
+interested in generating an endless cycle of:
 
 ::
 
index 6958cfc..9975abb 100644 (file)
@@ -1,30 +1,39 @@
 
-***********************************************************************
 `Quadratic formula <https://en.wikipedia.org/wiki/Quadratic_formula>`__
-***********************************************************************
+=======================================================================
 
-`The Quadratic formula <https://en.wikipedia.org/wiki/Quadratic_formula>`__
+.. code:: ipython2
 
-:math:`\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}`
+    from notebook_preamble import J, V, define
 
-In
+Cf.
 `jp-quadratic.html <http://www.kevinalbrecht.com/code/joy-mirror/jp-quadratic.html>`__
-a Joy function for the Quadratic formula is derived (along with one of my favorite combinators ``[i] map``,
-which I like to call ``pam``) starting with a version written in Scheme.  Here we investigate a different approach.
 
-Write a program with variable names.
-====================================
+::
+
+             -b  +/- sqrt(b^2 - 4 * a * c)
+             -----------------------------
+                        2 * a
+
+:math:`\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}`
+
+Write a straightforward program with variable names.
+----------------------------------------------------
 
 ::
 
     b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
 
-We use ``cleave`` to compute the sum and difference ("plus-or-minus") and then ``app2`` to finish computing both roots using a quoted program ``[2a truediv]`` built with ``cons``.
+We use ``cleave`` to compute the sum and difference and then ``app2`` to
+finish computing both roots using a quoted program ``[2a truediv]``
+built with ``cons``.
 
 Check it.
 ~~~~~~~~~
 
-Evaluating by hand::
+Evaluating by hand:
+
+::
 
      b neg b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
     -b     b sqr 4 a c * * - sqrt [+] [-] cleave a 2 * [truediv] cons app2
@@ -38,19 +47,21 @@ Evaluating by hand::
     -b -b+sqrt(b^2-4ac)    -b-sqrt(b^2-4ac)    [2a truediv]         app2
     -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a
 
-(Eventually we'll be able to use e.g. Sympy versions of the Joy commands to do this sort of thing symbolically.  This is part of what is meant by a "categorical" language.)
+(Eventually we’ll be able to use e.g. Sympy versions of the Joy commands
+to do this sort of thing symbolically. This is part of what is meant by
+a “categorical” language.)
 
 Cleanup
 ~~~~~~~
 
 ::
 
-    -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a    roll< pop
-       -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a -b       pop
+    -b -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a                          roll< pop
+       -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a -b                             pop
        -b+sqrt(b^2-4ac)/2a -b-sqrt(b^2-4ac)/2a
 
 Derive a definition.
-====================
+--------------------
 
 ::
 
@@ -62,10 +73,6 @@ Derive a definition.
 
 .. code:: ipython2
 
-    from notebook_preamble import J, V, define
-
-.. code:: ipython2
-
     define('quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt [+] [-] cleave] dip 2 * [truediv] cons app2 roll< pop')
 
 .. code:: ipython2
@@ -79,13 +86,13 @@ Derive a definition.
 
 
 Simplify
-~~~~~~~~
+--------
 
 We can define a ``pm`` plus-or-minus function:
 
-.. code:: ipython2
+::
 
-    define('pm == [+] [-] cleave popdd')
+    pm == [+] [-] cleave popdd
 
 Then ``quadratic`` becomes:
 
@@ -109,22 +116,15 @@ Define a "native" ``pm`` function.
 The definition of ``pm`` above is pretty elegant, but the implementation
 takes a lot of steps relative to what it's accomplishing. Since we are
 likely to use ``pm`` more than once in the future, let's write a
-primitive in Python and add it to the dictionary.
+primitive in Python and add it to the dictionary. (This has been done
+already.)
 
 .. code:: ipython2
 
-    from joy.library import SimpleFunctionWrapper
-    from notebook_preamble import D
-    
-    
-    @SimpleFunctionWrapper
     def pm(stack):
         a, (b, stack) = stack
         p, m, = b + a, b - a
         return m, (p, stack)
-    
-    
-    D['pm'] = pm
 
 The resulting trace is short enough to fit on a page.
 
index 8bc5e5f..ea26a9a 100644 (file)
@@ -1,4 +1,7 @@
 
+Traversing Datastructures with Zippers
+======================================
+
 This notebook is about using the "zipper" with joy datastructures. See
 the `Zipper wikipedia
 entry <https://en.wikipedia.org/wiki/Zipper_%28data_structure%29>`__ or
@@ -8,9 +11,6 @@ Huet <https://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/huet-
 Given a datastructure on the stack we can navigate through it, modify
 it, and rebuild it using the "zipper" technique.
 
-Preamble
-~~~~~~~~
-
 .. code:: ipython2
 
     from notebook_preamble import J, V, define
index c5abc23..d36d883 100644 (file)
@@ -12,9 +12,10 @@ These essays are adapted from Jupyter notebooks.  I hope to have those hosted so
    Replacing
    Ordered_Binary_Trees
    Treestep
-   Generator Programs
+   Generator_Programs
    Newton-Raphson
    Quadratic
+   Zipper
    NoUpdates
    Categorical
 
index 081e982..2097df9 100644 (file)
@@ -124,6 +124,9 @@ while == swap [nullary] cons dup dipd concat loop
 dudipd == dup dipd
 primrec == [i] genrec
 step_zero == 0 roll> step
+codireco == cons dip rest cons
+make_generator == [codireco] ccons
+ccons == cons cons
 '''
 
 ##Zipper