• R/O
  • SSH

Joypy: Commit

This repo is not current. Development has moved from Hg to Git. For the latest code use the "Source Code" tab above to go to the "Thun" git repo or navigate to:
https://osdn.net/projects/joypy/scm/git/Thun


Commit MetaInfo

Revisiona473a7dd2c193e78ab895c59d7c600f46a677e3c (tree)
Time2018-05-01 02:12:56
AuthorSimon Forman <sforman@hush...>
CommiterSimon Forman

Log Message

More docs changes.

Change Summary

Incremental Difference

diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/_modules/joy/joy.html
--- a/docs/sphinx_docs/_build/html/_modules/joy/joy.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/_modules/joy/joy.html Mon Apr 30 10:12:56 2018 -0700
@@ -75,11 +75,11 @@
7575 <span class="sd"> or functions. Literals are put onto the stack and functions are</span>
7676 <span class="sd"> executed.</span>
7777
78-
79-<span class="sd"> :param quote stack: The stack.</span>
80-<span class="sd"> :param quote expression: The expression to evaluate.</span>
81-<span class="sd"> :param dict dictionary: A `dict` mapping names to Joy functions.</span>
78+<span class="sd"> :param stack stack: The stack.</span>
79+<span class="sd"> :param stack expression: The expression to evaluate.</span>
80+<span class="sd"> :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
8281 <span class="sd"> :param function viewer: Optional viewer function.</span>
82+<span class="sd"> :rtype: (stack, (), dictionary)</span>
8383
8484 <span class="sd"> &#39;&#39;&#39;</span>
8585 <span class="k">while</span> <span class="n">expression</span><span class="p">:</span>
@@ -100,6 +100,13 @@
100100 <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>
101101 <span class="sd">&#39;&#39;&#39;</span>
102102 <span class="sd"> Return the stack resulting from running the Joy code text on the stack.</span>
103+
104+<span class="sd"> :param str text: Joy code.</span>
105+<span class="sd"> :param stack stack: The stack.</span>
106+<span class="sd"> :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
107+<span class="sd"> :param function viewer: Optional viewer function.</span>
108+<span class="sd"> :rtype: (stack, (), dictionary)</span>
109+
103110 <span class="sd"> &#39;&#39;&#39;</span>
104111 <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>
105112 <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>
@@ -110,6 +117,11 @@
110117 <span class="sd"> Read-Evaluate-Print Loop</span>
111118
112119 <span class="sd"> Accept input and run it on the stack, loop.</span>
120+
121+<span class="sd"> :param stack stack: The stack.</span>
122+<span class="sd"> :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
123+<span class="sd"> :rtype: stack</span>
124+
113125 <span class="sd"> &#39;&#39;&#39;</span>
114126 <span class="k">if</span> <span class="n">dictionary</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
115127 <span class="n">dictionary</span> <span class="o">=</span> <span class="p">{}</span>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/_modules/joy/library.html
--- a/docs/sphinx_docs/_build/html/_modules/joy/library.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/_modules/joy/library.html Mon Apr 30 10:12:56 2018 -0700
@@ -157,6 +157,13 @@
157157 <span class="s1">dudipd == dup dipd</span>
158158 <span class="s1">primrec == [i] genrec</span>
159159 <span class="s1">step_zero == 0 roll&gt; step</span>
160+<span class="s1">direco == dip rest cons</span>
161+<span class="s1">make_generator == [direco] cons [swap] swoncat cons</span>
162+<span class="s1">gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator</span>
163+<span class="s1">_within_P == [first - abs] dip &lt;=</span>
164+<span class="s1">_within_B == roll&lt; popop first</span>
165+<span class="s1">_within_R == [popd x] dip</span>
166+<span class="s1">within == x 0.000001 [_within_P] [_within_B] [_within_R] primrec</span>
160167 <span class="s1">&#39;&#39;&#39;</span>
161168
162169 <span class="c1">##Zipper</span>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/_modules/joy/parser.html
--- a/docs/sphinx_docs/_build/html/_modules/joy/parser.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/_modules/joy/parser.html Mon Apr 30 10:12:56 2018 -0700
@@ -84,7 +84,7 @@
8484 <span class="sd"> Any unbalanced square brackets will raise a ParseError.</span>
8585
8686 <span class="sd"> :param str text: Text to convert.</span>
87-<span class="sd"> :rtype: quote</span>
87+<span class="sd"> :rtype: stack</span>
8888 <span class="sd"> :raises ParseError: if the parse fails.</span>
8989 <span class="sd"> &#39;&#39;&#39;</span>
9090 <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>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html
--- a/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html Mon Apr 30 10:12:56 2018 -0700
@@ -51,7 +51,24 @@
5151 <span class="c1"># along with Thun. If not see &lt;http://www.gnu.org/licenses/&gt;.</span>
5252 <span class="c1">#</span>
5353 <span class="sd">&#39;&#39;&#39;</span>
54-<span class="sd">Pretty printing support.</span>
54+<span class="sd">Pretty printing support, e.g.::</span>
55+
56+<span class="sd"> Joy? 23 18 * 99 +</span>
57+<span class="sd"> . 23 18 mul 99 add</span>
58+<span class="sd"> 23 . 18 mul 99 add</span>
59+<span class="sd"> 23 18 . mul 99 add</span>
60+<span class="sd"> 414 . 99 add</span>
61+<span class="sd"> 414 99 . add</span>
62+<span class="sd"> 513 . </span>
63+
64+<span class="sd"> 513 &lt;-top</span>
65+
66+<span class="sd"> joy? </span>
67+
68+<span class="sd">On each line the stack is printed with the top to the right, then a ``.`` to</span>
69+<span class="sd">represent the current locus of processing, then the pending expression to the</span>
70+<span class="sd">left.</span>
71+
5572 <span class="sd">&#39;&#39;&#39;</span>
5673 <span class="c1"># (Kinda clunky and hacky. This should be swapped out in favor of much</span>
5774 <span class="c1"># smarter stuff.)</span>
@@ -62,29 +79,36 @@
6279
6380 <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>
6481 <span class="sd">&#39;&#39;&#39;</span>
65-<span class="sd"> This is what does the formatting, e.g.::</span>
66-
67-<span class="sd"> Joy? 23 18 * 99 +</span>
68-<span class="sd"> . 23 18 mul 99 add</span>
69-<span class="sd"> 23 . 18 mul 99 add</span>
70-<span class="sd"> 23 18 . mul 99 add</span>
71-<span class="sd"> 414 . 99 add</span>
72-<span class="sd"> 414 99 . add</span>
73-<span class="sd"> 513 . </span>
74-
82+<span class="sd"> This is what does the formatting. You instantiate it and pass the ``viewer()``</span>
83+<span class="sd"> method to the :py:func:`joy.joy.joy` function, then print it to see the</span>
84+<span class="sd"> trace.</span>
7585 <span class="sd"> &#39;&#39;&#39;</span>
7686
7787 <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
7888 <span class="bp">self</span><span class="o">.</span><span class="n">history</span> <span class="o">=</span> <span class="p">[]</span>
7989
8090 <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>
81- <span class="sd">&#39;&#39;&#39;Pass this method as the viewer to joy() function.&#39;&#39;&#39;</span>
91+ <span class="sd">&#39;&#39;&#39;</span>
92+<span class="sd"> Record the current stack and expression in the TracePrinter&#39;s history.</span>
93+<span class="sd"> Pass this method as the ``viewer`` argument to the :py:func:`joy.joy.joy` function.</span>
94+
95+<span class="sd"> :param stack quote: A stack.</span>
96+<span class="sd"> :param stack expression: A stack.</span>
97+<span class="sd"> &#39;&#39;&#39;</span>
8298 <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>
8399
84100 <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
85101 <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>
86102
87- <span class="k">def</span> <span class="nf">go</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
103+<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>
104+ <span class="sd">&#39;&#39;&#39;</span>
105+<span class="sd"> Return a list of strings, one for each entry in the history, prefixed</span>
106+<span class="sd"> with enough spaces to align all the interpreter dots.</span>
107+
108+<span class="sd"> This method is called internally by the ``__str__()`` method.</span>
109+
110+<span class="sd"> :rtype: list(str)</span>
111+<span class="sd"> &#39;&#39;&#39;</span>
88112 <span class="n">max_stack_length</span> <span class="o">=</span> <span class="mi">0</span>
89113 <span class="n">lines</span> <span class="o">=</span> <span class="p">[]</span>
90114 <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>
@@ -97,7 +121,7 @@
97121 <span class="k">return</span> <span class="p">[</span> <span class="c1"># Prefix spaces to line up &#39;.&#39;s.</span>
98122 <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>
99123 <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>
100- <span class="p">]</span>
124+ <span class="p">]</span></div>
101125
102126 <span class="k">def</span> <span class="nf">print_</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
103127 <span class="k">try</span><span class="p">:</span>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html
--- a/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html Mon Apr 30 10:12:56 2018 -0700
@@ -51,12 +51,13 @@
5151 <span class="c1"># along with Thun. If not see &lt;http://www.gnu.org/licenses/&gt;.</span>
5252 <span class="c1">#</span>
5353 <span class="sd">&#39;&#39;&#39;</span>
54-<span class="sd">When talking about Joy we use the terms &quot;stack&quot;, &quot;list&quot;, &quot;sequence&quot;,</span>
55-<span class="sd">&quot;quote&quot; and others to mean the same thing: a simple linear datatype that</span>
54+<span class="sd">When talking about Joy we use the terms &quot;stack&quot;, &quot;quote&quot;, &quot;sequence&quot;,</span>
55+<span class="sd">&quot;list&quot;, and others to mean the same thing: a simple linear datatype that</span>
5656 <span class="sd">permits certain operations such as iterating and pushing and popping</span>
5757 <span class="sd">values from (at least) one end.</span>
5858
59-<span class="sd">We use the `cons list`_, a venerable two-tuple recursive sequence datastructure, where the</span>
59+<span class="sd">There is no &quot;Stack&quot; Python class, instead we use the `cons list`_, a </span>
60+<span class="sd">venerable two-tuple recursive sequence datastructure, where the</span>
6061 <span class="sd">empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the recursive</span>
6162 <span class="sd">form of a stack with one or more items on it::</span>
6263
@@ -84,33 +85,36 @@
8485 <span class="sd">syntax doesn&#39;t require parentheses around tuples used in expressions</span>
8586 <span class="sd">where they would be redundant.)</span>
8687
88+<span class="sd">Unfortunately, the Sphinx documentation generator, which is used to generate this</span>
89+<span class="sd">web page, doesn&#39;t handle tuples in the function parameters. And in Python 3, this</span>
90+<span class="sd">syntax was removed entirely. Instead you would have to write::</span>
91+
92+<span class="sd"> def dup(stack):</span>
93+<span class="sd"> head, tail = stack</span>
94+<span class="sd"> return head, (head, tail)</span>
95+
96+
97+<span class="sd">We have two very simple functions, one to build up a stack from a Python</span>
98+<span class="sd">iterable and another to iterate through a stack and yield its items</span>
99+<span class="sd">one-by-one in order. There are also two functions to generate string representations</span>
100+<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>
101+<span class="sd">printed left-to-right. These functions are written to support :doc:`../pretty`.</span>
102+
87103 <span class="sd">.. _cons list: https://en.wikipedia.org/wiki/Cons#Lists</span>
88104
89105 <span class="sd">&#39;&#39;&#39;</span>
90106
91-<span class="c1">##We have two very simple functions to build up a stack from a Python</span>
92-<span class="c1">##iterable and also to iterate through a stack and yield its items</span>
93-<span class="c1">##one-by-one in order, and two functions to generate string representations</span>
94-<span class="c1">##of stacks::</span>
95-<span class="c1">##</span>
96-<span class="c1">## list_to_stack()</span>
97-<span class="c1">##</span>
98-<span class="c1">## iter_stack()</span>
99-<span class="c1">##</span>
100-<span class="c1">## expression_to_string() (prints left-to-right)</span>
101-<span class="c1">##</span>
102-<span class="c1">## stack_to_string() (prints right-to-left)</span>
103-<span class="c1">##</span>
104-<span class="c1">##</span>
105-<span class="c1">##A word about the stack data structure.</span>
106-
107-
108107
109108 <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>
110109 <span class="sd">&#39;&#39;&#39;Convert a Python list (or other sequence) to a Joy stack::</span>
111110
112111 <span class="sd"> [1, 2, 3] -&gt; (1, (2, (3, ())))</span>
113112
113+<span class="sd"> :param list el: A Python list or other sequence (iterators and generators</span>
114+<span class="sd"> won&#39;t work because ``reverse()`` is called on ``el``.)</span>
115+<span class="sd"> :param stack stack: A stack, optional, defaults to the empty stack.</span>
116+<span class="sd"> :rtype: stack</span>
117+
114118 <span class="sd"> &#39;&#39;&#39;</span>
115119 <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>
116120 <span class="n">stack</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">stack</span>
@@ -118,7 +122,11 @@
118122
119123
120124 <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>
121- <span class="sd">&#39;&#39;&#39;Iterate through the items on the stack.&#39;&#39;&#39;</span>
125+ <span class="sd">&#39;&#39;&#39;Iterate through the items on the stack.</span>
126+
127+<span class="sd"> :param stack stack: A stack.</span>
128+<span class="sd"> :rtype: iterator</span>
129+<span class="sd"> &#39;&#39;&#39;</span>
122130 <span class="k">while</span> <span class="n">stack</span><span class="p">:</span>
123131 <span class="n">item</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
124132 <span class="k">yield</span> <span class="n">item</span></div>
@@ -131,6 +139,9 @@
131139 <span class="sd"> The items are written right-to-left::</span>
132140
133141 <span class="sd"> (top, (second, ...)) -&gt; &#39;... second top&#39;</span>
142+
143+<span class="sd"> :param stack stack: A stack.</span>
144+<span class="sd"> :rtype: str</span>
134145 <span class="sd"> &#39;&#39;&#39;</span>
135146 <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>
136147 <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>
@@ -143,6 +154,9 @@
143154 <span class="sd"> The items are written left-to-right::</span>
144155
145156 <span class="sd"> (top, (second, ...)) -&gt; &#39;top second ...&#39;</span>
157+
158+<span class="sd"> :param stack expression: A stack.</span>
159+<span class="sd"> :rtype: str</span>
146160 <span class="sd"> &#39;&#39;&#39;</span>
147161 <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>
148162
@@ -165,7 +179,16 @@
165179 <span class="sd">&#39;&#39;&#39;Concatinate quote onto expression.</span>
166180
167181 <span class="sd"> In joy [1 2] [3 4] would become [1 2 3 4].</span>
182+
183+<span class="sd"> :param stack quote: A stack.</span>
184+<span class="sd"> :param stack expression: A stack.</span>
185+<span class="sd"> :raises RuntimeError: if quote is larger than sys.getrecursionlimit().</span>
186+<span class="sd"> :rtype: stack</span>
168187 <span class="sd"> &#39;&#39;&#39;</span>
188+ <span class="c1"># This is the fastest implementation, but will trigger</span>
189+ <span class="c1"># RuntimeError: maximum recursion depth exceeded</span>
190+ <span class="c1"># on quotes longer than sys.getrecursionlimit().</span>
191+ <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>
169192
170193 <span class="c1"># Original implementation.</span>
171194
@@ -182,15 +205,17 @@
182205 <span class="c1">## expression = item, expression</span>
183206 <span class="c1">## return expression</span>
184207
185- <span class="c1"># This is the fastest, but will trigger</span>
186- <span class="c1"># RuntimeError: maximum recursion depth exceeded</span>
187- <span class="c1"># on quotes longer than sys.getrecursionlimit().</span>
188- <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>
189208
190209
191210 <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>
192211 <span class="sd">&#39;&#39;&#39;</span>
193-<span class="sd"> Find the nth item on the stack. (Pick with zero is the same as &quot;dup&quot;.)</span>
212+<span class="sd"> Return the nth item on the stack.</span>
213+
214+<span class="sd"> :param stack s: A stack.</span>
215+<span class="sd"> :param int n: An index into the stack.</span>
216+<span class="sd"> :raises ValueError: if ``n`` is less than zero.</span>
217+<span class="sd"> :raises IndexError: if ``n`` is equal to or greater than the length of ``s``.</span>
218+<span class="sd"> :rtype: whatever</span>
194219 <span class="sd"> &#39;&#39;&#39;</span>
195220 <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
196221 <span class="k">raise</span> <span class="ne">ValueError</span>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/genindex.html
--- a/docs/sphinx_docs/_build/html/genindex.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/genindex.html Mon Apr 30 10:12:56 2018 -0700
@@ -166,6 +166,8 @@
166166 <td style="width: 33%; vertical-align: top;"><ul>
167167 <li><a href="library.html#joy.library.getitem">getitem() (in module joy.library)</a>
168168 </li>
169+ <li><a href="pretty.html#joy.utils.pretty_print.TracePrinter.go">go() (joy.utils.pretty_print.TracePrinter method)</a>
170+</li>
169171 </ul></td>
170172 </tr></table>
171173
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/index.html
--- a/docs/sphinx_docs/_build/html/index.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/index.html Mon Apr 30 10:12:56 2018 -0700
@@ -93,7 +93,7 @@
9393 <li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a><ul>
9494 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
9595 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#the-stack">The Stack</a></li>
96-<li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#purely-functional-datastructures">Purely Functional Datastructures.</a></li>
96+<li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#purely-functional-datastructures">Purely Functional Datastructures</a></li>
9797 <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>
9898 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#parser">Parser</a></li>
9999 <li class="toctree-l2"><a class="reference internal" href="notebooks/Intro.html#library">Library</a></li>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/joy.html
--- a/docs/sphinx_docs/_build/html/joy.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/joy.html Mon Apr 30 10:12:56 2018 -0700
@@ -17,7 +17,7 @@
1717 <link rel="index" title="Index" href="genindex.html" />
1818 <link rel="search" title="Search" href="search.html" />
1919 <link rel="next" title="Stack or Quote or Sequence or List…" href="stack.html" />
20- <link rel="prev" title="Thun 0.1.1 Documentation" href="index.html" />
20+ <link rel="prev" title="Thun: Joy in Python" href="notebooks/Intro.html" />
2121
2222 <link rel="stylesheet" href="_static/custom.css" type="text/css" />
2323
@@ -51,14 +51,17 @@
5151 <col class="field-name" />
5252 <col class="field-body" />
5353 <tbody valign="top">
54-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
55-<li><strong>stack</strong> (<em>quote</em>) – The stack.</li>
56-<li><strong>expression</strong> (<em>quote</em>) – The expression to evaluate.</li>
57-<li><strong>dictionary</strong> (<em>dict</em>) – A <cite>dict</cite> mapping names to Joy functions.</li>
54+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
55+<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
56+<li><strong>expression</strong> (<em>stack</em>) – The expression to evaluate.</li>
57+<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>
5858 <li><strong>viewer</strong> (<em>function</em>) – Optional viewer function.</li>
5959 </ul>
6060 </td>
6161 </tr>
62+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(stack, (), dictionary)</p>
63+</td>
64+</tr>
6265 </tbody>
6366 </table>
6467 </dd></dl>
@@ -68,12 +71,44 @@
6871 <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>
6972 <dd><p>Read-Evaluate-Print Loop</p>
7073 <p>Accept input and run it on the stack, loop.</p>
74+<table class="docutils field-list" frame="void" rules="none">
75+<col class="field-name" />
76+<col class="field-body" />
77+<tbody valign="top">
78+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
79+<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
80+<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>
81+</ul>
82+</td>
83+</tr>
84+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
85+</td>
86+</tr>
87+</tbody>
88+</table>
7189 </dd></dl>
7290
7391 <dl class="function">
7492 <dt id="joy.joy.run">
7593 <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>
7694 <dd><p>Return the stack resulting from running the Joy code text on the stack.</p>
95+<table class="docutils field-list" frame="void" rules="none">
96+<col class="field-name" />
97+<col class="field-body" />
98+<tbody valign="top">
99+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
100+<li><strong>text</strong> (<em>str</em>) – Joy code.</li>
101+<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
102+<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>
103+<li><strong>viewer</strong> (<em>function</em>) – Optional viewer function.</li>
104+</ul>
105+</td>
106+</tr>
107+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(stack, (), dictionary)</p>
108+</td>
109+</tr>
110+</tbody>
111+</table>
77112 </dd></dl>
78113
79114 </div>
@@ -96,7 +131,7 @@
96131 <h3>Related Topics</h3>
97132 <ul>
98133 <li><a href="index.html">Documentation overview</a><ul>
99- <li>Previous: <a href="index.html" title="previous chapter">Thun 0.1.1 Documentation</a></li>
134+ <li>Previous: <a href="notebooks/Intro.html" title="previous chapter">Thun: Joy in Python</a></li>
100135 <li>Next: <a href="stack.html" title="next chapter">Stack or Quote or Sequence or List…</a></li>
101136 </ul></li>
102137 </ul>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html
--- a/docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html Sat Apr 28 09:30:47 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,512 +0,0 @@
1-
2-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4-
5-<html xmlns="http://www.w3.org/1999/xhtml">
6- <head>
7- <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
8- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9- <title>Joypy &#8212; Thun 0.1.1 documentation</title>
10- <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
11- <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
12- <script type="text/javascript" src="../_static/documentation_options.js"></script>
13- <script type="text/javascript" src="../_static/jquery.js"></script>
14- <script type="text/javascript" src="../_static/underscore.js"></script>
15- <script type="text/javascript" src="../_static/doctools.js"></script>
16- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
17- <link rel="index" title="Index" href="../genindex.html" />
18- <link rel="search" title="Search" href="../search.html" />
19-
20- <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
21-
22-
23- <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
24-
25- </head><body>
26-
27-
28- <div class="document">
29- <div class="documentwrapper">
30- <div class="bodywrapper">
31- <div class="body" role="main">
32-
33- <div class="section" id="joypy">
34-<h1>Joypy<a class="headerlink" href="#joypy" title="Permalink to this headline">¶</a></h1>
35-<div class="section" id="joy-in-python">
36-<h2>Joy in Python<a class="headerlink" href="#joy-in-python" title="Permalink to this headline">¶</a></h2>
37-<p>This implementation is meant as a tool for exploring the programming
38-model and method of Joy. Python seems like a great implementation
39-language for Joy for several reasons.</p>
40-<p>We can lean on the Python immutable types for our basic semantics and
41-types: ints, floats, strings, and tuples, which enforces functional
42-purity. We get garbage collection for free. Compilation via Cython. Glue
43-language with loads of libraries.</p>
44-<div class="section" id="read-eval-print-loop-repl">
45-<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>
46-<p>The main way to interact with the Joy interpreter is through a simple
47-<a class="reference external" href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop">REPL</a>
48-that you start by running the package:</p>
49-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python -m joy
50-Joypy - Copyright © 2017 Simon Forman
51-This program comes with ABSOLUTELY NO WARRANTY; for details type &quot;warranty&quot;.
52-This is free software, and you are welcome to redistribute it
53-under certain conditions; type &quot;sharing&quot; for details.
54-Type &quot;words&quot; to see a list of all words, and &quot;[&lt;name&gt;] help&quot; to print the
55-docs for a word.
56-
57-
58- &lt;-top
59-
60-joy? _
61-</pre></div>
62-</div>
63-<p>The <code class="docutils literal notranslate"><span class="pre">&lt;-top</span></code> marker points to the top of the (initially empty) stack.
64-You can enter Joy notation at the prompt and a <a class="reference external" href="#The-TracePrinter.">trace of
65-evaluation</a> will be printed followed by the stack
66-and prompt again:</p>
67-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>joy? 23 sqr 18 +
68- . 23 sqr 18 +
69- 23 . sqr 18 +
70- 23 . dup mul 18 +
71- 23 23 . mul 18 +
72- 529 . 18 +
73-529 18 . +
74- 547 .
75-
76-547 &lt;-top
77-
78-joy?
79-</pre></div>
80-</div>
81-</div>
82-</div>
83-</div>
84-<div class="section" id="stacks-aka-list-quote-sequence-etc">
85-<h1>Stacks (aka list, quote, sequence, etc.)<a class="headerlink" href="#stacks-aka-list-quote-sequence-etc" title="Permalink to this headline">¶</a></h1>
86-<p>In Joy, in addition to the types Boolean, integer, float, and string,
87-there is a single sequence type represented by enclosing a sequence of
88-terms in brackets <code class="docutils literal notranslate"><span class="pre">[...]</span></code>. This sequence type is used to represent
89-both the stack and the expression. It is a <a class="reference external" href="https://en.wikipedia.org/wiki/Cons#Lists">cons
90-list</a> made from Python
91-tuples.</p>
92-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">inspect</span>
93-<span class="kn">import</span> <span class="nn">joy.utils.stack</span>
94-
95-
96-<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>
97-</pre></div>
98-</div>
99-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>§ Stack
100-
101-
102-When talking about Joy we use the terms &quot;stack&quot;, &quot;list&quot;, &quot;sequence&quot; and
103-&quot;aggregate&quot; to mean the same thing: a simple datatype that permits
104-certain operations such as iterating and pushing and popping values from
105-(at least) one end.
106-
107-We use the venerable two-tuple recursive form of sequences where the
108-empty tuple () is the empty stack and (head, rest) gives the recursive
109-form of a stack with one or more items on it.
110-
111- ()
112- (1, ())
113- (2, (1, ()))
114- (3, (2, (1, ())))
115- ...
116-
117-And so on.
118-
119-
120-We have two very simple functions to build up a stack from a Python
121-iterable and also to iterate through a stack and yield its items
122-one-by-one in order, and two functions to generate string representations
123-of stacks:
124-
125- list_to_stack()
126-
127- iter_stack()
128-
129- expression_to_string() (prints left-to-right)
130-
131- stack_to_string() (prints right-to-left)
132-
133-
134-A word about the stack data structure.
135-
136-Python has very nice &quot;tuple packing and unpacking&quot; in its syntax which
137-means we can directly &quot;unpack&quot; the expected arguments to a Joy function.
138-
139-For example:
140-
141- def dup(stack):
142- head, tail = stack
143- return head, (head, tail)
144-
145-We replace the argument &quot;stack&quot; by the expected structure of the stack,
146-in this case &quot;(head, tail)&quot;, and Python takes care of de-structuring the
147-incoming argument and assigning values to the names. Note that Python
148-syntax doesn&#39;t require parentheses around tuples used in expressions
149-where they would be redundant.
150-</pre></div>
151-</div>
152-<p>The 0th item in the list will be on the top of the stack and <em>vise
153-versa</em>.</p>
154-<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>
155-</pre></div>
156-</div>
157-<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>
158-</pre></div>
159-</div>
160-<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>
161-</pre></div>
162-</div>
163-<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>
164-</pre></div>
165-</div>
166-<p>This requires reversing the sequence (or iterating backwards) otherwise:</p>
167-<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>
168-
169-<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>
170- <span class="n">stack</span> <span class="o">=</span> <span class="n">n</span><span class="p">,</span> <span class="n">stack</span>
171-
172-<span class="nb">print</span> <span class="n">stack</span>
173-<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>
174-</pre></div>
175-</div>
176-<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>
177-<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>
178-</pre></div>
179-</div>
180-<p>Because Joy lists are made out of Python tuples they are immutable, so
181-all Joy datastructures are <em>`purely
182-functional &lt;https://en.wikipedia.org/wiki/Purely_functional_data_structure&gt;`__</em>.</p>
183-</div>
184-<div class="section" id="the-joy-function">
185-<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>
186-<div class="section" id="an-interpreter">
187-<h2>An Interpreter<a class="headerlink" href="#an-interpreter" title="Permalink to this headline">¶</a></h2>
188-<p>The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function is extrememly simple. It accepts a stack, an
189-expression, and a dictionary, and it iterates through the expression
190-putting values onto the stack and delegating execution to functions it
191-looks up in the dictionary.</p>
192-<p>Each function is passed the stack, expression, and dictionary and
193-returns them. Whatever the function returns becomes the new stack,
194-expression, and dictionary. (The dictionary is passed to enable e.g.
195-writing words that let you enter new words into the dictionary at
196-runtime, which nothing does yet and may be a bad idea, and the <code class="docutils literal notranslate"><span class="pre">help</span></code>
197-command.)</p>
198-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.joy</span>
199-
200-<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>
201-</pre></div>
202-</div>
203-<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>
204- <span class="sd">&#39;&#39;&#39;</span>
205-<span class="sd"> Evaluate the Joy expression on the stack.</span>
206-<span class="sd"> &#39;&#39;&#39;</span>
207- <span class="k">while</span> <span class="n">expression</span><span class="p">:</span>
208-
209- <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>
210-
211- <span class="n">term</span><span class="p">,</span> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span>
212- <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>
213- <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>
214- <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>
215- <span class="k">else</span><span class="p">:</span>
216- <span class="n">stack</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">stack</span>
217-
218- <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>
219- <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>
220-</pre></div>
221-</div>
222-<div class="section" id="view-function">
223-<h3>View function<a class="headerlink" href="#view-function" title="Permalink to this headline">¶</a></h3>
224-<p>The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function accepts a “viewer” function which it calls on
225-each iteration passing the current stack and expression just before
226-evaluation. This can be used for tracing, breakpoints, retrying after
227-exceptions, or interrupting an evaluation and saving to disk or sending
228-over the network to resume later. The stack and expression together
229-contain all the state of the computation at each step.</p>
230-</div>
231-<div class="section" id="the-traceprinter">
232-<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>
233-<p>A <code class="docutils literal notranslate"><span class="pre">viewer</span></code> records each step of the evaluation of a Joy program. The
234-<code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code> has a facility for printing out a trace of the
235-evaluation, one line per step. Each step is aligned to the current
236-interpreter position, signified by a period separating the stack on the
237-left from the pending expression (“continuation”) on the right.</p>
238-</div>
239-<div class="section" id="continuation-passing-style">
240-<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>
241-<p>One day I thought, What happens if you rewrite Joy to use
242-<a class="reference external" href="https://en.wikipedia.org/wiki/Continuation-passing_style">CSP</a>? I
243-made all the functions accept and return the expression as well as the
244-stack and found that all the combinators could be rewritten to work by
245-modifying the expression rather than making recursive calls to the
246-<code class="docutils literal notranslate"><span class="pre">joy()</span></code> function.</p>
247-</div>
248-</div>
249-</div>
250-<div class="section" id="parser">
251-<h1>Parser<a class="headerlink" href="#parser" title="Permalink to this headline">¶</a></h1>
252-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.parser</span>
253-
254-<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>
255-</pre></div>
256-</div>
257-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>§ Converting text to a joy expression.
258-
259-This module exports a single function:
260-
261- text_to_expression(text)
262-
263-As well as a single Symbol class and a single Exception type:
264-
265- ParseError
266-
267-When supplied with a string this function returns a Python datastructure
268-that represents the Joy datastructure described by the text expression.
269-Any unbalanced square brackets will raise a ParseError.
270-</pre></div>
271-</div>
272-<p>The parser is extremely simple, the undocumented <code class="docutils literal notranslate"><span class="pre">re.Scanner</span></code> class
273-does most of the tokenizing work and then you just build the tuple
274-structure out of the tokens. There’s no Abstract Syntax Tree or anything
275-like that.</p>
276-<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>
277-</pre></div>
278-</div>
279-<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>
280- <span class="sd">&#39;&#39;&#39;</span>
281-<span class="sd"> Return a stack/list expression of the tokens.</span>
282-<span class="sd"> &#39;&#39;&#39;</span>
283- <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
284- <span class="n">stack</span> <span class="o">=</span> <span class="p">[]</span>
285- <span class="k">for</span> <span class="n">tok</span> <span class="ow">in</span> <span class="n">tokens</span><span class="p">:</span>
286- <span class="k">if</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;[&#39;</span><span class="p">:</span>
287- <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>
288- <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
289- <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>
290- <span class="k">elif</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;]&#39;</span><span class="p">:</span>
291- <span class="k">try</span><span class="p">:</span>
292- <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>
293- <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
294- <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>
295- <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>
296- <span class="k">else</span><span class="p">:</span>
297- <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>
298- <span class="k">if</span> <span class="n">stack</span><span class="p">:</span>
299- <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>
300- <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>
301-</pre></div>
302-</div>
303-<p>That’s pretty much all there is to it.</p>
304-<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>
305-</pre></div>
306-</div>
307-<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>
308-</pre></div>
309-</div>
310-<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>
311-</pre></div>
312-</div>
313-<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>
314-</pre></div>
315-</div>
316-<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>
317- <span class="c1"># a Symbol, no lookup at</span>
318- <span class="c1"># parse-time. Haiku docs.</span>
319-</pre></div>
320-</div>
321-<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>
322-</pre></div>
323-</div>
324-<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>
325-</pre></div>
326-</div>
327-<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>
328-</pre></div>
329-</div>
330-<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>
331-</pre></div>
332-</div>
333-<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>
334-</pre></div>
335-</div>
336-</div>
337-<div class="section" id="library">
338-<h1>Library<a class="headerlink" href="#library" title="Permalink to this headline">¶</a></h1>
339-<p>The Joy library of functions (aka commands, or “words” after Forth
340-usage) encapsulates all the actual functionality (no pun intended) of
341-the Joy system. There are simple functions such as addition <code class="docutils literal notranslate"><span class="pre">add</span></code> (or
342-<code class="docutils literal notranslate"><span class="pre">+</span></code>, the library module supports aliases), and combinators which
343-provide control-flow and higher-order operations.</p>
344-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.library</span>
345-
346-<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>
347-</pre></div>
348-</div>
349-<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 •
350-</pre></div>
351-</div>
352-<p>Many of the functions are defined in Python, like <code class="docutils literal notranslate"><span class="pre">dip</span></code>:</p>
353-<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>
354-</pre></div>
355-</div>
356-<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>
357- <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>
358- <span class="n">expression</span> <span class="o">=</span> <span class="n">x</span><span class="p">,</span> <span class="n">expression</span>
359- <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>
360-</pre></div>
361-</div>
362-<p>Some functions are defined in equations in terms of other functions.
363-When the interpreter executes a definition function that function just
364-pushes its body expression onto the pending expression (the
365-continuation) and returns control to the interpreter.</p>
366-<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>
367-</pre></div>
368-</div>
369-<pre class="literal-block">
370-second == rest first
371-third == rest rest first
372-product == 1 swap [*] step
373-swons == swap cons
374-swoncat == swap concat
375-flatten == [] swap [concat] step
376-unit == [] cons
377-quoted == [unit] dip
378-unquoted == [i] dip
379-enstacken == stack [clear] dip
380-disenstacken == ? [uncons ?] loop pop
381-? == dup truthy
382-dinfrirst == dip infra first
383-nullary == [stack] dinfrirst
384-unary == [stack [pop] dip] dinfrirst
385-binary == [stack [popop] dip] dinfrirst
386-ternary == [stack [popop pop] dip] dinfrirst
387-pam == [i] map
388-run == [] swap infra
389-sqr == dup mul
390-size == 0 swap [pop ++] step
391-cleave == [i] app2 [popd] dip
392-average == [sum 1.0 <em>] [size] cleave /
393-gcd == 1 [tuck modulus dup 0 &gt;] loop pop
394-least_fraction == dup [gcd] infra [div] concat map
395-*fraction == [uncons] dip uncons [swap] dip concat [</em>] infra [*] dip cons
396-<em>fraction0 == concat [[swap] dip * [</em>] dip] infra
397-down_to_zero == [0 &gt;] [dup --] while
398-range_to_zero == unit [down_to_zero] infra
399-anamorphism == [pop []] swap [dip swons] genrec
400-range == [0 &lt;=] [1 - dup] anamorphism
401-while == swap [nullary] cons dup dipd concat loop
402-dudipd == dup dipd
403-primrec == [i] genrec
404-</pre>
405-<p>Currently, there’s no function to add new definitions to the dictionary
406-from “within” Joy code itself. Adding new definitions remains a
407-meta-interpreter action. You have to do it yourself, in Python, and wash
408-your hands afterward.</p>
409-<p>It would be simple enough to define one, but it would open the door to
410-<em>name binding</em> and break the idea that all state is captured in the
411-stack and expression. There’s an implicit <em>standard dictionary</em> that
412-defines the actual semantics of the syntactic stack and expression
413-datastructures (which only contain symbols, not the actual functions.
414-Pickle some and see for yourself.)</p>
415-<p>Which brings me to talking about one of my hopes and dreams for this
416-notation: “There should be only one.” What I mean is that there should
417-be one universal standard dictionary of commands, and all bespoke work
418-done in a UI for purposes takes place by direct interaction and macros.
419-There would be a <em>Grand Refactoring</em> biannually (two years, not six
420-months, that’s semi-annually) where any new definitions factored out of
421-the usage and macros of the previous time, along with new algorithms and
422-such, were entered into the dictionary and posted to e.g. IPFS.</p>
423-<p>Code should not burgeon wildly, as it does today. The variety of code
424-should map more-or-less to the well-factored variety of human
425-computably-solvable problems. There shouldn’t be dozens of chat apps, JS
426-frameworks, programming languages. It’s a waste of time, a <a class="reference external" href="https://en.wikipedia.org/wiki/Thundering_herd_problem">fractal
427-“thundering herd”
428-attack</a> on
429-human mentality.</p>
430-<p>If you read over the other notebooks you’ll see that developing code in
431-Joy is a lot like doing simple mathematics, and the descriptions of the
432-code resemble math papers. The code also works the first time, no bugs.
433-If you have any experience programming at all, you are probably
434-skeptical, as I was, but it seems to work: deriving code mathematically
435-seems to lead to fewer errors.</p>
436-<p>But my point now is that this great ratio of textual explanation to wind
437-up with code that consists of a few equations and could fit on an index
438-card is highly desirable. Less code has fewer errors. The structure of
439-Joy engenders a kind of thinking that seems to be very effective for
440-developing structured processes.</p>
441-<p>There seems to be an elegance and power to the notation.</p>
442-</div>
443-
444-
445- </div>
446- </div>
447- </div>
448- <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
449- <div class="sphinxsidebarwrapper">
450- <h3><a href="../index.html">Table Of Contents</a></h3>
451- <ul>
452-<li><a class="reference internal" href="#">Joypy</a><ul>
453-<li><a class="reference internal" href="#joy-in-python">Joy in Python</a><ul>
454-<li><a class="reference internal" href="#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
455-</ul>
456-</li>
457-</ul>
458-</li>
459-<li><a class="reference internal" href="#stacks-aka-list-quote-sequence-etc">Stacks (aka list, quote, sequence, etc.)</a></li>
460-<li><a class="reference internal" href="#the-joy-function">The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function.</a><ul>
461-<li><a class="reference internal" href="#an-interpreter">An Interpreter</a><ul>
462-<li><a class="reference internal" href="#view-function">View function</a></li>
463-<li><a class="reference internal" href="#the-traceprinter">The <code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code>.</a></li>
464-<li><a class="reference internal" href="#continuation-passing-style">Continuation-Passing Style</a></li>
465-</ul>
466-</li>
467-</ul>
468-</li>
469-<li><a class="reference internal" href="#parser">Parser</a></li>
470-<li><a class="reference internal" href="#library">Library</a></li>
471-</ul>
472-<div class="relations">
473-<h3>Related Topics</h3>
474-<ul>
475- <li><a href="../index.html">Documentation overview</a><ul>
476- </ul></li>
477-</ul>
478-</div>
479- <div role="note" aria-label="source link">
480- <h3>This Page</h3>
481- <ul class="this-page-menu">
482- <li><a href="../_sources/notebooks/0. This Implementation of Joy in Python.rst.txt"
483- rel="nofollow">Show Source</a></li>
484- </ul>
485- </div>
486-<div id="searchbox" style="display: none" role="search">
487- <h3>Quick search</h3>
488- <div class="searchformwrapper">
489- <form class="search" action="../search.html" method="get">
490- <input type="text" name="q" />
491- <input type="submit" value="Go" />
492- <input type="hidden" name="check_keywords" value="yes" />
493- <input type="hidden" name="area" value="default" />
494- </form>
495- </div>
496-</div>
497-<script type="text/javascript">$('#searchbox').show(0);</script>
498- </div>
499- </div>
500- <div class="clearer"></div>
501- </div>
502- <div class="footer" role="contentinfo">
503-<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
504-<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
505-</a>
506-<br />
507-<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>.
508- Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
509- </div>
510-
511- </body>
512-</html>
\ No newline at end of file
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html
--- a/docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html Mon Apr 30 10:12:56 2018 -0700
@@ -6,7 +6,7 @@
66 <head>
77 <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
88 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9- <title>within &#8212; Thun 0.1.1 documentation</title>
9+ <title>A Generator for Approximations &#8212; Thun 0.1.1 documentation</title>
1010 <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
1111 <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
1212 <script type="text/javascript" src="../_static/documentation_options.js"></script>
@@ -30,25 +30,88 @@
3030 <div class="bodywrapper">
3131 <div class="body" role="main">
3232
33- <div class="section" id="within">
34-<h1><code class="docutils literal notranslate"><span class="pre">within</span></code><a class="headerlink" href="#within" title="Permalink to this headline">¶</a></h1>
33+ <div class="section" id="a-generator-for-approximations">
34+<h1>A Generator for Approximations<a class="headerlink" href="#a-generator-for-approximations" title="Permalink to this headline">¶</a></h1>
35+<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>
36+<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>
37+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">a</span> <span class="n">F</span>
38+<span class="o">---------</span>
39+ <span class="n">a</span><span class="s1">&#39;</span>
40+</pre></div>
41+</div>
42+<div class="section" id="a-function-to-compute-the-next-approximation">
43+<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>
44+<p>Looking at the equation again:</p>
45+<p><span class="math notranslate nohighlight">\(a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}\)</span></p>
46+<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>
47+<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>
48+<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>
49+<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>
50+<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>
51+</pre></div>
52+</div>
53+<p>The function we want has the argument <code class="docutils literal notranslate"><span class="pre">n</span></code> in it:</p>
54+<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>
55+</pre></div>
56+</div>
57+</div>
58+<div class="section" id="make-it-into-a-generator">
59+<h2>Make it into a Generator<a class="headerlink" href="#make-it-into-a-generator" title="Permalink to this headline">¶</a></h2>
60+<p>Our generator would be created by:</p>
61+<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>
62+</pre></div>
63+</div>
64+<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>
65+<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>
66+<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>
67+<span class="mi">1</span> <span class="n">n</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
68+<span class="n">n</span><span class="o">+</span><span class="mi">1</span> <span class="mi">2</span> <span class="o">/</span>
69+<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>
70+</pre></div>
71+</div>
72+<p>The generator can be written as:</p>
73+<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>
74+</pre></div>
75+</div>
76+<p>Example:</p>
77+<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>
78+<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>
79+<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>
80+<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>
81+<span class="o">.</span>
82+<span class="o">.</span>
83+<span class="o">.</span>
84+<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>
85+</pre></div>
86+</div>
87+</div>
88+<div class="section" id="a-generator-of-square-root-approximations">
89+<h2>A Generator of Square Root Approximations<a class="headerlink" href="#a-generator-of-square-root-approximations" title="Permalink to this headline">¶</a></h2>
90+<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>
91+</pre></div>
92+</div>
93+</div>
94+</div>
95+<div class="section" id="finding-consecutive-approximations-within-a-tolerance">
96+<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>
3597 <blockquote>
3698 <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>
3799 <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
38100 Hughes</a></p>
39101 <p>(And note that by “list” he means a lazily-evaluated list.)</p>
40-<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>
102+<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>
41103 <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>
42-<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>
104+<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>
43105 <span class="n">b</span>
44-
45- <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>
46-<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>
106+</pre></div>
107+</div>
108+<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>
109+<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>
47110 <span class="o">.</span>
48111 <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>
49112 <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>
50113 <span class="o">.</span>
51-<span class="o">--------------------</span>
114+<span class="o">----------------------</span>
52115 <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>
53116 </pre></div>
54117 </div>
@@ -85,7 +148,7 @@
85148 </div>
86149 <ol class="arabic simple">
87150 <li>Discard <code class="docutils literal notranslate"><span class="pre">a</span></code>.</li>
88-<li>Use <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator to generate next term from G.</li>
151+<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>
89152 <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>
90153 </ol>
91154 <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 @@
104167 </div>
105168 <div class="section" id="setting-up">
106169 <h2>Setting up<a class="headerlink" href="#setting-up" title="Permalink to this headline">¶</a></h2>
107-<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>
108-<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>
170+<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>
171+<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>
172+<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>
109173 </pre></div>
110174 </div>
111-<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>
175+</div>
176+<div class="section" id="within">
177+<h2><code class="docutils literal notranslate"><span class="pre">within</span></code><a class="headerlink" href="#within" title="Permalink to this headline">¶</a></h2>
178+<p>Giving us the following definitions:</p>
179+<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>
180+<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>
181+<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>
182+<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>
112183 </pre></div>
113184 </div>
114185 </div>
115186 </div>
187+<div class="section" id="finding-square-roots">
188+<h1>Finding Square Roots<a class="headerlink" href="#finding-square-roots" title="Permalink to this headline">¶</a></h1>
189+<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>
190+</pre></div>
191+</div>
192+</div>
116193
117194
118195 </div>
@@ -122,13 +199,21 @@
122199 <div class="sphinxsidebarwrapper">
123200 <h3><a href="../index.html">Table Of Contents</a></h3>
124201 <ul>
125-<li><a class="reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">within</span></code></a><ul>
202+<li><a class="reference internal" href="#">A Generator for Approximations</a><ul>
203+<li><a class="reference internal" href="#a-function-to-compute-the-next-approximation">A Function to Compute the Next Approximation</a></li>
204+<li><a class="reference internal" href="#make-it-into-a-generator">Make it into a Generator</a></li>
205+<li><a class="reference internal" href="#a-generator-of-square-root-approximations">A Generator of Square Root Approximations</a></li>
206+</ul>
207+</li>
208+<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>
126209 <li><a class="reference internal" href="#predicate">Predicate</a></li>
127210 <li><a class="reference internal" href="#base-case">Base-Case</a></li>
128211 <li><a class="reference internal" href="#recur">Recur</a></li>
129212 <li><a class="reference internal" href="#setting-up">Setting up</a></li>
213+<li><a class="reference internal" href="#within"><code class="docutils literal notranslate"><span class="pre">within</span></code></a></li>
130214 </ul>
131215 </li>
216+<li><a class="reference internal" href="#finding-square-roots">Finding Square Roots</a></li>
132217 </ul>
133218 <div class="relations">
134219 <h3>Related Topics</h3>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/notebooks/Intro.html
--- a/docs/sphinx_docs/_build/html/notebooks/Intro.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/notebooks/Intro.html Mon Apr 30 10:12:56 2018 -0700
@@ -90,7 +90,7 @@
9090 tuples.</p>
9191 </div>
9292 <div class="section" id="purely-functional-datastructures">
93-<h2>Purely Functional Datastructures.<a class="headerlink" href="#purely-functional-datastructures" title="Permalink to this headline">¶</a></h2>
93+<h2>Purely Functional Datastructures<a class="headerlink" href="#purely-functional-datastructures" title="Permalink to this headline">¶</a></h2>
9494 <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>
9595 </div>
9696 <div class="section" id="the-joy-function">
@@ -138,7 +138,7 @@
138138 like that.</p>
139139 <div class="section" id="symbols">
140140 <h3>Symbols<a class="headerlink" href="#symbols" title="Permalink to this headline">¶</a></h3>
141-<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>
141+<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>
142142 </div>
143143 <div class="section" id="token-regular-expressions">
144144 <h3>Token Regular Expressions<a class="headerlink" href="#token-regular-expressions" title="Permalink to this headline">¶</a></h3>
@@ -300,7 +300,7 @@
300300 <li><a class="reference internal" href="#">Thun: Joy in Python</a><ul>
301301 <li><a class="reference internal" href="#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
302302 <li><a class="reference internal" href="#the-stack">The Stack</a></li>
303-<li><a class="reference internal" href="#purely-functional-datastructures">Purely Functional Datastructures.</a></li>
303+<li><a class="reference internal" href="#purely-functional-datastructures">Purely Functional Datastructures</a></li>
304304 <li><a class="reference internal" href="#the-joy-function">The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function</a><ul>
305305 <li><a class="reference internal" href="#an-interpreter">An Interpreter</a></li>
306306 <li><a class="reference internal" href="#continuation-passing-style">Continuation-Passing Style</a></li>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/objects.inv
Binary file docs/sphinx_docs/_build/html/objects.inv has changed
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/parser.html
--- a/docs/sphinx_docs/_build/html/parser.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/parser.html Mon Apr 30 10:12:56 2018 -0700
@@ -72,7 +72,7 @@
7272 <tbody valign="top">
7373 <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>
7474 </tr>
75-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">quote</td>
75+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">stack</td>
7676 </tr>
7777 <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>
7878 </tr>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/pretty.html
--- a/docs/sphinx_docs/_build/html/pretty.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/pretty.html Mon Apr 30 10:12:56 2018 -0700
@@ -36,11 +36,7 @@
3636 <h1>Tracing Joy Execution<a class="headerlink" href="#tracing-joy-execution" title="Permalink to this headline">¶</a></h1>
3737 <div class="section" id="module-joy.utils.pretty_print">
3838 <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>
39-<p>Pretty printing support.</p>
40-<dl class="class">
41-<dt id="joy.utils.pretty_print.TracePrinter">
42-<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>
43-<dd><p>This is what does the formatting, e.g.:</p>
39+<p>Pretty printing support, e.g.:</p>
4440 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Joy? 23 18 * 99 +
4541 . 23 18 mul 99 add
4642 23 . 18 mul 99 add
@@ -48,12 +44,54 @@
4844 414 . 99 add
4945 414 99 . add
5046 513 .
47+
48+513 &lt;-top
49+
50+joy?
5151 </pre></div>
5252 </div>
53+<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
54+represent the current locus of processing, then the pending expression to the
55+left.</p>
56+<dl class="class">
57+<dt id="joy.utils.pretty_print.TracePrinter">
58+<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>
59+<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>
60+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
61+trace.</p>
62+<dl class="method">
63+<dt id="joy.utils.pretty_print.TracePrinter.go">
64+<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>
65+<dd><p>Return a list of strings, one for each entry in the history, prefixed
66+with enough spaces to align all the interpreter dots.</p>
67+<p>This method is called internally by the <code class="docutils literal notranslate"><span class="pre">__str__()</span></code> method.</p>
68+<table class="docutils field-list" frame="void" rules="none">
69+<col class="field-name" />
70+<col class="field-body" />
71+<tbody valign="top">
72+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list(str)</td>
73+</tr>
74+</tbody>
75+</table>
76+</dd></dl>
77+
5378 <dl class="method">
5479 <dt id="joy.utils.pretty_print.TracePrinter.viewer">
5580 <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>
56-<dd><p>Pass this method as the viewer to joy() function.</p>
81+<dd><p>Record the current stack and expression in the TracePrinter’s history.
82+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>
83+<table class="docutils field-list" frame="void" rules="none">
84+<col class="field-name" />
85+<col class="field-body" />
86+<tbody valign="top">
87+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
88+<li><strong>quote</strong> (<em>stack</em>) – A stack.</li>
89+<li><strong>expression</strong> (<em>stack</em>) – A stack.</li>
90+</ul>
91+</td>
92+</tr>
93+</tbody>
94+</table>
5795 </dd></dl>
5896
5997 </dd></dl>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/searchindex.js
--- a/docs/sphinx_docs/_build/html/searchindex.js Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/searchindex.js Mon Apr 30 10:12:56 2018 -0700
@@ -1,1 +1,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
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":{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
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/_build/html/stack.html
--- a/docs/sphinx_docs/_build/html/stack.html Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/_build/html/stack.html Mon Apr 30 10:12:56 2018 -0700
@@ -36,11 +36,12 @@
3636 <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>
3737 <div class="section" id="module-joy.utils.stack">
3838 <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>
39-<p>When talking about Joy we use the terms “stack”, “list”, “sequence”,
40-“quote” and others to mean the same thing: a simple linear datatype that
39+<p>When talking about Joy we use the terms “stack”, “quote”, “sequence”,
40+“list”, and others to mean the same thing: a simple linear datatype that
4141 permits certain operations such as iterating and pushing and popping
4242 values from (at least) one end.</p>
43-<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
43+<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
44+venerable two-tuple recursive sequence datastructure, where the
4445 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
4546 form of a stack with one or more items on it:</p>
4647 <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 @@
6667 incoming tuple and assigning values to the names. (Note that Python
6768 syntax doesn’t require parentheses around tuples used in expressions
6869 where they would be redundant.)</p>
70+<p>Unfortunately, the Sphinx documentation generator, which is used to generate this
71+web page, doesn’t handle tuples in the function parameters. And in Python 3, this
72+syntax was removed entirely. Instead you would have to write:</p>
73+<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>
74+ <span class="n">head</span><span class="p">,</span> <span class="n">tail</span> <span class="o">=</span> <span class="n">stack</span>
75+ <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>
76+</pre></div>
77+</div>
78+<p>We have two very simple functions, one to build up a stack from a Python
79+iterable and another to iterate through a stack and yield its items
80+one-by-one in order. There are also two functions to generate string representations
81+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
82+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>
6983 <dl class="function">
7084 <dt id="joy.utils.stack.expression_to_string">
7185 <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 @@
7488 <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>
7589 </pre></div>
7690 </div>
91+<table class="docutils field-list" frame="void" rules="none">
92+<col class="field-name" />
93+<col class="field-body" />
94+<tbody valign="top">
95+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>expression</strong> (<em>stack</em>) – A stack.</td>
96+</tr>
97+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
98+</tr>
99+</tbody>
100+</table>
77101 </dd></dl>
78102
79103 <dl class="function">
80104 <dt id="joy.utils.stack.iter_stack">
81105 <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>
82106 <dd><p>Iterate through the items on the stack.</p>
107+<table class="docutils field-list" frame="void" rules="none">
108+<col class="field-name" />
109+<col class="field-body" />
110+<tbody valign="top">
111+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stack</strong> (<em>stack</em>) – A stack.</td>
112+</tr>
113+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">iterator</td>
114+</tr>
115+</tbody>
116+</table>
83117 </dd></dl>
84118
85119 <dl class="function">
@@ -89,12 +123,49 @@
89123 <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>
90124 </pre></div>
91125 </div>
126+<table class="docutils field-list" frame="void" rules="none">
127+<col class="field-name" />
128+<col class="field-body" />
129+<tbody valign="top">
130+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
131+<li><strong>el</strong> (<em>list</em>) – A Python list or other sequence (iterators and generators
132+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>
133+<li><strong>stack</strong> (<em>stack</em>) – A stack, optional, defaults to the empty stack.</li>
134+</ul>
135+</td>
136+</tr>
137+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
138+</td>
139+</tr>
140+</tbody>
141+</table>
92142 </dd></dl>
93143
94144 <dl class="function">
95145 <dt id="joy.utils.stack.pick">
96146 <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>
97-<dd><p>Find the nth item on the stack. (Pick with zero is the same as “dup”.)</p>
147+<dd><p>Return the nth item on the stack.</p>
148+<table class="docutils field-list" frame="void" rules="none">
149+<col class="field-name" />
150+<col class="field-body" />
151+<tbody valign="top">
152+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
153+<li><strong>s</strong> (<em>stack</em>) – A stack.</li>
154+<li><strong>n</strong> (<em>int</em>) – An index into the stack.</li>
155+</ul>
156+</td>
157+</tr>
158+<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first simple">
159+<li><strong>ValueError</strong> – if <code class="docutils literal notranslate"><span class="pre">n</span></code> is less than zero.</li>
160+<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>
161+</ul>
162+</td>
163+</tr>
164+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">whatever</p>
165+</td>
166+</tr>
167+</tbody>
168+</table>
98169 </dd></dl>
99170
100171 <dl class="function">
@@ -102,6 +173,24 @@
102173 <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>
103174 <dd><p>Concatinate quote onto expression.</p>
104175 <p>In joy [1 2] [3 4] would become [1 2 3 4].</p>
176+<table class="docutils field-list" frame="void" rules="none">
177+<col class="field-name" />
178+<col class="field-body" />
179+<tbody valign="top">
180+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
181+<li><strong>quote</strong> (<em>stack</em>) – A stack.</li>
182+<li><strong>expression</strong> (<em>stack</em>) – A stack.</li>
183+</ul>
184+</td>
185+</tr>
186+<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>
187+</td>
188+</tr>
189+<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
190+</td>
191+</tr>
192+</tbody>
193+</table>
105194 </dd></dl>
106195
107196 <dl class="function">
@@ -112,6 +201,16 @@
112201 <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>
113202 </pre></div>
114203 </div>
204+<table class="docutils field-list" frame="void" rules="none">
205+<col class="field-name" />
206+<col class="field-body" />
207+<tbody valign="top">
208+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stack</strong> (<em>stack</em>) – A stack.</td>
209+</tr>
210+<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
211+</tr>
212+</tbody>
213+</table>
115214 </dd></dl>
116215
117216 </div>
diff -r 21a600905247 -r a473a7dd2c19 docs/sphinx_docs/notebooks/AlsoNewton.rst
--- a/docs/sphinx_docs/notebooks/AlsoNewton.rst Sat Apr 28 09:30:47 2018 -0700
+++ b/docs/sphinx_docs/notebooks/AlsoNewton.rst Mon Apr 30 10:12:56 2018 -0700
@@ -1,6 +1,80 @@
1-***************
2-``within``
3-***************
1+
2+
3+
4+
5+A Generator for Approximations
6+==============================
7+
8+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.
9+
10+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::
11+
12+ a F
13+ ---------
14+ a'
15+
16+
17+A Function to Compute the Next Approximation
18+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19+
20+Looking at the equation again:
21+
22+:math:`a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}`
23+
24+::
25+
26+ a n over / + 2 /
27+ a n a / + 2 /
28+ a n/a + 2 /
29+ a+n/a 2 /
30+ (a+n/a)/2
31+
32+The function we want has the argument ``n`` in it::
33+
34+ F == n over / + 2 /
35+
36+
37+Make it into a Generator
38+^^^^^^^^^^^^^^^^^^^^^^^^
39+
40+Our generator would be created by::
41+
42+ a [dup F] make_generator
43+
44+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::
45+
46+ 1 n 1 / + 2 /
47+ 1 n/1 + 2 /
48+ 1 n + 2 /
49+ n+1 2 /
50+ (n+1)/2
51+
52+The generator can be written as::
53+
54+ 1 swap [over / + 2 /] cons [dup] swoncat make_generator
55+
56+Example::
57+
58+ 23 1 swap [over / + 2 /] cons [dup] swoncat make_generator
59+ 1 23 [over / + 2 /] cons [dup] swoncat make_generator
60+ 1 [23 over / + 2 /] [dup] swoncat make_generator
61+ 1 [dup 23 over / + 2 /] make_generator
62+ .
63+ .
64+ .
65+ [1 swap [dup 23 over / + 2 /] direco]
66+
67+
68+A Generator of Square Root Approximations
69+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70+
71+::
72+
73+ gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator
74+
75+
76+Finding Consecutive Approximations ``within`` a Tolerance
77+=========================================================
478
579 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.
680
@@ -9,21 +83,23 @@
983
1084 (And note that by "list" he means a lazily-evaluated list.)
1185
12-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...
86+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...
1387
1488 ::
1589
1690 a [b G] ε within
17- -------------------- a b - abs ε <=
91+ ---------------------- a b - abs ε <=
1892 b
1993
94+::
95+
2096 a [b G] ε within
21- -------------------- a b - abs ε >
97+ ---------------------- a b - abs ε >
2298 .
2399 [b G] x ε ...
24100 b [c G] ε ...
25101 .
26- --------------------
102+ ----------------------
27103 b [c G] ε within
28104
29105
@@ -60,6 +136,7 @@
60136
61137 B == roll< popop first
62138
139+
63140 Recur
64141 ^^^^^^^^^^^^^
65142
@@ -69,7 +146,7 @@
69146
70147
71148 1. Discard ``a``.
72-2. Use ``x`` combinator to generate next term from G.
149+2. Use ``x`` combinator to generate next term from ``G``.
73150 3. Run ``within`` with ``i`` (it is a ``primrec`` function.)
74151
75152 ::
@@ -87,38 +164,32 @@
87164
88165 R0 == [popd x] dip
89166
167+
90168 Setting up
91169 ^^^^^^^^^^
92170
93-::
171+The recursive function we have defined so far needs a slight preamble: ``x`` to prime the generator and the epsilon value to use::
94172
95- [a G] x ε
96- a [b G] ε
173+ [a G] x ε ...
174+ a [b G] ε ...
175+
176+
177+``within``
178+^^^^^^^^^^
179+
180+Giving us the following definitions::
181+
182+ _within_P == [first - abs] dip <=
183+ _within_B == roll< popop first
184+ _within_R == [popd x] dip
185+ within == x ε [_within_P] [_within_B] [_within_R] primrec
186+
187+
188+Finding Square Roots
189+====================
97190
98191 ::
99192
100- within == x ε [[first - abs] dip <=] [roll< popop first] [[popd x] dip] primrec
101-
102-
103-
104-
105-
106-
107-
108-
109-
193+ sqrt == gsra within
110194
111195
112-
113-
114-
115-
116-
117-
118-
119-
120-
121-
122-
123-
124-
Show on old repository browser