OSDN Git Service

More docs changes.
authorSimon Forman <sforman@hushmail.com>
Mon, 30 Apr 2018 17:12:56 +0000 (10:12 -0700)
committerSimon Forman <sforman@hushmail.com>
Mon, 30 Apr 2018 17:12:56 +0000 (10:12 -0700)
17 files changed:
docs/sphinx_docs/_build/html/_modules/joy/joy.html
docs/sphinx_docs/_build/html/_modules/joy/library.html
docs/sphinx_docs/_build/html/_modules/joy/parser.html
docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html
docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html
docs/sphinx_docs/_build/html/genindex.html
docs/sphinx_docs/_build/html/index.html
docs/sphinx_docs/_build/html/joy.html
docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html [deleted file]
docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html
docs/sphinx_docs/_build/html/notebooks/Intro.html
docs/sphinx_docs/_build/html/objects.inv
docs/sphinx_docs/_build/html/parser.html
docs/sphinx_docs/_build/html/pretty.html
docs/sphinx_docs/_build/html/searchindex.js
docs/sphinx_docs/_build/html/stack.html
docs/sphinx_docs/notebooks/AlsoNewton.rst

index 0c54fb9..a0aff00 100644 (file)
 <span class="sd">  or functions.  Literals are put onto the stack and functions are</span>
 <span class="sd">  executed.</span>
 
-
-<span class="sd">  :param quote stack: The stack.</span>
-<span class="sd">  :param quote expression: The expression to evaluate.</span>
-<span class="sd">  :param dict dictionary: A `dict` mapping names to Joy functions.</span>
+<span class="sd">  :param stack stack: The stack.</span>
+<span class="sd">  :param stack expression: The expression to evaluate.</span>
+<span class="sd">  :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
 <span class="sd">  :param function viewer: Optional viewer function.</span>
+<span class="sd">  :rtype: (stack, (), dictionary)</span>
 
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="k">while</span> <span class="n">expression</span><span class="p">:</span>
 <div class="viewcode-block" id="run"><a class="viewcode-back" href="../../joy.html#joy.joy.run">[docs]</a><span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
   <span class="sd">&#39;&#39;&#39;</span>
 <span class="sd">  Return the stack resulting from running the Joy code text on the stack.</span>
+
+<span class="sd">  :param str text: Joy code.</span>
+<span class="sd">  :param stack stack: The stack.</span>
+<span class="sd">  :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
+<span class="sd">  :param function viewer: Optional viewer function.</span>
+<span class="sd">  :rtype: (stack, (), dictionary)</span>
+
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="n">expression</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
   <span class="k">return</span> <span class="n">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="p">)</span></div>
 <span class="sd">  Read-Evaluate-Print Loop</span>
 
 <span class="sd">  Accept input and run it on the stack, loop.</span>
+
+<span class="sd">  :param stack stack: The stack.</span>
+<span class="sd">  :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
+<span class="sd">  :rtype: stack</span>
+
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="k">if</span> <span class="n">dictionary</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
     <span class="n">dictionary</span> <span class="o">=</span> <span class="p">{}</span>
index 06c4a01..7c4499a 100644 (file)
 <span class="s1">dudipd == dup dipd</span>
 <span class="s1">primrec == [i] genrec</span>
 <span class="s1">step_zero == 0 roll&gt; step</span>
+<span class="s1">direco == dip rest cons</span>
+<span class="s1">make_generator == [direco] cons [swap] swoncat cons</span>
+<span class="s1">gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator</span>
+<span class="s1">_within_P == [first - abs] dip &lt;=</span>
+<span class="s1">_within_B == roll&lt; popop first</span>
+<span class="s1">_within_R == [popd x] dip</span>
+<span class="s1">within == x 0.000001 [_within_P] [_within_B] [_within_R] primrec</span>
 <span class="s1">&#39;&#39;&#39;</span>
 
 <span class="c1">##Zipper</span>
index ad8404c..a847615 100644 (file)
@@ -84,7 +84,7 @@
 <span class="sd">  Any unbalanced square brackets will raise a ParseError.</span>
 
 <span class="sd">  :param str text: Text to convert.</span>
-<span class="sd">  :rtype: quote</span>
+<span class="sd">  :rtype: stack</span>
 <span class="sd">  :raises ParseError: if the parse fails.</span>
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="k">return</span> <span class="n">_parse</span><span class="p">(</span><span class="n">_tokenize</span><span class="p">(</span><span class="n">text</span><span class="p">))</span></div>
index 89b5ac4..6bc0d94 100644 (file)
 <span class="c1">#    along with Thun.  If not see &lt;http://www.gnu.org/licenses/&gt;.</span>
 <span class="c1">#</span>
 <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">Pretty printing support.</span>
+<span class="sd">Pretty printing support, e.g.::</span>
+
+<span class="sd">    Joy? 23 18 * 99 +</span>
+<span class="sd">           . 23 18 mul 99 add</span>
+<span class="sd">        23 . 18 mul 99 add</span>
+<span class="sd">     23 18 . mul 99 add</span>
+<span class="sd">       414 . 99 add</span>
+<span class="sd">    414 99 . add</span>
+<span class="sd">       513 . </span>
+
+<span class="sd">    513 &lt;-top</span>
+
+<span class="sd">    joy? </span>
+
+<span class="sd">On each line the stack is printed with the top to the right, then a ``.`` to</span>
+<span class="sd">represent the current locus of processing, then the pending expression to the</span>
+<span class="sd">left.</span>
+
 <span class="sd">&#39;&#39;&#39;</span>
 <span class="c1"># (Kinda clunky and hacky.  This should be swapped out in favor of much</span>
 <span class="c1"># smarter stuff.)</span>
 
 <div class="viewcode-block" id="TracePrinter"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter">[docs]</a><span class="k">class</span> <span class="nc">TracePrinter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
   <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">  This is what does the formatting, e.g.::</span>
-
-<span class="sd">    Joy? 23 18 * 99 +</span>
-<span class="sd">           . 23 18 mul 99 add</span>
-<span class="sd">        23 . 18 mul 99 add</span>
-<span class="sd">     23 18 . mul 99 add</span>
-<span class="sd">       414 . 99 add</span>
-<span class="sd">    414 99 . add</span>
-<span class="sd">       513 . </span>
-
+<span class="sd">  This is what does the formatting.  You instantiate it and pass the ``viewer()``</span>
+<span class="sd">  method to the :py:func:`joy.joy.joy` function, then print it to see the</span>
+<span class="sd">  trace.</span>
 <span class="sd">  &#39;&#39;&#39;</span>
 
   <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
     <span class="bp">self</span><span class="o">.</span><span class="n">history</span> <span class="o">=</span> <span class="p">[]</span>
 
 <div class="viewcode-block" id="TracePrinter.viewer"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.viewer">[docs]</a>  <span class="k">def</span> <span class="nf">viewer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">):</span>
-    <span class="sd">&#39;&#39;&#39;Pass this method as the viewer to joy() function.&#39;&#39;&#39;</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Record the current stack and expression in the TracePrinter&#39;s history.</span>
+<span class="sd">    Pass this method as the ``viewer`` argument to the :py:func:`joy.joy.joy` function.</span>
+
+<span class="sd">    :param stack quote: A stack.</span>
+<span class="sd">    :param stack expression: A stack.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
     <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span></div>
 
   <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
     <span class="k">return</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">go</span><span class="p">())</span>
 
-  <span class="k">def</span> <span class="nf">go</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+<div class="viewcode-block" id="TracePrinter.go"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.go">[docs]</a>  <span class="k">def</span> <span class="nf">go</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Return a list of strings, one for each entry in the history, prefixed</span>
+<span class="sd">    with enough spaces to align all the interpreter dots.</span>
+
+<span class="sd">    This method is called internally by the ``__str__()`` method.</span>
+
+<span class="sd">    :rtype: list(str)</span>
+<span class="sd">    &#39;&#39;&#39;</span>
     <span class="n">max_stack_length</span> <span class="o">=</span> <span class="mi">0</span>
     <span class="n">lines</span> <span class="o">=</span> <span class="p">[]</span>
     <span class="k">for</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">:</span>
     <span class="k">return</span> <span class="p">[</span>  <span class="c1"># Prefix spaces to line up &#39;.&#39;s.</span>
       <span class="p">(</span><span class="s1">&#39; &#39;</span> <span class="o">*</span> <span class="p">(</span><span class="n">max_stack_length</span> <span class="o">-</span> <span class="n">length</span><span class="p">)</span> <span class="o">+</span> <span class="n">line</span><span class="p">)</span>
       <span class="k">for</span> <span class="n">length</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span>
-      <span class="p">]</span>
+      <span class="p">]</span></div>
 
   <span class="k">def</span> <span class="nf">print_</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
     <span class="k">try</span><span class="p">:</span>
index e37004b..01cb345 100644 (file)
 <span class="c1">#    along with Thun.  If not see &lt;http://www.gnu.org/licenses/&gt;.</span>
 <span class="c1">#</span>
 <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">When talking about Joy we use the terms &quot;stack&quot;, &quot;list&quot;, &quot;sequence&quot;,</span>
-<span class="sd">&quot;quote&quot; and others to mean the same thing: a simple linear datatype that</span>
+<span class="sd">When talking about Joy we use the terms &quot;stack&quot;, &quot;quote&quot;, &quot;sequence&quot;,</span>
+<span class="sd">&quot;list&quot;, and others to mean the same thing: a simple linear datatype that</span>
 <span class="sd">permits certain operations such as iterating and pushing and popping</span>
 <span class="sd">values from (at least) one end.</span>
 
-<span class="sd">We use the  `cons list`_, a venerable two-tuple recursive sequence datastructure, where the</span>
+<span class="sd">There is no &quot;Stack&quot; Python class, instead we use the  `cons list`_, a </span>
+<span class="sd">venerable two-tuple recursive sequence datastructure, where the</span>
 <span class="sd">empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the recursive</span>
 <span class="sd">form of a stack with one or more items on it::</span>
 
 <span class="sd">syntax doesn&#39;t require parentheses around tuples used in expressions</span>
 <span class="sd">where they would be redundant.)</span>
 
-<span class="sd">.. _cons list: https://en.wikipedia.org/wiki/Cons#Lists</span>
+<span class="sd">Unfortunately, the Sphinx documentation generator, which is used to generate this</span>
+<span class="sd">web page, doesn&#39;t handle tuples in the function parameters.  And in Python 3, this</span>
+<span class="sd">syntax was removed entirely.  Instead you would have to write::</span>
 
-<span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">  def dup(stack):</span>
+<span class="sd">    head, tail = stack</span>
+<span class="sd">    return head, (head, tail)</span>
+
+
+<span class="sd">We have two very simple functions, one to build up a stack from a Python</span>
+<span class="sd">iterable and another to iterate through a stack and yield its items</span>
+<span class="sd">one-by-one in order.  There are also two functions to generate string representations</span>
+<span class="sd">of stacks.  They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left.  In both functions *internal stacks* are</span>
+<span class="sd">printed left-to-right.  These functions are written to support :doc:`../pretty`.</span>
 
-<span class="c1">##We have two very simple functions to build up a stack from a Python</span>
-<span class="c1">##iterable and also to iterate through a stack and yield its items</span>
-<span class="c1">##one-by-one in order, and two functions to generate string representations</span>
-<span class="c1">##of stacks::</span>
-<span class="c1">##</span>
-<span class="c1">##  list_to_stack()</span>
-<span class="c1">##</span>
-<span class="c1">##  iter_stack()</span>
-<span class="c1">##</span>
-<span class="c1">##  expression_to_string()  (prints left-to-right)</span>
-<span class="c1">##</span>
-<span class="c1">##  stack_to_string()  (prints right-to-left)</span>
-<span class="c1">##</span>
-<span class="c1">##</span>
-<span class="c1">##A word about the stack data structure.</span>
+<span class="sd">.. _cons list: https://en.wikipedia.org/wiki/Cons#Lists</span>
 
+<span class="sd">&#39;&#39;&#39;</span>
 
 
 <div class="viewcode-block" id="list_to_stack"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.list_to_stack">[docs]</a><span class="k">def</span> <span class="nf">list_to_stack</span><span class="p">(</span><span class="n">el</span><span class="p">,</span> <span class="n">stack</span><span class="o">=</span><span class="p">()):</span>
 
 <span class="sd">  [1, 2, 3] -&gt; (1, (2, (3, ())))</span>
 
+<span class="sd">  :param list el: A Python list or other sequence (iterators and generators</span>
+<span class="sd">       won&#39;t work because ``reverse()`` is called on ``el``.)</span>
+<span class="sd">  :param stack stack: A stack, optional, defaults to the empty stack.</span>
+<span class="sd">  :rtype: stack</span>
+
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="n">el</span><span class="p">):</span>
     <span class="n">stack</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">stack</span>
 
 
 <div class="viewcode-block" id="iter_stack"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.iter_stack">[docs]</a><span class="k">def</span> <span class="nf">iter_stack</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-  <span class="sd">&#39;&#39;&#39;Iterate through the items on the stack.&#39;&#39;&#39;</span>
+  <span class="sd">&#39;&#39;&#39;Iterate through the items on the stack.</span>
+
+<span class="sd">  :param stack stack: A stack.</span>
+<span class="sd">  :rtype: iterator</span>
+<span class="sd">  &#39;&#39;&#39;</span>
   <span class="k">while</span> <span class="n">stack</span><span class="p">:</span>
     <span class="n">item</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="k">yield</span> <span class="n">item</span></div>
 <span class="sd">  The items are written right-to-left::</span>
 
 <span class="sd">    (top, (second, ...)) -&gt; &#39;... second top&#39;</span>
+
+<span class="sd">  :param stack stack: A stack.</span>
+<span class="sd">  :rtype: str</span>
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="n">f</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">stack</span><span class="p">:</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">stack</span><span class="p">)))</span>
   <span class="k">return</span> <span class="n">_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span></div>
 <span class="sd">  The items are written left-to-right::</span>
 
 <span class="sd">    (top, (second, ...)) -&gt; &#39;top second ...&#39;</span>
+
+<span class="sd">  :param stack expression: A stack.</span>
+<span class="sd">  :rtype: str</span>
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="k">return</span> <span class="n">_to_string</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">iter_stack</span><span class="p">)</span></div>
 
   <span class="sd">&#39;&#39;&#39;Concatinate quote onto expression.</span>
 
 <span class="sd">  In joy [1 2] [3 4] would become [1 2 3 4].</span>
+
+<span class="sd">  :param stack quote: A stack.</span>
+<span class="sd">  :param stack expression: A stack.</span>
+<span class="sd">  :raises RuntimeError: if quote is larger than sys.getrecursionlimit().</span>
+<span class="sd">  :rtype: stack</span>
 <span class="sd">  &#39;&#39;&#39;</span>
+  <span class="c1"># This is the fastest implementation, but will trigger</span>
+  <span class="c1"># RuntimeError: maximum recursion depth exceeded</span>
+  <span class="c1"># on quotes longer than sys.getrecursionlimit().</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">quote</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">pushback</span><span class="p">(</span><span class="n">quote</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">expression</span><span class="p">))</span> <span class="k">if</span> <span class="n">quote</span> <span class="k">else</span> <span class="n">expression</span></div>
 
   <span class="c1"># Original implementation.</span>
 
 <span class="c1">##    expression = item, expression</span>
 <span class="c1">##  return expression</span>
 
-  <span class="c1"># This is the fastest, but will trigger</span>
-  <span class="c1"># RuntimeError: maximum recursion depth exceeded</span>
-  <span class="c1"># on quotes longer than sys.getrecursionlimit().</span>
-  <span class="k">return</span> <span class="p">(</span><span class="n">quote</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">pushback</span><span class="p">(</span><span class="n">quote</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">expression</span><span class="p">))</span> <span class="k">if</span> <span class="n">quote</span> <span class="k">else</span> <span class="n">expression</span></div>
 
 
 <div class="viewcode-block" id="pick"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.pick">[docs]</a><span class="k">def</span> <span class="nf">pick</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
   <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">  Find the nth item on the stack. (Pick with zero is the same as &quot;dup&quot;.)</span>
+<span class="sd">  Return the nth item on the stack.</span>
+
+<span class="sd">  :param stack s: A stack.</span>
+<span class="sd">  :param int n: An index into the stack.</span>
+<span class="sd">  :raises ValueError: if ``n`` is less than zero.</span>
+<span class="sd">  :raises IndexError: if ``n`` is equal to or greater than the length of ``s``.</span>
+<span class="sd">  :rtype: whatever</span>
 <span class="sd">  &#39;&#39;&#39;</span>
   <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
     <span class="k">raise</span> <span class="ne">ValueError</span>
index 9d8ecce..6eb5d7f 100644 (file)
   <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="library.html#joy.library.getitem">getitem() (in module joy.library)</a>
 </li>
+      <li><a href="pretty.html#joy.utils.pretty_print.TracePrinter.go">go() (joy.utils.pretty_print.TracePrinter method)</a>
+</li>
   </ul></td>
 </tr></table>
 
index 3f769aa..4a4ef75 100644 (file)
@@ -93,7 +93,7 @@ interesting aspects.  It’s quite a treasure trove.</p>
 <li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a><ul>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#the-stack">The Stack</a></li>
-<li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#purely-functional-datastructures">Purely Functional Datastructures.</a></li>
+<li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#purely-functional-datastructures">Purely Functional Datastructures</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#the-joy-function">The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#parser">Parser</a></li>
 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#library">Library</a></li>
index aa8ced9..5c31265 100644 (file)
@@ -17,7 +17,7 @@
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Stack or Quote or Sequence or List…" href="stack.html" />
-    <link rel="prev" title="Thun 0.1.1 Documentation" href="index.html" />
+    <link rel="prev" title="Thun: Joy in Python" href="notebooks/Intro.html" />
    
   <link rel="stylesheet" href="_static/custom.css" type="text/css" />
   
@@ -51,14 +51,17 @@ executed.</p>
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
-<li><strong>stack</strong> (<em>quote</em>) – The stack.</li>
-<li><strong>expression</strong> (<em>quote</em>) – The expression to evaluate.</li>
-<li><strong>dictionary</strong> (<em>dict</em>) – A <cite>dict</cite> mapping names to Joy functions.</li>
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
+<li><strong>expression</strong> (<em>stack</em>) – The expression to evaluate.</li>
+<li><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</li>
 <li><strong>viewer</strong> (<em>function</em>) – Optional viewer function.</li>
 </ul>
 </td>
 </tr>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(stack, (), dictionary)</p>
+</td>
+</tr>
 </tbody>
 </table>
 </dd></dl>
@@ -68,12 +71,44 @@ executed.</p>
 <code class="descclassname">joy.joy.</code><code class="descname">repl</code><span class="sig-paren">(</span><em>stack=()</em>, <em>dictionary=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#repl"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.joy.repl" title="Permalink to this definition">¶</a></dt>
 <dd><p>Read-Evaluate-Print Loop</p>
 <p>Accept input and run it on the stack, loop.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
+<li><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
+</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 <dl class="function">
 <dt id="joy.joy.run">
 <code class="descclassname">joy.joy.</code><code class="descname">run</code><span class="sig-paren">(</span><em>text</em>, <em>stack</em>, <em>dictionary</em>, <em>viewer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.joy.run" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return the stack resulting from running the Joy code text on the stack.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>text</strong> (<em>str</em>) – Joy code.</li>
+<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
+<li><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</li>
+<li><strong>viewer</strong> (<em>function</em>) – Optional viewer function.</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(stack, (), dictionary)</p>
+</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 </div>
@@ -96,7 +131,7 @@ executed.</p>
 <h3>Related Topics</h3>
 <ul>
   <li><a href="index.html">Documentation overview</a><ul>
-      <li>Previous: <a href="index.html" title="previous chapter">Thun 0.1.1 Documentation</a></li>
+      <li>Previous: <a href="notebooks/Intro.html" title="previous chapter">Thun: Joy in Python</a></li>
       <li>Next: <a href="stack.html" title="next chapter">Stack or Quote or Sequence or List…</a></li>
   </ul></li>
 </ul>
diff --git a/docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html b/docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html
deleted file mode 100644 (file)
index 7e2bc5c..0000000
+++ /dev/null
@@ -1,512 +0,0 @@
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <title>Joypy &#8212; Thun 0.1.1 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>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-    <link rel="index" title="Index" href="../genindex.html" />
-    <link rel="search" title="Search" href="../search.html" />
-   
-  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
-  
-  
-  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
-
-  </head><body>
-  
-
-    <div class="document">
-      <div class="documentwrapper">
-        <div class="bodywrapper">
-          <div class="body" role="main">
-            
-  <div class="section" id="joypy">
-<h1>Joypy<a class="headerlink" href="#joypy" title="Permalink to this headline">¶</a></h1>
-<div class="section" id="joy-in-python">
-<h2>Joy in Python<a class="headerlink" href="#joy-in-python" title="Permalink to this headline">¶</a></h2>
-<p>This implementation is meant as a tool for exploring the programming
-model and method of Joy. Python seems like a great implementation
-language for Joy for several reasons.</p>
-<p>We can lean on the Python immutable types for our basic semantics and
-types: ints, floats, strings, and tuples, which enforces functional
-purity. We get garbage collection for free. Compilation via Cython. Glue
-language with loads of libraries.</p>
-<div class="section" id="read-eval-print-loop-repl">
-<h3><a class="reference external" href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop">Read-Eval-Print Loop (REPL)</a><a class="headerlink" href="#read-eval-print-loop-repl" title="Permalink to this headline">¶</a></h3>
-<p>The main way to interact with the Joy interpreter is through a simple
-<a class="reference external" href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop">REPL</a>
-that you start by running the package:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python -m joy
-Joypy - Copyright © 2017 Simon Forman
-This program comes with ABSOLUTELY NO WARRANTY; for details type &quot;warranty&quot;.
-This is free software, and you are welcome to redistribute it
-under certain conditions; type &quot;sharing&quot; for details.
-Type &quot;words&quot; to see a list of all words, and &quot;[&lt;name&gt;] help&quot; to print the
-docs for a word.
-
-
- &lt;-top
-
-joy? _
-</pre></div>
-</div>
-<p>The <code class="docutils literal notranslate"><span class="pre">&lt;-top</span></code> marker points to the top of the (initially empty) stack.
-You can enter Joy notation at the prompt and a <a class="reference external" href="#The-TracePrinter.">trace of
-evaluation</a> will be printed followed by the stack
-and prompt again:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>joy? 23 sqr 18 +
-       . 23 sqr 18 +
-    23 . sqr 18 +
-    23 . dup mul 18 +
- 23 23 . mul 18 +
-   529 . 18 +
-529 18 . +
-   547 .
-
-547 &lt;-top
-
-joy?
-</pre></div>
-</div>
-</div>
-</div>
-</div>
-<div class="section" id="stacks-aka-list-quote-sequence-etc">
-<h1>Stacks (aka list, quote, sequence, etc.)<a class="headerlink" href="#stacks-aka-list-quote-sequence-etc" title="Permalink to this headline">¶</a></h1>
-<p>In Joy, in addition to the types Boolean, integer, float, and string,
-there is a single sequence type represented by enclosing a sequence of
-terms in brackets <code class="docutils literal notranslate"><span class="pre">[...]</span></code>. This sequence type is used to represent
-both the stack and the expression. It is a <a class="reference external" href="https://en.wikipedia.org/wiki/Cons#Lists">cons
-list</a> made from Python
-tuples.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">inspect</span>
-<span class="kn">import</span> <span class="nn">joy.utils.stack</span>
-
-
-<span class="nb">print</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getdoc</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">stack</span><span class="p">)</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>§ Stack
-
-
-When talking about Joy we use the terms &quot;stack&quot;, &quot;list&quot;, &quot;sequence&quot; and
-&quot;aggregate&quot; to mean the same thing: a simple datatype that permits
-certain operations such as iterating and pushing and popping values from
-(at least) one end.
-
-We use the venerable two-tuple recursive form of sequences where the
-empty tuple () is the empty stack and (head, rest) gives the recursive
-form of a stack with one or more items on it.
-
-  ()
-  (1, ())
-  (2, (1, ()))
-  (3, (2, (1, ())))
-  ...
-
-And so on.
-
-
-We have two very simple functions to build up a stack from a Python
-iterable and also to iterate through a stack and yield its items
-one-by-one in order, and two functions to generate string representations
-of stacks:
-
-  list_to_stack()
-
-  iter_stack()
-
-  expression_to_string()  (prints left-to-right)
-
-  stack_to_string()  (prints right-to-left)
-
-
-A word about the stack data structure.
-
-Python has very nice &quot;tuple packing and unpacking&quot; in its syntax which
-means we can directly &quot;unpack&quot; the expected arguments to a Joy function.
-
-For example:
-
-  def dup(stack):
-    head, tail = stack
-    return head, (head, tail)
-
-We replace the argument &quot;stack&quot; by the expected structure of the stack,
-in this case &quot;(head, tail)&quot;, and Python takes care of de-structuring the
-incoming argument and assigning values to the names.  Note that Python
-syntax doesn&#39;t require parentheses around tuples used in expressions
-where they would be redundant.
-</pre></div>
-</div>
-<p>The 0th item in the list will be on the top of the stack and <em>vise
-versa</em>.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">stack</span><span class="o">.</span><span class="n">list_to_stack</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">())))</span>
-</pre></div>
-</div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">list</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">stack</span><span class="o">.</span><span class="n">iter_stack</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">())))))</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
-</pre></div>
-</div>
-<p>This requires reversing the sequence (or iterating backwards) otherwise:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">stack</span> <span class="o">=</span> <span class="p">()</span>
-
-<span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]:</span>
-    <span class="n">stack</span> <span class="o">=</span> <span class="n">n</span><span class="p">,</span> <span class="n">stack</span>
-
-<span class="nb">print</span> <span class="n">stack</span>
-<span class="nb">print</span> <span class="nb">list</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">stack</span><span class="o">.</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">stack</span><span class="p">))</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">())))</span>
-<span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
-</pre></div>
-</div>
-<p>Because Joy lists are made out of Python tuples they are immutable, so
-all Joy datastructures are <em>`purely
-functional &lt;https://en.wikipedia.org/wiki/Purely_functional_data_structure&gt;`__</em>.</p>
-</div>
-<div class="section" id="the-joy-function">
-<h1>The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function.<a class="headerlink" href="#the-joy-function" title="Permalink to this headline">¶</a></h1>
-<div class="section" id="an-interpreter">
-<h2>An Interpreter<a class="headerlink" href="#an-interpreter" title="Permalink to this headline">¶</a></h2>
-<p>The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function is extrememly simple. It accepts a stack, an
-expression, and a dictionary, and it iterates through the expression
-putting values onto the stack and delegating execution to functions it
-looks up in the dictionary.</p>
-<p>Each function is passed the stack, expression, and dictionary and
-returns them. Whatever the function returns becomes the new stack,
-expression, and dictionary. (The dictionary is passed to enable e.g.
-writing words that let you enter new words into the dictionary at
-runtime, which nothing does yet and may be a bad idea, and the <code class="docutils literal notranslate"><span class="pre">help</span></code>
-command.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.joy</span>
-
-<span class="nb">print</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getsource</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">joy</span><span class="o">.</span><span class="n">joy</span><span class="p">)</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
-  <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">  Evaluate the Joy expression on the stack.</span>
-<span class="sd">  &#39;&#39;&#39;</span>
-  <span class="k">while</span> <span class="n">expression</span><span class="p">:</span>
-
-    <span class="k">if</span> <span class="n">viewer</span><span class="p">:</span> <span class="n">viewer</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-
-    <span class="n">term</span><span class="p">,</span> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span>
-    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="n">Symbol</span><span class="p">):</span>
-      <span class="n">term</span> <span class="o">=</span> <span class="n">dictionary</span><span class="p">[</span><span class="n">term</span><span class="p">]</span>
-      <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">term</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span>
-    <span class="k">else</span><span class="p">:</span>
-      <span class="n">stack</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">stack</span>
-
-  <span class="k">if</span> <span class="n">viewer</span><span class="p">:</span> <span class="n">viewer</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-  <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span>
-</pre></div>
-</div>
-<div class="section" id="view-function">
-<h3>View function<a class="headerlink" href="#view-function" title="Permalink to this headline">¶</a></h3>
-<p>The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function accepts a “viewer” function which it calls on
-each iteration passing the current stack and expression just before
-evaluation. This can be used for tracing, breakpoints, retrying after
-exceptions, or interrupting an evaluation and saving to disk or sending
-over the network to resume later. The stack and expression together
-contain all the state of the computation at each step.</p>
-</div>
-<div class="section" id="the-traceprinter">
-<h3>The <code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code>.<a class="headerlink" href="#the-traceprinter" title="Permalink to this headline">¶</a></h3>
-<p>A <code class="docutils literal notranslate"><span class="pre">viewer</span></code> records each step of the evaluation of a Joy program. The
-<code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code> has a facility for printing out a trace of the
-evaluation, one line per step. Each step is aligned to the current
-interpreter position, signified by a period separating the stack on the
-left from the pending expression (“continuation”) on the right.</p>
-</div>
-<div class="section" id="continuation-passing-style">
-<h3><a class="reference external" href="https://en.wikipedia.org/wiki/Continuation-passing_style">Continuation-Passing Style</a><a class="headerlink" href="#continuation-passing-style" title="Permalink to this headline">¶</a></h3>
-<p>One day I thought, What happens if you rewrite Joy to use
-<a class="reference external" href="https://en.wikipedia.org/wiki/Continuation-passing_style">CSP</a>? I
-made all the functions accept and return the expression as well as the
-stack and found that all the combinators could be rewritten to work by
-modifying the expression rather than making recursive calls to the
-<code class="docutils literal notranslate"><span class="pre">joy()</span></code> function.</p>
-</div>
-</div>
-</div>
-<div class="section" id="parser">
-<h1>Parser<a class="headerlink" href="#parser" title="Permalink to this headline">¶</a></h1>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.parser</span>
-
-<span class="nb">print</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getdoc</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="p">)</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>§ Converting text to a joy expression.
-
-This module exports a single function:
-
-  text_to_expression(text)
-
-As well as a single Symbol class and a single Exception type:
-
-  ParseError
-
-When supplied with a string this function returns a Python datastructure
-that represents the Joy datastructure described by the text expression.
-Any unbalanced square brackets will raise a ParseError.
-</pre></div>
-</div>
-<p>The parser is extremely simple, the undocumented <code class="docutils literal notranslate"><span class="pre">re.Scanner</span></code> class
-does most of the tokenizing work and then you just build the tuple
-structure out of the tokens. There’s no Abstract Syntax Tree or anything
-like that.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getsource</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">_parse</span><span class="p">)</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">_parse</span><span class="p">(</span><span class="n">tokens</span><span class="p">):</span>
-  <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">  Return a stack/list expression of the tokens.</span>
-<span class="sd">  &#39;&#39;&#39;</span>
-  <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
-  <span class="n">stack</span> <span class="o">=</span> <span class="p">[]</span>
-  <span class="k">for</span> <span class="n">tok</span> <span class="ow">in</span> <span class="n">tokens</span><span class="p">:</span>
-    <span class="k">if</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;[&#39;</span><span class="p">:</span>
-      <span class="n">stack</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
-      <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
-      <span class="n">stack</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
-    <span class="k">elif</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;]&#39;</span><span class="p">:</span>
-      <span class="k">try</span><span class="p">:</span>
-        <span class="n">frame</span> <span class="o">=</span> <span class="n">stack</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
-      <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
-        <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="s1">&#39;One or more extra closing brackets.&#39;</span><span class="p">)</span>
-      <span class="n">frame</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">frame</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
-    <span class="k">else</span><span class="p">:</span>
-      <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tok</span><span class="p">)</span>
-  <span class="k">if</span> <span class="n">stack</span><span class="p">:</span>
-    <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="s1">&#39;One or more unclosed brackets.&#39;</span><span class="p">)</span>
-  <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
-</pre></div>
-</div>
-<p>That’s pretty much all there is to it.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5&#39;</span><span class="p">)</span>  <span class="c1"># A simple sequence.</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="p">())))))</span>
-</pre></div>
-</div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[1 2 3] 4 5&#39;</span><span class="p">)</span>  <span class="c1"># Three items, the first is a list with three items</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">()))),</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="p">())))</span>
-</pre></div>
-</div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;1 23 [&quot;four&quot; [-5.0] cons] 8888&#39;</span><span class="p">)</span>  <span class="c1"># A mixed bag. cons is</span>
-                                                                 <span class="c1"># a Symbol, no lookup at</span>
-                                                                 <span class="c1"># parse-time.  Haiku docs.</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">23</span><span class="p">,</span> <span class="p">((</span><span class="s1">&#39;four&#39;</span><span class="p">,</span> <span class="p">((</span><span class="o">-</span><span class="mf">5.0</span><span class="p">,</span> <span class="p">()),</span> <span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="p">()))),</span> <span class="p">(</span><span class="mi">8888</span><span class="p">,</span> <span class="p">()))))</span>
-</pre></div>
-</div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[][][][][]&#39;</span><span class="p">)</span>  <span class="c1"># Five empty lists.</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((),</span> <span class="p">((),</span> <span class="p">((),</span> <span class="p">((),</span> <span class="p">((),</span> <span class="p">())))))</span>
-</pre></div>
-</div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[[[[[]]]]]&#39;</span><span class="p">)</span>  <span class="c1"># Five nested lists.</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((((((),</span> <span class="p">()),</span> <span class="p">()),</span> <span class="p">()),</span> <span class="p">()),</span> <span class="p">())</span>
-</pre></div>
-</div>
-</div>
-<div class="section" id="library">
-<h1>Library<a class="headerlink" href="#library" title="Permalink to this headline">¶</a></h1>
-<p>The Joy library of functions (aka commands, or “words” after Forth
-usage) encapsulates all the actual functionality (no pun intended) of
-the Joy system. There are simple functions such as addition <code class="docutils literal notranslate"><span class="pre">add</span></code> (or
-<code class="docutils literal notranslate"><span class="pre">+</span></code>, the library module supports aliases), and combinators which
-provide control-flow and higher-order operations.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.library</span>
-
-<span class="nb">print</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">library</span><span class="o">.</span><span class="n">initialize</span><span class="p">()))</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>!= % &amp; * *fraction *fraction0 + ++ - -- / &lt; &lt;&lt; &lt;= &lt;&gt; = &gt; &gt;= &gt;&gt; ? ^ add anamorphism and app1 app2 app3 average b binary branch choice clear cleave concat cons dinfrirst dip dipd dipdd disenstacken div down_to_zero dudipd dup dupd dupdip enstacken eq first flatten floordiv gcd ge genrec getitem gt help i id ifte infra le least_fraction loop lshift lt map min mod modulus mul ne neg not nullary or over pam parse pm pop popd popdd popop pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll&lt; roll&gt; rolldown rollup rshift run second select sharing shunt size sqr sqrt stack step sub succ sum swaack swap swoncat swons ternary third times truediv truthy tuck unary uncons unit unquoted unstack void warranty while words x xor zip •
-</pre></div>
-</div>
-<p>Many of the functions are defined in Python, like <code class="docutils literal notranslate"><span class="pre">dip</span></code>:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getsource</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">library</span><span class="o">.</span><span class="n">dip</span><span class="p">)</span>
-</pre></div>
-</div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">dip</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-  <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</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">expression</span> <span class="o">=</span> <span class="n">x</span><span class="p">,</span> <span class="n">expression</span>
-  <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">pushback</span><span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span>
-</pre></div>
-</div>
-<p>Some functions are defined in equations in terms of other functions.
-When the interpreter executes a definition function that function just
-pushes its body expression onto the pending expression (the
-continuation) and returns control to the interpreter.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">joy</span><span class="o">.</span><span class="n">library</span><span class="o">.</span><span class="n">definitions</span>
-</pre></div>
-</div>
-<pre class="literal-block">
-second == rest first
-third == rest rest first
-product == 1 swap [*] step
-swons == swap cons
-swoncat == swap concat
-flatten == [] swap [concat] step
-unit == [] cons
-quoted == [unit] dip
-unquoted == [i] dip
-enstacken == stack [clear] dip
-disenstacken == ? [uncons ?] loop pop
-? == dup truthy
-dinfrirst == dip infra first
-nullary == [stack] dinfrirst
-unary == [stack [pop] dip] dinfrirst
-binary == [stack [popop] dip] dinfrirst
-ternary == [stack [popop pop] dip] dinfrirst
-pam == [i] map
-run == [] swap infra
-sqr == dup mul
-size == 0 swap [pop ++] step
-cleave == [i] app2 [popd] dip
-average == [sum 1.0 <em>] [size] cleave /
-gcd == 1 [tuck modulus dup 0 &gt;] loop pop
-least_fraction == dup [gcd] infra [div] concat map
-*fraction == [uncons] dip uncons [swap] dip concat [</em>] infra [*] dip cons
-<em>fraction0 == concat [[swap] dip * [</em>] dip] infra
-down_to_zero == [0 &gt;] [dup --] while
-range_to_zero == unit [down_to_zero] infra
-anamorphism == [pop []] swap [dip swons] genrec
-range == [0 &lt;=] [1 - dup] anamorphism
-while == swap [nullary] cons dup dipd concat loop
-dudipd == dup dipd
-primrec == [i] genrec
-</pre>
-<p>Currently, there’s no function to add new definitions to the dictionary
-from “within” Joy code itself. Adding new definitions remains a
-meta-interpreter action. You have to do it yourself, in Python, and wash
-your hands afterward.</p>
-<p>It would be simple enough to define one, but it would open the door to
-<em>name binding</em> and break the idea that all state is captured in the
-stack and expression. There’s an implicit <em>standard dictionary</em> that
-defines the actual semantics of the syntactic stack and expression
-datastructures (which only contain symbols, not the actual functions.
-Pickle some and see for yourself.)</p>
-<p>Which brings me to talking about one of my hopes and dreams for this
-notation: “There should be only one.” What I mean is that there should
-be one universal standard dictionary of commands, and all bespoke work
-done in a UI for purposes takes place by direct interaction and macros.
-There would be a <em>Grand Refactoring</em> biannually (two years, not six
-months, that’s semi-annually) where any new definitions factored out of
-the usage and macros of the previous time, along with new algorithms and
-such, were entered into the dictionary and posted to e.g. IPFS.</p>
-<p>Code should not burgeon wildly, as it does today. The variety of code
-should map more-or-less to the well-factored variety of human
-computably-solvable problems. There shouldn’t be dozens of chat apps, JS
-frameworks, programming languages. It’s a waste of time, a <a class="reference external" href="https://en.wikipedia.org/wiki/Thundering_herd_problem">fractal
-“thundering herd”
-attack</a> on
-human mentality.</p>
-<p>If you read over the other notebooks you’ll see that developing code in
-Joy is a lot like doing simple mathematics, and the descriptions of the
-code resemble math papers. The code also works the first time, no bugs.
-If you have any experience programming at all, you are probably
-skeptical, as I was, but it seems to work: deriving code mathematically
-seems to lead to fewer errors.</p>
-<p>But my point now is that this great ratio of textual explanation to wind
-up with code that consists of a few equations and could fit on an index
-card is highly desirable. Less code has fewer errors. The structure of
-Joy engenders a kind of thinking that seems to be very effective for
-developing structured processes.</p>
-<p>There seems to be an elegance and power to the notation.</p>
-</div>
-
-
-          </div>
-        </div>
-      </div>
-      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Joypy</a><ul>
-<li><a class="reference internal" href="#joy-in-python">Joy in Python</a><ul>
-<li><a class="reference internal" href="#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#stacks-aka-list-quote-sequence-etc">Stacks (aka list, quote, sequence, etc.)</a></li>
-<li><a class="reference internal" href="#the-joy-function">The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function.</a><ul>
-<li><a class="reference internal" href="#an-interpreter">An Interpreter</a><ul>
-<li><a class="reference internal" href="#view-function">View function</a></li>
-<li><a class="reference internal" href="#the-traceprinter">The <code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code>.</a></li>
-<li><a class="reference internal" href="#continuation-passing-style">Continuation-Passing Style</a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#parser">Parser</a></li>
-<li><a class="reference internal" href="#library">Library</a></li>
-</ul>
-<div class="relations">
-<h3>Related Topics</h3>
-<ul>
-  <li><a href="../index.html">Documentation overview</a><ul>
-  </ul></li>
-</ul>
-</div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/0. This Implementation of Joy in Python.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
-<div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
-    <div class="searchformwrapper">
-    <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
-      <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
-    </form>
-    </div>
-</div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
-        </div>
-      </div>
-      <div class="clearer"></div>
-    </div>
-    <div class="footer" role="contentinfo">
-<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
-<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
-</a>
-<br />
-<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
-    </div>
-
-  </body>
-</html>
\ No newline at end of file
index c53e852..f1ca011 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>within &#8212; Thun 0.1.1 documentation</title>
+    <title>A Generator for Approximations &#8212; Thun 0.1.1 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">
             
-  <div class="section" id="within">
-<h1><code class="docutils literal notranslate"><span class="pre">within</span></code><a class="headerlink" href="#within" title="Permalink to this headline">¶</a></h1>
+  <div class="section" id="a-generator-for-approximations">
+<h1>A Generator for Approximations<a class="headerlink" href="#a-generator-for-approximations" title="Permalink to this headline">¶</a></h1>
+<p>In <a class="reference internal" href="Generator Programs.html"><span class="doc">Using x to Generate Values</span></a> we derive a function <code class="docutils literal notranslate"><span class="pre">G</span></code> (called <code class="docutils literal notranslate"><span class="pre">make_generator</span></code> in the dictionary) that accepts an initial value and a quoted program and returns a new quoted program that, when driven by the <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator (<a class="reference internal" href="../library.html#joy.library.x" title="joy.library.x"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.library.x()</span></code></a>), acts like a lazy stream.</p>
+<p>To make a generator that generates successive approximations let’s start by assuming an initial approximation and then derive the function that computes the next approximation:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="n">F</span>
+<span class="o">---------</span>
+    <span class="n">a</span><span class="s1">&#39;</span>
+</pre></div>
+</div>
+<div class="section" id="a-function-to-compute-the-next-approximation">
+<h2>A Function to Compute the Next Approximation<a class="headerlink" href="#a-function-to-compute-the-next-approximation" title="Permalink to this headline">¶</a></h2>
+<p>Looking at the equation again:</p>
+<p><span class="math notranslate nohighlight">\(a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}\)</span></p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="n">n</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
+<span class="n">a</span> <span class="n">n</span> <span class="n">a</span>    <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
+<span class="n">a</span> <span class="n">n</span><span class="o">/</span><span class="n">a</span>      <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
+<span class="n">a</span><span class="o">+</span><span class="n">n</span><span class="o">/</span><span class="n">a</span>        <span class="mi">2</span> <span class="o">/</span>
+<span class="p">(</span><span class="n">a</span><span class="o">+</span><span class="n">n</span><span class="o">/</span><span class="n">a</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span>
+</pre></div>
+</div>
+<p>The function we want has the argument <code class="docutils literal notranslate"><span class="pre">n</span></code> in it:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">F</span> <span class="o">==</span> <span class="n">n</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="make-it-into-a-generator">
+<h2>Make it into a Generator<a class="headerlink" href="#make-it-into-a-generator" title="Permalink to this headline">¶</a></h2>
+<p>Our generator would be created by:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">dup</span> <span class="n">F</span><span class="p">]</span> <span class="n">make_generator</span>
+</pre></div>
+</div>
+<p>With <code class="docutils literal notranslate"><span class="pre">n</span></code> as part of the function <code class="docutils literal notranslate"><span class="pre">F</span></code>, but <code class="docutils literal notranslate"><span class="pre">n</span></code> is the input to the <code class="docutils literal notranslate"><span class="pre">sqrt</span></code> function we’re writing.  If we let 1 be the initial approximation:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="n">n</span> <span class="mi">1</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
+<span class="mi">1</span> <span class="n">n</span><span class="o">/</span><span class="mi">1</span>   <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
+<span class="mi">1</span> <span class="n">n</span>     <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
+<span class="n">n</span><span class="o">+</span><span class="mi">1</span>       <span class="mi">2</span> <span class="o">/</span>
+<span class="p">(</span><span class="n">n</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span>
+</pre></div>
+</div>
+<p>The generator can be written as:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
+</pre></div>
+</div>
+<p>Example:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span> <span class="mi">1</span> <span class="n">swap</span>  <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
+<span class="mi">1</span> <span class="mi">23</span>       <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
+<span class="mi">1</span>       <span class="p">[</span><span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span>      <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
+<span class="mi">1</span>   <span class="p">[</span><span class="n">dup</span> <span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span>                    <span class="n">make_generator</span>
+<span class="o">.</span>
+<span class="o">.</span>
+<span class="o">.</span>
+<span class="p">[</span><span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="a-generator-of-square-root-approximations">
+<h2>A Generator of Square Root Approximations<a class="headerlink" href="#a-generator-of-square-root-approximations" title="Permalink to this headline">¶</a></h2>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">gsra</span> <span class="o">==</span> <span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">make_generator</span>
+</pre></div>
+</div>
+</div>
+</div>
+<div class="section" id="finding-consecutive-approximations-within-a-tolerance">
+<h1>Finding Consecutive Approximations <code class="docutils literal notranslate"><span class="pre">within</span></code> a Tolerance<a class="headerlink" href="#finding-consecutive-approximations-within-a-tolerance" title="Permalink to this headline">¶</a></h1>
 <blockquote>
 <div>The remainder of a square root finder is a function <em>within</em>, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.</div></blockquote>
 <p>From <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why Functional Programming Matters” by John
 Hughes</a></p>
 <p>(And note that by “list” he means a lazily-evaluated list.)</p>
-<p>Using a <a class="reference internal" href="Generator Programs.html"><span class="doc">generator</span></a> driven by <code class="docutils literal notranslate"><span class="pre">x</span></code> and assuming such for square root approximations (or whatever) <code class="docutils literal notranslate"><span class="pre">G</span></code>, and further assuming that the first term <code class="docutils literal notranslate"><span class="pre">a</span></code> has been generated already and epsilon <code class="docutils literal notranslate"><span class="pre">ε</span></code> is handy on the stack…</p>
+<p>Using the <em>output</em> <code class="docutils literal notranslate"><span class="pre">[a</span> <span class="pre">G]</span></code> of the above <a class="reference internal" href="Generator Programs.html"><span class="doc">generator</span></a> for square root approximations, and further assuming that the first term <code class="docutils literal notranslate"><span class="pre">a</span></code> has been generated already and epsilon <code class="docutils literal notranslate"><span class="pre">ε</span></code> is handy on the stack…</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
-<span class="o">--------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&lt;=</span>
+<span class="o">----------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&lt;=</span>
       <span class="n">b</span>
-
-   <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
-<span class="o">--------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&gt;</span>
+</pre></div>
+</div>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
+<span class="o">----------------------</span> <span class="n">a</span> <span class="n">b</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span> <span class="o">&gt;</span>
        <span class="o">.</span>
    <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">x</span> <span class="n">ε</span> <span class="o">...</span>
    <span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="o">...</span>
        <span class="o">.</span>
-<span class="o">--------------------</span>
+<span class="o">----------------------</span>
    <span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
 </pre></div>
 </div>
@@ -85,7 +148,7 @@ Hughes</a></p>
 </div>
 <ol class="arabic simple">
 <li>Discard <code class="docutils literal notranslate"><span class="pre">a</span></code>.</li>
-<li>Use <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator to generate next term from G.</li>
+<li>Use <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator to generate next term from <code class="docutils literal notranslate"><span class="pre">G</span></code>.</li>
 <li>Run <code class="docutils literal notranslate"><span class="pre">within</span></code> with <code class="docutils literal notranslate"><span class="pre">i</span></code> (it is a <code class="docutils literal notranslate"><span class="pre">primrec</span></code> function.)</li>
 </ol>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span>        <span class="n">ε</span> <span class="n">R0</span>           <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">R1</span>
@@ -104,15 +167,29 @@ Hughes</a></p>
 </div>
 <div class="section" id="setting-up">
 <h2>Setting up<a class="headerlink" href="#setting-up" title="Permalink to this headline">¶</a></h2>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">a</span> <span class="n">G</span><span class="p">]</span> <span class="n">x</span> <span class="n">ε</span>
-<span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span>
+<p>The recursive function we have defined so far needs a slight preamble: <code class="docutils literal notranslate"><span class="pre">x</span></code> to prime the generator and the epsilon value to use:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">a</span> <span class="n">G</span><span class="p">]</span> <span class="n">x</span> <span class="n">ε</span> <span class="o">...</span>
+<span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="o">...</span>
 </pre></div>
 </div>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">within</span> <span class="o">==</span> <span class="n">x</span> <span class="n">ε</span> <span class="p">[[</span><span class="n">first</span> <span class="o">-</span> <span class="nb">abs</span><span class="p">]</span> <span class="n">dip</span> <span class="o">&lt;=</span><span class="p">]</span> <span class="p">[</span><span class="n">roll</span><span class="o">&lt;</span> <span class="n">popop</span> <span class="n">first</span><span class="p">]</span> <span class="p">[[</span><span class="n">popd</span> <span class="n">x</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span> <span class="n">primrec</span>
+</div>
+<div class="section" id="within">
+<h2><code class="docutils literal notranslate"><span class="pre">within</span></code><a class="headerlink" href="#within" title="Permalink to this headline">¶</a></h2>
+<p>Giving us the following definitions:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">_within_P</span> <span class="o">==</span> <span class="p">[</span><span class="n">first</span> <span class="o">-</span> <span class="nb">abs</span><span class="p">]</span> <span class="n">dip</span> <span class="o">&lt;=</span>
+<span class="n">_within_B</span> <span class="o">==</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="n">popop</span> <span class="n">first</span>
+<span class="n">_within_R</span> <span class="o">==</span> <span class="p">[</span><span class="n">popd</span> <span class="n">x</span><span class="p">]</span> <span class="n">dip</span>
+<span class="n">within</span> <span class="o">==</span> <span class="n">x</span> <span class="n">ε</span> <span class="p">[</span><span class="n">_within_P</span><span class="p">]</span> <span class="p">[</span><span class="n">_within_B</span><span class="p">]</span> <span class="p">[</span><span class="n">_within_R</span><span class="p">]</span> <span class="n">primrec</span>
 </pre></div>
 </div>
 </div>
 </div>
+<div class="section" id="finding-square-roots">
+<h1>Finding Square Roots<a class="headerlink" href="#finding-square-roots" title="Permalink to this headline">¶</a></h1>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sqrt</span> <span class="o">==</span> <span class="n">gsra</span> <span class="n">within</span>
+</pre></div>
+</div>
+</div>
 
 
           </div>
@@ -122,13 +199,21 @@ Hughes</a></p>
         <div class="sphinxsidebarwrapper">
   <h3><a href="../index.html">Table Of Contents</a></h3>
   <ul>
-<li><a class="reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">within</span></code></a><ul>
+<li><a class="reference internal" href="#">A Generator for Approximations</a><ul>
+<li><a class="reference internal" href="#a-function-to-compute-the-next-approximation">A Function to Compute the Next Approximation</a></li>
+<li><a class="reference internal" href="#make-it-into-a-generator">Make it into a Generator</a></li>
+<li><a class="reference internal" href="#a-generator-of-square-root-approximations">A Generator of Square Root Approximations</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#finding-consecutive-approximations-within-a-tolerance">Finding Consecutive Approximations <code class="docutils literal notranslate"><span class="pre">within</span></code> a Tolerance</a><ul>
 <li><a class="reference internal" href="#predicate">Predicate</a></li>
 <li><a class="reference internal" href="#base-case">Base-Case</a></li>
 <li><a class="reference internal" href="#recur">Recur</a></li>
 <li><a class="reference internal" href="#setting-up">Setting up</a></li>
+<li><a class="reference internal" href="#within"><code class="docutils literal notranslate"><span class="pre">within</span></code></a></li>
 </ul>
 </li>
+<li><a class="reference internal" href="#finding-square-roots">Finding Square Roots</a></li>
 </ul>
 <div class="relations">
 <h3>Related Topics</h3>
index df81c79..4fde6b0 100644 (file)
@@ -90,7 +90,7 @@ list</a> made from Python
 tuples.</p>
 </div>
 <div class="section" id="purely-functional-datastructures">
-<h2>Purely Functional Datastructures.<a class="headerlink" href="#purely-functional-datastructures" title="Permalink to this headline">¶</a></h2>
+<h2>Purely Functional Datastructures<a class="headerlink" href="#purely-functional-datastructures" title="Permalink to this headline">¶</a></h2>
 <p>Because Joy stacks are made out of Python tuples they are immutable, as are the other Python types we “borrow” for Joy, so all Joy datastructures are <a class="reference external" href="https://en.wikipedia.org/wiki/Purely_functional_data_structure">purely functional</a>.</p>
 </div>
 <div class="section" id="the-joy-function">
@@ -138,7 +138,7 @@ structure out of the tokens. There’s no Abstract Syntax Tree or anything
 like that.</p>
 <div class="section" id="symbols">
 <h3>Symbols<a class="headerlink" href="#symbols" title="Permalink to this headline">¶</a></h3>
-<p>TODO: Symbols are just a string subclass; used by the parser to represent function names and by the interpreter to look up functions in the dictionary.  N.B.: Symbols are not looked up at parse-time.  You <em>could</em> define recursive functions, er, recusively, without <code class="docutils literal notranslate"><span class="pre">genrec</span></code> or other recursion combinators  <code class="docutils literal notranslate"><span class="pre">foo</span> <span class="pre">==</span> <span class="pre">...</span> <span class="pre">fooo</span> <span class="pre">...</span></code> but don’t do that.</p>
+<p>TODO: Symbols are just a string subclass; used by the parser to represent function names and by the interpreter to look up functions in the dictionary.  N.B.: Symbols are not looked up at parse-time.  You <em>could</em> define recursive functions, er, recusively, without <code class="docutils literal notranslate"><span class="pre">genrec</span></code> or other recursion combinators  <code class="docutils literal notranslate"><span class="pre">foo</span> <span class="pre">==</span> <span class="pre">...</span> <span class="pre">foo</span> <span class="pre">...</span></code> but don’t do that.</p>
 </div>
 <div class="section" id="token-regular-expressions">
 <h3>Token Regular Expressions<a class="headerlink" href="#token-regular-expressions" title="Permalink to this headline">¶</a></h3>
@@ -300,7 +300,7 @@ developing structured processes.</p>
 <li><a class="reference internal" href="#">Thun: Joy in Python</a><ul>
 <li><a class="reference internal" href="#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
 <li><a class="reference internal" href="#the-stack">The Stack</a></li>
-<li><a class="reference internal" href="#purely-functional-datastructures">Purely Functional Datastructures.</a></li>
+<li><a class="reference internal" href="#purely-functional-datastructures">Purely Functional Datastructures</a></li>
 <li><a class="reference internal" href="#the-joy-function">The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function</a><ul>
 <li><a class="reference internal" href="#an-interpreter">An Interpreter</a></li>
 <li><a class="reference internal" href="#continuation-passing-style">Continuation-Passing Style</a></li>
index 6b116c6..677395a 100644 (file)
Binary files a/docs/sphinx_docs/_build/html/objects.inv and b/docs/sphinx_docs/_build/html/objects.inv differ
index 1644664..98b8ba9 100644 (file)
@@ -72,7 +72,7 @@ Any unbalanced square brackets will raise a ParseError.</p>
 <tbody valign="top">
 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>text</strong> (<em>str</em>) – Text to convert.</td>
 </tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">quote</td>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">stack</td>
 </tr>
 <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><a class="reference internal" href="#joy.parser.ParseError" title="joy.parser.ParseError"><strong>ParseError</strong></a> – if the parse fails.</td>
 </tr>
index 9c27e73..c16e007 100644 (file)
 <h1>Tracing Joy Execution<a class="headerlink" href="#tracing-joy-execution" title="Permalink to this headline">¶</a></h1>
 <div class="section" id="module-joy.utils.pretty_print">
 <span id="joy-utils-pretty-print"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.utils.pretty_print</span></code><a class="headerlink" href="#module-joy.utils.pretty_print" title="Permalink to this headline">¶</a></h2>
-<p>Pretty printing support.</p>
-<dl class="class">
-<dt id="joy.utils.pretty_print.TracePrinter">
-<em class="property">class </em><code class="descclassname">joy.utils.pretty_print.</code><code class="descname">TracePrinter</code><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter" title="Permalink to this definition">¶</a></dt>
-<dd><p>This is what does the formatting, e.g.:</p>
+<p>Pretty printing support, e.g.:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Joy? 23 18 * 99 +
        . 23 18 mul 99 add
     23 . 18 mul 99 add
    414 . 99 add
 414 99 . add
    513 . 
+
+513 &lt;-top
+
+joy? 
 </pre></div>
 </div>
+<p>On each line the stack is printed with the top to the right, then a <code class="docutils literal notranslate"><span class="pre">.</span></code> to
+represent the current locus of processing, then the pending expression to the
+left.</p>
+<dl class="class">
+<dt id="joy.utils.pretty_print.TracePrinter">
+<em class="property">class </em><code class="descclassname">joy.utils.pretty_print.</code><code class="descname">TracePrinter</code><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter" title="Permalink to this definition">¶</a></dt>
+<dd><p>This is what does the formatting.  You instantiate it and pass the <code class="docutils literal notranslate"><span class="pre">viewer()</span></code>
+method to the <a class="reference internal" href="joy.html#joy.joy.joy" title="joy.joy.joy"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.joy.joy()</span></code></a> function, then print it to see the
+trace.</p>
+<dl class="method">
+<dt id="joy.utils.pretty_print.TracePrinter.go">
+<code class="descname">go</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter.go"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.go" title="Permalink to this definition">¶</a></dt>
+<dd><p>Return a list of strings, one for each entry in the history, prefixed
+with enough spaces to align all the interpreter dots.</p>
+<p>This method is called internally by the <code class="docutils literal notranslate"><span class="pre">__str__()</span></code> method.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list(str)</td>
+</tr>
+</tbody>
+</table>
+</dd></dl>
+
 <dl class="method">
 <dt id="joy.utils.pretty_print.TracePrinter.viewer">
 <code class="descname">viewer</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter.viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.viewer" title="Permalink to this definition">¶</a></dt>
-<dd><p>Pass this method as the viewer to joy() function.</p>
+<dd><p>Record the current stack and expression in the TracePrinter’s history.
+Pass this method as the <code class="docutils literal notranslate"><span class="pre">viewer</span></code> argument to the <a class="reference internal" href="joy.html#joy.joy.joy" title="joy.joy.joy"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.joy.joy()</span></code></a> function.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
+<li><strong>quote</strong> (<em>stack</em>) – A stack.</li>
+<li><strong>expression</strong> (<em>stack</em>) – A stack.</li>
+</ul>
+</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 </dd></dl>
index 1230b7a..7c24c6f 100644 (file)
@@ -1 +1 @@
-Search.setIndex({docnames:["index","joy","lib","library","notebooks/4. Replacing Functions in the Dictionary","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/AlsoNewton","notebooks/Categorical","notebooks/Developing","notebooks/Generator Programs","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Quadratic","notebooks/Trees","notebooks/Zipper","notebooks/index","parser","pretty","stack"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/4. Replacing Functions in the Dictionary.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/AlsoNewton.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/Quadratic.rst","notebooks/Trees.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,""],concat:[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:[23,4,1,""],Symbol:[23,2,1,""],text_to_expression:[23,1,1,""]},"joy.utils":{pretty_print:[24,0,0,"-"],stack:[25,0,0,"-"]},"joy.utils.pretty_print":{TracePrinter:[24,2,1,""]},"joy.utils.pretty_print.TracePrinter":{viewer:[24,5,1,""]},"joy.utils.stack":{expression_to_string:[25,1,1,""],iter_stack:[25,1,1,""],list_to_stack:[25,1,1,""],pick:[25,1,1,""],pushback:[25,1,1,""],stack_to_string:[25,1,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[23,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":13,"0th":[],"10m":15,"10n":15,"4ac":19,"5bkei":20,"\u03b5":[11,17],"abstract":[16,20],"boolean":[2,3,16,20],"break":[10,16],"byte":13,"case":[2,3,4,6,10,15,25],"class":[3,16,23,24],"default":[3,9,14],"export":[3,23],"final":[2,7,15],"float":[3,16,21,23],"function":[0,1,4,5,6,7,8,9,11,12,13,14,17,18,21,22,23,24,25],"g\u00e9rard":21,"import":[2,4,5,6,7,8,9,10,13,14,15,17,19,20,21],"int":[7,14,15,16,21,23],"new":[2,3,4,7,14,15,16,18,20],"public":18,"return":[1,3,4,6,7,9,10,13,15,16,19,20,23,25],"short":19,"static":[2,18],"switch":2,"true":[2,3,6,7,13,15,20],"try":[7,14,15],"void":[0,3],"while":[3,7,9,10,16,23],Adding:[16,22],And:[5,7,11,13,14,15,17,20,21],But:[0,6,12,13,15,16,20],CPS:16,For:[2,3,5,6,7,8,9,14,15,20,22,25],Going:6,Has:3,Its:3,Not:7,One:[2,16],RHS:20,TOS:[2,3,15],That:[13,15,20],The:[0,1,2,3,4,5,6,7,8,9,11,12,14,17,18,19,21,22,23,25],Then:[2,3,6,9,19,20],There:[7,9,15,20],These:22,Use:[3,11,15],Using:[7,11,15,20],With:[5,15],_pars:[],aaa:8,abbrevi:20,abl:19,about:[0,7,9,16,20,21,25],abov:[0,4,7,13,17,19,20],abs:[7,11,17],absolut:[7,16],accept:[1,2,3,13,15,16,20,21],access:[7,9],accomplish:19,accordingli:20,accumul:13,across:[7,9],action:[16,21],actual:[2,7,13,16,20],adapt:22,add:[3,5,6,7,13,14,16,19,24],add_alias:3,add_def:3,add_definit:[3,9,15,20],add_if_match:5,add_valu:9,added:[12,20],adding:[7,18],addit:[0,2,3,9,13,15,16,20],admit:7,advantag:15,after:[5,7,9,13,14,16],afterward:16,again:[2,3,7,9,13,16,20],against:[6,7],aggreg:[3,21],aka:[16,21],albrecht:0,algebra:20,algorithm:16,alia:3,alias:[3,16],align:16,all:[3,5,6,13,14,15,16,17,20],alloc:7,allow:[15,18,20],almost:20,alon:17,along:[15,16,19],alphabet:3,alreadi:[4,7,11,21],also:[0,13,15,16],altern:[12,20],although:[5,12,20],altogeth:14,alwai:[7,13,15,18],amort:20,amount:7,analysi:[12,22],anamorph:16,ani:[9,12,13,16,18,20,21,23],annual:16,anonym:20,anoth:[5,15,20],answer:7,anyth:[2,3,16],aoc20017:6,aoc20173:7,aoc2017:[5,6,7,8,9,10],api:18,app1:3,app2:[3,4,6,16,19],app3:3,app:16,appear:[2,8,12,13,20],append:9,appli:[2,3,6,13,17,20],applic:14,approach:[13,19],approxim:11,archiv:0,aren:21,arg:[2,3],argument:[2,3,14,15,16,25],arithmet:2,ariti:2,around:[13,25],arrai:9,arrang:9,arriv:[14,20],articl:[0,12],ask:[7,12,14],aspect:[0,7],assembl:9,assert:[7,10],assign:25,associ:20,assum:[5,6,8,9,11],asterisk:20,attack:16,attempt:[0,1],attribut:3,automat:[12,15,22],avail:[0,8],averag:[4,16],avoid:20,awar:2,awkward:20,azur:22,back:[7,9,20],backward:[18,20],bad:[],bag:16,banana:[15,20],bank:10,barb:15,base:[0,2,3,6,10,15,18],basic:[1,2,3,5,7,16,20],bear:9,beat:9,becaus:[2,3,5,6,7,9,15,16,20,21],becom:[5,19,20,25],been:[11,15,18,20,21],befor:[6,9,14,15,16,20],begin:[7,15,20],behavior:[18,20],behaviour:[0,1],behind:9,being:0,belong:9,below:[2,3,7,13,14,17,20,21],bespok:16,best:0,better:[7,13,14,20],between:[0,6,7,13],biannual:16,big:[7,9,20],binari:[0,14,16,20],binary_search_tre:20,binarybuiltinwrapp:3,bind:16,bingo:21,bit:[7,13,14,20],block:[10,13],bodi:[2,16,20],body_text:3,bool:[6,15],borrow:16,both:[2,4,7,9,13,15,16,17,19],bottom:14,boundari:7,bracket:[7,16,23],branch:[3,5,6,9,13,14,17,20],breakpoint:16,bring:[13,16],btree:22,buck:20,bug:[0,16],build:[15,16,20,21],built:[15,19],bundl:[2,3],burgeon:16,calcul:7,calculu:12,call:[2,15,16,18,19],caller:20,came:[9,20],can:[0,2,3,4,5,6,7,12,13,14,15,16,17,18,19,21,22,25],candid:6,captur:16,card:16,care:[7,13,25],carefulli:[20,21],carri:[5,7,15],cartesian:12,catamorph:4,categor:[0,19,22],categori:12,ccc:12,ccon:20,ceil:7,certain:[16,25],certainli:20,chang:[2,7,9,18,20,21],charact:21,chat:16,chatter:0,cheat:10,check:[6,14,15],checksum:6,child0:20,childn:20,children:20,choic:[3,15],choos:[18,20],circuit:12,circular:[5,20],cite_not:20,classmethod:3,clear:[3,7,13,16],cleav:[4,5,6,8,16,19],close:[0,1,12],clunki:13,cmp:22,cmp_:20,code:[0,1,12,15,17,20],collaps:15,collect:[12,14,16],column:7,combin:[0,3,8,11,13,14,16,19,21,22],come:[7,9,16],command:[5,16,19,20],common:[2,13,15],compar:[7,12],comparison:0,compel:12,compil:[2,9,12,15,16],complet:12,complex:[3,21],compos:15,compound:20,comput:[2,6,7,9,12,13,16,19,22],con:[3,6,9,10,13,14,15,16,19,21,25],conal:12,concat:[3,5,14,15,16,20],concaten:0,concatin:[0,3,25],concis:7,concret:15,concurr:2,condit:[9,16],condition:6,confid:7,conflict:20,cons2:20,consecut:14,consid:[9,13,14,15,20,21],consist:[2,7,16,20],constant:20,constitu:15,consum:[6,15],contain:[0,2,3,7,8,14,15,16],context:2,continu:[0,6,15,21],control:16,conveni:12,convert:[4,15,20,23,25],cook:15,cool:20,copi:[2,3,5,13,15,20,22],copyright:16,corner:7,correct:7,correctli:20,correspond:12,could:[2,7,9,12,13,15,16,18,20,21],count:[3,7,8,14],count_stat:10,counter:13,cours:[7,9,13,15,20],cover:7,cpu:7,crack:20,crap:22,crash:20,creat:[0,2,3,5,13,14,15,20],crude:[20,23],csp:[],current:[2,3,9,15,16,21],custom:18,cycl:[13,14],cython:16,dai:[15,16],data:[2,3,7,22],datastructur:[0,2,15,21,23,25],datatyp:25,ddididi:21,deal:[0,5,20],debugg:15,decid:20,decor:3,decoupl:15,decreas:7,decrement:3,deduc:13,deeper:0,deepli:12,def:[3,4,7,9,10,15,16,19,20,25],defi:3,defin:[2,3,5,6,7,8,9,10,12,13,14,15,16,17,18,21],definit:[2,3,4,8,9,13,14,15,16,18,20,22],definitionwrapp:[3,9,15,20],deleg:16,delet:22,demonstr:[12,15],depend:[15,20],deposit:20,dequot:[5,15],deriv:[2,3,5,6,13,16,22],descend:6,describ:[3,12,15,20,23],descript:[13,16,20],design:[2,3,6,20],desir:[7,16,20],destruct:20,detail:[7,16,20],detect:[6,14,15,20],determin:[6,7],develop:[0,14,16,22],diagram:13,dialect:1,dict:[1,3],dictionari:[1,3,4,16,19,20],did:7,didn:15,differ:[0,6,8,11,12,13,15,19,20],differenti:12,dig:21,digit:[5,13],dimension:7,dinfrirst:16,dip:[3,4,6,7,9,10,11,13,14,15,16,17,19,20],dipd:[3,9,14,15,16,19,20,21],dipdd:[3,20],direco:10,direct:16,directli:[7,13,20,25],disappear:2,discard:[3,11,14,15,17,20],discov:6,disenstacken:[16,20],disk:16,displac:2,distanc:7,distribut:10,ditch:20,div:[3,16],dive:20,divid:6,divis:[6,20],divisor:6,divmod:[3,6],divmod_:3,doc:[2,3,16],document:[22,23],doe:[0,1,6,7,9,12,15,16,22,24],doesn:[5,9,13,15,18,20,25],dog:20,doing:[7,12,13,15,16,21],domain:[7,12],don:[6,7,9,13,16,20],done:[2,13,14,16,18],doodl:7,door:16,doubl:[13,16],down:[2,3,7,9,11,21],down_to_zero:16,downward:9,dozen:16,draft:[10,12,18],dream:16,drive:14,driven:[11,13],driver:14,drop:[3,5,20],dudipd:16,due:5,dummi:6,dup:[3,5,6,7,9,10,13,14,15,16,17,19,20,21,25],dupd:3,dupdip:[3,6,7,13,15,19,20],duplic:[3,8,15,20],durat:2,dure:[2,4,15],each:[2,3,4,5,6,7,9,12,13,15,16,20],easi:[0,7,17,20,21],easier:[3,5,20],easili:12,edit:22,effect:[2,3,16,21],effici:[7,9,21],either:[1,2,3,6,15,20],eleg:[9,16,19,20],element:[2,3],elif:[],elliott:12,els:[2,3,5,6,9,10,15],embed:[12,20,21],empti:[3,6,16,25],enabl:[],encapsul:16,enclos:16,encod:[9,14],encount:9,end:[7,9,13,15,25],endless:14,enforc:[2,16],engend:16,enlarg:7,enough:[7,15,16,19],enstacken:[14,16],ensur:8,enter:16,entri:[3,21],epsilon:11,equal:13,equat:[7,16,17],ergo:[7,15,20],err:[17,20],error:[7,16,22,23],escap:9,essai:0,estim:17,etc:[3,7,21,23],euler:22,eval:0,evalu:[1,2,3,4,5,11,15,16,19,20],even:9,evenli:6,eventu:[7,19],everi:14,everyth:[3,20],evolv:18,exactli:15,exampl:[0,3,5,6,7,8,9,13,14,15,20,23,25],exce:14,except:[16,20,23],execut:[0,1,2,3,4,6,16,17,21],exist:12,exit:9,expect:[2,3,6,15,17,20,25],experi:16,experiment:7,explan:16,explor:16,express:[0,1,2,3,4,12,15,20,21,24,25],expression_to_str:25,extend:7,extra:[5,6,13],extrem:16,extrememli:16,facet:0,facil:16,fact:[20,23],factor:[2,13,16,22],fail:[2,3,6,20,23],fals:[2,3,6,10,13,15],far:[9,15,20],fascin:0,fast:7,faster:7,favorit:19,fear:20,feel:7,few:[7,13,16],fewer:[3,16],fib:14,fib_gen:14,figur:[2,3,7,20],filter:20,fin:13,find:[2,3,5,6,13,14,20,22,25],finder:11,fine:[0,13,20],finish:19,first:[3,4,5,6,7,9,10,11,14,15,16,19,20,21,22],fit:[13,16,19],five:[13,15,16],fix:[2,3],flag:6,flatten:[16,20],flexibl:20,floor:[3,7],floordiv:13,flow:16,follow:[0,2,3,6,9,15,16,18,21],foo:[16,18,20],foo_ii:18,fooo:16,form:[2,3,6,8,12,13,14,22,25],forman:16,format:[22,24],formula:[0,7,13,22],forth:[5,9,16,20],fortun:9,forum:0,forward:[6,9],found:[9,10,16,20],four:[2,3,7,9,13,14,16,20],fourteen:13,fourth:[2,3,5,20],fractal:16,fraction0:16,fraction:[2,16],fragment:17,frame:[],framework:16,free:[12,16,20],freeli:[2,7],from:[0,1,2,3,4,5,6,7,8,9,10,11,13,14,16,17,19,20,21,22,25],front:[2,3],full:[8,13],fun:7,functionwrapp:[3,20],funtion:20,further:[11,22],futur:19,garbag:16,gari:20,gcd:16,gen:10,gener:[2,3,7,9,11,12,17,22],genrec:[3,6,9,15,16,17,20],geometr:13,geometri:20,get:[2,4,6,7,12,13,14,15,16,17,22],get_valu:9,getdoc:[],getitem:3,getsourc:16,ghc:12,give:[7,12,13,15,25],given:[2,3,4,5,6,7,9,10,11,13,14,21],glue:16,goal:9,going:[6,7,9,20,21],good:[9,13,20],grab:3,grammar:23,grand:16,graph:7,great:[0,5,7,16,22],greater:7,grid:7,group:[0,7],guard:[6,7],had:[13,21],haiku:16,half:[13,21],half_of_s:5,halfwai:5,hand:[4,16,19,20,22],handi:11,happen:[7,16,20],hard:[17,21],hardli:15,hardwar:12,has:[0,2,6,7,9,11,14,15,16,18,20,21,25],haskel:12,have:[2,3,5,6,7,9,10,13,14,15,16,18,20,21,22],head:[6,15,25],help:[4,8,15,16,20],help_:3,helper:[3,6],herd:16,here:[7,13,14,15,17,19,20,21],heterogen:20,heurist:[5,9],hide:20,higher:[16,20],highest:6,highli:[16,20],hindsight:6,hmm:20,hog:20,hoist:3,hold:13,hood:9,hope:[0,13,16,22],host:22,how:[0,7,8,9,12,15,20,21],html:[2,3,14,19,22],http:20,huet:21,hugh:[11,17,20],human:16,hypothet:2,id_:3,idea:[12,13,16,20],ident:[3,15],identifi:7,ift:[3,5,6,9,15,17,20],ignor:[3,20],illustr:15,imagin:21,immedi:[9,15],immut:[16,20],imper:15,implement:[0,1,2,3,7,10,12,15,16,18,19,20],impli:6,implicit:16,includ:[8,12],inclus:13,incom:25,incompat:18,incr_at:9,incr_step_count:9,incr_valu:9,increas:[7,9,13],increment:[3,12,13,18],index:[0,7,10,16],index_of:10,indexerror:[],indic:20,infil:20,infinit:7,inform:3,infra:[3,4,14,15,16,19],infrastructur:3,init:9,init_print:7,initi:[2,3,4,6,7,8,9,16,20],inlin:20,inner:6,input:[1,5,6,7,8,15],inscrib:3,inspect:16,instal:0,instanti:12,instead:[7,13,14,15,20,21],instruct:9,integ:[2,3,5,6,7,8,9,14,15,16],integr:3,intend:[0,16],interact:[16,22],interest:[0,7,13,14,20],interlock:7,interlud:22,intermedi:15,intern:0,interpret:[0,12,15,18,23],interrupt:16,interv:[12,13],introduc:18,introduct:0,invari:3,invers:3,investig:19,ipf:16,ipynb:14,isinst:[],isn:[15,21],item:[2,3,5,6,10,15,16,20,25],iter:[1,3,7,15,16,22,25],iter_stack:[4,10,25],its:[0,2,3,6,7,12,13,15,16,20,25],itself:[0,2,9,16,20],j05cmp:[2,3],jenni:20,job:[9,22],john:[11,17,20],joi:[2,4,5,6,8,9,10,12,18,19,20],join:[],joypi:[9,10,15,16,20,21],jump:9,jupyt:22,just:[0,2,3,5,6,7,9,14,15,16,18,21],keep:21,kei:22,kevin:0,key_n:20,keyerror:20,kind:[2,7,9,12,15,16,20],kleen:20,know:[7,13,15,20],known:12,labda:12,lambda:[12,15],lambdifi:7,languag:[12,16,18,19,20],larg:7,larger:7,largest:[3,6,9],last:[5,9,13,15],lastli:[14,15],later:[9,16,17],law:2,lazili:11,lcm:13,lead:[9,16],leaf:20,lean:16,learn:[0,10],least:[2,7,9,13,15,25],least_fract:16,leav:[6,7,9,13,14,17,20],left:[7,14,15,16,21,25],leftov:15,legendari:9,legibl:9,len:10,length:[3,13],lens:15,less:[13,14,15,16],lesser:7,let:[5,6,7,9,14,15,17,19,20,21],level:[12,20],librari:[0,4,7,9,10,19,20],lieu:20,like:[2,3,6,7,10,13,15,16,19,23],line:[3,6,9,15,16,20],linear:25,link:0,linux:0,list:[0,3,5,6,8,9,10,11,13,16,21,22],list_to_stack:[9,10,25],liter:[1,20,21,23],littl:[7,9,20,22],live:22,lkei:20,load:[13,16],locat:[2,7],log_2:20,logic:[0,13],longer:20,look:[7,11,14,16,20],lookup:[16,20],loop:[0,1,3,13],lot:[16,19,20,21],love:13,low:12,lower:13,lowest:6,lshift:[],machin:[0,20],machineri:20,macro:16,made:[0,6,16,20,21],mai:[2,9,15,20],mail:0,main:[0,3,5,16,21],mainloop:18,maintain:21,major:18,make:[2,3,4,5,12,13,15,16,21],make_distributor:10,manfr:[0,2,3,12],manhattan:7,mani:[0,7,8,9,14,15,16],manipul:7,manual:[7,15],map:[1,3,13,15,16,18,19,20],map_:3,mark:[7,9],marker:16,mask:[13,14],match:[0,1,5],materi:0,math:[0,7,9,16,20],mathemat:[7,16],matter:[5,11,13,15,17,20],max:[6,7,10],max_:3,maximum:[3,20],maxmin:6,mayb:[15,20],maze:9,mean:[6,11,12,13,15,16,20,25],meant:[15,16,19,20],meantim:9,mem:9,member:[2,3,7],memori:7,mental:16,mention:2,mercuri:0,merg:20,meta:[16,20],methink:20,method:[0,3,7,16,22,24],mfloor:7,midpoint:13,might:[5,12,14,15,20],million:14,min:6,min_:3,mind:9,minimum:3,minu:[3,19],mirror:0,miscellan:[0,22],mistak:10,mix:16,mnemon:5,mod:3,model:[12,16],modern:0,modif:14,modifi:[9,16,21],modul:[0,1,3,16,23],modulu:16,monkei:7,month:16,more:[0,3,4,8,9,11,12,13,14,15,16,19,20,23,25],most:20,mostli:0,move:[5,7,9],movement:2,mrank_of:7,much:[7,9,13,15,20],muck:20,mul:[16,19,21,24],multi:3,multipl:[15,22],must:[2,3,6,7,8,13,15,18],mutabl:9,n_kei:20,n_rang:14,n_valu:20,nail:9,name:[1,3,4,5,16,18,21,22,23,25],natur:[13,14,20],navig:21,need:[2,3,5,6,7,9,10,13,14,15,17,18,20],neg:[3,9,19],nest:[16,20,21],network:16,never:18,newton:[0,22],next:[4,5,6,7,9,11,13,15,17,20],nice:[0,5,7,15,25],niether:2,node:22,non:[6,20],none:[1,3],normal:[8,15],notat:[16,20],note:[2,7,11,13,20,25],notebook:[13,16,21,22],notebook_preambl:[2,4,5,6,7,8,9,10,13,14,15,17,19,20,21],noth:[2,20],notic:13,now:[4,5,6,7,13,14,15,16,17,22],nth:[3,25],nullari:[6,9,10,16,17,20],number:[1,2,3,4,6,13,14,22,25],object:23,observ:13,obviou:[14,17],obvious:[6,8,9],occur:20,odd:[13,14],off:[2,3,7,13,14,21],offset:9,offset_of:7,old:[2,4],old_siz:4,old_sum:4,omit:15,onc:[3,8,18,19,20],one:[2,3,5,6,7,8,9,13,14,15,19,20,25],ones:14,onli:[2,3,5,6,7,9,13,15,20,21],onto:[1,2,3,16,25],open:[8,16],oper:[3,6,15,16,20,25],oppos:5,option:[1,16],order:[2,3,5,6,15,16,22],org:[0,20],origin:[0,1,2,3,5,20,21],other:[0,2,3,6,7,12,15,16,20,25],otherwis:[3,6,13,14,20],our:[5,6,7,13,14,15,16],ourselv:15,out:[2,3,7,12,13,14,15,16,20,21],outcom:20,output:[7,15],outsid:[9,12],outward:7,over:[3,5,7,12,13,14,16,19,20,22],overhead:7,overkil:15,overshadow:7,own:[7,20],pack:[20,25],packag:[0,16],page:[0,19,20],pair:[2,3,5,6,13,14],pair_up:5,palidrom:13,palindrom:13,pam:[16,19],paper:[7,12,15,16,20,21],parallel:2,paramet:[1,2,3,9,15,23],paranthes:20,parenthes:[9,20,25],pariti:14,pars:[0,3,16,20],parse_definit:3,parseerror:23,parser:0,part:[2,3,6,9,15,19,20],partial:[7,15],particular:21,particularli:9,pass:[0,20,24],passphras:8,path:7,pattern:[7,13,20],payoff:15,pe1:[13,14],pe2:14,pearl:21,pend:[3,15,16,21],peopl:22,per:[7,16],perform:9,perhap:14,period:16,permit:[9,25],persist:20,phase:2,pick:[13,14,25],pickl:16,pictur:20,piec:15,pip:0,pita:10,place:[3,7,9,13,15,16],plai:0,plain:9,plane:7,plu:[3,7,19],plug:[14,15,20],point:[7,12,15,16,20],pointless:2,pop:[3,4,5,6,9,10,13,14,15,16,19,20,25],popd:[3,4,9,11,16,17],popdd:[3,6,14,19],popop:[3,5,6,9,10,11,13,14,15,16,17,20],port:7,posit:[3,9,13,15,16],possibilit:20,possibl:[6,20,22],post:[16,20],potenti:3,pow:[],power:16,pragmat:13,pre:[9,15,20],precis:[0,1,17],pred:3,predic:[2,6,14,15,17],prefer:15,prefix:15,prep:[6,20],prepar:[9,15],preprocessor:15,present:20,preserv:12,pretti:[7,17,19,20,24,25],pretty_print:0,prevent:15,previou:[7,9,16],prime:6,primit:[2,3,4,9,17,19],primrec:[3,6,9,10,11,14,15,16,17],print:[0,1,2,3,7,15,24,25],probabl:[5,14,16,20],problem:[7,16,22],proc_curr:20,proc_left:20,proc_right:20,proce:[5,13],process:[9,15,16],processor:20,produc:[5,13,15,20],product:16,program:[0,2,3,5,6,7,9,11,14,16,17,21],project:22,prompt:16,proper:[2,3],properli:9,properti:0,provid:[0,3,12,16],prune:20,pun:[0,16],pure:[0,20],purely_functional_data_structur:[],puriti:16,purpos:16,push:[2,3,15,16,21,25],pushback:[16,20,25],put:[1,2,14,16,25],puzzl:[5,6,7,8],pypi:0,pyramid:7,python:[0,2,3,4,7,9,15,19,20,21,23,25],qed:[],quadrat:[0,7,22],queri:20,queu:15,quit:[0,1,7],quot:[0,1,3,4,14,15,16,19,20,21,23],quotat:[2,3],quotient:3,rais:[20,23],random:9,rang:[7,15,16],range_sum:15,range_to_zero:16,rank_and_offset:7,rank_of:7,raphson:17,rather:[13,15,16,20],ratio:16,reach:[9,13,14,15],read:[0,1,13,14,20,21],readabl:4,real:20,realiz:[5,9,12,20],realli:[4,7],rearrang:[2,15],reason:[7,13,16],rebuild:21,rec1:[2,3],rec2:[2,3],recogn:23,record:16,recur:15,recurs:[2,3,6,9,10,14,16,17,22,25],recus:16,recusr:20,redistribut:[3,16],reduc:2,redund:25,reexamin:20,refactor:[15,16,18],refer:[0,2],refin:17,regist:2,regular:23,rel:[9,19],releas:18,relev:7,rem:[],remain:[2,3,16,18],remaind:[3,11],remind:15,remov:[3,7,20],renam:20,render:[20,22],repeat:[5,7,13],repeatedli:13,repl:[0,1],replac:[2,3,14,15,17,21,25],repositori:0,repres:[2,16,20,23],represent:[],reprod:14,request:7,requir:[7,25],resembl:16,respect:13,rest:[3,6,10,13,14,16,20,21,22,25],restor:2,result:[1,2,3,6,13,14,15,19,20,21],resum:16,retir:2,retri:16,reus:20,revers:[3,5,6,13,14,15,21],rewrit:[9,16],rewritten:16,richard:20,right:[7,14,15,16,25],rightmost:13,rkei:20,role:20,roll:[3,6,8,9,11,15,19,20],rolldown:3,rollup:3,root:[3,7,11,19,22],rotate_seq:5,round:5,row:[6,7],row_valu:7,rshift:[],run:[0,1,3,7,11,13,15,16,20,21],runtim:7,sai:20,same:[2,12,13,15,20,25],sandwich:[2,3],save:[2,13,16],scan:3,scanner:[16,23],scenario:21,scheme:[19,20],scope:[5,20],search:[0,7,20],second:[3,5,6,15,16,20,25],secur:8,see:[0,4,7,14,15,16,18,20,21],seem:[0,10,13,16,20],seen:21,select:[3,7],semant:[2,3,16,18,20],semi:16,send:16,sens:[0,2,13,21],separ:16,sequenc:[0,1,2,3,4,5,6,8,9,10,13,16,20,21,23],seri:[7,13,14,15,20,21],serv:15,set:[2,3,15],seven:[13,14],sever:[0,12,16],shadow:4,share:[3,7,16],shelf:2,shift:[13,14],shine:9,shortest:7,should:[2,6,13,15,17,20],shouldn:16,show:[7,12,20,21],shunt:[3,21],side:20,sign:7,signal:6,signifi:[16,20],silli:20,similar:20,simon:16,simpl:[7,15,16,25],simplefunctionwrapp:[3,4,9,10,19],simplest:22,simpli:12,simplifi:[7,13,20,21],sinc:[2,7,13,19,20],singl:[3,4,14,16,23],situ:20,situat:20,six:[13,14,16],sixti:[13,14],size:[5,8,9,10,16],skeptic:16,skip:[7,9],slightli:[15,20],small:[5,20],smallest:[3,6],smart:[9,15],sneaki:7,softwar:16,solei:2,solut:[7,13],solv:7,solvabl:16,some:[2,3,6,7,9,14,15,16,20,22,25],somehow:20,someth:[2,5,9,18],sometim:20,somewher:[15,20,22],sophist:7,sort:[3,6,15,19,20],sort_:3,sourc:[0,1,3,23,24,25],space:[7,13],span:13,special:[14,15,20],specif:[0,12],speed:[4,7,9],sphinx:22,spiral:7,spirit:[0,1,20],split_at:5,spreadsheet:6,sqr:[16,17,19,21],sqrt:[3,7,19],squar:[3,7,11,22,23],stack:[0,1,3,4,6,9,10,11,13,14,15,17,19,20,21,24],stack_:3,stack_to_str:25,stage:20,stai:[0,1],stand:12,standard:16,star:20,stare:20,start:[6,7,9,10,13,14,15,16,19,20],state:[6,9,16],step:[3,4,5,6,7,8,13,16,19,20,21],step_zero:[5,6,8],still:[7,9,15],stop:20,storag:[13,15,20],store:[7,13,15],stori:15,str:23,straightforward:[1,5,7,14],strang:9,stream:13,string:[1,2,3,5,16,21,23,25],strip:7,structur:[15,16,20,21,25],stuff:20,style:[0,12],sub:18,subclass:16,subject:21,subract:7,substitut:[7,15],subtract:[6,7,13],succ:3,success:11,suffici:[9,15],suggest:[6,12,20],suitabl:[3,12,13],sum:[3,5,6,14,15,16,19,20],sum_:[3,4],summand:13,suppli:[15,20,23],support:[7,16,24],sure:[7,15],suspect:2,swaack:[3,4,15,19,20,21],swap:[3,4,5,6,7,8,10,13,14,15,16,20,21],swon:[3,10,14,15,16,20,21],swoncat:[9,10,14,15,16,20],symbol:[2,3,7,19,21,23],symmetr:13,sympi:19,syntact:16,syntax:[16,25],sys:7,system:[7,8,16,20],tail:[6,20,25],take:[3,5,7,9,11,13,14,16,19,20,25],taken:9,talk:[16,20,25],target:[7,21],task:7,tast:12,tbd:16,technic:2,techniqu:[12,21],technolog:2,teh:20,temporari:21,ten:13,term:[1,2,6,9,10,11,15,16,23,25],termin:[2,3,6],ternari:16,test:[2,3],text:[0,1,3],text_to_express:[16,23],textual:16,than:[0,3,7,8,11,13,14,16,19],thei:[2,4,6,7,13,14,15,16,20,21,23,25],them:[2,3,4,6,7,13,14,15,20,21,22],theori:[2,3],therefor:[14,20],thi:[0,1,2,3,4,5,6,7,9,10,12,13,14,15,16,17,19,21,23,24,25],thing:[2,6,7,9,14,15,19,20,21,23,25],think:[2,9,13,15,16,20],third:[3,5,6,14,16,20],thirti:13,those:[2,3,6,7,9,15,20,22],though:[13,14,20],thought:16,thousand:13,thread:2,three:[2,3,9,13,16,20],through:[1,13,16,21,25],thu:5,thun:[2,3,12,18],thunder:16,tied:20,tile:7,time:[3,7,9,10,13,15,16,20,21],tini:20,to_set:20,todai:16,todo:[16,22,23],togeth:[14,16],tok:[],token:23,toler:11,tommi:20,too:[15,20],took:7,tool:16,top:[2,3,16,25],total:[5,7,13],total_match:5,trace:[0,16,19,21],traceprint:24,track:21,tracker:0,trade:7,transform:[12,15],translat:[7,12,15],travers:[21,22],treasur:0,treat:[0,2,3,22],treatment:14,tree:[0,16,22],treemap:15,tri:13,trick:[13,20],tricki:[7,9],trivial:[6,9,20],trobe:0,trove:0,truediv:19,truthi:[3,16],ts0:[15,20],ts1:[15,20],tuck:[3,6,16,17,20],tupl:[3,16,25],turn:[2,3,7],twice:[7,15,20],two:[2,3,6,7,11,13,15,16,17,20,21,25],type:[12,15,16,22,23],typic:[2,3],unari:[9,15,16,17],unarybuiltinwrapp:3,unbalanc:23,unclos:[],uncon:[3,5,6,14,15,16,20,21],under:[2,3,9,16],understand:[0,7,20],undocu:16,uniqu:[3,8,20],unit:[5,15,16,20],univers:[0,16],unless:[7,15],unlik:15,unnecessari:22,unpack:[2,3,25],unpair:13,unquot:[15,16,20],unstack:3,untangl:[14,15],until:[6,7,9,14],unus:13,unusu:20,updat:[0,22],upward:9,usag:16,use:[0,2,3,4,7,9,12,13,14,16,18,19,20,21,25],used:[3,12,15,16,20,21,23,25],useful:[0,17],user:7,uses:[2,6,13,15],using:[3,6,7,14,15,19,20,21],usual:[0,2],util:[0,4,9,10,20],valid:8,valu:[2,3,4,6,7,13,15,16,17,22,25],value_n:20,vanilla:9,variabl:[15,22],variat:15,varient:20,varieti:[12,16],variou:0,vener:25,verbos:12,veri:[0,1,7,12,16,20,25],versa:2,version:[0,1,2,14,18,19,21,22],via:16,vice:2,view:22,viewer:[1,16,18,24],vise:[],von:[0,2,3,12],wai:[0,2,3,5,7,9,12,13,15,16,17,20],walk:20,wall:7,want:[2,7,9,13,14,17,20],warranti:[3,16],wash:16,wast:16,websit:[0,13],welcom:16,well:[0,5,6,7,12,16,20,23],were:[7,9,15,16,21],what:[2,3,6,9,10,12,15,16,19,20,24],whatev:[2,3,11,14,20],when:[13,14,15,16,20,21,23,25],where:[2,3,5,6,9,15,16,20,22,25],whether:15,which:[0,1,3,6,7,9,11,13,15,16,19,20,21,25],whole:[2,3,6,13,20],whose:14,why:[7,11,17,20],wiki:20,wikipedia:[0,20,21],wildli:16,wind:16,winner:7,wire:15,wit:9,within:[16,17,20],without:[2,16,20],won:20,word:[0,3,5,6,8,13,14,16,20,21],work:[0,5,6,7,9,13,14,15,16,20,21],worth:[7,13],would:[2,6,7,8,9,10,13,14,15,16,20,21,25],wouldn:9,wrap:[3,7,16],write:[5,7,9,12,14,15,20,21,22],written:[0,1,4,9,19,25],wrong:2,wtf:15,wtfmorphism:15,xor:[],year:16,yet:[9,15,20,21],yield:[2,3],you:[0,2,3,4,6,7,9,13,14,15,16,18,20,21],your:[2,3,5,6,7,8,16],yourself:[16,20],zero:[3,6,7,9,15,20,23,25],zip:[5,13],zip_:3,zstr:21},titles:["Thun 0.1.1 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Preamble","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","<code class=\"docutils literal notranslate\"><span class=\"pre\">within</span></code>","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","Quadratic formula","Treating Trees","Preamble","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026"],titleterms:{"1st":5,"2nd":6,"3rd":7,"4th":8,"5th":9,"6th":10,"case":[11,17,20],"final":6,"function":[2,3,10,15,16,19,20],"long":4,"void":2,"while":2,Adding:20,One:14,The:[13,15,16,20],There:16,Use:20,Using:14,about:22,abov:15,add:[2,9,20],adding:20,address:21,advent:[5,6,7,8,9,10],aka:[],all:[7,9],ana:15,analysi:[7,13],anamorph:[2,15],app1:2,app2:2,app3:2,appendix:15,approxim:17,automat:20,averag:2,base:[11,17,20],befor:10,better:15,binari:2,block:6,branch:2,breakdown:9,btree:20,can:20,cata:15,catamorph:15,categor:12,chatter:2,check:19,child:20,choic:2,cleanup:19,clear:2,cleav:2,cmp:20,code:[5,6,7,8,9,10,16],combin:[2,15,20],compar:20,comparison:2,compil:[4,14],comput:17,con:[2,20],concat:2,continu:16,count:[9,10],crap:20,current:20,data:20,datastructur:[16,20],decemb:[5,6,7,8,9,10],defin:[19,20],definit:19,delet:20,deriv:[15,19,20],determin:21,develop:13,dialect:0,dip:[2,21],dipd:2,dipdd:2,direco:14,disenstacken:2,div:2,document:0,doe:20,down:6,down_to_zero:2,drive:10,drop:2,dup:2,dupd:2,dupdip:2,els:20,empti:20,enstacken:2,epsilon:17,equal:20,error:17,essai:22,etc:[],euler:[13,14],eval:16,even:14,exampl:[2,16,17],execut:24,express:[16,23],extract:[15,20],factor:[15,20],factori:15,fibonacci:14,filter:13,find:[7,15,17],first:[2,13],five:14,flatten:2,floordiv:2,form:[15,20],formula:19,four:15,from:15,ftw:5,fun:15,further:13,fusion:15,gcd:2,gener:[10,13,14,15,20],genrec:2,get:[9,20],getitem:2,given:[15,20],gotten:9,greater:20,group:2,help:2,host:0,how:[10,13,14],hylo:15,hylomorph:15,ift:2,increment:9,index:9,indic:0,inform:0,infra:[2,20,21],initi:17,integ:13,interlud:20,intern:23,interpret:[1,16],isn:20,item:21,iter:[13,20],joi:[0,1,3,7,13,15,16,21,22,23,24,25],joypi:[],just:[13,20],kei:20,languag:0,law:15,least_fract:2,left:20,less:20,let:13,librari:[3,16],like:20,list:[2,15,20,25],literari:16,littl:13,logic:2,loop:[2,6,16],lshift:2,maintain:[],make:20,mani:[10,13],map:2,math:2,method:17,min:2,miscellan:[2,20],mod:2,modif:20,modulu:2,mul:2,multipl:[13,14],must:20,name:[19,20],nativ:19,neg:2,newton:17,node:[15,20],now:[9,20],nullari:2,number:[7,15,17],offset:7,one:16,onli:16,order:20,osdn:0,our:20,out:6,over:2,pack:13,pam:2,paper:6,para:15,paramet:20,parameter:[15,20],paramorph:15,pars:[2,23],parser:[16,23],pass:16,path:21,pattern:15,per:20,piec:6,pop:2,popd:2,popop:2,pow:2,power:14,preambl:[4,9,15,21],pred:2,predic:[9,11,13,20],pretty_print:24,primrec:2,print:16,problem:[13,14],process:20,product:2,program:[10,12,13,15,19,20,22],project:[0,13,14],pure:16,put:[7,20],python:16,quadrat:19,quick:0,quot:[2,25],rang:[2,13],range_to_zero:2,rank:7,read:16,recal:10,recur:[11,17,20],recurs:[15,20],redefin:20,refactor:[5,13,20],refer:3,regular:16,rem:2,remaind:2,remov:2,render:13,repeat:10,repl:16,replac:4,rescu:7,reset:14,rest:[2,15],revers:2,right:[20,21],roll:2,rolldown:2,rollup:2,root:17,rshift:2,run:[2,14],sat:6,second:2,select:2,sequenc:[14,25],set:[9,11,20],should:16,shunt:2,simplest:13,simplifi:19,size:[2,4],slight:20,sqr:2,sqrt:2,squar:17,stack:[2,16,25],start:0,state:10,step:[2,9,15],style:16,sub:2,succ:2,sum:[2,4,13],swaack:2,swap:2,swon:2,swoncat:2,symbol:[15,16],sympi:7,tabl:0,tail:15,take:2,term:[13,14,20],ternari:2,text:23,than:[15,20],thi:20,think:6,third:2,three:14,thun:[0,16],time:[2,14],todo:20,togeth:[7,9,20],toi:20,token:16,trace:[4,24],traceprint:16,travers:20,treat:20,tree:[15,20,21],treestep:[15,20],triangular:15,tricki:6,truediv:2,truthi:2,tuck:2,two:14,type:20,unari:2,uncon:2,unfinish:15,unit:2,unnecessari:13,unquot:2,unstack:2,updat:18,use:15,usual:15,util:[24,25],valu:[9,14,20],variabl:19,version:[4,7,13,20],view:16,want:6,within:11,word:2,write:19,xor:2,zero:14,zip:2,zipper:21}})
\ No newline at end of file
+Search.setIndex({docnames:["index","joy","lib","library","notebooks/4. Replacing Functions in the Dictionary","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/AlsoNewton","notebooks/Categorical","notebooks/Developing","notebooks/Generator Programs","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Quadratic","notebooks/Trees","notebooks/Zipper","notebooks/index","parser","pretty","stack"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/4. Replacing Functions in the Dictionary.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/AlsoNewton.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/Quadratic.rst","notebooks/Trees.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,""],concat:[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:[23,4,1,""],Symbol:[23,2,1,""],text_to_expression:[23,1,1,""]},"joy.utils":{pretty_print:[24,0,0,"-"],stack:[25,0,0,"-"]},"joy.utils.pretty_print":{TracePrinter:[24,2,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[24,5,1,""],viewer:[24,5,1,""]},"joy.utils.stack":{expression_to_string:[25,1,1,""],iter_stack:[25,1,1,""],list_to_stack:[25,1,1,""],pick:[25,1,1,""],pushback:[25,1,1,""],stack_to_string:[25,1,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[23,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":13,"10m":15,"10n":15,"4ac":19,"5bkei":20,"\u03b5":[11,17],"abstract":[16,20],"boolean":[2,3,16,20],"break":[10,16],"byte":13,"case":[2,3,4,6,10,15,25],"class":[3,16,23,24,25],"default":[3,9,14,25],"export":[3,23],"final":[2,7,15],"float":[3,16,21,23],"function":[0,1,4,5,6,7,8,9,12,13,14,17,18,21,22,23,24,25],"g\u00e9rard":21,"import":[2,4,5,6,7,8,9,10,13,14,15,17,19,20,21],"int":[7,14,15,16,21,23,25],"new":[2,3,4,7,11,14,15,16,18,20],"public":18,"return":[1,3,4,6,7,9,10,11,13,15,16,19,20,23,24,25],"short":19,"static":[2,18],"switch":2,"true":[2,3,6,7,13,15,20],"try":[7,14,15],"void":[0,3],"while":[3,7,9,10,16,23,25],Adding:[16,22],And:[5,7,11,13,14,15,17,20,21,25],But:[0,6,12,13,15,16,20],CPS:16,For:[2,3,5,6,7,8,9,14,15,20,22,25],Going:6,Has:3,Its:3,Not:7,One:[2,16],RHS:20,TOS:[2,3,15],That:[13,15,20],The:[0,1,2,3,4,5,6,7,8,9,11,12,14,17,18,19,21,22,23,25],Then:[2,3,6,9,19,20],There:[7,9,15,20,25],These:[22,25],Use:[3,11,15],Using:[7,11,15,20],With:[5,11,15],__str__:24,_within_b:11,_within_p:11,_within_r:11,aaa:8,abbrevi:20,abl:19,about:[0,7,9,16,20,21,25],abov:[0,4,7,11,13,17,19,20],abs:[7,11,17],absolut:[7,16],accept:[1,2,3,11,13,15,16,20,21],access:[7,9],accomplish:19,accordingli:20,accumul:13,across:[7,9],act:11,action:[16,21],actual:[2,7,13,16,20],adapt:22,add:[3,5,6,7,13,14,16,19,24],add_alias:3,add_def:3,add_definit:[3,9,15,20],add_if_match:5,add_valu:9,added:[12,20],adding:[7,18],addit:[0,2,3,9,13,15,16,20],admit:7,advantag:15,after:[5,7,9,13,14,16],afterward:16,again:[2,3,7,9,11,13,16,20],against:[6,7],aggreg:[3,21],aka:[16,21],albrecht:0,algebra:20,algorithm:16,alia:3,alias:[3,16],align:[16,24],all:[3,5,6,13,14,15,16,17,20,24],alloc:7,allow:[15,18,20],almost:20,alon:17,along:[15,16,19],alphabet:3,alreadi:[4,7,11,21],also:[0,13,15,16,25],altern:[12,20],although:[5,12,20],altogeth:14,alwai:[7,13,15,18],amort:20,amount:7,analysi:[12,22],anamorph:16,ani:[9,12,13,16,18,20,21,23],annual:16,anonym:20,anoth:[5,15,20,25],answer:7,anyth:[2,3,16],aoc20017:6,aoc20173:7,aoc2017:[5,6,7,8,9,10],api:18,app1:3,app2:[3,4,6,16,19],app3:3,app:16,appear:[2,8,12,13,20],append:9,appli:[2,3,6,13,17,20],applic:14,approach:[13,19],archiv:0,aren:21,arg:[2,3],argument:[2,3,11,14,15,16,24,25],arithmet:2,ariti:2,around:[13,25],arrai:9,arrang:9,arriv:[14,20],articl:[0,12],ask:[7,12,14],aspect:[0,7],assembl:9,assert:[7,10],assign:25,associ:20,assum:[5,6,8,9,11],asterisk:20,attack:16,attempt:[0,1],attribut:3,automat:[12,15,22],avail:[0,8],averag:[4,16],avoid:20,awar:2,awkward:20,azur:22,back:[7,9,20],backward:[18,20],bag:16,banana:[15,20],bank:10,barb:15,base:[0,2,3,6,10,15,18],basic:[1,2,3,5,7,16,20],bear:9,beat:9,becaus:[2,3,5,6,7,9,15,16,20,21,25],becom:[5,19,20,25],been:[11,15,18,20,21],befor:[6,9,14,15,16,20],begin:[7,15,20],behavior:[18,20],behaviour:[0,1],behind:9,being:0,belong:9,below:[2,3,7,13,14,17,20,21],bespok:16,best:0,better:[7,13,14,20],between:[0,6,7,13],biannual:16,big:[7,9,20],binari:[0,14,16,20],binary_search_tre:20,binarybuiltinwrapp:3,bind:16,bingo:21,bit:[7,13,14,20],block:[10,13],bodi:[2,16,20],body_text:3,bool:[6,15],borrow:16,both:[2,4,7,9,13,15,16,17,19,25],bottom:14,boundari:7,bracket:[7,16,23],branch:[3,5,6,9,13,14,17,20],breakpoint:16,bring:[13,16],btree:22,buck:20,bug:[0,16],build:[15,16,20,21,25],built:[15,19],bundl:[2,3],burgeon:16,calcul:7,calculu:12,call:[2,11,15,16,18,19,24,25],caller:20,came:[9,20],can:[0,2,3,4,5,6,7,11,12,13,14,15,16,17,18,19,21,22,25],candid:6,captur:16,card:16,care:[7,13,25],carefulli:[20,21],carri:[5,7,15],cartesian:12,catamorph:4,categor:[0,19,22],categori:12,ccc:12,ccon:20,ceil:7,certain:[16,25],certainli:20,chang:[2,7,9,18,20,21],charact:21,chat:16,chatter:0,cheat:10,check:[6,14,15],checksum:6,child0:20,childn:20,children:20,choic:[3,15],choos:[18,20],circuit:12,circular:[5,20],cite_not:20,classmethod:3,clear:[3,7,13,16],cleav:[4,5,6,8,16,19],close:[0,1,12],clunki:13,cmp:22,cmp_:20,code:[0,1,12,15,17,20],collaps:15,collect:[12,14,16],column:7,combin:[0,3,8,11,13,14,16,19,21,22],come:[7,9,16],command:[5,16,19,20],common:[2,13,15],compar:[7,12],comparison:0,compel:12,compil:[2,9,12,15,16],complet:12,complex:[3,21],compos:15,compound:20,comput:[2,6,7,9,12,13,16,19,22],con:[3,6,9,10,11,13,14,15,16,19,21,25],conal:12,concat:[3,5,14,15,16,20],concaten:0,concatin:[0,3,25],concis:7,concret:15,concurr:2,condit:[9,16],condition:6,confid:7,conflict:20,cons2:20,consecut:14,consid:[9,13,14,15,20,21],consist:[2,7,16,20],constant:20,constitu:15,consum:[6,15],contain:[0,2,3,7,8,14,15,16],context:2,continu:[0,6,15,21],control:16,conveni:12,convert:[4,15,20,23,25],cook:15,cool:20,copi:[2,3,5,13,15,20,22],copyright:16,corner:7,correct:7,correctli:20,correspond:12,could:[2,7,9,12,13,15,16,18,20,21],count:[3,7,8,14],count_stat:10,counter:13,cours:[7,9,13,15,20],cover:7,cpu:7,crack:20,crap:22,crash:20,creat:[0,2,3,5,11,13,14,15,20],crude:[20,23],current:[2,3,9,15,16,21,24],custom:18,cycl:[13,14],cython:16,dai:[15,16],data:[2,3,7,22],datastructur:[0,2,15,21,23,25],datatyp:25,ddididi:21,deal:[0,5,20],debugg:15,decid:20,decor:3,decoupl:15,decreas:7,decrement:3,deduc:13,deeper:0,deepli:12,def:[3,4,7,9,10,15,16,19,20,25],defi:3,defin:[2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,21],definit:[2,3,4,8,9,11,13,14,15,16,18,20,22],definitionwrapp:[3,9,15,20],deleg:16,delet:22,demonstr:[12,15],depend:[15,20],deposit:20,dequot:[5,15],deriv:[2,3,5,6,11,13,16,22],descend:6,describ:[3,12,15,20,23],descript:[13,16,20],design:[2,3,6,20],desir:[7,16,20],destruct:20,detail:[7,16,20],detect:[6,14,15,20],determin:[6,7],develop:[0,14,16,22],diagram:13,dialect:1,dict:[1,3],dictionari:[1,3,4,11,16,19,20],did:7,didn:15,differ:[0,6,8,11,12,13,15,19,20,25],differenti:12,dig:21,digit:[5,13],dimension:7,dinfrirst:16,dip:[3,4,6,7,9,10,11,13,14,15,16,17,19,20],dipd:[3,9,14,15,16,19,20,21],dipdd:[3,20],direco:[10,11],direct:16,directli:[7,13,20,25],disappear:2,discard:[3,11,14,15,17,20],discov:6,disenstacken:[16,20],disk:16,displac:2,distanc:7,distribut:10,ditch:20,div:[3,16],dive:20,divid:6,divis:[6,20],divisor:6,divmod:[3,6],divmod_:3,doc:[2,3,16],document:[22,23,25],doe:[0,1,6,7,9,12,15,16,22,24],doesn:[5,9,13,15,18,20,25],dog:20,doing:[7,12,13,15,16,21],domain:[7,12],don:[6,7,9,13,16,20],done:[2,13,14,16,18],doodl:7,door:16,dot:24,doubl:[13,16],down:[2,3,7,9,11,21],down_to_zero:16,downward:9,dozen:16,draft:[10,12,18],dream:16,drive:14,driven:[11,13],driver:14,drop:[3,5,20],dudipd:16,due:5,dummi:6,dup:[3,5,6,7,9,10,11,13,14,15,16,17,19,20,21,25],dupd:3,dupdip:[3,6,7,13,15,19,20],duplic:[3,8,15,20],durat:2,dure:[2,4,15],each:[2,3,4,5,6,7,9,12,13,15,16,20,24],easi:[0,7,17,20,21],easier:[3,5,20],easili:12,edit:22,effect:[2,3,16,21],effici:[7,9,21],either:[1,2,3,6,15,20],eleg:[9,16,19,20],element:[2,3],elliott:12,els:[2,3,5,6,9,10,15],embed:[12,20,21],empti:[3,6,16,25],encapsul:16,enclos:16,encod:[9,14],encount:9,end:[7,9,13,15,25],endless:14,enforc:[2,16],engend:16,enlarg:7,enough:[7,15,16,19,24],enstacken:[14,16],ensur:8,enter:16,entir:25,entri:[3,21,24],epsilon:11,equal:[13,25],equat:[7,11,16,17],ergo:[7,15,20],err:[17,20],error:[7,16,22,23],escap:9,essai:0,estim:17,etc:[3,7,21,23],euler:22,eval:0,evalu:[1,2,3,4,5,11,15,16,19,20],even:9,evenli:6,eventu:[7,19],everi:14,everyth:[3,20],evolv:18,exactli:15,exampl:[0,3,5,6,7,8,9,11,13,14,15,20,23,25],exce:14,except:[16,20,23],execut:[0,1,2,3,4,6,16,17,21,25],exist:12,exit:9,expect:[2,3,6,15,17,20,25],experi:16,experiment:7,explan:16,explor:16,express:[0,1,2,3,4,12,15,20,21,24,25],expression_to_str:25,extend:7,extra:[5,6,13],extrem:16,extrememli:16,facet:0,facil:16,fact:[20,23],factor:[2,13,16,22],fail:[2,3,6,20,23],fals:[2,3,6,10,13,15],far:[9,11,15,20],fascin:0,fast:7,faster:7,favorit:19,fear:20,feel:7,few:[7,13,16],fewer:[3,16],fib:14,fib_gen:14,figur:[2,3,7,20],filter:20,fin:13,find:[2,3,5,6,13,14,20,22],finder:11,fine:[0,13,20],finish:19,first:[3,4,5,6,7,9,10,11,14,15,16,19,20,21,22],fit:[13,16,19],five:[13,15,16],fix:[2,3],flag:6,flatten:[16,20],flexibl:20,floor:[3,7],floordiv:13,flow:16,follow:[0,2,3,6,9,11,15,16,18,21],foo:[16,18,20],foo_ii:18,form:[2,3,6,8,12,13,14,22,25],forman:16,format:[22,24],formula:[0,7,13,22],forth:[5,9,16,20],fortun:9,forum:0,forward:[6,9],found:[9,10,16,20],four:[2,3,7,9,13,14,16,20],fourteen:13,fourth:[2,3,5,20],fractal:16,fraction0:16,fraction:[2,16],fragment:17,framework:16,free:[12,16,20],freeli:[2,7],from:[0,1,2,3,4,5,6,7,8,9,10,11,13,14,16,17,19,20,21,22,25],front:[2,3],full:[8,13],fun:7,functionwrapp:[3,20],funtion:20,further:[11,22],futur:19,garbag:16,gari:20,gcd:16,gen:10,gener:[2,3,7,9,12,17,22,25],genrec:[3,6,9,15,16,17,20],geometr:13,geometri:20,get:[2,4,6,7,12,13,14,15,16,17,22],get_valu:9,getitem:3,getrecursionlimit:25,getsourc:16,ghc:12,give:[7,11,12,13,15,25],given:[2,3,4,5,6,7,9,10,11,13,14,21],glue:16,goal:9,going:[6,7,9,20,21],good:[9,13,20],grab:3,grammar:23,grand:16,graph:7,great:[0,5,7,16,22],greater:[7,25],grid:7,group:[0,7],gsra:11,guard:[6,7],had:[13,21],haiku:16,half:[13,21],half_of_s:5,halfwai:5,hand:[4,16,19,20,22],handi:11,handl:25,happen:[7,16,20],hard:[17,21],hardli:15,hardwar:12,has:[0,2,6,7,9,11,14,15,16,18,20,21,25],haskel:12,have:[2,3,5,6,7,9,10,11,13,14,15,16,18,20,21,22,25],head:[6,15,25],help:[4,8,15,16,20],help_:3,helper:[3,6],herd:16,here:[7,13,14,15,17,19,20,21],heterogen:20,heurist:[5,9],hide:20,higher:[16,20],highest:6,highli:[16,20],hindsight:6,histori:24,hmm:20,hog:20,hoist:3,hold:13,hood:9,hope:[0,13,16,22],host:22,how:[0,7,8,9,12,15,20,21],html:[2,3,14,19,22],http:20,huet:21,hugh:[11,17,20],human:16,hypothet:2,id_:3,idea:[12,13,16,20],ident:[3,15],identifi:7,ift:[3,5,6,9,15,17,20],ignor:[3,20],illustr:15,imagin:21,immedi:[9,15],immut:[16,20],imper:15,implement:[0,1,2,3,7,10,12,15,16,18,19,20],impli:6,implicit:16,includ:[8,12],inclus:13,incom:25,incompat:18,incr_at:9,incr_step_count:9,incr_valu:9,increas:[7,9,13],increment:[3,12,13,18],index:[0,7,10,16,25],index_of:10,indexerror:25,indic:20,infil:20,infinit:7,inform:3,infra:[3,4,14,15,16,19],infrastructur:3,init:9,init_print:7,initi:[2,3,4,6,7,8,9,11,16,20],inlin:20,inner:6,input:[1,5,6,7,8,11,15],inscrib:3,inspect:16,instal:0,instanti:[12,24],instead:[7,13,14,15,20,21,25],instruct:9,integ:[2,3,5,6,7,8,9,14,15,16],integr:3,intend:[0,16],interact:[16,22],interest:[0,7,13,14,20],interlock:7,interlud:22,intermedi:15,intern:[0,24,25],interpret:[0,12,15,18,23,24],interrupt:16,interv:[12,13],introduc:18,introduct:0,invari:3,invers:3,investig:19,ipf:16,ipynb:14,isn:[15,21],item:[2,3,5,6,10,15,16,20,25],iter:[1,3,7,15,16,22,25],iter_stack:[4,10,25],its:[0,2,3,6,7,12,13,15,16,20,25],itself:[0,2,9,16,20],j05cmp:[2,3],jenni:20,job:[9,22],john:[11,17,20],joi:[2,4,5,6,8,9,10,11,12,18,19,20],joypi:[9,10,15,16,20,21],jump:9,jupyt:22,just:[0,2,3,5,6,7,9,14,15,16,18,21],keep:21,kei:22,kevin:0,key_n:20,keyerror:20,kind:[2,7,9,12,15,16,20],kleen:20,know:[7,13,15,20],known:12,labda:12,lambda:[12,15],lambdifi:7,languag:[12,16,18,19,20],larg:7,larger:[7,25],largest:[3,6,9],last:[5,9,13,15],lastli:[14,15],later:[9,16,17],law:2,lazi:11,lazili:11,lcm:13,lead:[9,16],leaf:20,lean:16,learn:[0,10],least:[2,7,9,13,15,25],least_fract:16,leav:[6,7,9,13,14,17,20],left:[7,14,15,16,21,24,25],leftov:15,legendari:9,legibl:9,len:10,length:[3,13,25],lens:15,less:[13,14,15,16,25],lesser:7,let:[5,6,7,9,11,14,15,17,19,20,21],level:[12,20],librari:[0,4,7,9,10,11,19,20],lieu:20,like:[2,3,6,7,10,11,13,15,16,19,23],line:[3,6,9,15,16,20,24],linear:25,link:0,linux:0,list:[0,3,5,6,8,9,10,11,13,16,21,22,24],list_to_stack:[9,10,25],liter:[1,20,21,23],littl:[7,9,20,22],live:22,lkei:20,load:[13,16],locat:[2,7],locu:24,log_2:20,logic:[0,13],longer:20,look:[7,11,14,16,20],lookup:[16,20],loop:[0,1,3,13],lot:[16,19,20,21],love:13,low:12,lower:13,lowest:6,machin:[0,20],machineri:20,macro:16,made:[0,6,16,20,21],mai:[2,9,15,20],mail:0,main:[0,3,5,16,21],mainloop:18,maintain:21,major:18,make:[2,3,4,5,12,13,15,16,21],make_distributor:10,make_gener:11,manfr:[0,2,3,12],manhattan:7,mani:[0,7,8,9,14,15,16],manipul:7,manual:[7,15],map:[1,3,13,15,16,18,19,20],map_:3,mark:[7,9],marker:16,mask:[13,14],match:[0,1,5],materi:0,math:[0,7,9,16,20],mathemat:[7,16],matter:[5,11,13,15,17,20],max:[6,7,10],max_:3,maximum:[3,20],maxmin:6,mayb:[15,20],maze:9,mean:[6,11,12,13,15,16,20,25],meant:[15,16,19,20],meantim:9,mem:9,member:[2,3,7],memori:7,mental:16,mention:2,mercuri:0,merg:20,meta:[16,20],methink:20,method:[0,3,7,16,22,24],mfloor:7,midpoint:13,might:[5,12,14,15,20],million:14,min:6,min_:3,mind:9,minimum:3,minu:[3,19],mirror:0,miscellan:[0,22],mistak:10,mix:16,mnemon:5,mod:3,model:[12,16],modern:0,modif:14,modifi:[9,16,21],modul:[0,1,3,16,23],modulu:16,monkei:7,month:16,more:[0,3,4,8,9,11,12,13,14,15,16,19,20,23,25],most:20,mostli:0,move:[5,7,9],movement:2,mrank_of:7,much:[7,9,13,15,20],muck:20,mul:[16,19,21,24],multi:3,multipl:[15,22],must:[2,3,6,7,8,13,15,18],mutabl:9,n_kei:20,n_rang:14,n_valu:20,nail:9,name:[1,3,4,5,16,18,21,22,23,25],natur:[13,14,20],navig:21,need:[2,3,5,6,7,9,10,11,13,14,15,17,18,20],neg:[3,9,19],nest:[16,20,21],network:16,never:18,newton:[0,22],next:[4,5,6,7,9,13,15,17,20],nice:[0,5,7,15,25],niether:2,node:22,non:[6,20],none:[1,3],normal:[8,15],notat:[16,20],note:[2,7,11,13,20,25],notebook:[13,16,21,22],notebook_preambl:[2,4,5,6,7,8,9,10,13,14,15,17,19,20,21],noth:[2,20],notic:13,now:[4,5,6,7,13,14,15,16,17,22],nth:[3,25],nullari:[6,9,10,16,17,20],number:[1,2,3,4,6,13,14,22,25],object:23,observ:13,obviou:[14,17],obvious:[6,8,9],occur:20,odd:[13,14],off:[2,3,7,13,14,21],offset:9,offset_of:7,old:[2,4],old_siz:4,old_sum:4,omit:15,onc:[3,8,18,19,20],one:[2,3,5,6,7,8,9,13,14,15,19,20,24,25],ones:14,onli:[2,3,5,6,7,9,13,15,20,21,25],onto:[1,2,3,16,25],open:[8,16],oper:[3,6,15,16,20,25],oppos:5,option:[1,16,25],order:[2,3,5,6,15,16,22,25],org:[0,20],origin:[0,1,2,3,5,20,21],other:[0,2,3,6,7,12,15,16,20,25],otherwis:[3,6,13,14,20],our:[5,6,7,11,13,14,15,16],ourselv:15,out:[2,3,7,12,13,14,15,16,20,21],outcom:20,output:[7,11,15],outsid:[9,12],outward:7,over:[3,5,7,11,12,13,14,16,19,20,22],overhead:7,overkil:15,overshadow:7,own:[7,20],pack:[20,25],packag:[0,16],page:[0,19,20,25],pair:[2,3,5,6,13,14],pair_up:5,palidrom:13,palindrom:13,pam:[16,19],paper:[7,12,15,16,20,21],parallel:2,paramet:[1,2,3,9,15,23,24,25],paranthes:20,parenthes:[9,20,25],pariti:14,pars:[0,3,16,20],parse_definit:3,parseerror:23,parser:0,part:[2,3,6,9,11,15,19,20],partial:[7,15],particular:21,particularli:9,pass:[0,20,24],passphras:8,path:7,pattern:[7,13,20],payoff:15,pe1:[13,14],pe2:14,pearl:21,pend:[3,15,16,21,24],peopl:22,per:[7,16],perform:9,perhap:14,period:16,permit:[9,25],persist:20,phase:2,pick:[13,14,25],pickl:16,pictur:20,piec:15,pip:0,pita:10,place:[3,7,9,13,15,16],plai:0,plain:9,plane:7,plu:[3,7,19],plug:[14,15,20],point:[7,12,15,16,20],pointless:2,pop:[3,4,5,6,9,10,13,14,15,16,19,20,25],popd:[3,4,9,11,16,17],popdd:[3,6,14,19],popop:[3,5,6,9,10,11,13,14,15,16,17,20],port:7,posit:[3,9,13,15,16],possibilit:20,possibl:[6,20,22],post:[16,20],potenti:3,power:16,pragmat:13,pre:[9,15,20],preambl:11,precis:[0,1,17],pred:3,predic:[2,6,14,15,17],prefer:15,prefix:[15,24],prep:[6,20],prepar:[9,15],preprocessor:15,present:20,preserv:12,pretti:[7,17,19,20,24,25],pretty_print:0,prevent:15,previou:[7,9,16],prime:[6,11],primit:[2,3,4,9,17,19],primrec:[3,6,9,10,11,14,15,16,17],print:[0,1,2,3,7,15,24,25],probabl:[5,14,16,20],problem:[7,16,22],proc_curr:20,proc_left:20,proc_right:20,proce:[5,13],process:[9,15,16,24],processor:20,produc:[5,13,15,20],product:16,program:[0,2,3,5,6,7,9,11,14,16,17,21],project:22,prompt:16,proper:[2,3],properli:9,properti:0,provid:[0,3,12,16],prune:20,pun:[0,16],pure:[0,20],puriti:16,purpos:16,push:[2,3,15,16,21,25],pushback:[16,20,25],put:[1,2,14,16,25],puzzl:[5,6,7,8],pypi:0,pyramid:7,python:[0,2,3,4,7,9,15,19,20,21,23,25],quadrat:[0,7,22],queri:20,queu:15,quit:[0,1,7],quot:[0,3,4,11,14,15,16,19,20,21,24],quotat:[2,3],quotient:3,rais:[20,23,25],random:9,rang:[7,15,16],range_sum:15,range_to_zero:16,rank_and_offset:7,rank_of:7,raphson:17,rather:[13,15,16,20],ratio:16,reach:[9,13,14,15],read:[0,1,13,14,20,21],readabl:4,real:20,realiz:[5,9,12,20],realli:[4,7],rearrang:[2,15],reason:[7,13,16],rebuild:21,rec1:[2,3],rec2:[2,3],recogn:23,record:[16,24],recur:15,recurs:[2,3,6,9,10,11,14,16,17,22,25],recus:16,recusr:20,redistribut:[3,16],reduc:2,redund:25,reexamin:20,refactor:[15,16,18],refer:[0,2],refin:17,regist:2,regular:23,rel:[9,19],releas:18,relev:7,remain:[2,3,16,18],remaind:[3,11],remind:15,remov:[3,7,20,25],renam:20,render:[20,22],repeat:[5,7,13],repeatedli:13,repl:[0,1],replac:[2,3,14,15,17,21,25],repositori:0,repres:[2,16,20,23,24],represent:25,reprod:14,request:7,requir:[7,25],resembl:16,respect:13,rest:[3,6,10,13,14,16,20,21,22,25],restor:2,result:[1,2,3,6,13,14,15,19,20,21],resum:16,retir:2,retri:16,reus:20,revers:[3,5,6,13,14,15,21,25],rewrit:[9,16],rewritten:16,richard:20,right:[7,14,15,16,24,25],rightmost:13,rkei:20,role:20,roll:[3,6,8,9,11,15,19,20],rolldown:3,rollup:3,root:[3,7,19,22],rotate_seq:5,round:5,row:[6,7],row_valu:7,run:[0,1,3,7,11,13,15,16,20,21],runtim:7,runtimeerror:25,sai:20,same:[2,12,13,15,20,25],sandwich:[2,3],save:[2,13,16],scan:3,scanner:[16,23],scenario:21,scheme:[19,20],scope:[5,20],search:[0,7,20],second:[3,5,6,15,16,20,25],secur:8,see:[0,4,7,14,15,16,18,20,21,24],seem:[0,10,13,16,20],seen:21,select:[3,7],semant:[2,3,16,18,20],semi:16,send:16,sens:[0,2,13,21],separ:16,sequenc:[0,1,2,3,4,5,6,8,9,10,13,16,20,21,23],seri:[7,13,14,15,20,21],serv:15,set:[2,3,15],seven:[13,14],sever:[0,12,16],shadow:4,share:[3,7,16],shelf:2,shift:[13,14],shine:9,shortest:7,should:[2,6,13,15,17,20],shouldn:16,show:[7,12,20,21],shunt:[3,21],side:20,sign:7,signal:6,signifi:[16,20],silli:20,similar:20,simon:16,simpl:[7,15,16,25],simplefunctionwrapp:[3,4,9,10,19],simplest:22,simpli:12,simplifi:[7,13,20,21],sinc:[2,7,13,19,20],singl:[3,4,14,16,23],situ:20,situat:20,six:[13,14,16],sixti:[13,14],size:[5,8,9,10,16],skeptic:16,skip:[7,9],slight:11,slightli:[15,20],small:[5,20],smallest:[3,6],smart:[9,15],sneaki:7,softwar:16,solei:2,solut:[7,13],solv:7,solvabl:16,some:[2,3,6,7,9,14,15,16,20,22,25],somehow:20,someth:[2,5,9,18],sometim:20,somewher:[15,20,22],sophist:7,sort:[3,6,15,19,20],sort_:3,sourc:[0,1,3,23,24,25],space:[7,13,24],span:13,special:[14,15,20],specif:[0,12],speed:[4,7,9],sphinx:[22,25],spiral:7,spirit:[0,1,20],split_at:5,spreadsheet:6,sqr:[16,17,19,21],sqrt:[3,7,11,19],squar:[3,7,22,23],stack:[0,1,3,4,6,9,10,11,13,14,15,17,19,20,21,23,24],stack_:3,stack_to_str:25,stage:20,stai:[0,1],stand:12,standard:16,star:20,stare:20,start:[6,7,9,10,11,13,14,15,16,19,20],state:[6,9,16],step:[3,4,5,6,7,8,13,16,19,20,21],step_zero:[5,6,8],still:[7,9,15],stop:20,storag:[13,15,20],store:[7,13,15],stori:15,str:[1,23,24,25],straightforward:[1,5,7,14],strang:9,stream:[11,13],string:[1,2,3,5,16,21,23,24,25],strip:7,structur:[15,16,20,21,25],stuff:20,style:[0,12],sub:18,subclass:16,subject:21,subract:7,substitut:[7,15],subtract:[6,7,13],succ:3,success:11,suffici:[9,15],suggest:[6,12,20],suitabl:[3,12,13],sum:[3,5,6,14,15,16,19,20],sum_:[3,4],summand:13,suppli:[15,20,23],support:[7,16,24,25],sure:[7,15],suspect:2,swaack:[3,4,15,19,20,21],swap:[3,4,5,6,7,8,10,11,13,14,15,16,20,21],swon:[3,10,14,15,16,20,21],swoncat:[9,10,11,14,15,16,20],symbol:[2,3,7,19,21,23],symmetr:13,sympi:19,syntact:16,syntax:[16,25],sys:[7,25],system:[7,8,16,20],tail:[6,20,25],take:[3,5,7,9,11,13,14,16,19,20,25],taken:9,talk:[16,20,25],target:[7,21],task:7,tast:12,tbd:16,technic:2,techniqu:[12,21],technolog:2,teh:20,temporari:21,ten:13,term:[1,2,6,9,10,11,15,16,23,25],termin:[2,3,6],ternari:16,test:[2,3],text:[0,1,3],text_to_express:[16,23],textual:16,than:[0,3,7,8,11,13,14,16,19,25],thei:[2,4,6,7,13,14,15,16,20,21,23,25],them:[2,3,4,6,7,13,14,15,20,21,22],theori:[2,3],therefor:[14,20],thi:[0,1,2,3,4,5,6,7,9,10,12,13,14,15,16,17,19,21,23,24,25],thing:[2,6,7,9,14,15,19,20,21,23,25],think:[2,9,13,15,16,20],third:[3,5,6,14,16,20],thirti:13,those:[2,3,6,7,9,15,20,22],though:[13,14,20],thought:16,thousand:13,thread:2,three:[2,3,9,13,16,20],through:[1,13,16,21,25],thu:5,thun:[2,3,12,18],thunder:16,tied:20,tile:7,time:[3,7,9,10,13,15,16,20,21],tini:20,to_set:20,todai:16,todo:[16,22,23],togeth:[14,16],token:23,tommi:20,too:[15,20],took:7,tool:16,top:[2,3,16,24,25],total:[5,7,13],total_match:5,trace:[0,16,19,21,25],traceprint:24,track:21,tracker:0,trade:7,transform:[12,15],translat:[7,12,15],travers:[21,22],treasur:0,treat:[0,2,3,22],treatment:14,tree:[0,16,22],treemap:15,tri:13,trick:[13,20],tricki:[7,9],trivial:[6,9,20],trobe:0,trove:0,truediv:19,truthi:[3,16],ts0:[15,20],ts1:[15,20],tuck:[3,6,16,17,20],tupl:[3,16,25],turn:[2,3,7],twice:[7,15,20],two:[2,3,6,7,11,13,15,16,17,20,21,25],type:[1,12,15,16,22,23,24,25],typic:[2,3],unari:[9,15,16,17],unarybuiltinwrapp:3,unbalanc:23,uncon:[3,5,6,14,15,16,20,21],under:[2,3,9,16],understand:[0,7,20],undocu:16,unfortun:25,uniqu:[3,8,20],unit:[5,15,16,20],univers:[0,16],unless:[7,15],unlik:15,unnecessari:22,unpack:[2,3,25],unpair:13,unquot:[15,16,20],unstack:3,untangl:[14,15],until:[6,7,9,14],unus:13,unusu:20,updat:[0,22],upward:9,usag:16,use:[0,2,3,4,7,9,11,12,13,14,16,18,19,20,21,25],used:[3,12,15,16,20,21,23,25],useful:[0,17],user:7,uses:[2,6,13,15],using:[3,6,7,14,15,19,20,21],usual:[0,2],util:[0,4,9,10,20],valid:8,valu:[2,3,4,6,7,11,13,15,16,17,22,25],value_n:20,valueerror:25,vanilla:9,variabl:[15,22],variat:15,varient:20,varieti:[12,16],variou:0,vener:25,verbos:12,veri:[0,1,7,12,16,20,25],versa:2,version:[0,1,2,14,18,19,21,22],via:16,vice:2,view:22,viewer:[1,16,18,24],von:[0,2,3,12],wai:[0,2,3,5,7,9,12,13,15,16,17,20],walk:20,wall:7,want:[2,7,9,11,13,14,17,20],warranti:[3,16],wash:16,wast:16,web:25,websit:[0,13],welcom:16,well:[0,5,6,7,12,16,20,23],were:[7,9,15,16,21],what:[2,3,6,9,10,12,15,16,19,20,24],whatev:[2,3,14,20,25],when:[11,13,14,15,16,20,21,23,25],where:[2,3,5,6,9,15,16,20,22,25],whether:15,which:[0,1,3,6,7,9,11,13,15,16,19,20,21,25],whole:[2,3,6,13,20],whose:14,why:[7,11,17,20],wiki:20,wikipedia:[0,20,21],wildli:16,wind:16,winner:7,wire:15,wit:9,within:[16,17,20],without:[2,16,20],won:[20,25],word:[0,3,5,6,8,13,14,16,20,21],work:[0,5,6,7,9,13,14,15,16,20,21,25],worth:[7,13],would:[2,6,7,8,9,10,11,13,14,15,16,20,21,25],wouldn:9,wrap:[3,7,16],write:[5,7,9,11,12,14,15,20,21,22,25],written:[0,1,4,9,11,19,25],wrong:2,wtf:15,wtfmorphism:15,year:16,yet:[9,15,20,21],yield:[2,3,25],you:[0,2,3,4,6,7,9,13,14,15,16,18,20,21,24,25],your:[2,3,5,6,7,8,16],yourself:[16,20],zero:[3,6,7,9,15,20,23,25],zip:[5,13],zip_:3,zstr:21},titles:["Thun 0.1.1 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Preamble","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","A Generator for Approximations","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","Quadratic formula","Treating Trees","Preamble","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026"],titleterms:{"1st":5,"2nd":6,"3rd":7,"4th":8,"5th":9,"6th":10,"case":[11,17,20],"final":6,"function":[2,3,10,11,15,16,19,20],"long":4,"void":2,"while":2,Adding:20,One:14,The:[13,15,16,20],There:16,Use:20,Using:14,about:22,abov:15,add:[2,9,20],adding:20,address:21,advent:[5,6,7,8,9,10],all:[7,9],ana:15,analysi:[7,13],anamorph:[2,15],app1:2,app2:2,app3:2,appendix:15,approxim:[11,17],automat:20,averag:2,base:[11,17,20],befor:10,better:15,binari:2,block:6,branch:2,breakdown:9,btree:20,can:20,cata:15,catamorph:15,categor:12,chatter:2,check:19,child:20,choic:2,cleanup:19,clear:2,cleav:2,cmp:20,code:[5,6,7,8,9,10,16],combin:[2,15,20],compar:20,comparison:2,compil:[4,14],comput:[11,17],con:[2,20],concat:2,consecut:11,continu:16,count:[9,10],crap:20,current:20,data:20,datastructur:[16,20],decemb:[5,6,7,8,9,10],defin:[19,20],definit:19,delet:20,deriv:[15,19,20],determin:21,develop:13,dialect:0,dip:[2,21],dipd:2,dipdd:2,direco:14,disenstacken:2,div:2,document:0,doe:20,down:6,down_to_zero:2,drive:10,drop:2,dup:2,dupd:2,dupdip:2,els:20,empti:20,enstacken:2,epsilon:17,equal:20,error:17,essai:22,euler:[13,14],eval:16,even:14,exampl:[2,16,17],execut:24,express:[16,23],extract:[15,20],factor:[15,20],factori:15,fibonacci:14,filter:13,find:[7,11,15,17],first:[2,13],five:14,flatten:2,floordiv:2,form:[15,20],formula:19,four:15,from:15,ftw:5,fun:15,further:13,fusion:15,gcd:2,gener:[10,11,13,14,15,20],genrec:2,get:[9,20],getitem:2,given:[15,20],gotten:9,greater:20,group:2,help:2,host:0,how:[10,13,14],hylo:15,hylomorph:15,ift:2,increment:9,index:9,indic:0,inform:0,infra:[2,20,21],initi:17,integ:13,interlud:20,intern:23,interpret:[1,16],isn:20,item:21,iter:[13,20],joi:[0,1,3,7,13,15,16,21,22,23,24,25],just:[13,20],kei:20,languag:0,law:15,least_fract:2,left:20,less:20,let:13,librari:[3,16],like:20,list:[2,15,20,25],literari:16,littl:13,logic:2,loop:[2,6,16],lshift:2,make:[11,20],mani:[10,13],map:2,math:2,method:17,min:2,miscellan:[2,20],mod:2,modif:20,modulu:2,mul:2,multipl:[13,14],must:20,name:[19,20],nativ:19,neg:2,newton:17,next:11,node:[15,20],now:[9,20],nullari:2,number:[7,15,17],offset:7,one:16,onli:16,order:20,osdn:0,our:20,out:6,over:2,pack:13,pam:2,paper:6,para:15,paramet:20,parameter:[15,20],paramorph:15,pars:[2,23],parser:[16,23],pass:16,path:21,pattern:15,per:20,piec:6,pop:2,popd:2,popop:2,pow:2,power:14,preambl:[4,9,15,21],pred:2,predic:[9,11,13,20],pretty_print:24,primrec:2,print:16,problem:[13,14],process:20,product:2,program:[10,12,13,15,19,20,22],project:[0,13,14],pure:16,put:[7,20],python:16,quadrat:19,quick:0,quot:[2,25],rang:[2,13],range_to_zero:2,rank:7,read:16,recal:10,recur:[11,17,20],recurs:[15,20],redefin:20,refactor:[5,13,20],refer:3,regular:16,rem:2,remaind:2,remov:2,render:13,repeat:10,repl:16,replac:4,rescu:7,reset:14,rest:[2,15],revers:2,right:[20,21],roll:2,rolldown:2,rollup:2,root:[11,17],rshift:2,run:[2,14],sat:6,second:2,select:2,sequenc:[14,25],set:[9,11,20],should:16,shunt:2,simplest:13,simplifi:19,size:[2,4],slight:20,sqr:2,sqrt:2,squar:[11,17],stack:[2,16,25],start:0,state:10,step:[2,9,15],style:16,sub:2,succ:2,sum:[2,4,13],swaack:2,swap:2,swon:2,swoncat:2,symbol:[15,16],sympi:7,tabl:0,tail:15,take:2,term:[13,14,20],ternari:2,text:23,than:[15,20],thi:20,think:6,third:2,three:14,thun:[0,16],time:[2,14],todo:20,togeth:[7,9,20],toi:20,token:16,toler:11,trace:[4,24],traceprint:16,travers:20,treat:20,tree:[15,20,21],treestep:[15,20],triangular:15,tricki:6,truediv:2,truthi:2,tuck:2,two:14,type:20,unari:2,uncon:2,unfinish:15,unit:2,unnecessari:13,unquot:2,unstack:2,updat:18,use:15,usual:15,util:[24,25],valu:[9,14,20],variabl:19,version:[4,7,13,20],view:16,want:6,within:11,word:2,write:19,xor:2,zero:14,zip:2,zipper:21}})
\ No newline at end of file
index 2a84f25..5e777ef 100644 (file)
 <h1>Stack or Quote or Sequence or List…<a class="headerlink" href="#stack-or-quote-or-sequence-or-list" title="Permalink to this headline">¶</a></h1>
 <div class="section" id="module-joy.utils.stack">
 <span id="joy-utils-stack"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.utils.stack</span></code><a class="headerlink" href="#module-joy.utils.stack" title="Permalink to this headline">¶</a></h2>
-<p>When talking about Joy we use the terms “stack”, “list”, “sequence”,
-“quote” and others to mean the same thing: a simple linear datatype that
+<p>When talking about Joy we use the terms “stack”, “quote”, “sequence”,
+“list”, and others to mean the same thing: a simple linear datatype that
 permits certain operations such as iterating and pushing and popping
 values from (at least) one end.</p>
-<p>We use the  <a class="reference external" href="https://en.wikipedia.org/wiki/Cons#Lists">cons list</a>, a venerable two-tuple recursive sequence datastructure, where the
+<p>There is no “Stack” Python class, instead we use the  <a class="reference external" href="https://en.wikipedia.org/wiki/Cons#Lists">cons list</a>, a 
+venerable two-tuple recursive sequence datastructure, where the
 empty tuple <code class="docutils literal notranslate"><span class="pre">()</span></code> is the empty stack and <code class="docutils literal notranslate"><span class="pre">(head,</span> <span class="pre">rest)</span></code> gives the recursive
 form of a stack with one or more items on it:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">stack</span> <span class="p">:</span><span class="o">=</span> <span class="p">()</span> <span class="o">|</span> <span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
@@ -66,6 +67,19 @@ in this case “(head, tail)”, and Python takes care of unpacking the
 incoming tuple and assigning values to the names.  (Note that Python
 syntax doesn’t require parentheses around tuples used in expressions
 where they would be redundant.)</p>
+<p>Unfortunately, the Sphinx documentation generator, which is used to generate this
+web page, doesn’t handle tuples in the function parameters.  And in Python 3, this
+syntax was removed entirely.  Instead you would have to write:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">dup</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="n">head</span><span class="p">,</span> <span class="n">tail</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="n">head</span><span class="p">,</span> <span class="p">(</span><span class="n">head</span><span class="p">,</span> <span class="n">tail</span><span class="p">)</span>
+</pre></div>
+</div>
+<p>We have two very simple functions, one to build up a stack from a Python
+iterable and another to iterate through a stack and yield its items
+one-by-one in order.  There are also two functions to generate string representations
+of stacks.  They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left.  In both functions <em>internal stacks</em> are
+printed left-to-right.  These functions are written to support <a class="reference internal" href="pretty.html"><span class="doc">Tracing Joy Execution</span></a>.</p>
 <dl class="function">
 <dt id="joy.utils.stack.expression_to_string">
 <code class="descclassname">joy.utils.stack.</code><code class="descname">expression_to_string</code><span class="sig-paren">(</span><em>expression</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#expression_to_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.expression_to_string" title="Permalink to this definition">¶</a></dt>
@@ -74,12 +88,32 @@ where they would be redundant.)</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">top</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="o">...</span><span class="p">))</span> <span class="o">-&gt;</span> <span class="s1">&#39;top second ...&#39;</span>
 </pre></div>
 </div>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>expression</strong> (<em>stack</em>) – A stack.</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 <dl class="function">
 <dt id="joy.utils.stack.iter_stack">
 <code class="descclassname">joy.utils.stack.</code><code class="descname">iter_stack</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#iter_stack"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.iter_stack" title="Permalink to this definition">¶</a></dt>
 <dd><p>Iterate through the items on the stack.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stack</strong> (<em>stack</em>) – A stack.</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">iterator</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 <dl class="function">
@@ -89,12 +123,49 @@ where they would be redundant.)</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">())))</span>
 </pre></div>
 </div>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>el</strong> (<em>list</em>) – A Python list or other sequence (iterators and generators
+won’t work because <code class="docutils literal notranslate"><span class="pre">reverse()</span></code> is called on <code class="docutils literal notranslate"><span class="pre">el</span></code>.)</li>
+<li><strong>stack</strong> (<em>stack</em>) – A stack, optional, defaults to the empty stack.</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
+</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 <dl class="function">
 <dt id="joy.utils.stack.pick">
 <code class="descclassname">joy.utils.stack.</code><code class="descname">pick</code><span class="sig-paren">(</span><em>s</em>, <em>n</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#pick"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.pick" title="Permalink to this definition">¶</a></dt>
-<dd><p>Find the nth item on the stack. (Pick with zero is the same as “dup”.)</p>
+<dd><p>Return the nth item on the stack.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>s</strong> (<em>stack</em>) – A stack.</li>
+<li><strong>n</strong> (<em>int</em>) – An index into the stack.</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first simple">
+<li><strong>ValueError</strong> – if <code class="docutils literal notranslate"><span class="pre">n</span></code> is less than zero.</li>
+<li><strong>IndexError</strong> – if <code class="docutils literal notranslate"><span class="pre">n</span></code> is equal to or greater than the length of <code class="docutils literal notranslate"><span class="pre">s</span></code>.</li>
+</ul>
+</td>
+</tr>
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">whatever</p>
+</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 <dl class="function">
@@ -102,6 +173,24 @@ where they would be redundant.)</p>
 <code class="descclassname">joy.utils.stack.</code><code class="descname">pushback</code><span class="sig-paren">(</span><em>quote</em>, <em>expression</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#pushback"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.pushback" title="Permalink to this definition">¶</a></dt>
 <dd><p>Concatinate quote onto expression.</p>
 <p>In joy [1 2] [3 4] would become [1 2 3 4].</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>quote</strong> (<em>stack</em>) – A stack.</li>
+<li><strong>expression</strong> (<em>stack</em>) – A stack.</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><strong>RuntimeError</strong> – if quote is larger than sys.getrecursionlimit().</p>
+</td>
+</tr>
+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
+</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 <dl class="function">
@@ -112,6 +201,16 @@ where they would be redundant.)</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">top</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="o">...</span><span class="p">))</span> <span class="o">-&gt;</span> <span class="s1">&#39;... second top&#39;</span>
 </pre></div>
 </div>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stack</strong> (<em>stack</em>) – A stack.</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
+</tr>
+</tbody>
+</table>
 </dd></dl>
 
 </div>
index 4251a23..89b5262 100644 (file)
@@ -1,6 +1,80 @@
-***************
-``within``
-***************
+
+
+
+
+A Generator for Approximations
+==============================
+
+In :doc:`Generator Programs` we derive a function ``G`` (called ``make_generator`` in the dictionary) that accepts an initial value and a quoted program and returns a new quoted program that, when driven by the ``x`` combinator (:py:func:`joy.library.x`), acts like a lazy stream.
+
+To make a generator that generates successive approximations let's start by assuming an initial approximation and then derive the function that computes the next approximation::
+
+       a F
+    ---------
+        a'
+
+
+A Function to Compute the Next Approximation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Looking at the equation again:
+
+:math:`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
+
+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::
+
+    1 swap [over / + 2 /] cons [dup] swoncat make_generator
+
+Example::
+
+    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
+    .
+    .
+    .
+    [1 swap [dup 23 over / + 2 /] direco]
+
+
+A Generator of Square Root Approximations
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+::
+
+    gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator
+
+
+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.
 
@@ -9,21 +83,23 @@ 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 a :doc:`generator <Generator Programs>` driven by ``x`` and assuming such for square root approximations (or whatever) ``G``, and further assuming that the first term ``a`` has been generated already and epsilon ``ε`` is handy on the stack...
+Using the *output* ``[a G]`` of the above :doc:`generator <Generator Programs>` for square root approximations, and further assuming that the first term ``a`` has been generated already and epsilon ``ε`` is handy on the stack...
 
 ::
 
        a [b G] ε within
-    -------------------- a b - abs ε <=
+    ---------------------- a b - abs ε <=
           b
 
+::
+
        a [b G] ε within
-    -------------------- a b - abs ε >
+    ---------------------- a b - abs ε >
            .
        [b G] x ε ...
        b [c G] ε ...
            .
-    --------------------
+    ----------------------
        b [c G] ε within
 
 
@@ -60,6 +136,7 @@ Base-Case
 
    B == roll< popop first
 
+
 Recur
 ^^^^^^^^^^^^^
 
@@ -69,7 +146,7 @@ Recur
 
 
 1. Discard ``a``.
-2. Use ``x`` combinator to generate next term from G.
+2. Use ``x`` combinator to generate next term from ``G``.
 3. Run ``within`` with ``i`` (it is a ``primrec`` function.)
 
 ::
@@ -87,38 +164,32 @@ Recur
 
     R0 == [popd x] dip
 
+
 Setting up
 ^^^^^^^^^^
 
-::
-
-    [a G] x ε
-    a [b G] ε
-
-::
-
-    within == x ε [[first - abs] dip <=] [roll< popop first] [[popd x] dip] primrec
-
-
-
-
-
-
-
-
-
-
-
-
-
+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] ε ...
 
 
+``within``
+^^^^^^^^^^
 
+Giving us the following definitions::
 
+    _within_P == [first - abs] dip <=
+    _within_B == roll< popop first
+    _within_R == [popd x] dip
+    within == x ε [_within_P] [_within_B] [_within_R] primrec
 
 
+Finding Square Roots
+====================
 
+::
 
+    sqrt == gsra within