OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/joypy/Thun
authorSimon Forman <sforman@hushmail.com>
Mon, 22 Nov 2021 18:29:53 +0000 (10:29 -0800)
committerSimon Forman <sforman@hushmail.com>
Mon, 22 Nov 2021 18:29:53 +0000 (10:29 -0800)
122 files changed:
LICENSE [moved from COPYING with 100% similarity]
MANIFEST.in
Makefile
README
docs/sphinx_docs/_build/doctrees/environment.pickle [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/index.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/joy.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/lib.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/library.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Categorical.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Derivatives_of_Regular_Expressions.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Developing.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Generator_Programs.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Intro.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Newton-Raphson.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/NoUpdates.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Ordered_Binary_Trees.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Quadratic.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Recursion_Combinators.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Replacing.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Treestep.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/TypeChecking.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Types.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/Zipper.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/notebooks/index.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/parser.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/pretty.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/stack.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/doctrees/types.doctree [new file with mode: 0644]
docs/sphinx_docs/_build/html/.buildinfo [new file with mode: 0644]
docs/sphinx_docs/_build/html/_images/omg.svg [new file with mode: 0644]
docs/sphinx_docs/_build/html/_modules/index.html
docs/sphinx_docs/_build/html/_modules/joy/joy.html
docs/sphinx_docs/_build/html/_modules/joy/library.html
docs/sphinx_docs/_build/html/_modules/joy/parser.html
docs/sphinx_docs/_build/html/_modules/joy/utils/generated_library.html [new file with mode: 0644]
docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html
docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html
docs/sphinx_docs/_build/html/_sources/lib.rst.txt
docs/sphinx_docs/_build/html/_sources/notebooks/Categorical.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Derivatives_of_Regular_Expressions.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Developing.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Generator_Programs.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Intro.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Newton-Raphson.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/NoUpdates.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Ordered_Binary_Trees.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Quadratic.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Recursion_Combinators.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Replacing.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/The_Four_Operations.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Treestep.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/TypeChecking.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Types.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/Zipper.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/notebooks/index.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_sources/types.rst.txt [new file with mode: 0644]
docs/sphinx_docs/_build/html/_static/alabaster.css
docs/sphinx_docs/_build/html/_static/basic.css
docs/sphinx_docs/_build/html/_static/doctools.js
docs/sphinx_docs/_build/html/_static/documentation_options.js
docs/sphinx_docs/_build/html/_static/jquery-3.5.1.js [new file with mode: 0644]
docs/sphinx_docs/_build/html/_static/jquery.js
docs/sphinx_docs/_build/html/_static/language_data.js [new file with mode: 0644]
docs/sphinx_docs/_build/html/_static/pygments.css
docs/sphinx_docs/_build/html/_static/searchtools.js
docs/sphinx_docs/_build/html/_static/underscore-1.13.1.js [new file with mode: 0644]
docs/sphinx_docs/_build/html/_static/underscore.js
docs/sphinx_docs/_build/html/genindex.html
docs/sphinx_docs/_build/html/index.html
docs/sphinx_docs/_build/html/joy.html
docs/sphinx_docs/_build/html/lib.html
docs/sphinx_docs/_build/html/library.html
docs/sphinx_docs/_build/html/notebooks/Categorical.html
docs/sphinx_docs/_build/html/notebooks/Derivatives_of_Regular_Expressions.html
docs/sphinx_docs/_build/html/notebooks/Developing.html
docs/sphinx_docs/_build/html/notebooks/Generator_Programs.html
docs/sphinx_docs/_build/html/notebooks/Intro.html
docs/sphinx_docs/_build/html/notebooks/Newton-Raphson.html
docs/sphinx_docs/_build/html/notebooks/NoUpdates.html
docs/sphinx_docs/_build/html/notebooks/Ordered_Binary_Trees.html
docs/sphinx_docs/_build/html/notebooks/Quadratic.html
docs/sphinx_docs/_build/html/notebooks/Recursion_Combinators.html
docs/sphinx_docs/_build/html/notebooks/Replacing.html
docs/sphinx_docs/_build/html/notebooks/The_Four_Operations.html
docs/sphinx_docs/_build/html/notebooks/Treestep.html
docs/sphinx_docs/_build/html/notebooks/TypeChecking.html
docs/sphinx_docs/_build/html/notebooks/Types.html
docs/sphinx_docs/_build/html/notebooks/Zipper.html
docs/sphinx_docs/_build/html/notebooks/index.html
docs/sphinx_docs/_build/html/objects.inv
docs/sphinx_docs/_build/html/parser.html
docs/sphinx_docs/_build/html/pretty.html
docs/sphinx_docs/_build/html/py-modindex.html
docs/sphinx_docs/_build/html/search.html
docs/sphinx_docs/_build/html/searchindex.js
docs/sphinx_docs/_build/html/stack.html
docs/sphinx_docs/_build/html/types.html
docs/sphinx_docs/lib.rst
docs/sphinx_docs/notebooks/Derivatives_of_Regular_Expressions.rst
docs/sphinx_docs/notebooks/Developing.rst
docs/sphinx_docs/notebooks/Generator_Programs.rst
docs/sphinx_docs/notebooks/Intro.rst
docs/sphinx_docs/notebooks/Newton-Raphson.rst
docs/sphinx_docs/notebooks/Ordered_Binary_Trees.rst
docs/sphinx_docs/notebooks/Quadratic.rst
docs/sphinx_docs/notebooks/Recursion_Combinators.rst
docs/sphinx_docs/notebooks/Replacing.rst
docs/sphinx_docs/notebooks/Treestep.rst
docs/sphinx_docs/notebooks/TypeChecking.rst
docs/sphinx_docs/notebooks/Types.rst
docs/sphinx_docs/notebooks/Zipper.rst
joy/__main__.py
joy/joy.py
joy/library.py
joy/parser.py
joy/utils/errors.py [new file with mode: 0644]
joy/utils/generated_library.py
joy/utils/pretty_print.py
joy/utils/stack.py
startREPL.bat [deleted file]

diff --git a/COPYING b/LICENSE
similarity index 100%
rename from COPYING
rename to LICENSE
index 8bd646c..1111bcd 100644 (file)
@@ -1,3 +1,3 @@
 include archive/*
-include COPYING
+include LICENSE
 recursive-include joy *.py
index 970f76a..c19350a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,14 @@
 # My make-fu style is old and tired.  I just want to have a few helper commands.
 
-TESTDIR = ./test00
-VERSION = 0.4.1
 WEBSERVER = sforman@shell.osdn.net
 
-.PHONY: clean sdist test docs upload-docs
+.PHONY: clean docs upload-docs
 
 
 clean:
-       $(RM) -r Thun.egg-info/ dist/ build/ __pycache__/ $(TESTDIR)
+       $(RM) -r Thun.egg-info/ dist/ build/ __pycache__/
        find . -name '*.pyc' | xargs $(RM)
 
-sdist:
-       python ./setup.py sdist bdist_wheel
-
-
-# In order to support testing the code as installed
-# create a virtualenv and install the source dist zip there.
-test: sdist
-       $(RM) -r $(TESTDIR)
-       virtualenv --system-site-packages --never-download $(TESTDIR)
-       . $(TESTDIR)/bin/activate && \
-               pip install --no-cache-dir --no-index ./dist/Thun-$(VERSION).tar.gz
-       echo "Type: source $(TESTDIR)/bin/activate"
-
-
 docs:
        cd ./docs && make && make mov && cd ./sphinx_docs && make html
 
diff --git a/README b/README
index c099933..0be7158 100644 (file)
--- a/README
+++ b/README
@@ -64,6 +64,12 @@ To start a crude REPL:
 
     python -m joy
 
+There is a "quiet" mode for e.g. using joy from a shell script:
+
+    python -m joy -q
+
+This supresses the initial banner output and the prompt text.
+
 
 §.3 Documentation
 
diff --git a/docs/sphinx_docs/_build/doctrees/environment.pickle b/docs/sphinx_docs/_build/doctrees/environment.pickle
new file mode 100644 (file)
index 0000000..8ba2534
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/environment.pickle differ
diff --git a/docs/sphinx_docs/_build/doctrees/index.doctree b/docs/sphinx_docs/_build/doctrees/index.doctree
new file mode 100644 (file)
index 0000000..d7f0037
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/index.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/joy.doctree b/docs/sphinx_docs/_build/doctrees/joy.doctree
new file mode 100644 (file)
index 0000000..1511b25
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/joy.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/lib.doctree b/docs/sphinx_docs/_build/doctrees/lib.doctree
new file mode 100644 (file)
index 0000000..785d5bb
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/lib.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/library.doctree b/docs/sphinx_docs/_build/doctrees/library.doctree
new file mode 100644 (file)
index 0000000..cf28142
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/library.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Categorical.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Categorical.doctree
new file mode 100644 (file)
index 0000000..c6dc0a7
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Categorical.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Derivatives_of_Regular_Expressions.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Derivatives_of_Regular_Expressions.doctree
new file mode 100644 (file)
index 0000000..f834481
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Derivatives_of_Regular_Expressions.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Developing.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Developing.doctree
new file mode 100644 (file)
index 0000000..5204cb8
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Developing.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Generator_Programs.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Generator_Programs.doctree
new file mode 100644 (file)
index 0000000..eac2cc4
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Generator_Programs.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Intro.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Intro.doctree
new file mode 100644 (file)
index 0000000..1a78f94
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Intro.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Newton-Raphson.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Newton-Raphson.doctree
new file mode 100644 (file)
index 0000000..1367d10
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Newton-Raphson.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/NoUpdates.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/NoUpdates.doctree
new file mode 100644 (file)
index 0000000..53ec006
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/NoUpdates.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Ordered_Binary_Trees.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Ordered_Binary_Trees.doctree
new file mode 100644 (file)
index 0000000..38d5c96
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Ordered_Binary_Trees.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Quadratic.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Quadratic.doctree
new file mode 100644 (file)
index 0000000..11a77fc
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Quadratic.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Recursion_Combinators.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Recursion_Combinators.doctree
new file mode 100644 (file)
index 0000000..32d4dc1
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Recursion_Combinators.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Replacing.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Replacing.doctree
new file mode 100644 (file)
index 0000000..3bde7b5
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Replacing.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree
new file mode 100644 (file)
index 0000000..00fd5d3
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Treestep.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Treestep.doctree
new file mode 100644 (file)
index 0000000..62d36b7
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Treestep.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/TypeChecking.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/TypeChecking.doctree
new file mode 100644 (file)
index 0000000..646bf47
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/TypeChecking.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Types.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Types.doctree
new file mode 100644 (file)
index 0000000..e144f9e
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Types.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/Zipper.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/Zipper.doctree
new file mode 100644 (file)
index 0000000..e51d16c
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/Zipper.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/index.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/index.doctree
new file mode 100644 (file)
index 0000000..d8c2f71
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/notebooks/index.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/parser.doctree b/docs/sphinx_docs/_build/doctrees/parser.doctree
new file mode 100644 (file)
index 0000000..1e0b37e
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/parser.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/pretty.doctree b/docs/sphinx_docs/_build/doctrees/pretty.doctree
new file mode 100644 (file)
index 0000000..49a54bd
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/pretty.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/stack.doctree b/docs/sphinx_docs/_build/doctrees/stack.doctree
new file mode 100644 (file)
index 0000000..c54b1d9
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/stack.doctree differ
diff --git a/docs/sphinx_docs/_build/doctrees/types.doctree b/docs/sphinx_docs/_build/doctrees/types.doctree
new file mode 100644 (file)
index 0000000..b207837
Binary files /dev/null and b/docs/sphinx_docs/_build/doctrees/types.doctree differ
diff --git a/docs/sphinx_docs/_build/html/.buildinfo b/docs/sphinx_docs/_build/html/.buildinfo
new file mode 100644 (file)
index 0000000..73c8c3e
--- /dev/null
@@ -0,0 +1,4 @@
+# Sphinx build info version 1
+# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
+config: d581c6009ec2b560e43b1edcc2912d38
+tags: 645f666f9bcd5a90fca523b33c5a78b7
diff --git a/docs/sphinx_docs/_build/html/_images/omg.svg b/docs/sphinx_docs/_build/html/_images/omg.svg
new file mode 100644 (file)
index 0000000..a3be69c
--- /dev/null
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.38.0 (20140413.2041)
+ -->
+<!-- Title: finite_state_machine Pages: 1 -->
+<svg width="534pt" height="270pt"
+ viewBox="0.00 0.00 534.00 270.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 266)">
+<title>finite_state_machine</title>
+<polygon fill="white" stroke="none" points="-4,4 -4,-266 530,-266 530,4 -4,4"/>
+<!-- i -->
+<g id="node1" class="node"><title>i</title>
+<ellipse fill="none" stroke="black" cx="338" cy="-146" rx="18" ry="18"/>
+<ellipse fill="none" stroke="black" cx="338" cy="-146" rx="22" ry="22"/>
+<text text-anchor="middle" x="338" y="-142.3" font-family="Times,serif" font-size="14.00">i</text>
+</g>
+<!-- i&#45;&gt;i -->
+<g id="edge17" class="edge"><title>i&#45;&gt;i</title>
+<path fill="none" stroke="black" d="M330.317,-166.991C329.369,-177.087 331.93,-186 338,-186 341.889,-186 344.337,-182.342 345.346,-177.059"/>
+<polygon fill="black" stroke="black" points="348.846,-177.102 345.683,-166.991 341.85,-176.868 348.846,-177.102"/>
+<text text-anchor="middle" x="338" y="-189.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- j -->
+<g id="node10" class="node"><title>j</title>
+<ellipse fill="none" stroke="black" cx="421" cy="-136" rx="18" ry="18"/>
+<text text-anchor="middle" x="421" y="-132.3" font-family="Times,serif" font-size="14.00">j</text>
+</g>
+<!-- i&#45;&gt;j -->
+<g id="edge18" class="edge"><title>i&#45;&gt;j</title>
+<path fill="none" stroke="black" d="M357.466,-135.495C363.775,-132.451 371.008,-129.536 378,-128 383.213,-126.855 388.811,-126.984 394.167,-127.763"/>
+<polygon fill="black" stroke="black" points="393.487,-131.197 404.002,-129.894 394.97,-124.355 393.487,-131.197"/>
+<text text-anchor="middle" x="381.5" y="-131.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- h -->
+<g id="node2" class="node"><title>h</title>
+<ellipse fill="none" stroke="black" cx="504" cy="-85" rx="18" ry="18"/>
+<ellipse fill="none" stroke="black" cx="504" cy="-85" rx="22" ry="22"/>
+<text text-anchor="middle" x="504" y="-81.3" font-family="Times,serif" font-size="14.00">h</text>
+</g>
+<!-- h&#45;&gt;i -->
+<g id="edge15" class="edge"><title>h&#45;&gt;i</title>
+<path fill="none" stroke="black" d="M481.868,-83.4025C461.033,-82.62 428.676,-83.5645 403,-94 387.267,-100.394 372.373,-112.028 360.918,-122.673"/>
+<polygon fill="black" stroke="black" points="358.306,-120.33 353.569,-129.807 363.182,-125.353 358.306,-120.33"/>
+<text text-anchor="middle" x="421" y="-97.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- h&#45;&gt;h -->
+<g id="edge16" class="edge"><title>h&#45;&gt;h</title>
+<path fill="none" stroke="black" d="M496.317,-105.991C495.369,-116.087 497.93,-125 504,-125 507.889,-125 510.337,-121.342 511.346,-116.059"/>
+<polygon fill="black" stroke="black" points="514.846,-116.102 511.683,-105.991 507.85,-115.868 514.846,-116.102"/>
+<text text-anchor="middle" x="504" y="-128.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- a -->
+<g id="node3" class="node"><title>a</title>
+<ellipse fill="none" stroke="black" cx="18" cy="-128" rx="18" ry="18"/>
+<text text-anchor="middle" x="18" y="-124.3" font-family="Times,serif" font-size="14.00">a</text>
+</g>
+<!-- b -->
+<g id="node4" class="node"><title>b</title>
+<ellipse fill="none" stroke="black" cx="255" cy="-113" rx="18" ry="18"/>
+<text text-anchor="middle" x="255" y="-109.3" font-family="Times,serif" font-size="14.00">b</text>
+</g>
+<!-- a&#45;&gt;b -->
+<g id="edge1" class="edge"><title>a&#45;&gt;b</title>
+<path fill="none" stroke="black" d="M36.2801,-126.897C76.7816,-124.312 178.091,-117.845 226.89,-114.73"/>
+<polygon fill="black" stroke="black" points="227.255,-118.214 237.011,-114.084 226.809,-111.229 227.255,-118.214"/>
+<text text-anchor="middle" x="136.5" y="-123.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- c -->
+<g id="node5" class="node"><title>c</title>
+<ellipse fill="none" stroke="black" cx="97" cy="-155" rx="18" ry="18"/>
+<text text-anchor="middle" x="97" y="-151.3" font-family="Times,serif" font-size="14.00">c</text>
+</g>
+<!-- a&#45;&gt;c -->
+<g id="edge2" class="edge"><title>a&#45;&gt;c</title>
+<path fill="none" stroke="black" d="M35.3297,-133.726C45.4364,-137.27 58.635,-141.898 70.1398,-145.932"/>
+<polygon fill="black" stroke="black" points="69.099,-149.276 79.6938,-149.282 71.4153,-142.67 69.099,-149.276"/>
+<text text-anchor="middle" x="57.5" y="-145.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- b&#45;&gt;b -->
+<g id="edge3" class="edge"><title>b&#45;&gt;b</title>
+<path fill="none" stroke="black" d="M248.266,-130.037C246.892,-139.858 249.137,-149 255,-149 258.665,-149 260.916,-145.429 261.753,-140.353"/>
+<polygon fill="black" stroke="black" points="265.252,-140.031 261.734,-130.037 258.252,-140.044 265.252,-140.031"/>
+<text text-anchor="middle" x="255" y="-152.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- d -->
+<g id="node6" class="node"><title>d</title>
+<ellipse fill="none" stroke="black" cx="338" cy="-79" rx="18" ry="18"/>
+<text text-anchor="middle" x="338" y="-75.3" font-family="Times,serif" font-size="14.00">d</text>
+</g>
+<!-- b&#45;&gt;d -->
+<g id="edge4" class="edge"><title>b&#45;&gt;d</title>
+<path fill="none" stroke="black" d="M272.003,-106.283C283.319,-101.533 298.722,-95.0674 311.693,-89.6227"/>
+<polygon fill="black" stroke="black" points="313.164,-92.801 321.03,-85.7034 310.455,-86.3466 313.164,-92.801"/>
+<text text-anchor="middle" x="294.5" y="-101.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- c&#45;&gt;b -->
+<g id="edge5" class="edge"><title>c&#45;&gt;b</title>
+<path fill="none" stroke="black" d="M114.862,-150.653C138.269,-144.593 181.917,-133.2 219,-123 221.799,-122.23 224.721,-121.414 227.631,-120.594"/>
+<polygon fill="black" stroke="black" points="228.623,-123.951 237.284,-117.849 226.708,-117.218 228.623,-123.951"/>
+<text text-anchor="middle" x="176" y="-142.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- e -->
+<g id="node7" class="node"><title>e</title>
+<ellipse fill="none" stroke="black" cx="176" cy="-206" rx="18" ry="18"/>
+<text text-anchor="middle" x="176" y="-202.3" font-family="Times,serif" font-size="14.00">e</text>
+</g>
+<!-- c&#45;&gt;e -->
+<g id="edge6" class="edge"><title>c&#45;&gt;e</title>
+<path fill="none" stroke="black" d="M112.483,-164.593C123.668,-172.001 139.356,-182.392 152.219,-190.911"/>
+<polygon fill="black" stroke="black" points="150.312,-193.846 160.582,-196.45 154.177,-188.01 150.312,-193.846"/>
+<text text-anchor="middle" x="136.5" y="-185.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- d&#45;&gt;b -->
+<g id="edge7" class="edge"><title>d&#45;&gt;b</title>
+<path fill="none" stroke="black" d="M320.205,-74.8763C311.208,-73.4911 300.131,-73.1424 291,-77 284.094,-79.9175 277.879,-84.9376 272.669,-90.3183"/>
+<polygon fill="black" stroke="black" points="269.694,-88.4067 265.791,-98.2568 274.985,-92.9902 269.694,-88.4067"/>
+<text text-anchor="middle" x="294.5" y="-80.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- f -->
+<g id="node8" class="node"><title>f</title>
+<ellipse fill="none" stroke="black" cx="176" cy="-46" rx="18" ry="18"/>
+<text text-anchor="middle" x="176" y="-42.3" font-family="Times,serif" font-size="14.00">f</text>
+</g>
+<!-- d&#45;&gt;f -->
+<g id="edge8" class="edge"><title>d&#45;&gt;f</title>
+<path fill="none" stroke="black" d="M319.923,-75.478C292.098,-69.7389 236.768,-58.3271 203.708,-51.5086"/>
+<polygon fill="black" stroke="black" points="204.321,-48.0614 193.82,-49.4692 202.907,-54.9171 204.321,-48.0614"/>
+<text text-anchor="middle" x="255" y="-69.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- e&#45;&gt;b -->
+<g id="edge9" class="edge"><title>e&#45;&gt;b</title>
+<path fill="none" stroke="black" d="M190.241,-194.796C198.908,-187.136 210.212,-176.503 219,-166 226.507,-157.028 233.803,-146.389 239.774,-137.007"/>
+<polygon fill="black" stroke="black" points="242.759,-138.834 245.056,-128.491 236.81,-135.144 242.759,-138.834"/>
+<text text-anchor="middle" x="215.5" y="-176.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- g -->
+<g id="node9" class="node"><title>g</title>
+<ellipse fill="none" stroke="black" cx="255" cy="-211" rx="18" ry="18"/>
+<text text-anchor="middle" x="255" y="-207.3" font-family="Times,serif" font-size="14.00">g</text>
+</g>
+<!-- e&#45;&gt;g -->
+<g id="edge10" class="edge"><title>e&#45;&gt;g</title>
+<path fill="none" stroke="black" d="M194.089,-207.11C203.659,-207.731 215.817,-208.521 226.677,-209.226"/>
+<polygon fill="black" stroke="black" points="226.753,-212.738 236.959,-209.893 227.207,-205.753 226.753,-212.738"/>
+<text text-anchor="middle" x="215.5" y="-211.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- f&#45;&gt;h -->
+<g id="edge12" class="edge"><title>f&#45;&gt;h</title>
+<path fill="none" stroke="black" d="M189.02,-33.1864C203.151,-19.5754 227.995,-0 254,-0 254,-0 254,-0 422,-0 453.632,-0 476.677,-31.2311 489.924,-55.8314"/>
+<polygon fill="black" stroke="black" points="486.862,-57.5325 494.518,-64.8562 493.1,-54.3566 486.862,-57.5325"/>
+<text text-anchor="middle" x="338" y="-3.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- f&#45;&gt;b -->
+<g id="edge11" class="edge"><title>f&#45;&gt;b</title>
+<path fill="none" stroke="black" d="M190.834,-56.7689C199.13,-63.3319 209.817,-71.9742 219,-80 224.034,-84.4001 229.343,-89.2757 234.262,-93.899"/>
+<polygon fill="black" stroke="black" points="231.917,-96.4985 241.576,-100.852 236.74,-91.4252 231.917,-96.4985"/>
+<text text-anchor="middle" x="215.5" y="-83.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- g&#45;&gt;i -->
+<g id="edge13" class="edge"><title>g&#45;&gt;i</title>
+<path fill="none" stroke="black" d="M269.741,-199.974C281.437,-190.587 298.524,-176.876 312.548,-165.622"/>
+<polygon fill="black" stroke="black" points="314.778,-168.32 320.387,-159.331 310.397,-162.86 314.778,-168.32"/>
+<text text-anchor="middle" x="294.5" y="-185.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- g&#45;&gt;g -->
+<g id="edge14" class="edge"><title>g&#45;&gt;g</title>
+<path fill="none" stroke="black" d="M248.266,-228.037C246.892,-237.858 249.137,-247 255,-247 258.665,-247 260.916,-243.429 261.753,-238.353"/>
+<polygon fill="black" stroke="black" points="265.252,-238.031 261.734,-228.037 258.252,-238.044 265.252,-238.031"/>
+<text text-anchor="middle" x="255" y="-250.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+<!-- j&#45;&gt;i -->
+<g id="edge19" class="edge"><title>j&#45;&gt;i</title>
+<path fill="none" stroke="black" d="M403.34,-139.8C397.561,-140.993 391.021,-142.205 385,-143 380.321,-143.618 375.357,-144.11 370.488,-144.502"/>
+<polygon fill="black" stroke="black" points="369.864,-141.036 360.126,-145.209 370.341,-148.02 369.864,-141.036"/>
+<text text-anchor="middle" x="381.5" y="-146.8" font-family="Times,serif" font-size="14.00">0</text>
+</g>
+<!-- j&#45;&gt;h -->
+<g id="edge20" class="edge"><title>j&#45;&gt;h</title>
+<path fill="none" stroke="black" d="M436.857,-126.646C447.841,-119.73 463.1,-110.122 476.194,-101.878"/>
+<polygon fill="black" stroke="black" points="478.237,-104.727 484.835,-96.4375 474.507,-98.8038 478.237,-104.727"/>
+<text text-anchor="middle" x="460.5" y="-116.8" font-family="Times,serif" font-size="14.00">1</text>
+</g>
+</g>
+</svg>
index 60816bb..a09f508 100644 (file)
@@ -1,19 +1,17 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Overview: module code &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
    
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
   <h1>All modules for which code is available</h1>
-<ul><li><a href="__builtin__.html">__builtin__</a></li>
-<li><a href="joy/joy.html">joy.joy</a></li>
+<ul><li><a href="joy/joy.html">joy.joy</a></li>
 <li><a href="joy/library.html">joy.library</a></li>
 <li><a href="joy/parser.html">joy.parser</a></li>
 <li><a href="joy/utils/generated_library.html">joy.utils.generated_library</a></li>
 <li><a href="joy/utils/pretty_print.html">joy.utils.pretty_print</a></li>
 <li><a href="joy/utils/stack.html">joy.utils.stack</a></li>
-<li><a href="joy/utils/types.html">joy.utils.types</a></li>
 </ul>
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="../notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 56e94f5..e0e1647 100644 (file)
@@ -1,19 +1,17 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>joy.joy &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../../_static/jquery.js"></script>
-    <script type="text/javascript" src="../../_static/underscore.js"></script>
-    <script type="text/javascript" src="../../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../../_static/alabaster.css" />
+    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
+    <script src="../../_static/jquery.js"></script>
+    <script src="../../_static/underscore.js"></script>
+    <script src="../../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../../genindex.html" />
     <link rel="search" title="Search" href="../../search.html" />
    
@@ -28,6 +26,8 @@
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
   <h1>Source code for joy.joy</h1><div class="highlight"><pre>
 <span class="sd">match the behaviour of the original version(s) written in C.</span>
 
 <span class="sd">&#39;&#39;&#39;</span>
-<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span>
-<span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">input</span>
-<span class="kn">from</span> <span class="nn">traceback</span> <span class="k">import</span> <span class="n">print_exc</span>
-<span class="kn">from</span> <span class="nn">.parser</span> <span class="k">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">ParseError</span><span class="p">,</span> <span class="n">Symbol</span>
-<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="k">import</span> <span class="n">stack_to_string</span>
+<span class="kn">from</span> <span class="nn">builtins</span> <span class="kn">import</span> <span class="nb">input</span>
+<span class="kn">from</span> <span class="nn">traceback</span> <span class="kn">import</span> <span class="n">print_exc</span>
+<span class="kn">from</span> <span class="nn">.parser</span> <span class="kn">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">ParseError</span><span class="p">,</span> <span class="n">Symbol</span>
+<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="kn">import</span> <span class="n">stack_to_string</span>
+<span class="kn">from</span> <span class="nn">.utils.errors</span> <span class="kn">import</span> <span class="p">(</span>
+    <span class="n">NotAListError</span><span class="p">,</span>
+    <span class="n">NotAnIntError</span><span class="p">,</span>
+    <span class="n">StackUnderflowError</span><span class="p">,</span>
+    <span class="p">)</span>
+
+
+<div class="viewcode-block" id="UnknownSymbolError"><a class="viewcode-back" href="../../joy.html#joy.joy.UnknownSymbolError">[docs]</a><span class="k">class</span> <span class="nc">UnknownSymbolError</span><span class="p">(</span><span class="ne">KeyError</span><span class="p">):</span> <span class="k">pass</span></div>
 
 
 <div class="viewcode-block" id="joy"><a class="viewcode-back" href="../../joy.html#joy.joy.joy">[docs]</a><span class="k">def</span> <span class="nf">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Evaluate a Joy expression on a stack.</span>
+    <span class="sd">&#39;&#39;&#39;Evaluate a Joy expression on a stack.</span>
 
-<span class="sd">      This function iterates through a sequence of terms which are either</span>
-<span class="sd">      literals (strings, numbers, sequences of terms) or function symbols.</span>
-<span class="sd">      Literals are put onto the stack and functions are looked up in the</span>
-<span class="sd">      disctionary and executed.</span>
+<span class="sd">  This function iterates through a sequence of terms which are either</span>
+<span class="sd">  literals (strings, numbers, sequences of terms) or function symbols.</span>
+<span class="sd">  Literals are put onto the stack and functions are looked up in the</span>
+<span class="sd">  dictionary and executed.</span>
 
-<span class="sd">      The viewer is a function that is called with the stack and expression</span>
-<span class="sd">      on every iteration, its return value is ignored.</span>
+<span class="sd">    The viewer is a function that is called with the stack and expression</span>
+<span class="sd">    on every iteration, its return value is ignored.</span>
 
-<span class="sd">      :param stack stack: The stack.</span>
-<span class="sd">      :param stack expression: The expression to evaluate.</span>
-<span class="sd">      :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
-<span class="sd">      :param function viewer: Optional viewer function.</span>
-<span class="sd">      :rtype: (stack, (), dictionary)</span>
+<span class="sd">    :param stack stack: The stack.</span>
+<span class="sd">    :param stack expression: The expression to evaluate.</span>
+<span class="sd">    :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
+<span class="sd">    :param function viewer: Optional viewer function.</span>
+<span class="sd">    :rtype: (stack, (), dictionary)</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">while</span> <span class="n">expression</span><span class="p">:</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">while</span> <span class="n">expression</span><span class="p">:</span>
 
-               <span class="k">if</span> <span class="n">viewer</span><span class="p">:</span> <span class="n">viewer</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">viewer</span><span class="p">:</span> <span class="n">viewer</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
 
-               <span class="n">term</span><span class="p">,</span> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span>
-               <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="n">Symbol</span><span class="p">):</span>
-                       <span class="n">term</span> <span class="o">=</span> <span class="n">dictionary</span><span class="p">[</span><span class="n">term</span><span class="p">]</span>
-                       <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">term</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span>
-               <span class="k">else</span><span class="p">:</span>
-                       <span class="n">stack</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">stack</span>
+        <span class="n">term</span><span class="p">,</span> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span>
+        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="n">Symbol</span><span class="p">):</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">term</span> <span class="o">=</span> <span class="n">dictionary</span><span class="p">[</span><span class="n">term</span><span class="p">]</span>
+            <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+                <span class="k">raise</span> <span class="n">UnknownSymbolError</span><span class="p">(</span><span class="n">term</span><span class="p">)</span>
+            <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">term</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">stack</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">stack</span>
 
-       <span class="k">if</span> <span class="n">viewer</span><span class="p">:</span> <span class="n">viewer</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+    <span class="k">if</span> <span class="n">viewer</span><span class="p">:</span> <span class="n">viewer</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="run"><a class="viewcode-back" href="../../joy.html#joy.joy.run">[docs]</a><span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Return the stack resulting from running the Joy code text on the stack.</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Return the stack resulting from running the Joy code text on the stack.</span>
 
-<span class="sd">      :param str text: Joy code.</span>
-<span class="sd">      :param stack stack: The stack.</span>
-<span class="sd">      :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
-<span class="sd">      :param function viewer: Optional viewer function.</span>
-<span class="sd">      :rtype: (stack, (), dictionary)</span>
+<span class="sd">    :param str text: Joy code.</span>
+<span class="sd">    :param stack stack: The stack.</span>
+<span class="sd">    :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
+<span class="sd">    :param function viewer: Optional viewer function.</span>
+<span class="sd">    :rtype: (stack, (), dictionary)</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="p">)</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">viewer</span><span class="p">)</span></div>
 
 
 <div class="viewcode-block" id="repl"><a class="viewcode-back" href="../../joy.html#joy.joy.repl">[docs]</a><span class="k">def</span> <span class="nf">repl</span><span class="p">(</span><span class="n">stack</span><span class="o">=</span><span class="p">(),</span> <span class="n">dictionary</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Read-Evaluate-Print Loop</span>
-
-<span class="sd">      Accept input and run it on the stack, loop.</span>
-
-<span class="sd">      :param stack stack: The stack.</span>
-<span class="sd">      :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
-<span class="sd">      :rtype: stack</span>
-
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">if</span> <span class="n">dictionary</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
-               <span class="n">dictionary</span> <span class="o">=</span> <span class="p">{}</span>
-       <span class="k">try</span><span class="p">:</span>
-               <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
-                       <span class="nb">print</span><span class="p">()</span>
-                       <span class="nb">print</span><span class="p">(</span><span class="n">stack_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">),</span> <span class="s1">&#39;&lt;-top&#39;</span><span class="p">)</span>
-                       <span class="nb">print</span><span class="p">()</span>
-                       <span class="k">try</span><span class="p">:</span>
-                               <span class="n">text</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s1">&#39;joy? &#39;</span><span class="p">)</span>
-                       <span class="k">except</span> <span class="p">(</span><span class="ne">EOFError</span><span class="p">,</span> <span class="ne">KeyboardInterrupt</span><span class="p">):</span>
-                               <span class="k">break</span>
-                       <span class="k">try</span><span class="p">:</span>
-                               <span class="n">stack</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">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="k">except</span><span class="p">:</span>
-                               <span class="n">print_exc</span><span class="p">()</span>
-       <span class="k">except</span><span class="p">:</span>
-               <span class="n">print_exc</span><span class="p">()</span>
-       <span class="nb">print</span><span class="p">()</span>
-       <span class="k">return</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Read-Evaluate-Print Loop</span>
+
+<span class="sd">    Accept input and run it on the stack, loop.</span>
+
+<span class="sd">    :param stack stack: The stack.</span>
+<span class="sd">    :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
+<span class="sd">    :rtype: stack</span>
+
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">if</span> <span class="n">dictionary</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+        <span class="n">dictionary</span> <span class="o">=</span> <span class="p">{}</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
+            <span class="nb">print</span><span class="p">()</span>
+            <span class="nb">print</span><span class="p">(</span><span class="n">stack_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">),</span> <span class="s1">&#39;&lt;-top&#39;</span><span class="p">)</span>
+            <span class="nb">print</span><span class="p">()</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">text</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s1">&#39;joy? &#39;</span><span class="p">)</span>
+            <span class="k">except</span> <span class="p">(</span><span class="ne">EOFError</span><span class="p">,</span> <span class="ne">KeyboardInterrupt</span><span class="p">):</span>
+                <span class="k">break</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">stack</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">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="k">except</span><span class="p">:</span>
+                <span class="n">print_exc</span><span class="p">()</span>
+    <span class="k">except</span><span class="p">:</span>
+        <span class="n">print_exc</span><span class="p">()</span>
+    <span class="nb">print</span><span class="p">()</span>
+    <span class="k">return</span> <span class="n">stack</span></div>
+
+
+<div class="viewcode-block" id="interp"><a class="viewcode-back" href="../../joy.html#joy.joy.interp">[docs]</a><span class="k">def</span> <span class="nf">interp</span><span class="p">(</span><span class="n">stack</span><span class="o">=</span><span class="p">(),</span> <span class="n">dictionary</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Simple REPL with no extra output, suitable for use in scripts.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">if</span> <span class="n">dictionary</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+        <span class="n">dictionary</span> <span class="o">=</span> <span class="p">{}</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">text</span> <span class="o">=</span> <span class="nb">input</span><span class="p">()</span>
+            <span class="k">except</span> <span class="p">(</span><span class="ne">EOFError</span><span class="p">,</span> <span class="ne">KeyboardInterrupt</span><span class="p">):</span>
+                <span class="k">break</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">stack</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">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="k">except</span> <span class="n">UnknownSymbolError</span> <span class="k">as</span> <span class="n">sym</span><span class="p">:</span>
+                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Unknown:&#39;</span><span class="p">,</span> <span class="n">sym</span><span class="p">)</span>
+            <span class="k">except</span> <span class="n">StackUnderflowError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
+                <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>  <span class="c1"># &#39;Not enough values on stack.&#39;</span>
+            <span class="k">except</span> <span class="n">NotAnIntError</span><span class="p">:</span>
+                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Not an integer.&#39;</span><span class="p">)</span>
+            <span class="k">except</span> <span class="n">NotAListError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
+                <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>  <span class="c1"># &#39;Not a list.&#39;</span>
+            <span class="k">except</span><span class="p">:</span>
+                <span class="n">print_exc</span><span class="p">()</span>
+            <span class="nb">print</span><span class="p">(</span><span class="n">stack_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">))</span>
+    <span class="k">except</span><span class="p">:</span>
+        <span class="n">print_exc</span><span class="p">()</span>
+    <span class="k">return</span> <span class="n">stack</span></div>
 </pre></div>
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="../../notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../../index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 23a4e18..afa5beb 100644 (file)
@@ -1,19 +1,17 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>joy.library &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../../_static/jquery.js"></script>
-    <script type="text/javascript" src="../../_static/underscore.js"></script>
-    <script type="text/javascript" src="../../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../../_static/alabaster.css" />
+    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
+    <script src="../../_static/jquery.js"></script>
+    <script src="../../_static/underscore.js"></script>
+    <script src="../../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../../genindex.html" />
     <link rel="search" title="Search" href="../../search.html" />
    
@@ -28,6 +26,8 @@
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
   <h1>Source code for joy.library</h1><div class="highlight"><pre>
 <span class="sd">returns a dictionary of Joy functions suitable for use with the joy()</span>
 <span class="sd">function.</span>
 <span class="sd">&#39;&#39;&#39;</span>
-<span class="kn">from</span> <span class="nn">inspect</span> <span class="k">import</span> <span class="n">getdoc</span><span class="p">,</span> <span class="n">getmembers</span><span class="p">,</span> <span class="n">isfunction</span>
-<span class="kn">from</span> <span class="nn">functools</span> <span class="k">import</span> <span class="n">wraps</span>
-<span class="kn">from</span> <span class="nn">itertools</span> <span class="k">import</span> <span class="n">count</span>
+<span class="kn">from</span> <span class="nn">inspect</span> <span class="kn">import</span> <span class="n">getdoc</span><span class="p">,</span> <span class="n">getmembers</span><span class="p">,</span> <span class="n">isfunction</span>
+<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span>
+<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">count</span>
 <span class="kn">import</span> <span class="nn">operator</span><span class="o">,</span> <span class="nn">math</span>
 
-<span class="kn">from</span> <span class="nn">.parser</span> <span class="k">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">Symbol</span>
-<span class="kn">from</span> <span class="nn">.utils</span> <span class="k">import</span> <span class="n">generated_library</span> <span class="k">as</span> <span class="n">genlib</span>
-<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="k">import</span> <span class="p">(</span>
-       <span class="n">concat</span><span class="p">,</span>
-       <span class="n">expression_to_string</span><span class="p">,</span>
-       <span class="n">iter_stack</span><span class="p">,</span>
-       <span class="n">list_to_stack</span><span class="p">,</span>
-       <span class="n">pick</span><span class="p">,</span>
-       <span class="p">)</span>
+<span class="kn">from</span> <span class="nn">.parser</span> <span class="kn">import</span> <span class="n">text_to_expression</span><span class="p">,</span> <span class="n">Symbol</span>
+<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">generated_library</span> <span class="k">as</span> <span class="n">genlib</span>
+<span class="kn">from</span> <span class="nn">.utils.errors</span> <span class="kn">import</span> <span class="p">(</span>
+    <span class="n">NotAListError</span><span class="p">,</span>
+    <span class="n">NotAnIntError</span><span class="p">,</span>
+    <span class="n">StackUnderflowError</span><span class="p">,</span>
+    <span class="p">)</span>
+<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="kn">import</span> <span class="p">(</span>
+    <span class="n">concat</span><span class="p">,</span>
+    <span class="n">expression_to_string</span><span class="p">,</span>
+    <span class="n">iter_stack</span><span class="p">,</span>
+    <span class="n">list_to_stack</span><span class="p">,</span>
+    <span class="n">pick</span><span class="p">,</span>
+    <span class="p">)</span>
 
 
 <span class="n">HELP_TEMPLATE</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
 
 
 <div class="viewcode-block" id="inscribe"><a class="viewcode-back" href="../../library.html#joy.library.inscribe">[docs]</a><span class="k">def</span> <span class="nf">inscribe</span><span class="p">(</span><span class="n">function</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;A decorator to inscribe functions into the default dictionary.&#39;&#39;&#39;</span>
-       <span class="n">_dictionary</span><span class="p">[</span><span class="n">function</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">function</span>
-       <span class="k">return</span> <span class="n">function</span></div>
+    <span class="sd">&#39;&#39;&#39;A decorator to inscribe functions into the default dictionary.&#39;&#39;&#39;</span>
+    <span class="n">_dictionary</span><span class="p">[</span><span class="n">function</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">function</span>
+    <span class="k">return</span> <span class="n">function</span></div>
 
 
 <div class="viewcode-block" id="initialize"><a class="viewcode-back" href="../../library.html#joy.library.initialize">[docs]</a><span class="k">def</span> <span class="nf">initialize</span><span class="p">():</span>
-       <span class="sd">&#39;&#39;&#39;Return a dictionary of Joy functions for use with joy().&#39;&#39;&#39;</span>
-       <span class="k">return</span> <span class="n">_dictionary</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span></div>
+    <span class="sd">&#39;&#39;&#39;Return a dictionary of Joy functions for use with joy().&#39;&#39;&#39;</span>
+    <span class="k">return</span> <span class="n">_dictionary</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span></div>
 
 
 <span class="n">ALIASES</span> <span class="o">=</span> <span class="p">(</span>
-       <span class="p">(</span><span class="s1">&#39;add&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;+&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;and&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&amp;&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;bool&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;truthy&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;mul&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;*&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;floordiv&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;/floor&#39;</span><span class="p">,</span> <span class="s1">&#39;//&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;truediv&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="s1">&#39;div&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;mod&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;%&#39;</span><span class="p">,</span> <span class="s1">&#39;rem&#39;</span><span class="p">,</span> <span class="s1">&#39;remainder&#39;</span><span class="p">,</span> <span class="s1">&#39;modulus&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;eq&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;=&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;ge&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&gt;=&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;getitem&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;pick&#39;</span><span class="p">,</span> <span class="s1">&#39;at&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;gt&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&gt;&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;le&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;=&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;lshift&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;&lt;&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;lt&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;ne&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;!=&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;rshift&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&gt;&gt;&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;sub&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;-&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;xor&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;^&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;succ&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;++&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;pred&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;--&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;rolldown&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;roll&lt;&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;rollup&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;roll&gt;&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;eh&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;?&#39;</span><span class="p">]),</span>
-       <span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="p">[</span><span class="sa">u</span><span class="s1">&#39;•&#39;</span><span class="p">]),</span>
-       <span class="p">)</span>
+    <span class="p">(</span><span class="s1">&#39;add&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;+&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;and&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&amp;&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;bool&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;truthy&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;mul&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;*&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;floordiv&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;/floor&#39;</span><span class="p">,</span> <span class="s1">&#39;//&#39;</span><span class="p">,</span> <span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="s1">&#39;div&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;mod&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;%&#39;</span><span class="p">,</span> <span class="s1">&#39;rem&#39;</span><span class="p">,</span> <span class="s1">&#39;remainder&#39;</span><span class="p">,</span> <span class="s1">&#39;modulus&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;eq&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;=&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;ge&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&gt;=&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;getitem&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;pick&#39;</span><span class="p">,</span> <span class="s1">&#39;at&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;gt&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&gt;&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;le&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;=&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;lshift&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;&lt;&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;lt&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;ne&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&lt;&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;!=&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;rshift&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;&gt;&gt;&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;sub&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;-&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;xor&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;^&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;succ&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;++&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;pred&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;--&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;rolldown&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;roll&lt;&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;rollup&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;roll&gt;&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;eh&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;?&#39;</span><span class="p">]),</span>
+    <span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="p">[</span><span class="sa">u</span><span class="s1">&#39;•&#39;</span><span class="p">]),</span>
+    <span class="p">)</span>
 
 
 <div class="viewcode-block" id="add_aliases"><a class="viewcode-back" href="../../library.html#joy.library.add_aliases">[docs]</a><span class="k">def</span> <span class="nf">add_aliases</span><span class="p">(</span><span class="n">D</span><span class="p">,</span> <span class="n">A</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Given a dict and a iterable of (name, [alias, ...]) pairs, create</span>
-<span class="sd">      additional entries in the dict mapping each alias to the named function</span>
-<span class="sd">      if it&#39;s in the dict.  Aliases for functions not in the dict are ignored.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">aliases</span> <span class="ow">in</span> <span class="n">A</span><span class="p">:</span>
-               <span class="k">try</span><span class="p">:</span>
-                       <span class="n">F</span> <span class="o">=</span> <span class="n">D</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
-               <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
-                       <span class="k">continue</span>
-               <span class="k">for</span> <span class="n">alias</span> <span class="ow">in</span> <span class="n">aliases</span><span class="p">:</span>
-                       <span class="n">D</span><span class="p">[</span><span class="n">alias</span><span class="p">]</span> <span class="o">=</span> <span class="n">F</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Given a dict and a iterable of (name, [alias, ...]) pairs, create</span>
+<span class="sd">    additional entries in the dict mapping each alias to the named function</span>
+<span class="sd">    if it&#39;s in the dict.  Aliases for functions not in the dict are ignored.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">aliases</span> <span class="ow">in</span> <span class="n">A</span><span class="p">:</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="n">F</span> <span class="o">=</span> <span class="n">D</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
+        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+            <span class="k">continue</span>
+        <span class="k">for</span> <span class="n">alias</span> <span class="ow">in</span> <span class="n">aliases</span><span class="p">:</span>
+            <span class="n">D</span><span class="p">[</span><span class="n">alias</span><span class="p">]</span> <span class="o">=</span> <span class="n">F</span></div>
 
 
 <span class="n">definitions</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
-<span class="s1">? dup truthy</span>
-<span class="s1">*fraction [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons</span>
-<span class="s1">*fraction0 concat [[swap] dip * [*] dip] infra</span>
-<span class="s1">anamorphism [pop []] swap [dip swons] genrec</span>
-<span class="s1">average [sum 1.0 *] [size] cleave /</span>
-<span class="s1">binary nullary [popop] dip</span>
-<span class="s1">cleave fork [popd] dip</span>
-<span class="s1">codireco cons dip rest cons</span>
-<span class="s1">dinfrirst dip infra first</span>
-<span class="s1">unstack ? [uncons ?] loop pop</span>
-<span class="s1">down_to_zero [0 &gt;] [dup --] while</span>
-<span class="s1">dupdipd dup dipd</span>
-<span class="s1">enstacken stack [clear] dip</span>
-<span class="s1">flatten [] swap [concat] step</span>
-<span class="s1">fork [i] app2</span>
-<span class="s1">gcd 1 [tuck modulus dup 0 &gt;] loop pop</span>
-<span class="s1">ifte [nullary not] dipd branch</span>
-<span class="s1">ii [dip] dupdip i</span>
-<span class="s1">least_fraction dup [gcd] infra [div] concat map</span>
-<span class="s1">make_generator [codireco] ccons</span>
-<span class="s1">nullary [stack] dinfrirst</span>
-<span class="s1">of swap at</span>
-<span class="s1">pam [i] map</span>
-<span class="s1">tailrec [i] genrec</span>
-<span class="s1">product 1 swap [*] step</span>
-<span class="s1">quoted [unit] dip</span>
-<span class="s1">range [0 &lt;=] [1 - dup] anamorphism</span>
-<span class="s1">range_to_zero unit [down_to_zero] infra</span>
-<span class="s1">run [] swap infra</span>
-<span class="s1">size 0 swap [pop ++] step</span>
-<span class="s1">sqr dup mul</span>
-<span class="s1">step_zero 0 roll&gt; step</span>
-<span class="s1">swoncat swap concat</span>
-<span class="s1">tailrec [i] genrec</span>
-<span class="s1">ternary unary [popop] dip</span>
-<span class="s1">unary nullary popd</span>
-<span class="s1">unquoted [i] dip</span>
-<span class="s1">while swap [nullary] cons dup dipd concat loop</span>
+<span class="s1">? == dup truthy</span>
+<span class="s1">*fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons</span>
+<span class="s1">*fraction0 == concat [[swap] dip * [*] dip] infra</span>
+<span class="s1">anamorphism == [pop []] swap [dip swons] genrec</span>
+<span class="s1">average == [sum 1.0 *] [size] cleave /</span>
+<span class="s1">binary == nullary [popop] dip</span>
+<span class="s1">cleave == fork [popd] dip</span>
+<span class="s1">codireco == cons dip rest cons</span>
+<span class="s1">dinfrirst == dip infra first</span>
+<span class="s1">unstack == ? [uncons ?] loop pop</span>
+<span class="s1">down_to_zero == [0 &gt;] [dup --] while</span>
+<span class="s1">dupdipd == dup dipd</span>
+<span class="s1">enstacken == stack [clear] dip</span>
+<span class="s1">flatten == [] swap [concat] step</span>
+<span class="s1">fork == [i] app2</span>
+<span class="s1">gcd == 1 [tuck modulus dup 0 &gt;] loop pop</span>
+<span class="s1">ifte == [nullary not] dipd branch</span>
+<span class="s1">ii == [dip] dupdip i</span>
+<span class="s1">least_fraction == dup [gcd] infra [div] concat map</span>
+<span class="s1">make_generator == [codireco] ccons</span>
+<span class="s1">nullary == [stack] dinfrirst</span>
+<span class="s1">of == swap at</span>
+<span class="s1">pam == [i] map</span>
+<span class="s1">tailrec == [i] genrec</span>
+<span class="s1">product == 1 swap [*] step</span>
+<span class="s1">quoted == [unit] dip</span>
+<span class="s1">range == [0 &lt;=] [1 - dup] anamorphism</span>
+<span class="s1">range_to_zero == unit [down_to_zero] infra</span>
+<span class="s1">run == [] swap infra</span>
+<span class="s1">size == 0 swap [pop ++] step</span>
+<span class="s1">sqr == dup mul</span>
+<span class="s1">step_zero == 0 roll&gt; step</span>
+<span class="s1">swoncat == swap concat</span>
+<span class="s1">tailrec == [i] genrec</span>
+<span class="s1">ternary == unary [popop] dip</span>
+<span class="s1">unary == nullary popd</span>
+<span class="s1">unquoted == [i] dip</span>
+<span class="s1">while == swap [nullary] cons dup dipd concat loop</span>
 <span class="s1">&#39;&#39;&#39;</span>
 <span class="c1">#</span>
 <span class="c1">#</span>
 
 
 <div class="viewcode-block" id="FunctionWrapper"><a class="viewcode-back" href="../../library.html#joy.library.FunctionWrapper">[docs]</a><span class="k">def</span> <span class="nf">FunctionWrapper</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Set name attribute.&#39;&#39;&#39;</span>
-       <span class="k">if</span> <span class="ow">not</span> <span class="n">f</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">:</span>
-               <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Function </span><span class="si">%s</span><span class="s1"> must have doc string.&#39;</span> <span class="o">%</span> <span class="n">f</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)</span>
-       <span class="n">f</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="vm">__name__</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)</span>  <span class="c1"># Don&#39;t shadow builtins.</span>
-       <span class="k">return</span> <span class="n">f</span></div>
+    <span class="sd">&#39;&#39;&#39;Set name attribute.&#39;&#39;&#39;</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">f</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Function </span><span class="si">%s</span><span class="s1"> must have doc string.&#39;</span> <span class="o">%</span> <span class="n">f</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)</span>
+    <span class="n">f</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="vm">__name__</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)</span>  <span class="c1"># Don&#39;t shadow builtins.</span>
+    <span class="k">return</span> <span class="n">f</span></div>
 
 
 <div class="viewcode-block" id="SimpleFunctionWrapper"><a class="viewcode-back" href="../../library.html#joy.library.SimpleFunctionWrapper">[docs]</a><span class="k">def</span> <span class="nf">SimpleFunctionWrapper</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Wrap functions that take and return just a stack.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="nd">@FunctionWrapper</span>
-       <span class="nd">@wraps</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
-       <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-               <span class="k">return</span> <span class="n">f</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="k">return</span> <span class="n">inner</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Wrap functions that take and return just a stack.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="nd">@FunctionWrapper</span>
+    <span class="nd">@wraps</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
+    <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
+        <span class="k">return</span> <span class="n">f</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="k">return</span> <span class="n">inner</span></div>
 
 
 <div class="viewcode-block" id="BinaryBuiltinWrapper"><a class="viewcode-back" href="../../library.html#joy.library.BinaryBuiltinWrapper">[docs]</a><span class="k">def</span> <span class="nf">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Wrap functions that take two arguments and return a single result.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="nd">@FunctionWrapper</span>
-       <span class="nd">@wraps</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
-       <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-               <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-               <span class="n">result</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span>
-               <span class="k">return</span> <span class="p">(</span><span class="n">result</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="k">return</span> <span class="n">inner</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Wrap functions that take two arguments and return a single result.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="nd">@FunctionWrapper</span>
+    <span class="nd">@wraps</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
+    <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+        <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span>
+            <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span>
+            <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="nb">bool</span><span class="p">)</span>  <span class="c1"># Because bools are ints in Python.</span>
+            <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="nb">bool</span><span class="p">)</span>
+            <span class="p">):</span>
+            <span class="k">raise</span> <span class="n">NotAnIntError</span>
+        <span class="n">result</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span>
+        <span class="k">return</span> <span class="p">(</span><span class="n">result</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="k">return</span> <span class="n">inner</span></div>
 
 
 <div class="viewcode-block" id="UnaryBuiltinWrapper"><a class="viewcode-back" href="../../library.html#joy.library.UnaryBuiltinWrapper">[docs]</a><span class="k">def</span> <span class="nf">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Wrap functions that take one argument and return a single result.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="nd">@FunctionWrapper</span>
-       <span class="nd">@wraps</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
-       <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-               <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
-               <span class="n">result</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
-               <span class="k">return</span> <span class="p">(</span><span class="n">result</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="k">return</span> <span class="n">inner</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Wrap functions that take one argument and return a single result.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="nd">@FunctionWrapper</span>
+    <span class="nd">@wraps</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
+    <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
+        <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+        <span class="n">result</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
+        <span class="k">return</span> <span class="p">(</span><span class="n">result</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="k">return</span> <span class="n">inner</span></div>
 
 
 <div class="viewcode-block" id="DefinitionWrapper"><a class="viewcode-back" href="../../library.html#joy.library.DefinitionWrapper">[docs]</a><span class="k">class</span> <span class="nc">DefinitionWrapper</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Provide implementation of defined functions, and some helper methods.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-
-       <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">body_text</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
-               <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">=</span> <span class="n">name</span>
-               <span class="bp">self</span><span class="o">.</span><span class="n">body</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">body_text</span><span class="p">)</span>
-               <span class="bp">self</span><span class="o">.</span><span class="n">_body</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">body</span><span class="p">))</span>
-               <span class="bp">self</span><span class="o">.</span><span class="vm">__doc__</span> <span class="o">=</span> <span class="n">doc</span> <span class="ow">or</span> <span class="n">body_text</span>
-               <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</span> <span class="o">=</span> <span class="kc">None</span>
-
-       <span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-               <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</span><span class="p">:</span>
-                       <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</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="c1"># pylint: disable=E1102</span>
-               <span class="n">expression</span> <span class="o">=</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_body</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-               <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span>
-
-<div class="viewcode-block" id="DefinitionWrapper.parse_definition"><a class="viewcode-back" href="../../library.html#joy.library.DefinitionWrapper.parse_definition">[docs]</a>       <span class="nd">@classmethod</span>
-       <span class="k">def</span> <span class="nf">parse_definition</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">defi</span><span class="p">):</span>
-               <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">              Given some text describing a Joy function definition parse it and</span>
-<span class="sd">              return a DefinitionWrapper.</span>
-<span class="sd">              &#39;&#39;&#39;</span>
-               <span class="k">return</span> <span class="n">class_</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">defi</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="mi">1</span><span class="p">)))</span></div>
-
-<div class="viewcode-block" id="DefinitionWrapper.add_definitions"><a class="viewcode-back" href="../../library.html#joy.library.DefinitionWrapper.add_definitions">[docs]</a> <span class="nd">@classmethod</span>
-       <span class="k">def</span> <span class="nf">add_definitions</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-               <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">              Scan multi-line string defs for definitions and add them to the</span>
-<span class="sd">              dictionary.</span>
-<span class="sd">              &#39;&#39;&#39;</span>
-               <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">_text_to_defs</span><span class="p">(</span><span class="n">defs</span><span class="p">):</span>
-                       <span class="n">class_</span><span class="o">.</span><span class="n">add_def</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span></div>
-
-<div class="viewcode-block" id="DefinitionWrapper.add_def"><a class="viewcode-back" href="../../library.html#joy.library.DefinitionWrapper.add_def">[docs]</a> <span class="nd">@classmethod</span>
-       <span class="k">def</span> <span class="nf">add_def</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">definition</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">fail_fails</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
-               <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">              Add the definition to the dictionary.</span>
-<span class="sd">              &#39;&#39;&#39;</span>
-               <span class="n">F</span> <span class="o">=</span> <span class="n">class_</span><span class="o">.</span><span class="n">parse_definition</span><span class="p">(</span><span class="n">definition</span><span class="p">)</span>
-               <span class="n">dictionary</span><span class="p">[</span><span class="n">F</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">F</span></div>
-
-       <span class="nd">@classmethod</span>
-       <span class="k">def</span> <span class="nf">load_definitions</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-               <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
-                       <span class="n">lines</span> <span class="o">=</span> <span class="p">[</span><span class="n">line</span> <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">f</span> <span class="k">if</span> <span class="s1">&#39;==&#39;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">]</span>
-               <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
-                       <span class="n">class_</span><span class="o">.</span><span class="n">add_def</span><span class="p">(</span><span class="n">line</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Provide implementation of defined functions, and some helper methods.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">body_text</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">=</span> <span class="n">name</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">body</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">body_text</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_body</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">body</span><span class="p">))</span>
+        <span class="bp">self</span><span class="o">.</span><span class="vm">__doc__</span> <span class="o">=</span> <span class="n">doc</span> <span class="ow">or</span> <span class="n">body_text</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</span> <span class="o">=</span> <span class="kc">None</span>
+
+    <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_compiled</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="c1"># pylint: disable=E1102</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_body</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span>
+
+<div class="viewcode-block" id="DefinitionWrapper.parse_definition"><a class="viewcode-back" href="../../library.html#joy.library.DefinitionWrapper.parse_definition">[docs]</a>    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">parse_definition</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">defi</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">        Given some text describing a Joy function definition parse it and</span>
+<span class="sd">        return a DefinitionWrapper.</span>
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="c1"># At some point I decided that the definitions file should NOT</span>
+        <span class="c1"># use &#39;==&#39; to separate the name from the body.  But somehow the</span>
+        <span class="c1"># xerblin\gui\default_joy_home\definitions.txt file didn&#39;t get</span>
+        <span class="c1"># the memo.  Nor did the load_definitions() method.</span>
+        <span class="c1"># So I think the simplest way forward at the moment will be to</span>
+        <span class="c1"># edit this function to expect &#39;==&#39;.</span>
+
+        <span class="n">name</span><span class="p">,</span> <span class="n">part</span><span class="p">,</span> <span class="n">body</span> <span class="o">=</span> <span class="n">defi</span><span class="o">.</span><span class="n">partition</span><span class="p">(</span><span class="s1">&#39;==&#39;</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">part</span><span class="p">:</span>
+            <span class="k">return</span> <span class="n">class_</span><span class="p">(</span><span class="n">name</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="n">body</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
+        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;No &#39;==&#39; in definition text </span><span class="si">%r</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">defi</span><span class="p">,))</span></div>
+
+        <span class="c1"># return class_(*(n.strip() for n in defi.split(None, 1)))</span>
+
+<div class="viewcode-block" id="DefinitionWrapper.add_definitions"><a class="viewcode-back" href="../../library.html#joy.library.DefinitionWrapper.add_definitions">[docs]</a>    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">add_definitions</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">        Scan multi-line string defs for definitions and add them to the</span>
+<span class="sd">        dictionary.</span>
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">_text_to_defs</span><span class="p">(</span><span class="n">defs</span><span class="p">):</span>
+            <span class="n">class_</span><span class="o">.</span><span class="n">add_def</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span></div>
+
+<div class="viewcode-block" id="DefinitionWrapper.add_def"><a class="viewcode-back" href="../../library.html#joy.library.DefinitionWrapper.add_def">[docs]</a>    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">add_def</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">definition</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">fail_fails</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">        Add the definition to the dictionary.</span>
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="n">F</span> <span class="o">=</span> <span class="n">class_</span><span class="o">.</span><span class="n">parse_definition</span><span class="p">(</span><span class="n">definition</span><span class="p">)</span>
+        <span class="n">dictionary</span><span class="p">[</span><span class="n">F</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">F</span></div>
+
+    <span class="nd">@classmethod</span>
+    <span class="k">def</span> <span class="nf">load_definitions</span><span class="p">(</span><span class="n">class_</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
+        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
+            <span class="n">lines</span> <span class="o">=</span> <span class="p">[</span><span class="n">line</span> <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">f</span> <span class="k">if</span> <span class="s1">&#39;==&#39;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">]</span>
+        <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
+            <span class="n">class_</span><span class="o">.</span><span class="n">add_def</span><span class="p">(</span><span class="n">line</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">)</span></div>
 
 
 <span class="k">def</span> <span class="nf">_text_to_defs</span><span class="p">(</span><span class="n">text</span><span class="p">):</span>
-       <span class="k">return</span> <span class="p">(</span>
-               <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
-               <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">text</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span>
-               <span class="k">if</span> <span class="n">line</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;#&#39;</span><span class="p">)</span>
-               <span class="p">)</span>
+    <span class="k">return</span> <span class="p">(</span>
+        <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
+        <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">text</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span>
+        <span class="k">if</span> <span class="n">line</span>
+           <span class="ow">and</span> <span class="ow">not</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;#&#39;</span><span class="p">)</span>
+           <span class="ow">and</span> <span class="s1">&#39;==&#39;</span> <span class="ow">in</span> <span class="n">line</span>
+        <span class="p">)</span>
 
 
 <span class="c1">#</span>
 <div class="viewcode-block" id="inscribe_"><a class="viewcode-back" href="../../library.html#joy.library.inscribe_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">inscribe_</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Create a new Joy function definition in the Joy dictionary.  A</span>
-<span class="sd">      definition is given as a string with a name followed by a double</span>
-<span class="sd">      equal sign then one or more Joy functions, the body. for example:</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Create a new Joy function definition in the Joy dictionary.  A</span>
+<span class="sd">    definition is given as a string with a name followed by a double</span>
+<span class="sd">    equal sign then one or more Joy functions, the body. for example:</span>
 
-<span class="sd">              sqr == dup mul</span>
+<span class="sd">        sqr == dup mul</span>
 
-<span class="sd">      If you want the definition to persist over restarts, enter it into</span>
-<span class="sd">      the definitions.txt resource.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">definition</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_def</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">fail_fails</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+<span class="sd">    If you want the definition to persist over restarts, enter it into</span>
+<span class="sd">    the definitions.txt resource.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">definition</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_def</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">fail_fails</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="parse"><a class="viewcode-back" href="../../library.html#joy.library.parse">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Parse the string on the stack to a Joy expression.&#39;&#39;&#39;</span>
-       <span class="n">text</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">expression</span><span class="p">,</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;Parse the string on the stack to a Joy expression.&#39;&#39;&#39;</span>
+    <span class="n">text</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">expression</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <span class="c1"># @inscribe</span>
 <span class="c1"># @SimpleFunctionWrapper</span>
 <span class="c1"># def infer_(stack):</span>
-<span class="c1">#     &#39;&#39;&#39;Attempt to infer the stack effect of a Joy expression.&#39;&#39;&#39;</span>
-<span class="c1">#     E, stack = stack</span>
-<span class="c1">#     effects = infer_expression(E)</span>
-<span class="c1">#     e = list_to_stack([(fi, (fo, ())) for fi, fo in effects])</span>
-<span class="c1">#     return e, stack</span>
+<span class="c1">#     &#39;&#39;&#39;Attempt to infer the stack effect of a Joy expression.&#39;&#39;&#39;</span>
+<span class="c1">#     E, stack = stack</span>
+<span class="c1">#     effects = infer_expression(E)</span>
+<span class="c1">#     e = list_to_stack([(fi, (fo, ())) for fi, fo in effects])</span>
+<span class="c1">#     return e, stack</span>
 
 
 <div class="viewcode-block" id="getitem"><a class="viewcode-back" href="../../library.html#joy.library.getitem">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">getitem</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              getitem == drop first</span>
+<span class="sd">        getitem == drop first</span>
 
-<span class="sd">      Expects an integer and a quote on the stack and returns the item at the</span>
-<span class="sd">      nth position in the quote counting from 0.</span>
-<span class="sd">      ::</span>
+<span class="sd">    Expects an integer and a quote on the stack and returns the item at the</span>
+<span class="sd">    nth position in the quote counting from 0.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 [a b c d] 0 getitem</span>
-<span class="sd">              -------------------------</span>
-<span class="sd">                  a</span>
+<span class="sd">           [a b c d] 0 getitem</span>
+<span class="sd">        -------------------------</span>
+<span class="sd">            a</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">pick</span><span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">stack</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">pick</span><span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="drop"><a class="viewcode-back" href="../../library.html#joy.library.drop">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              drop == [rest] times</span>
+<span class="sd">        drop == [rest] times</span>
 
-<span class="sd">      Expects an integer and a quote on the stack and returns the quote with</span>
-<span class="sd">      n items removed off the top.</span>
-<span class="sd">      ::</span>
+<span class="sd">    Expects an integer and a quote on the stack and returns the quote with</span>
+<span class="sd">    n items removed off the top.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 [a b c d] 2 drop</span>
-<span class="sd">              ----------------------</span>
-<span class="sd">                     [c d]</span>
+<span class="sd">           [a b c d] 2 drop</span>
+<span class="sd">        ----------------------</span>
+<span class="sd">               [c d]</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">while</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
-               <span class="k">try</span><span class="p">:</span>
-                       <span class="n">_</span><span class="p">,</span> <span class="n">Q</span> <span class="o">=</span> <span class="n">Q</span>
-               <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
-                       <span class="k">raise</span> <span class="ne">IndexError</span>
-               <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
-       <span class="k">return</span> <span class="n">Q</span><span class="p">,</span> <span class="n">stack</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">while</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="n">_</span><span class="p">,</span> <span class="n">Q</span> <span class="o">=</span> <span class="n">Q</span>
+        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">IndexError</span>
+        <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
+    <span class="k">return</span> <span class="n">Q</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="take"><a class="viewcode-back" href="../../library.html#joy.library.take">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">take</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Expects an integer and a quote on the stack and returns the quote with</span>
-<span class="sd">      just the top n items in reverse order (because that&#39;s easier and you can</span>
-<span class="sd">      use reverse if needed.)</span>
-<span class="sd">      ::</span>
-
-<span class="sd">                 [a b c d] 2 take</span>
-<span class="sd">              ----------------------</span>
-<span class="sd">                     [b a]</span>
-
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">x</span> <span class="o">=</span> <span class="p">()</span>
-       <span class="k">while</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
-               <span class="k">try</span><span class="p">:</span>
-                       <span class="n">item</span><span class="p">,</span> <span class="n">Q</span> <span class="o">=</span> <span class="n">Q</span>
-               <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
-                       <span class="k">raise</span> <span class="ne">IndexError</span>
-               <span class="n">x</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">x</span>
-               <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
-       <span class="k">return</span> <span class="n">x</span><span class="p">,</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Expects an integer and a quote on the stack and returns the quote with</span>
+<span class="sd">    just the top n items in reverse order (because that&#39;s easier and you can</span>
+<span class="sd">    use reverse if needed.)</span>
+<span class="sd">    ::</span>
+
+<span class="sd">           [a b c d] 2 take</span>
+<span class="sd">        ----------------------</span>
+<span class="sd">               [b a]</span>
+
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="n">x</span> <span class="o">=</span> <span class="p">()</span>
+    <span class="k">while</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="n">item</span><span class="p">,</span> <span class="n">Q</span> <span class="o">=</span> <span class="n">Q</span>
+        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">IndexError</span>
+        <span class="n">x</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">x</span>
+        <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
+    <span class="k">return</span> <span class="n">x</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="choice"><a class="viewcode-back" href="../../library.html#joy.library.choice">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">choice</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Use a Boolean value to select one of two items.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Use a Boolean value to select one of two items.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 A B False choice</span>
-<span class="sd">              ----------------------</span>
-<span class="sd">                 A</span>
+<span class="sd">           A B False choice</span>
+<span class="sd">        ----------------------</span>
+<span class="sd">           A</span>
 
 
-<span class="sd">                 A B True choice</span>
-<span class="sd">              ---------------------</span>
-<span class="sd">                   B</span>
+<span class="sd">           A B True choice</span>
+<span class="sd">        ---------------------</span>
+<span class="sd">             B</span>
 
-<span class="sd">      Currently Python semantics are used to evaluate the &quot;truthiness&quot; of the</span>
-<span class="sd">      Boolean value (so empty string, zero, etc. are counted as false, etc.)</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">if_</span><span class="p">,</span> <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">then</span> <span class="k">if</span> <span class="n">if_</span> <span class="k">else</span> <span class="n">else_</span><span class="p">,</span> <span class="n">stack</span></div>
+<span class="sd">    Currently Python semantics are used to evaluate the &quot;truthiness&quot; of the</span>
+<span class="sd">    Boolean value (so empty string, zero, etc. are counted as false, etc.)</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">if_</span><span class="p">,</span> <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">then</span> <span class="k">if</span> <span class="n">if_</span> <span class="k">else</span> <span class="n">else_</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="select"><a class="viewcode-back" href="../../library.html#joy.library.select">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Use a Boolean value to select one of two items from a sequence.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Use a Boolean value to select one of two items from a sequence.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 [A B] False select</span>
-<span class="sd">              ------------------------</span>
-<span class="sd">                  A</span>
+<span class="sd">           [A B] False select</span>
+<span class="sd">        ------------------------</span>
+<span class="sd">            A</span>
 
 
-<span class="sd">                 [A B] True select</span>
-<span class="sd">              -----------------------</span>
-<span class="sd">                    B</span>
+<span class="sd">           [A B] True select</span>
+<span class="sd">        -----------------------</span>
+<span class="sd">              B</span>
 
-<span class="sd">      The sequence can contain more than two items but not fewer.</span>
-<span class="sd">      Currently Python semantics are used to evaluate the &quot;truthiness&quot; of the</span>
-<span class="sd">      Boolean value (so empty string, zero, etc. are counted as false, etc.)</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">flag</span><span class="p">,</span> <span class="p">(</span><span class="n">choices</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">_</span><span class="p">))</span> <span class="o">=</span> <span class="n">choices</span>
-       <span class="k">return</span> <span class="n">then</span> <span class="k">if</span> <span class="n">flag</span> <span class="k">else</span> <span class="n">else_</span><span class="p">,</span> <span class="n">stack</span></div>
+<span class="sd">    The sequence can contain more than two items but not fewer.</span>
+<span class="sd">    Currently Python semantics are used to evaluate the &quot;truthiness&quot; of the</span>
+<span class="sd">    Boolean value (so empty string, zero, etc. are counted as false, etc.)</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">flag</span><span class="p">,</span> <span class="p">(</span><span class="n">choices</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">_</span><span class="p">))</span> <span class="o">=</span> <span class="n">choices</span>
+    <span class="k">return</span> <span class="n">then</span> <span class="k">if</span> <span class="n">flag</span> <span class="k">else</span> <span class="n">else_</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="max_"><a class="viewcode-back" href="../../library.html#joy.library.max_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">max_</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Given a list find the maximum.&#39;&#39;&#39;</span>
-       <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">return</span> <span class="nb">max</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">)),</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;Given a list find the maximum.&#39;&#39;&#39;</span>
+    <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">return</span> <span class="nb">max</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">)),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="min_"><a class="viewcode-back" href="../../library.html#joy.library.min_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">min_</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Given a list find the minimum.&#39;&#39;&#39;</span>
-       <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">return</span> <span class="nb">min</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">)),</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;Given a list find the minimum.&#39;&#39;&#39;</span>
+    <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">return</span> <span class="nb">min</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">)),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="sum_"><a class="viewcode-back" href="../../library.html#joy.library.sum_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">sum_</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Given a quoted sequence of numbers return the sum.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Given a quoted sequence of numbers return the sum.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              sum == 0 swap [+] step</span>
+<span class="sd">        sum == 0 swap [+] step</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">)),</span> <span class="n">stack</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">)),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="remove"><a class="viewcode-back" href="../../library.html#joy.library.remove">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">remove</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Expects an item on the stack and a quote under it and removes that item</span>
-<span class="sd">      from the the quote.  The item is only removed once.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Expects an item on the stack and a quote under it and removes that item</span>
+<span class="sd">    from the the quote.  The item is only removed once.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 [1 2 3 1] 1 remove</span>
-<span class="sd">              ------------------------</span>
-<span class="sd">                   [2 3 1]</span>
+<span class="sd">           [1 2 3 1] 1 remove</span>
+<span class="sd">        ------------------------</span>
+<span class="sd">             [2 3 1]</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">l</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">second</span><span class="p">))</span>
-       <span class="n">l</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">tos</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">l</span><span class="p">),</span> <span class="n">stack</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">l</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">second</span><span class="p">))</span>
+    <span class="n">l</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">tos</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">l</span><span class="p">),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="unique"><a class="viewcode-back" href="../../library.html#joy.library.unique">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">unique</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Given a list remove duplicate items.&#39;&#39;&#39;</span>
-       <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">I</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">))</span>
-       <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">I</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="n">I</span><span class="o">.</span><span class="n">index</span><span class="p">)),</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;Given a list remove duplicate items.&#39;&#39;&#39;</span>
+    <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">I</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">I</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="n">I</span><span class="o">.</span><span class="n">index</span><span class="p">)),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="sort_"><a class="viewcode-back" href="../../library.html#joy.library.sort_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">sort_</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Given a list return it sorted.&#39;&#39;&#39;</span>
-       <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">))),</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;Given a list return it sorted.&#39;&#39;&#39;</span>
+    <span class="n">tos</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">))),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="clear"><a class="viewcode-back" href="../../library.html#joy.library.clear">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">clear</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Clear everything from the stack.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;Clear everything from the stack.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              clear == stack [pop stack] loop</span>
+<span class="sd">        clear == stack [pop stack] loop</span>
 
-<span class="sd">                 ... clear</span>
-<span class="sd">              ---------------</span>
+<span class="sd">           ... clear</span>
+<span class="sd">        ---------------</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">return</span> <span class="p">()</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">return</span> <span class="p">()</span></div>
 
 
 <div class="viewcode-block" id="disenstacken"><a class="viewcode-back" href="../../library.html#joy.library.disenstacken">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">disenstacken</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      The disenstacken operator expects a list on top of the stack and makes that</span>
-<span class="sd">      the stack discarding the rest of the stack.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    The disenstacken operator expects a list on top of the stack and makes that</span>
+<span class="sd">    the stack discarding the rest of the stack.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></div>
 
 
 <div class="viewcode-block" id="reverse"><a class="viewcode-back" href="../../library.html#joy.library.reverse">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">reverse</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Reverse the list on the top of the stack.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Reverse the list on the top of the stack.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              reverse == [] swap shunt</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">res</span> <span class="o">=</span> <span class="p">()</span>
-       <span class="k">for</span> <span class="n">term</span> <span class="ow">in</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">):</span>
-               <span class="n">res</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">res</span>
-       <span class="k">return</span> <span class="n">res</span><span class="p">,</span> <span class="n">stack</span></div>
+<span class="sd">        reverse == [] swap shunt</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">res</span> <span class="o">=</span> <span class="p">()</span>
+    <span class="k">for</span> <span class="n">term</span> <span class="ow">in</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">):</span>
+        <span class="n">res</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">res</span>
+    <span class="k">return</span> <span class="n">res</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="concat_"><a class="viewcode-back" href="../../library.html#joy.library.concat_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">concat_</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Concatinate the two lists on the top of the stack.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Concatinate the two lists on the top of the stack.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 [a b c] [d e f] concat</span>
-<span class="sd">              ----------------------------</span>
-<span class="sd">                     [a b c d e f]</span>
+<span class="sd">           [a b c] [d e f] concat</span>
+<span class="sd">        ----------------------------</span>
+<span class="sd">               [a b c d e f]</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">return</span> <span class="n">concat</span><span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">tos</span><span class="p">),</span> <span class="n">stack</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">return</span> <span class="n">concat</span><span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">tos</span><span class="p">),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="shunt"><a class="viewcode-back" href="../../library.html#joy.library.shunt">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">shunt</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Like concat but reverses the top list into the second.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Like concat but reverses the top list into the second.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              shunt == [swons] step == reverse swap concat</span>
+<span class="sd">        shunt == [swons] step == reverse swap concat</span>
 
-<span class="sd">                 [a b c] [d e f] shunt</span>
-<span class="sd">              ---------------------------</span>
-<span class="sd">                     [f e d a b c] </span>
+<span class="sd">           [a b c] [d e f] shunt</span>
+<span class="sd">        ---------------------------</span>
+<span class="sd">               [f e d a b c] </span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">while</span> <span class="n">tos</span><span class="p">:</span>
-               <span class="n">term</span><span class="p">,</span> <span class="n">tos</span> <span class="o">=</span> <span class="n">tos</span>
-               <span class="n">second</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">second</span>
-       <span class="k">return</span> <span class="n">second</span><span class="p">,</span> <span class="n">stack</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">while</span> <span class="n">tos</span><span class="p">:</span>
+        <span class="n">term</span><span class="p">,</span> <span class="n">tos</span> <span class="o">=</span> <span class="n">tos</span>
+        <span class="n">second</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">second</span>
+    <span class="k">return</span> <span class="n">second</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="zip_"><a class="viewcode-back" href="../../library.html#joy.library.zip_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">zip_</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Replace the two lists on the top of the stack with a list of the pairs</span>
-<span class="sd">      from each list.  The smallest list sets the length of the result list.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">accumulator</span> <span class="o">=</span> <span class="p">[</span>
-               <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">()))</span>
-               <span class="k">for</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">),</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">second</span><span class="p">))</span>
-               <span class="p">]</span>
-       <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">accumulator</span><span class="p">),</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Replace the two lists on the top of the stack with a list of the pairs</span>
+<span class="sd">    from each list.  The smallest list sets the length of the result list.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">accumulator</span> <span class="o">=</span> <span class="p">[</span>
+        <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">()))</span>
+        <span class="k">for</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">tos</span><span class="p">),</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">second</span><span class="p">))</span>
+        <span class="p">]</span>
+    <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">accumulator</span><span class="p">),</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="succ"><a class="viewcode-back" href="../../library.html#joy.library.succ">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">succ</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Increment TOS.&#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">return</span> <span class="n">tos</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;Increment TOS.&#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">return</span> <span class="n">tos</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="pred"><a class="viewcode-back" href="../../library.html#joy.library.pred">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">pred</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Decrement TOS.&#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">return</span> <span class="n">tos</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;Decrement TOS.&#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">tos</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">return</span> <span class="n">tos</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="pm"><a class="viewcode-back" href="../../library.html#joy.library.pm">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">pm</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Plus or minus</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Plus or minus</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 a b pm</span>
-<span class="sd">              -------------</span>
-<span class="sd">                 a+b a-b</span>
+<span class="sd">           a b pm</span>
+<span class="sd">        -------------</span>
+<span class="sd">           a+b a-b</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">p</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="o">=</span> <span class="n">b</span> <span class="o">+</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">-</span> <span class="n">a</span>
-       <span class="k">return</span> <span class="n">m</span><span class="p">,</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="n">p</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="o">=</span> <span class="n">b</span> <span class="o">+</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">-</span> <span class="n">a</span>
+    <span class="k">return</span> <span class="n">m</span><span class="p">,</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span></div>
 
 
 <div class="viewcode-block" id="floor"><a class="viewcode-back" href="../../library.html#joy.library.floor">[docs]</a><span class="k">def</span> <span class="nf">floor</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
-       <span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">floor</span><span class="p">(</span><span class="n">n</span><span class="p">))</span></div>
+    <span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">floor</span><span class="p">(</span><span class="n">n</span><span class="p">))</span></div>
 
 <span class="n">floor</span><span class="o">.</span><span class="vm">__doc__</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">floor</span><span class="o">.</span><span class="vm">__doc__</span>
 
 <div class="viewcode-block" id="divmod_"><a class="viewcode-back" href="../../library.html#joy.library.divmod_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">divmod_</span><span class="p">(</span><span class="n">S</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      divmod(x, y) -&gt; (quotient, remainder)</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    divmod(x, y) -&gt; (quotient, remainder)</span>
 
-<span class="sd">      Return the tuple (x//y, x%y).  Invariant: div*y + mod == x.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">d</span><span class="p">,</span> <span class="n">m</span> <span class="o">=</span> <span class="nb">divmod</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span></div>
+<span class="sd">    Return the tuple (x//y, x%y).  Invariant: div*y + mod == x.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">d</span><span class="p">,</span> <span class="n">m</span> <span class="o">=</span> <span class="nb">divmod</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span></div>
 
 
 <div class="viewcode-block" id="sqrt"><a class="viewcode-back" href="../../library.html#joy.library.sqrt">[docs]</a><span class="k">def</span> <span class="nf">sqrt</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Return the square root of the number a.</span>
-<span class="sd">      Negative numbers return complex roots.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">try</span><span class="p">:</span>
-               <span class="n">r</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
-       <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
-               <span class="k">assert</span> <span class="n">a</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">repr</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
-               <span class="n">r</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="o">-</span><span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1</span><span class="n">j</span>
-       <span class="k">return</span> <span class="n">r</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Return the square root of the number a.</span>
+<span class="sd">    Negative numbers return complex roots.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="n">r</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
+    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+        <span class="k">assert</span> <span class="n">a</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">repr</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
+        <span class="n">r</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="o">-</span><span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1</span><span class="n">j</span>
+    <span class="k">return</span> <span class="n">r</span></div>
 
 
 <span class="c1">#def execute(S):</span>
 <div class="viewcode-block" id="id_"><a class="viewcode-back" href="../../library.html#joy.library.id_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">id_</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;The identity function.&#39;&#39;&#39;</span>
-       <span class="k">return</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;The identity function.&#39;&#39;&#39;</span>
+    <span class="k">return</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="void"><a class="viewcode-back" href="../../library.html#joy.library.void">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@SimpleFunctionWrapper</span>
 <span class="k">def</span> <span class="nf">void</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;True if the form on TOS is void otherwise False.&#39;&#39;&#39;</span>
-       <span class="n">form</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">_void</span><span class="p">(</span><span class="n">form</span><span class="p">),</span> <span class="n">stack</span></div>
+    <span class="sd">&#39;&#39;&#39;True if the form on TOS is void otherwise False.&#39;&#39;&#39;</span>
+    <span class="n">form</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">_void</span><span class="p">(</span><span class="n">form</span><span class="p">),</span> <span class="n">stack</span></div>
 
 
 <span class="k">def</span> <span class="nf">_void</span><span class="p">(</span><span class="n">form</span><span class="p">):</span>
-       <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="ow">not</span> <span class="n">_void</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">form</span><span class="p">))</span>
+    <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="ow">not</span> <span class="n">_void</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">form</span><span class="p">))</span>
 
 
 
 <div class="viewcode-block" id="words"><a class="viewcode-back" href="../../library.html#joy.library.words">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">words</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="sd">&#39;&#39;&#39;Print all the words in alphabetical order.&#39;&#39;&#39;</span>
-       <span class="nb">print</span><span class="p">(</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">dictionary</span><span class="p">)))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+    <span class="sd">&#39;&#39;&#39;Print all the words in alphabetical order.&#39;&#39;&#39;</span>
+    <span class="nb">print</span><span class="p">(</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">dictionary</span><span class="p">)))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="sharing"><a class="viewcode-back" href="../../library.html#joy.library.sharing">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">sharing</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="sd">&#39;&#39;&#39;Print redistribution information.&#39;&#39;&#39;</span>
-       <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;You may convey verbatim copies of the Program&#39;s source code as&quot;</span>
-       <span class="s1">&#39; you receive it, in any medium, provided that you conspicuously&#39;</span>
-       <span class="s1">&#39; and appropriately publish on each copy an appropriate copyright&#39;</span>
-       <span class="s1">&#39; notice; keep intact all notices stating that this License and&#39;</span>
-       <span class="s1">&#39; any non-permissive terms added in accord with section 7 apply&#39;</span>
-       <span class="s1">&#39; to the code; keep intact all notices of the absence of any&#39;</span>
-       <span class="s1">&#39; warranty; and give all recipients a copy of this License along&#39;</span>
-       <span class="s1">&#39; with the Program.&#39;</span>
-       <span class="s1">&#39; You should have received a copy of the GNU General Public License&#39;</span>
-       <span class="s1">&#39; along with Thun.  If not see &lt;http://www.gnu.org/licenses/&gt;.&#39;</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+    <span class="sd">&#39;&#39;&#39;Print redistribution information.&#39;&#39;&#39;</span>
+    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;You may convey verbatim copies of the Program&#39;s source code as&quot;</span>
+    <span class="s1">&#39; you receive it, in any medium, provided that you conspicuously&#39;</span>
+    <span class="s1">&#39; and appropriately publish on each copy an appropriate copyright&#39;</span>
+    <span class="s1">&#39; notice; keep intact all notices stating that this License and&#39;</span>
+    <span class="s1">&#39; any non-permissive terms added in accord with section 7 apply&#39;</span>
+    <span class="s1">&#39; to the code; keep intact all notices of the absence of any&#39;</span>
+    <span class="s1">&#39; warranty; and give all recipients a copy of this License along&#39;</span>
+    <span class="s1">&#39; with the Program.&#39;</span>
+    <span class="s1">&#39; You should have received a copy of the GNU General Public License&#39;</span>
+    <span class="s1">&#39; along with Thun.  If not see &lt;http://www.gnu.org/licenses/&gt;.&#39;</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="warranty"><a class="viewcode-back" href="../../library.html#joy.library.warranty">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">warranty</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="sd">&#39;&#39;&#39;Print warranty information.&#39;&#39;&#39;</span>
-       <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY&#39;</span>
-       <span class="s1">&#39; APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE&#39;</span>
-       <span class="s1">&#39; COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM&#39;</span>
-       <span class="s1">&#39; &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR&#39;</span>
-       <span class="s1">&#39; IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES&#39;</span>
-       <span class="s1">&#39; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE&#39;</span>
-       <span class="s1">&#39; ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS&#39;</span>
-       <span class="s1">&#39; WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE&#39;</span>
-       <span class="s1">&#39; COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.&#39;</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+    <span class="sd">&#39;&#39;&#39;Print warranty information.&#39;&#39;&#39;</span>
+    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY&#39;</span>
+    <span class="s1">&#39; APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE&#39;</span>
+    <span class="s1">&#39; COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM&#39;</span>
+    <span class="s1">&#39; &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR&#39;</span>
+    <span class="s1">&#39; IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES&#39;</span>
+    <span class="s1">&#39; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE&#39;</span>
+    <span class="s1">&#39; ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS&#39;</span>
+    <span class="s1">&#39; WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE&#39;</span>
+    <span class="s1">&#39; COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.&#39;</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <span class="c1"># def simple_manual(stack):</span>
 <div class="viewcode-block" id="help_"><a class="viewcode-back" href="../../library.html#joy.library.help_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">help_</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;Accepts a quoted symbol on the top of the stack and prints its docs.&#39;&#39;&#39;</span>
-       <span class="p">((</span><span class="n">symbol</span><span class="p">,</span> <span class="n">_</span><span class="p">),</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">word</span> <span class="o">=</span> <span class="n">dictionary</span><span class="p">[</span><span class="n">symbol</span><span class="p">]</span>
-       <span class="nb">print</span><span class="p">(</span><span class="n">HELP_TEMPLATE</span> <span class="o">%</span> <span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">getdoc</span><span class="p">(</span><span class="n">word</span><span class="p">),</span> <span class="n">symbol</span><span class="p">))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+    <span class="sd">&#39;&#39;&#39;Accepts a quoted symbol on the top of the stack and prints its docs.&#39;&#39;&#39;</span>
+    <span class="p">((</span><span class="n">symbol</span><span class="p">,</span> <span class="n">_</span><span class="p">),</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">word</span> <span class="o">=</span> <span class="n">dictionary</span><span class="p">[</span><span class="n">symbol</span><span class="p">]</span>
+    <span class="nb">print</span><span class="p">(</span><span class="n">HELP_TEMPLATE</span> <span class="o">%</span> <span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">getdoc</span><span class="p">(</span><span class="n">word</span><span class="p">),</span> <span class="n">symbol</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <span class="c1">#</span>
 <div class="viewcode-block" id="i"><a class="viewcode-back" href="../../library.html#joy.library.i">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">i</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      The i combinator expects a quoted program on the stack and unpacks it</span>
-<span class="sd">      onto the pending expression for evaluation.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    The i combinator expects a quoted program on the stack and unpacks it</span>
+<span class="sd">    onto the pending expression for evaluation.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 [Q] i</span>
-<span class="sd">              -----------</span>
-<span class="sd">                  Q</span>
+<span class="sd">           [Q] i</span>
+<span class="sd">        -----------</span>
+<span class="sd">            Q</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">quote</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="n">quote</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
 
 
 <div class="viewcode-block" id="x"><a class="viewcode-back" href="../../library.html#joy.library.x">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">x</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              x == dup i</span>
+<span class="sd">        x == dup i</span>
 
-<span class="sd">              ... [Q] x = ... [Q] dup i</span>
-<span class="sd">              ... [Q] x = ... [Q] [Q] i</span>
-<span class="sd">              ... [Q] x = ... [Q]  Q</span>
+<span class="sd">        ... [Q] x = ... [Q] dup i</span>
+<span class="sd">        ... [Q] x = ... [Q] [Q] i</span>
+<span class="sd">        ... [Q] x = ... [Q]  Q</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">quote</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">quote</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
 
 
 <div class="viewcode-block" id="b"><a class="viewcode-back" href="../../library.html#joy.library.b">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">b</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              b == [i] dip i</span>
+<span class="sd">        b == [i] dip i</span>
 
-<span class="sd">              ... [P] [Q] b == ... [P] i [Q] i</span>
-<span class="sd">              ... [P] [Q] b == ... P Q</span>
+<span class="sd">        ... [P] [Q] b == ... [P] i [Q] i</span>
+<span class="sd">        ... [P] [Q] b == ... P Q</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">q</span><span class="p">,</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="n">expression</span><span class="p">)),</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">q</span><span class="p">,</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="n">expression</span><span class="p">)),</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="dupdip"><a class="viewcode-back" href="../../library.html#joy.library.dupdip">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">dupdip</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              [F] dupdip == dup [F] dip</span>
+<span class="sd">        [F] dupdip == dup [F] dip</span>
 
-<span class="sd">              ... a [F] dupdip</span>
-<span class="sd">              ... a dup [F] dip</span>
-<span class="sd">              ... a a   [F] dip</span>
-<span class="sd">              ... a F a</span>
+<span class="sd">        ... a [F] dupdip</span>
+<span class="sd">        ... a dup [F] dip</span>
+<span class="sd">        ... a a   [F] dip</span>
+<span class="sd">        ... a F a</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">F</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">a</span> <span class="o">=</span> <span class="n">stack</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span>  <span class="n">expression</span><span class="p">)),</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">F</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="n">a</span> <span class="o">=</span> <span class="n">stack</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span>  <span class="n">expression</span><span class="p">)),</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="infra"><a class="viewcode-back" href="../../library.html#joy.library.infra">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">infra</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Accept a quoted program and a list on the stack and run the program</span>
-<span class="sd">      with the list as its stack.  Does not affect the rest of the stack.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Accept a quoted program and a list on the stack and run the program</span>
+<span class="sd">    with the list as its stack.  Does not affect the rest of the stack.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 ... [a b c] [Q] . infra</span>
-<span class="sd">              -----------------------------</span>
-<span class="sd">                  c b a . Q [...] swaack</span>
+<span class="sd">           ... [a b c] [Q] . infra</span>
+<span class="sd">        -----------------------------</span>
+<span class="sd">            c b a . Q [...] swaack</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">aggregate</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">aggregate</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="p">(</span><span class="n">S_swaack</span><span class="p">,</span> <span class="n">expression</span><span class="p">))),</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">aggregate</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">aggregate</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="p">(</span><span class="n">S_swaack</span><span class="p">,</span> <span class="n">expression</span><span class="p">))),</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="genrec"><a class="viewcode-back" href="../../library.html#joy.library.genrec">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">genrec</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      General Recursion Combinator.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    General Recursion Combinator.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                                [if] [then] [rec1] [rec2] genrec</span>
-<span class="sd">          ---------------------------------------------------------------------</span>
-<span class="sd">             [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte</span>
+<span class="sd">                  [if] [then] [rec1] [rec2] genrec</span>
+<span class="sd">        ---------------------------------------------------------------------</span>
+<span class="sd">           [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte</span>
 
-<span class="sd">      From &quot;Recursion Theory and Joy&quot; (j05cmp.html) by Manfred von Thun:</span>
-<span class="sd">      &quot;The genrec combinator takes four program parameters in addition to</span>
-<span class="sd">      whatever data parameters it needs. Fourth from the top is an if-part,</span>
-<span class="sd">      followed by a then-part. If the if-part yields true, then the then-part</span>
-<span class="sd">      is executed and the combinator terminates. The other two parameters are</span>
-<span class="sd">      the rec1-part and the rec2-part. If the if-part yields false, the</span>
-<span class="sd">      rec1-part is executed. Following that the four program parameters and</span>
-<span class="sd">      the combinator are again pushed onto the stack bundled up in a quoted</span>
-<span class="sd">      form. Then the rec2-part is executed, where it will find the bundled</span>
-<span class="sd">      form. Typically it will then execute the bundled form, either with i or</span>
-<span class="sd">      with app2, or some other combinator.&quot;</span>
+<span class="sd">    From &quot;Recursion Theory and Joy&quot; (j05cmp.html) by Manfred von Thun:</span>
+<span class="sd">    &quot;The genrec combinator takes four program parameters in addition to</span>
+<span class="sd">    whatever data parameters it needs. Fourth from the top is an if-part,</span>
+<span class="sd">    followed by a then-part. If the if-part yields true, then the then-part</span>
+<span class="sd">    is executed and the combinator terminates. The other two parameters are</span>
+<span class="sd">    the rec1-part and the rec2-part. If the if-part yields false, the</span>
+<span class="sd">    rec1-part is executed. Following that the four program parameters and</span>
+<span class="sd">    the combinator are again pushed onto the stack bundled up in a quoted</span>
+<span class="sd">    form. Then the rec2-part is executed, where it will find the bundled</span>
+<span class="sd">    form. Typically it will then execute the bundled form, either with i or</span>
+<span class="sd">    with app2, or some other combinator.&quot;</span>
 
-<span class="sd">      The way to design one of these is to fix your base case [then] and the</span>
-<span class="sd">      test [if], and then treat rec1 and rec2 as an else-part &quot;sandwiching&quot;</span>
-<span class="sd">      a quotation of the whole function.</span>
+<span class="sd">    The way to design one of these is to fix your base case [then] and the</span>
+<span class="sd">    test [if], and then treat rec1 and rec2 as an else-part &quot;sandwiching&quot;</span>
+<span class="sd">    a quotation of the whole function.</span>
 
-<span class="sd">      For example, given a (general recursive) function &#39;F&#39;:</span>
-<span class="sd">      ::</span>
+<span class="sd">    For example, given a (general recursive) function &#39;F&#39;:</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              F == [I] [T] [R1] [R2] genrec</span>
+<span class="sd">        F == [I] [T] [R1] [R2] genrec</span>
 
-<span class="sd">      If the [I] if-part fails you must derive R1 and R2 from:</span>
-<span class="sd">      ::</span>
+<span class="sd">    If the [I] if-part fails you must derive R1 and R2 from:</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              ... R1 [F] R2</span>
+<span class="sd">        ... R1 [F] R2</span>
 
-<span class="sd">      Just set the stack arguments in front, and figure out what R1 and R2</span>
-<span class="sd">      have to do to apply the quoted [F] in the proper way.  In effect, the</span>
-<span class="sd">      genrec combinator turns into an ifte combinator with a quoted copy of</span>
-<span class="sd">      the original definition in the else-part:</span>
-<span class="sd">      ::</span>
+<span class="sd">    Just set the stack arguments in front, and figure out what R1 and R2</span>
+<span class="sd">    have to do to apply the quoted [F] in the proper way.  In effect, the</span>
+<span class="sd">    genrec combinator turns into an ifte combinator with a quoted copy of</span>
+<span class="sd">    the original definition in the else-part:</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              F == [I] [T] [R1]   [R2] genrec</span>
-<span class="sd">                == [I] [T] [R1 [F] R2] ifte</span>
+<span class="sd">        F == [I] [T] [R1]   [R2] genrec</span>
+<span class="sd">          == [I] [T] [R1 [F] R2] ifte</span>
 
-<span class="sd">      Primitive recursive functions are those where R2 == i.</span>
-<span class="sd">      ::</span>
+<span class="sd">    Primitive recursive functions are those where R2 == i.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              P == [I] [T] [R] tailrec</span>
-<span class="sd">                == [I] [T] [R [P] i] ifte</span>
-<span class="sd">                == [I] [T] [R P] ifte</span>
+<span class="sd">        P == [I] [T] [R] tailrec</span>
+<span class="sd">          == [I] [T] [R [P] i] ifte</span>
+<span class="sd">          == [I] [T] [R P] ifte</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">rec2</span><span class="p">,</span> <span class="p">(</span><span class="n">rec1</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">if_</span><span class="p">,</span> <span class="n">_</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">F</span> <span class="o">=</span> <span class="p">(</span><span class="n">if_</span><span class="p">,</span> <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">rec1</span><span class="p">,</span> <span class="p">(</span><span class="n">rec2</span><span class="p">,</span> <span class="p">(</span><span class="n">S_genrec</span><span class="p">,</span> <span class="p">())))))</span>
-       <span class="n">else_</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">rec1</span><span class="p">,</span> <span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">rec2</span><span class="p">))</span>
-       <span class="k">return</span> <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="p">(</span><span class="n">S_ifte</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">rec2</span><span class="p">,</span> <span class="p">(</span><span class="n">rec1</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">if_</span><span class="p">,</span> <span class="n">_</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="n">F</span> <span class="o">=</span> <span class="p">(</span><span class="n">if_</span><span class="p">,</span> <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">rec1</span><span class="p">,</span> <span class="p">(</span><span class="n">rec2</span><span class="p">,</span> <span class="p">(</span><span class="n">S_genrec</span><span class="p">,</span> <span class="p">())))))</span>
+    <span class="n">else_</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">rec1</span><span class="p">,</span> <span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">rec2</span><span class="p">))</span>
+    <span class="k">return</span> <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="p">(</span><span class="n">S_ifte</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="map_"><a class="viewcode-back" href="../../library.html#joy.library.map_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">map_</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Run the quoted program on TOS on the items in the list under it, push a</span>
-<span class="sd">      new list with the results in place of the program and original list.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="c1"># (quote, (aggregate, stack)) = S</span>
-       <span class="c1"># results = list_to_stack([</span>
-       <span class="c1"># joy((term, stack), quote, dictionary)[0][0]</span>
-       <span class="c1"># for term in iter_stack(aggregate)</span>
-       <span class="c1"># ])</span>
-       <span class="c1"># return (results, stack), expression, dictionary</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">aggregate</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">if</span> <span class="ow">not</span> <span class="n">aggregate</span><span class="p">:</span>
-               <span class="k">return</span> <span class="p">(</span><span class="n">aggregate</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="n">batch</span> <span class="o">=</span> <span class="p">()</span>
-       <span class="k">for</span> <span class="n">term</span> <span class="ow">in</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">aggregate</span><span class="p">):</span>
-               <span class="n">s</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">stack</span>
-               <span class="n">batch</span> <span class="o">=</span> <span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span> <span class="n">batch</span><span class="p">))))</span>
-       <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">batch</span><span class="p">,</span> <span class="p">((),</span> <span class="n">stack</span><span class="p">))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Run the quoted program on TOS on the items in the list under it, push a</span>
+<span class="sd">    new list with the results in place of the program and original list.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="c1"># (quote, (aggregate, stack)) = S</span>
+    <span class="c1"># results = list_to_stack([</span>
+    <span class="c1"># joy((term, stack), quote, dictionary)[0][0]</span>
+    <span class="c1"># for term in iter_stack(aggregate)</span>
+    <span class="c1"># ])</span>
+    <span class="c1"># return (results, stack), expression, dictionary</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">aggregate</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">aggregate</span><span class="p">:</span>
+        <span class="k">return</span> <span class="p">(</span><span class="n">aggregate</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="n">batch</span> <span class="o">=</span> <span class="p">()</span>
+    <span class="k">for</span> <span class="n">term</span> <span class="ow">in</span> <span class="n">iter_stack</span><span class="p">(</span><span class="n">aggregate</span><span class="p">):</span>
+        <span class="n">s</span> <span class="o">=</span> <span class="n">term</span><span class="p">,</span> <span class="n">stack</span>
+        <span class="n">batch</span> <span class="o">=</span> <span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span> <span class="n">batch</span><span class="p">))))</span>
+    <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">batch</span><span class="p">,</span> <span class="p">((),</span> <span class="n">stack</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="primrec"><a class="viewcode-back" href="../../library.html#joy.library.primrec">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">primrec</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      From the &quot;Overview of the language JOY&quot;:</span>
-
-<span class="sd">      &gt; The primrec combinator expects two quoted programs in addition to a</span>
-<span class="sd">      data parameter. For an integer data parameter it works like this: If</span>
-<span class="sd">      the data parameter is zero, then the first quotation has to produce</span>
-<span class="sd">      the value to be returned. If the data parameter is positive then the</span>
-<span class="sd">      second has to combine the data parameter with the result of applying</span>
-<span class="sd">      the function to its predecessor.::</span>
-
-<span class="sd">              5  [1]  [*]  primrec</span>
-
-<span class="sd">      &gt; Then primrec tests whether the top element on the stack (initially</span>
-<span class="sd">      the 5) is equal to zero. If it is, it pops it off and executes one of</span>
-<span class="sd">      the quotations, the [1] which leaves 1 on the stack as the result.</span>
-<span class="sd">      Otherwise it pushes a decremented copy of the top element and</span>
-<span class="sd">      recurses. On the way back from the recursion it uses the other</span>
-<span class="sd">      quotation, [*], to multiply what is now a factorial on top of the</span>
-<span class="sd">      stack by the second element on the stack.::</span>
-
-<span class="sd">              n [Base] [Recur] primrec</span>
-
-<span class="sd">                 0 [Base] [Recur] primrec</span>
-<span class="sd">              ------------------------------</span>
-<span class="sd">                    Base</span>
-
-<span class="sd">                       n [Base] [Recur] primrec</span>
-<span class="sd">              ------------------------------------------ n &gt; 0</span>
-<span class="sd">                 n (n-1) [Base] [Recur] primrec Recur</span>
-
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">recur</span><span class="p">,</span> <span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
-               <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-       <span class="k">else</span><span class="p">:</span>
-               <span class="n">expression</span> <span class="o">=</span> <span class="n">S_primrec</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">recur</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-               <span class="n">stack</span> <span class="o">=</span> <span class="n">recur</span><span class="p">,</span> <span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    From the &quot;Overview of the language JOY&quot;:</span>
+
+<span class="sd">    &gt; The primrec combinator expects two quoted programs in addition to a</span>
+<span class="sd">    data parameter. For an integer data parameter it works like this: If</span>
+<span class="sd">    the data parameter is zero, then the first quotation has to produce</span>
+<span class="sd">    the value to be returned. If the data parameter is positive then the</span>
+<span class="sd">    second has to combine the data parameter with the result of applying</span>
+<span class="sd">    the function to its predecessor.::</span>
+
+<span class="sd">        5  [1]  [*]  primrec</span>
+
+<span class="sd">    &gt; Then primrec tests whether the top element on the stack (initially</span>
+<span class="sd">    the 5) is equal to zero. If it is, it pops it off and executes one of</span>
+<span class="sd">    the quotations, the [1] which leaves 1 on the stack as the result.</span>
+<span class="sd">    Otherwise it pushes a decremented copy of the top element and</span>
+<span class="sd">    recurses. On the way back from the recursion it uses the other</span>
+<span class="sd">    quotation, [*], to multiply what is now a factorial on top of the</span>
+<span class="sd">    stack by the second element on the stack.::</span>
+
+<span class="sd">        n [Base] [Recur] primrec</span>
+
+<span class="sd">           0 [Base] [Recur] primrec</span>
+<span class="sd">        ------------------------------</span>
+<span class="sd">              Base</span>
+
+<span class="sd">             n [Base] [Recur] primrec</span>
+<span class="sd">        ------------------------------------------ n &gt; 0</span>
+<span class="sd">           n (n-1) [Base] [Recur] primrec Recur</span>
+
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">recur</span><span class="p">,</span> <span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+    <span class="k">else</span><span class="p">:</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">S_primrec</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">recur</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+        <span class="n">stack</span> <span class="o">=</span> <span class="n">recur</span><span class="p">,</span> <span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <span class="c1">#def cleave(S, expression, dictionary):</span>
 <div class="viewcode-block" id="branch"><a class="viewcode-back" href="../../library.html#joy.library.branch">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">branch</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Use a Boolean value to select one of two quoted programs to run.</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Use a Boolean value to select one of two quoted programs to run.</span>
 
-<span class="sd">      ::</span>
+<span class="sd">    ::</span>
 
-<span class="sd">              branch == roll&lt; choice i</span>
+<span class="sd">        branch == roll&lt; choice i</span>
 
-<span class="sd">      ::</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 False [F] [T] branch</span>
-<span class="sd">              --------------------------</span>
-<span class="sd">                        F</span>
+<span class="sd">           False [F] [T] branch</span>
+<span class="sd">        --------------------------</span>
+<span class="sd">              F</span>
 
-<span class="sd">                 True [F] [T] branch</span>
-<span class="sd">              -------------------------</span>
-<span class="sd">                           T</span>
+<span class="sd">           True [F] [T] branch</span>
+<span class="sd">        -------------------------</span>
+<span class="sd">                 T</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="p">(</span><span class="n">flag</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">then</span> <span class="k">if</span> <span class="n">flag</span> <span class="k">else</span> <span class="n">else_</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="p">(</span><span class="n">flag</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">then</span> <span class="k">if</span> <span class="n">flag</span> <span class="k">else</span> <span class="n">else_</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span></div>
 
 
 <span class="c1">##@inscribe</span>
 <div class="viewcode-block" id="cond"><a class="viewcode-back" href="../../library.html#joy.library.cond">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">cond</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      This combinator works like a case statement.  It expects a single quote</span>
-<span class="sd">      on the stack that must contain zero or more condition quotes and a </span>
-<span class="sd">      default quote.  Each condition clause should contain a quoted predicate</span>
-<span class="sd">      followed by the function expression to run if that predicate returns</span>
-<span class="sd">      true.  If no predicates return true the default function runs.</span>
-
-<span class="sd">      It works by rewriting into a chain of nested `ifte` expressions, e.g.::</span>
-
-<span class="sd">                    [[[B0] T0] [[B1] T1] [D]] cond</span>
-<span class="sd">              -----------------------------------------</span>
-<span class="sd">                 [B0] [T0] [[B1] [T1] [D] ifte] ifte</span>
-
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">conditions</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">if</span> <span class="n">conditions</span><span class="p">:</span>
-               <span class="n">expression</span> <span class="o">=</span> <span class="n">_cond</span><span class="p">(</span><span class="n">conditions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-               <span class="k">try</span><span class="p">:</span>
-                       <span class="c1"># Attempt to preload the args to first ifte.</span>
-                       <span class="p">(</span><span class="n">P</span><span class="p">,</span> <span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="p">(</span><span class="n">E</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span> <span class="o">=</span> <span class="n">expression</span>
-               <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
-                       <span class="c1"># If, for any reason, the argument to cond should happen to contain</span>
-                       <span class="c1"># only the default clause then this optimization will fail.</span>
-                       <span class="k">pass</span>
-               <span class="k">else</span><span class="p">:</span>
-                       <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">E</span><span class="p">,</span> <span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="p">(</span><span class="n">P</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span>
-       <span class="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></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    This combinator works like a case statement.  It expects a single quote</span>
+<span class="sd">    on the stack that must contain zero or more condition quotes and a </span>
+<span class="sd">    default quote.  Each condition clause should contain a quoted predicate</span>
+<span class="sd">    followed by the function expression to run if that predicate returns</span>
+<span class="sd">    true.  If no predicates return true the default function runs.</span>
+
+<span class="sd">    It works by rewriting into a chain of nested `ifte` expressions, e.g.::</span>
+
+<span class="sd">              [[[B0] T0] [[B1] T1] [D]] cond</span>
+<span class="sd">        -----------------------------------------</span>
+<span class="sd">           [B0] [T0] [[B1] [T1] [D] ifte] ifte</span>
+
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">conditions</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">if</span> <span class="n">conditions</span><span class="p">:</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">_cond</span><span class="p">(</span><span class="n">conditions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="c1"># Attempt to preload the args to first ifte.</span>
+            <span class="p">(</span><span class="n">P</span><span class="p">,</span> <span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="p">(</span><span class="n">E</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span> <span class="o">=</span> <span class="n">expression</span>
+        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+            <span class="c1"># If, for any reason, the argument to cond should happen to contain</span>
+            <span class="c1"># only the default clause then this optimization will fail.</span>
+            <span class="k">pass</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">E</span><span class="p">,</span> <span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="p">(</span><span class="n">P</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span>
+    <span class="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></div>
 
 
 <span class="k">def</span> <span class="nf">_cond</span><span class="p">(</span><span class="n">conditions</span><span class="p">,</span> <span class="n">expression</span><span class="p">):</span>
-       <span class="p">(</span><span class="n">clause</span><span class="p">,</span> <span class="n">rest</span><span class="p">)</span> <span class="o">=</span> <span class="n">conditions</span>
-       <span class="k">if</span> <span class="ow">not</span> <span class="n">rest</span><span class="p">:</span>  <span class="c1"># clause is [D]</span>
-               <span class="k">return</span> <span class="n">clause</span>
-       <span class="n">P</span><span class="p">,</span> <span class="n">T</span> <span class="o">=</span> <span class="n">clause</span>
-       <span class="k">return</span> <span class="p">(</span><span class="n">P</span><span class="p">,</span> <span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="p">(</span><span class="n">_cond</span><span class="p">(</span><span class="n">rest</span><span class="p">,</span> <span class="p">()),</span> <span class="p">(</span><span class="n">S_ifte</span><span class="p">,</span> <span class="n">expression</span><span class="p">))))</span>
+    <span class="p">(</span><span class="n">clause</span><span class="p">,</span> <span class="n">rest</span><span class="p">)</span> <span class="o">=</span> <span class="n">conditions</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">rest</span><span class="p">:</span>  <span class="c1"># clause is [D]</span>
+        <span class="k">return</span> <span class="n">clause</span>
+    <span class="n">P</span><span class="p">,</span> <span class="n">T</span> <span class="o">=</span> <span class="n">clause</span>
+    <span class="k">return</span> <span class="p">(</span><span class="n">P</span><span class="p">,</span> <span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="p">(</span><span class="n">_cond</span><span class="p">(</span><span class="n">rest</span><span class="p">,</span> <span class="p">()),</span> <span class="p">(</span><span class="n">S_ifte</span><span class="p">,</span> <span class="n">expression</span><span class="p">))))</span>
 
 
 <div class="viewcode-block" id="dip"><a class="viewcode-back" href="../../library.html#joy.library.dip">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">dip</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      The dip combinator expects a quoted program on the stack and below it</span>
-<span class="sd">      some item, it hoists the item into the expression and runs the program</span>
-<span class="sd">      on the rest of the stack.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    The dip combinator expects a quoted program on the stack and below it</span>
+<span class="sd">    some item, it hoists the item into the expression and runs the program</span>
+<span class="sd">    on the rest of the stack.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 ... x [Q] dip</span>
-<span class="sd">              -------------------</span>
-<span class="sd">                   ... Q x</span>
+<span class="sd">           ... x [Q] dip</span>
+<span class="sd">        -------------------</span>
+<span class="sd">             ... Q x</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
 
 
 <div class="viewcode-block" id="dipd"><a class="viewcode-back" href="../../library.html#joy.library.dipd">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">dipd</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Like dip but expects two items.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Like dip but expects two items.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 ... y x [Q] dip</span>
-<span class="sd">              ---------------------</span>
-<span class="sd">                   ... Q y x</span>
+<span class="sd">           ... y x [Q] dip</span>
+<span class="sd">        ---------------------</span>
+<span class="sd">             ... Q y x</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
 
 
 <div class="viewcode-block" id="dipdd"><a class="viewcode-back" href="../../library.html#joy.library.dipdd">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">dipdd</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Like dip but expects three items.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Like dip but expects three items.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 ... z y x [Q] dip</span>
-<span class="sd">              -----------------------</span>
-<span class="sd">                   ... Q z y x</span>
+<span class="sd">           ... z y x [Q] dip</span>
+<span class="sd">        -----------------------</span>
+<span class="sd">             ... Q z y x</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</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></div>
 
 
 <div class="viewcode-block" id="app1"><a class="viewcode-back" href="../../library.html#joy.library.app1">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">app1</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Given a quoted program on TOS and anything as the second stack item run</span>
-<span class="sd">      the program and replace the two args with the first result of the</span>
-<span class="sd">      program.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Given a quoted program on TOS and anything as the second stack item run</span>
+<span class="sd">    the program and replace the two args with the first result of the</span>
+<span class="sd">    program.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                       ... x [Q] . app1</span>
-<span class="sd">              -----------------------------------</span>
-<span class="sd">                 ... [x ...] [Q] . infra first</span>
+<span class="sd">             ... x [Q] . app1</span>
+<span class="sd">        -----------------------------------</span>
+<span class="sd">           ... [x ...] [Q] . infra first</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">((</span><span class="n">x</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="n">stack</span><span class="p">))</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">((</span><span class="n">x</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="n">stack</span><span class="p">))</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="app2"><a class="viewcode-back" href="../../library.html#joy.library.app2">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">app2</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;Like app1 with two items.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;Like app1 with two items.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                     ... y x [Q] . app2</span>
-<span class="sd">              -----------------------------------</span>
-<span class="sd">                 ... [y ...] [Q] . infra first</span>
-<span class="sd">                     [x ...] [Q]   infra first</span>
+<span class="sd">               ... y x [Q] . app2</span>
+<span class="sd">        -----------------------------------</span>
+<span class="sd">           ... [y ...] [Q] . infra first</span>
+<span class="sd">               [x ...] [Q]   infra first</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</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="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span>
-                       <span class="n">expression</span><span class="p">))))))</span>
-       <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">((</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="n">stack</span><span class="p">))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</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="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span>
+            <span class="n">expression</span><span class="p">))))))</span>
+    <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">((</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="n">stack</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="app3"><a class="viewcode-back" href="../../library.html#joy.library.app3">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">app3</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;Like app1 with three items.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;Like app1 with three items.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                   ... z y x [Q] . app3</span>
-<span class="sd">              -----------------------------------</span>
-<span class="sd">                 ... [z ...] [Q] . infra first</span>
-<span class="sd">                     [y ...] [Q]   infra first</span>
-<span class="sd">                     [x ...] [Q]   infra first</span>
+<span class="sd">             ... z y x [Q] . app3</span>
+<span class="sd">        -----------------------------------</span>
+<span class="sd">           ... [z ...] [Q] . infra first</span>
+<span class="sd">               [y ...] [Q]   infra first</span>
+<span class="sd">               [x ...] [Q]   infra first</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span>
-               <span class="p">((</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</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="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span>
-                       <span class="n">expression</span><span class="p">))))))))))</span>
-       <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">((</span><span class="n">z</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="n">stack</span><span class="p">))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span>
+        <span class="p">((</span><span class="n">y</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</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="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_infra</span><span class="p">,</span> <span class="p">(</span><span class="n">S_first</span><span class="p">,</span>
+            <span class="n">expression</span><span class="p">))))))))))</span>
+    <span class="n">stack</span> <span class="o">=</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">((</span><span class="n">z</span><span class="p">,</span> <span class="n">stack</span><span class="p">),</span> <span class="n">stack</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="step"><a class="viewcode-back" href="../../library.html#joy.library.step">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">step</span><span class="p">(</span><span class="n">S</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Run a quoted program on each item in a sequence.</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Run a quoted program on each item in a sequence.</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 ... [] [Q] . step</span>
-<span class="sd">              -----------------------</span>
-<span class="sd">                        ... .</span>
+<span class="sd">           ... [] [Q] . step</span>
+<span class="sd">        -----------------------</span>
+<span class="sd">              ... .</span>
 
 
-<span class="sd">                 ... [a] [Q] . step</span>
-<span class="sd">              ------------------------</span>
-<span class="sd">                       ... a . Q</span>
+<span class="sd">           ... [a] [Q] . step</span>
+<span class="sd">        ------------------------</span>
+<span class="sd">             ... a . Q</span>
 
 
-<span class="sd">                 ... [a b c] [Q] . step</span>
-<span class="sd">              ----------------------------------------</span>
-<span class="sd">                           ... a . Q [b c] [Q] step</span>
+<span class="sd">           ... [a b c] [Q] . step</span>
+<span class="sd">        ----------------------------------------</span>
+<span class="sd">                 ... a . Q [b c] [Q] step</span>
 
-<span class="sd">      The step combinator executes the quotation on each member of the list</span>
-<span class="sd">      on top of the stack.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">aggregate</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
-       <span class="k">if</span> <span class="ow">not</span> <span class="n">aggregate</span><span class="p">:</span>
-               <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span>
-       <span class="n">head</span><span class="p">,</span> <span class="n">tail</span> <span class="o">=</span> <span class="n">aggregate</span>
-       <span class="n">stack</span> <span class="o">=</span> <span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">head</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
-       <span class="k">if</span> <span class="n">tail</span><span class="p">:</span>
-               <span class="n">expression</span> <span class="o">=</span> <span class="n">tail</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_step</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="n">S_i</span><span class="p">,</span> <span class="n">expression</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+<span class="sd">    The step combinator executes the quotation on each member of the list</span>
+<span class="sd">    on top of the stack.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">aggregate</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">S</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">aggregate</span><span class="p">:</span>
+        <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span>
+    <span class="n">head</span><span class="p">,</span> <span class="n">tail</span> <span class="o">=</span> <span class="n">aggregate</span>
+    <span class="n">stack</span> <span class="o">=</span> <span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">head</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">tail</span><span class="p">:</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">tail</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_step</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="n">S_i</span><span class="p">,</span> <span class="n">expression</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="times"><a class="viewcode-back" href="../../library.html#joy.library.times">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">times</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      times == [-- dip] cons [swap] infra [0 &gt;] swap while pop</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    times == [-- dip] cons [swap] infra [0 &gt;] swap while pop</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 ... n [Q] . times</span>
-<span class="sd">              ---------------------  w/ n &lt;= 0</span>
-<span class="sd">                       ... .</span>
+<span class="sd">           ... n [Q] . times</span>
+<span class="sd">        ---------------------  w/ n &lt;= 0</span>
+<span class="sd">             ... .</span>
 
 
-<span class="sd">                 ... 1 [Q] . times</span>
-<span class="sd">              -----------------------</span>
-<span class="sd">                       ... . Q</span>
+<span class="sd">           ... 1 [Q] . times</span>
+<span class="sd">        -----------------------</span>
+<span class="sd">             ... . Q</span>
 
 
-<span class="sd">                 ... n [Q] . times</span>
-<span class="sd">              -------------------------------------  w/ n &gt; 1</span>
-<span class="sd">                       ... . Q (n - 1) [Q] times</span>
+<span class="sd">           ... n [Q] . times</span>
+<span class="sd">        -------------------------------------  w/ n &gt; 1</span>
+<span class="sd">             ... . Q (n - 1) [Q] times</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="c1"># times == [-- dip] cons [swap] infra [0 &gt;] swap while pop</span>
-       <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
-               <span class="k">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>
-       <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
-       <span class="k">if</span> <span class="n">n</span><span class="p">:</span>
-               <span class="n">expression</span> <span class="o">=</span> <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_times</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</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="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></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="c1"># times == [-- dip] cons [swap] infra [0 &gt;] swap while pop</span>
+    <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
+        <span class="k">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>
+    <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
+    <span class="k">if</span> <span class="n">n</span><span class="p">:</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">n</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_times</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</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="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></div>
 
 
 <span class="c1"># The current definition above works like this:</span>
 <div class="viewcode-block" id="loop"><a class="viewcode-back" href="../../library.html#joy.library.loop">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">loop</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Basic loop combinator.</span>
-<span class="sd">      ::</span>
-
-<span class="sd">                 ... True [Q] loop</span>
-<span class="sd">              -----------------------</span>
-<span class="sd">                    ... Q [Q] loop</span>
-
-<span class="sd">                 ... False [Q] loop</span>
-<span class="sd">              ------------------------</span>
-<span class="sd">                        ...</span>
-
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">flag</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">if</span> <span class="n">flag</span><span class="p">:</span>
-               <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_loop</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Basic loop combinator.</span>
+<span class="sd">    ::</span>
+
+<span class="sd">           ... True [Q] loop</span>
+<span class="sd">        -----------------------</span>
+<span class="sd">              ... Q [Q] loop</span>
+
+<span class="sd">           ... False [Q] loop</span>
+<span class="sd">        ------------------------</span>
+<span class="sd">              ...</span>
+
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="n">quote</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
+        <span class="k">raise</span> <span class="n">NotAListError</span><span class="p">(</span><span class="s1">&#39;Loop body not a list.&#39;</span><span class="p">)</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="p">(</span><span class="n">flag</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">flag</span><span class="p">:</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="p">(</span><span class="n">S_loop</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <div class="viewcode-block" id="cmp_"><a class="viewcode-back" href="../../library.html#joy.library.cmp_">[docs]</a><span class="nd">@inscribe</span>
 <span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">cmp_</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="sd">&#39;&#39;&#39;</span>
-<span class="sd">      cmp takes two values and three quoted programs on the stack and runs</span>
-<span class="sd">      one of the three depending on the results of comparing the two values:</span>
-<span class="sd">      ::</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    cmp takes two values and three quoted programs on the stack and runs</span>
+<span class="sd">    one of the three depending on the results of comparing the two values:</span>
+<span class="sd">    ::</span>
 
-<span class="sd">                 a b [G] [E] [L] cmp</span>
-<span class="sd">              ------------------------- a &gt; b</span>
-<span class="sd">                      G</span>
+<span class="sd">           a b [G] [E] [L] cmp</span>
+<span class="sd">        ------------------------- a &gt; b</span>
+<span class="sd">            G</span>
 
-<span class="sd">                 a b [G] [E] [L] cmp</span>
-<span class="sd">              ------------------------- a = b</span>
-<span class="sd">                          E</span>
+<span class="sd">           a b [G] [E] [L] cmp</span>
+<span class="sd">        ------------------------- a = b</span>
+<span class="sd">                E</span>
 
-<span class="sd">                 a b [G] [E] [L] cmp</span>
-<span class="sd">              ------------------------- a &lt; b</span>
-<span class="sd">                              L</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">L</span><span class="p">,</span> <span class="p">(</span><span class="n">E</span><span class="p">,</span> <span class="p">(</span><span class="n">G</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">G</span> <span class="k">if</span> <span class="n">a</span> <span class="o">&gt;</span> <span class="n">b</span> <span class="k">else</span> <span class="n">L</span> <span class="k">if</span> <span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span> <span class="k">else</span> <span class="n">E</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
+<span class="sd">           a b [G] [E] [L] cmp</span>
+<span class="sd">        ------------------------- a &lt; b</span>
+<span class="sd">                L</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">L</span><span class="p">,</span> <span class="p">(</span><span class="n">E</span><span class="p">,</span> <span class="p">(</span><span class="n">G</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="n">expression</span> <span class="o">=</span> <span class="n">concat</span><span class="p">(</span><span class="n">G</span> <span class="k">if</span> <span class="n">a</span> <span class="o">&gt;</span> <span class="n">b</span> <span class="k">else</span> <span class="n">L</span> <span class="k">if</span> <span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span> <span class="k">else</span> <span class="n">E</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
 
 
 <span class="c1">#  FunctionWrapper(cleave),</span>
 
 <span class="k">for</span> <span class="n">F</span> <span class="ow">in</span> <span class="p">(</span>
 
-       <span class="c1">#divmod_ = pm = __(n2, n1), __(n4, n3)</span>
-
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">eq</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">ge</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">gt</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">le</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">lt</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">ne</span><span class="p">),</span>
-
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">xor</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">lshift</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">rshift</span><span class="p">),</span>
-
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">and_</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">or_</span><span class="p">),</span>
-
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">floordiv</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">mod</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">mul</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">pow</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">sub</span><span class="p">),</span>
-       <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">truediv</span><span class="p">),</span>
-
-       <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="nb">bool</span><span class="p">),</span>
-       <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">not_</span><span class="p">),</span>
-
-       <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="nb">abs</span><span class="p">),</span>
-       <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">neg</span><span class="p">),</span>
-       <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">sqrt</span><span class="p">),</span>
-
-       <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">floor</span><span class="p">),</span>
-       <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="nb">round</span><span class="p">),</span>
-       <span class="p">):</span>
-       <span class="n">inscribe</span><span class="p">(</span><span class="n">F</span><span class="p">)</span>
+    <span class="c1">#divmod_ = pm = __(n2, n1), __(n4, n3)</span>
+
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">eq</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">ge</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">gt</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">le</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">lt</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">ne</span><span class="p">),</span>
+
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">xor</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">lshift</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">rshift</span><span class="p">),</span>
+
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">and_</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">or_</span><span class="p">),</span>
+
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">floordiv</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">mod</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">mul</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">pow</span><span class="p">),</span>
+    <span class="n">BinaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">sub</span><span class="p">),</span>
+<span class="c1">##    BinaryBuiltinWrapper(operator.truediv),</span>
+
+    <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="nb">bool</span><span class="p">),</span>
+    <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">not_</span><span class="p">),</span>
+
+    <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="nb">abs</span><span class="p">),</span>
+    <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">neg</span><span class="p">),</span>
+    <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">sqrt</span><span class="p">),</span>
+
+    <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="n">floor</span><span class="p">),</span>
+    <span class="n">UnaryBuiltinWrapper</span><span class="p">(</span><span class="nb">round</span><span class="p">),</span>
+    <span class="p">):</span>
+    <span class="n">inscribe</span><span class="p">(</span><span class="n">F</span><span class="p">)</span>
 <span class="k">del</span> <span class="n">F</span>  <span class="c1"># Otherwise Sphinx autodoc will pick it up.</span>
 
 
 <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">primitive</span> <span class="ow">in</span> <span class="n">getmembers</span><span class="p">(</span><span class="n">genlib</span><span class="p">,</span> <span class="n">isfunction</span><span class="p">):</span>
-       <span class="n">inscribe</span><span class="p">(</span><span class="n">SimpleFunctionWrapper</span><span class="p">(</span><span class="n">primitive</span><span class="p">))</span>
+    <span class="n">inscribe</span><span class="p">(</span><span class="n">SimpleFunctionWrapper</span><span class="p">(</span><span class="n">primitive</span><span class="p">))</span>
 
 
 <span class="n">add_aliases</span><span class="p">(</span><span class="n">_dictionary</span><span class="p">,</span> <span class="n">ALIASES</span><span class="p">)</span>
 </pre></div>
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="../../notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../../index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index f63bdaf..46f58ec 100644 (file)
@@ -1,19 +1,17 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>joy.parser &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../../_static/jquery.js"></script>
-    <script type="text/javascript" src="../../_static/underscore.js"></script>
-    <script type="text/javascript" src="../../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../../_static/alabaster.css" />
+    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
+    <script src="../../_static/jquery.js"></script>
+    <script src="../../_static/underscore.js"></script>
+    <script src="../../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../../genindex.html" />
     <link rel="search" title="Search" href="../../search.html" />
    
@@ -28,6 +26,8 @@
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
   <h1>Source code for joy.parser</h1><div class="highlight"><pre>
 <span class="sd">around square brackets.</span>
 
 <span class="sd">&#39;&#39;&#39;</span>
-<span class="kn">from</span> <span class="nn">re</span> <span class="k">import</span> <span class="n">Scanner</span>
-<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="k">import</span> <span class="n">list_to_stack</span>
+<span class="kn">from</span> <span class="nn">re</span> <span class="kn">import</span> <span class="n">Scanner</span>
+<span class="kn">from</span> <span class="nn">.utils.stack</span> <span class="kn">import</span> <span class="n">list_to_stack</span>
 
 
-<span class="c1">#TODO: explain the details of float lits and strings.</span>
-<span class="n">FLOAT</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;-?\d+\.\d*(e(-|\+)\d+)?&#39;</span>
-<span class="n">INT</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;-?\d+&#39;</span>
-<span class="n">SYMBOL</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;[•\w!@$%^&amp;*()_+&lt;&gt;?|\/;:`~,.=-]+&#39;</span>
 <span class="n">BRACKETS</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;\[|\]&#39;</span>
-<span class="n">STRING_DOUBLE_QUOTED</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;&quot;(?:[^&quot;</span><span class="se">\\</span><span class="s1">]|</span><span class="se">\\</span><span class="s1">.)*&quot;&#39;</span>
-<span class="n">STRING_SINGLE_QUOTED</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;&#39;(?:[^&#39;</span><span class="se">\\</span><span class="s2">]|</span><span class="se">\\</span><span class="s2">.)*&#39;&quot;</span>
 <span class="n">BLANKS</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;\s+&#39;</span>
+<span class="n">WORDS</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;[^[\]\s]+&#39;</span>
+
+
+<span class="n">token_scanner</span> <span class="o">=</span> <span class="n">Scanner</span><span class="p">([</span>
+    <span class="p">(</span><span class="n">BRACKETS</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">token</span><span class="p">),</span>
+    <span class="p">(</span><span class="n">BLANKS</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span>
+    <span class="p">(</span><span class="n">WORDS</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">token</span><span class="p">),</span>
+    <span class="p">])</span>
 
 
 <div class="viewcode-block" id="Symbol"><a class="viewcode-back" href="../../parser.html#joy.parser.Symbol">[docs]</a><span class="k">class</span> <span class="nc">Symbol</span><span class="p">(</span><span class="nb">str</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;A string class that represents Joy function names.&#39;&#39;&#39;</span>
-       <span class="fm">__repr__</span> <span class="o">=</span> <span class="nb">str</span><span class="o">.</span><span class="fm">__str__</span></div>
+    <span class="sd">&#39;&#39;&#39;A string class that represents Joy function names.&#39;&#39;&#39;</span>
+    <span class="fm">__repr__</span> <span class="o">=</span> <span class="nb">str</span><span class="o">.</span><span class="fm">__str__</span></div>
 
 
 <div class="viewcode-block" id="text_to_expression"><a class="viewcode-back" href="../../parser.html#joy.parser.text_to_expression">[docs]</a><span class="k">def</span> <span class="nf">text_to_expression</span><span class="p">(</span><span class="n">text</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Convert a string to a Joy expression.</span>
+    <span class="sd">&#39;&#39;&#39;Convert a string to a Joy expression.</span>
 
-<span class="sd">      When supplied with a string this function returns a Python datastructure</span>
-<span class="sd">      that represents the Joy datastructure described by the text expression.</span>
-<span class="sd">      Any unbalanced square brackets will raise a ParseError.</span>
+<span class="sd">    When supplied with a string this function returns a Python datastructure</span>
+<span class="sd">    that represents the Joy datastructure described by the text expression.</span>
+<span class="sd">    Any unbalanced square brackets will raise a ParseError.</span>
 
-<span class="sd">      :param str text: Text to convert.</span>
-<span class="sd">      :rtype: stack</span>
-<span class="sd">      :raises ParseError: if the parse fails.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">return</span> <span class="n">_parse</span><span class="p">(</span><span class="n">_tokenize</span><span class="p">(</span><span class="n">text</span><span class="p">))</span></div>
+<span class="sd">    :param str text: Text to convert.</span>
+<span class="sd">    :rtype: stack</span>
+<span class="sd">    :raises ParseError: if the parse fails.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">return</span> <span class="n">_parse</span><span class="p">(</span><span class="n">_tokenize</span><span class="p">(</span><span class="n">text</span><span class="p">))</span></div>
 
 
 <div class="viewcode-block" id="ParseError"><a class="viewcode-back" href="../../parser.html#joy.parser.ParseError">[docs]</a><span class="k">class</span> <span class="nc">ParseError</span><span class="p">(</span><span class="ne">ValueError</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Raised when there is a error while parsing text.&#39;&#39;&#39;</span></div>
+    <span class="sd">&#39;&#39;&#39;Raised when there is a error while parsing text.&#39;&#39;&#39;</span></div>
 
 
 <span class="k">def</span> <span class="nf">_tokenize</span><span class="p">(</span><span class="n">text</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Convert a text into a stream of tokens.</span>
+    <span class="sd">&#39;&#39;&#39;Convert a text into a stream of tokens.</span>
 
-<span class="sd">      Converts function names to Symbols.</span>
+<span class="sd">    Converts function names to Symbols.</span>
 
-<span class="sd">      Raise ParseError (with some of the failing text) if the scan fails.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">tokens</span><span class="p">,</span> <span class="n">rest</span> <span class="o">=</span> <span class="n">_scanner</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
-       <span class="k">if</span> <span class="n">rest</span><span class="p">:</span>
-               <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span>
-                       <span class="s1">&#39;Scan failed at position </span><span class="si">%i</span><span class="s1">, </span><span class="si">%r</span><span class="s1">&#39;</span>
-                       <span class="o">%</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">rest</span><span class="p">),</span> <span class="n">rest</span><span class="p">[:</span><span class="mi">10</span><span class="p">])</span>
-                       <span class="p">)</span>
-       <span class="k">return</span> <span class="n">tokens</span>
+<span class="sd">    Raise ParseError (with some of the failing text) if the scan fails.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">tokens</span><span class="p">,</span> <span class="n">rest</span> <span class="o">=</span> <span class="n">token_scanner</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">rest</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span>
+            <span class="s1">&#39;Scan failed at position </span><span class="si">%i</span><span class="s1">, </span><span class="si">%r</span><span class="s1">&#39;</span>
+            <span class="o">%</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">rest</span><span class="p">),</span> <span class="n">rest</span><span class="p">[:</span><span class="mi">10</span><span class="p">])</span>
+            <span class="p">)</span>
+    <span class="k">return</span> <span class="n">tokens</span>
 
 
 <span class="k">def</span> <span class="nf">_parse</span><span class="p">(</span><span class="n">tokens</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Return a stack/list expression of the tokens.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
-       <span class="n">stack</span> <span class="o">=</span> <span class="p">[]</span>
-       <span class="k">for</span> <span class="n">tok</span> <span class="ow">in</span> <span class="n">tokens</span><span class="p">:</span>
-               <span class="k">if</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;[&#39;</span><span class="p">:</span>
-                       <span class="n">stack</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
-                       <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
-                       <span class="n">stack</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
-               <span class="k">elif</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;]&#39;</span><span class="p">:</span>
-                       <span class="k">try</span><span class="p">:</span>
-                               <span class="n">frame</span> <span class="o">=</span> <span class="n">stack</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
-                       <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
-                               <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="s1">&#39;Extra closing bracket.&#39;</span><span class="p">)</span>
-                       <span class="n">frame</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">frame</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
-               <span class="k">else</span><span class="p">:</span>
-                       <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tok</span><span class="p">)</span>
-       <span class="k">if</span> <span class="n">stack</span><span class="p">:</span>
-               <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="s1">&#39;Unclosed bracket.&#39;</span><span class="p">)</span>
-       <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
-
-
-<span class="n">_scanner</span> <span class="o">=</span> <span class="n">Scanner</span><span class="p">([</span>
-       <span class="p">(</span><span class="n">FLOAT</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">token</span><span class="p">)),</span>
-       <span class="p">(</span><span class="n">INT</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="n">token</span><span class="p">)),</span>
-       <span class="p">(</span><span class="n">SYMBOL</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">Symbol</span><span class="p">(</span><span class="n">token</span><span class="p">)),</span>
-       <span class="p">(</span><span class="n">BRACKETS</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">token</span><span class="p">),</span>
-       <span class="p">(</span><span class="n">STRING_DOUBLE_QUOTED</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">token</span><span class="p">[</span><span class="mi">1</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">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\\</span><span class="s1">&quot;&#39;</span><span class="p">,</span> <span class="s1">&#39;&quot;&#39;</span><span class="p">)),</span>
-       <span class="p">(</span><span class="n">STRING_SINGLE_QUOTED</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">_</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">token</span><span class="p">[</span><span class="mi">1</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">replace</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&#39;&quot;</span><span class="p">,</span> <span class="s2">&quot;&#39;&quot;</span><span class="p">)),</span>
-       <span class="p">(</span><span class="n">BLANKS</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span>
-       <span class="p">])</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Return a stack/list expression of the tokens.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
+    <span class="n">stack</span> <span class="o">=</span> <span class="p">[]</span>
+    <span class="k">for</span> <span class="n">tok</span> <span class="ow">in</span> <span class="n">tokens</span><span class="p">:</span>
+        <span class="k">if</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;[&#39;</span><span class="p">:</span>
+            <span class="n">stack</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
+            <span class="n">frame</span> <span class="o">=</span> <span class="p">[]</span>
+        <span class="k">elif</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;]&#39;</span><span class="p">:</span>
+            <span class="n">v</span> <span class="o">=</span> <span class="n">frame</span>
+            <span class="k">try</span><span class="p">:</span> <span class="n">frame</span> <span class="o">=</span> <span class="n">stack</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
+            <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
+                <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="s1">&#39;Extra closing bracket.&#39;</span><span class="p">)</span>
+            <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">list_to_stack</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
+        <span class="k">elif</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;true&#39;</span><span class="p">:</span>
+            <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
+        <span class="k">elif</span> <span class="n">tok</span> <span class="o">==</span> <span class="s1">&#39;false&#39;</span><span class="p">:</span>
+            <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">thing</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">tok</span><span class="p">)</span>
+            <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+                <span class="n">thing</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="n">tok</span><span class="p">)</span>
+            <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">thing</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">stack</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="s1">&#39;Unclosed bracket.&#39;</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">list_to_stack</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
 </pre></div>
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="../../notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../../index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
diff --git a/docs/sphinx_docs/_build/html/_modules/joy/utils/generated_library.html b/docs/sphinx_docs/_build/html/_modules/joy/utils/generated_library.html
new file mode 100644 (file)
index 0000000..806e479
--- /dev/null
@@ -0,0 +1,519 @@
+
+<!DOCTYPE html>
+
+<html>
+  <head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>joy.utils.generated_library &#8212; Thun 0.4.1 documentation</title>
+    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
+    <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
+    <script src="../../../_static/jquery.js"></script>
+    <script src="../../../_static/underscore.js"></script>
+    <script src="../../../_static/doctools.js"></script>
+    <link rel="index" title="Index" href="../../../genindex.html" />
+    <link rel="search" title="Search" href="../../../search.html" />
+   
+  <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" />
+  
+  
+  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
+
+  </head><body>
+  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          
+
+          <div class="body" role="main">
+            
+  <h1>Source code for joy.utils.generated_library</h1><div class="highlight"><pre>
+<span></span><span class="c1"># GENERATED FILE. DO NOT EDIT.</span>
+<span class="c1"># The code that generated these functions is in the repo history</span>
+<span class="c1"># at the v0.4.0 tag.</span>
+<span class="kn">from</span> <span class="nn">.errors</span> <span class="kn">import</span> <span class="n">NotAListError</span><span class="p">,</span> <span class="n">StackUnderflowError</span>
+
+
+<span class="k">def</span> <span class="nf">_Tree_add_Ee</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="p">((</span><span class="n">a4</span><span class="p">,</span> <span class="p">(</span><span class="n">a5</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">((</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">)</span>
+
+
+<span class="k">def</span> <span class="nf">_Tree_delete_R0</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a2 ...1] a1 -- [a2 ...1] a2 a1 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">((</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="n">s2</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">((</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="n">s2</span><span class="p">))))</span>
+
+
+<span class="k">def</span> <span class="nf">_Tree_delete_clear_stuff</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a3 a2 [a1 ...1] -- [...1])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s2</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span>
+
+
+<span class="k">def</span> <span class="nf">_Tree_get_E</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a3 a4 ...1] a2 a1 -- a4)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">((</span><span class="n">a3</span><span class="p">,</span> <span class="p">(</span><span class="n">a4</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a4</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span>
+
+
+<div class="viewcode-block" id="ccons"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.ccons">[docs]</a><span class="k">def</span> <span class="nf">ccons</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a2 a1 [...1] -- [a2 a1 ...1])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s2</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">((</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="cons"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.cons">[docs]</a><span class="k">def</span> <span class="nf">cons</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a1 [...0] -- [a1 ...0])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="k">try</span><span class="p">:</span> <span class="n">s0</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+  <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">s0</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span> <span class="k">raise</span> <span class="n">NotAListError</span><span class="p">(</span><span class="s1">&#39;Not a list.&#39;</span><span class="p">)</span>
+  <span class="k">try</span><span class="p">:</span> <span class="n">a1</span><span class="p">,</span> <span class="n">s23</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+  <span class="k">return</span> <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="n">s0</span><span class="p">),</span> <span class="n">s23</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="dup"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.dup">[docs]</a><span class="k">def</span> <span class="nf">dup</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a1 -- a1 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span></div>
+
+
+<div class="viewcode-block" id="dupd"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.dupd">[docs]</a><span class="k">def</span> <span class="nf">dupd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a2 a1 -- a2 a2 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span></div>
+
+
+<div class="viewcode-block" id="dupdd"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.dupdd">[docs]</a><span class="k">def</span> <span class="nf">dupdd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a3 a2 a1 -- a3 a3 a2 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s23</span><span class="p">))))</span></div>
+
+
+<div class="viewcode-block" id="first"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.first">[docs]</a><span class="k">def</span> <span class="nf">first</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 ...1] -- a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="n">s23</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="first_two"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.first_two">[docs]</a><span class="k">def</span> <span class="nf">first_two</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 a2 ...1] -- a1 a2)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s2</span><span class="p">))</span></div>
+
+
+<div class="viewcode-block" id="fourth"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.fourth">[docs]</a><span class="k">def</span> <span class="nf">fourth</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 a2 a3 a4 ...1] -- a4)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="p">(</span><span class="n">a4</span><span class="p">,</span> <span class="n">s1</span><span class="p">)))),</span> <span class="n">s2</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a4</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="over"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.over">[docs]</a><span class="k">def</span> <span class="nf">over</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a2 a1 -- a2 a1 a2)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span></div>
+
+
+<div class="viewcode-block" id="pop"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.pop">[docs]</a><span class="k">def</span> <span class="nf">pop</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a1 --)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="k">try</span><span class="p">:</span>
+    <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+    <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Cannot pop empty stack.&#39;</span><span class="p">)</span>
+  <span class="k">return</span> <span class="n">s23</span></div>
+
+
+<div class="viewcode-block" id="popd"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.popd">[docs]</a><span class="k">def</span> <span class="nf">popd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a2 a1 -- a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="popdd"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.popdd">[docs]</a><span class="k">def</span> <span class="nf">popdd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a3 a2 a1 -- a2 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span></div>
+
+
+<div class="viewcode-block" id="popop"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.popop">[docs]</a><span class="k">def</span> <span class="nf">popop</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a2 a1 --)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="n">s23</span></div>
+
+
+<div class="viewcode-block" id="popopd"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.popopd">[docs]</a><span class="k">def</span> <span class="nf">popopd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a3 a2 a1 -- a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="popopdd"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.popopdd">[docs]</a><span class="k">def</span> <span class="nf">popopdd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a4 a3 a2 a1 -- a2 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="p">(</span><span class="n">a4</span><span class="p">,</span> <span class="n">s23</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span></div>
+
+
+<div class="viewcode-block" id="rest"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.rest">[docs]</a><span class="k">def</span> <span class="nf">rest</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 ...0] -- [...0])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="k">try</span><span class="p">:</span>
+    <span class="n">s0</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+    <span class="k">raise</span> <span class="n">StackUnderflowError</span>
+  <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">s0</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
+    <span class="k">raise</span> <span class="n">NotAListError</span><span class="p">(</span><span class="s1">&#39;Not a list.&#39;</span><span class="p">)</span>
+  <span class="k">try</span><span class="p">:</span>
+    <span class="n">_</span><span class="p">,</span> <span class="n">s1</span> <span class="o">=</span> <span class="n">s0</span>
+  <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+    <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Cannot take rest of empty list.&#39;</span><span class="p">)</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="rolldown"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.rolldown">[docs]</a><span class="k">def</span> <span class="nf">rolldown</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a1 a2 a3 -- a2 a3 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span></div>
+
+
+<div class="viewcode-block" id="rollup"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.rollup">[docs]</a><span class="k">def</span> <span class="nf">rollup</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a1 a2 a3 -- a3 a1 a2)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span></div>
+
+
+<div class="viewcode-block" id="rrest"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.rrest">[docs]</a><span class="k">def</span> <span class="nf">rrest</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 a2 ...1] -- [...1])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="second"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.second">[docs]</a><span class="k">def</span> <span class="nf">second</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 a2 ...1] -- a2)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="stack"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.stack">[docs]</a><span class="k">def</span> <span class="nf">stack</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (... -- ... [...])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="n">s0</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s0</span><span class="p">,</span> <span class="n">s0</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="stuncons"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.stuncons">[docs]</a><span class="k">def</span> <span class="nf">stuncons</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (... a1 -- ... a1 a1 [...])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">)))</span></div>
+
+
+<div class="viewcode-block" id="stununcons"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.stununcons">[docs]</a><span class="k">def</span> <span class="nf">stununcons</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (... a2 a1 -- ... a2 a1 a1 a2 [...])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">)))))</span></div>
+
+
+<div class="viewcode-block" id="swaack"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.swaack">[docs]</a><span class="k">def</span> <span class="nf">swaack</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([...1] -- [...0])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="k">try</span><span class="p">:</span>
+    <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s0</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+    <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+  <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
+    <span class="k">raise</span> <span class="n">NotAListError</span><span class="p">(</span><span class="s1">&#39;Not a list.&#39;</span><span class="p">)</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s0</span><span class="p">,</span> <span class="n">s1</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="swap"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.swap">[docs]</a><span class="k">def</span> <span class="nf">swap</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a1 a2 -- a2 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="k">try</span><span class="p">:</span>
+    <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+    <span class="k">raise</span> <span class="n">StackUnderflowError</span><span class="p">(</span><span class="s1">&#39;Not enough values on stack.&#39;</span><span class="p">)</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span></div>
+
+
+<div class="viewcode-block" id="swons"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.swons">[docs]</a><span class="k">def</span> <span class="nf">swons</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([...1] a1 -- [a1 ...1])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="n">s2</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="third"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.third">[docs]</a><span class="k">def</span> <span class="nf">third</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 a2 a3 ...1] -- a3)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s1</span><span class="p">))),</span> <span class="n">s2</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="tuck"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.tuck">[docs]</a><span class="k">def</span> <span class="nf">tuck</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a2 a1 -- a1 a2 a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)))</span></div>
+
+
+<div class="viewcode-block" id="uncons"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.uncons">[docs]</a><span class="k">def</span> <span class="nf">uncons</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 ...0] -- a1 [...0])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="n">s0</span><span class="p">),</span> <span class="n">s23</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">s0</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">))</span></div>
+
+
+<div class="viewcode-block" id="unit"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.unit">[docs]</a><span class="k">def</span> <span class="nf">unit</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    (a1 -- [a1 ])</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s23</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="p">()),</span> <span class="n">s23</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="unswons"><a class="viewcode-back" href="../../../library.html#joy.utils.generated_library.unswons">[docs]</a><span class="k">def</span> <span class="nf">unswons</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+  <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">  ::</span>
+
+<span class="sd">    ([a1 ...1] -- [...1] a1)</span>
+
+<span class="sd">  &quot;&quot;&quot;</span>
+  <span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="n">s2</span><span class="p">)</span> <span class="o">=</span> <span class="n">stack</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">))</span></div>
+
+</pre></div>
+
+          </div>
+          
+        </div>
+      </div>
+      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../../../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
+<h3>Related Topics</h3>
+<ul>
+  <li><a href="../../../index.html">Documentation overview</a><ul>
+  <li><a href="../../index.html">Module code</a><ul>
+  </ul></li>
+  </ul></li>
+</ul>
+</div>
+<div id="searchbox" style="display: none" role="search">
+  <h3 id="searchlabel">Quick search</h3>
+    <div class="searchformwrapper">
+    <form class="search" action="../../../search.html" method="get">
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
+      <input type="submit" value="Go" />
+    </form>
+    </div>
+</div>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
+        </div>
+      </div>
+      <div class="clearer"></div>
+    </div>
+    <div class="footer" role="contentinfo">
+<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
+<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
+</a>
+<br />
+<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
+    </div>
+
+  </body>
+</html>
\ No newline at end of file
index b7b87d2..4c5a225 100644 (file)
@@ -1,19 +1,17 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>joy.utils.pretty_print &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../../../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../../../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../../../_static/jquery.js"></script>
-    <script type="text/javascript" src="../../../_static/underscore.js"></script>
-    <script type="text/javascript" src="../../../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
+    <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
+    <script src="../../../_static/jquery.js"></script>
+    <script src="../../../_static/underscore.js"></script>
+    <script src="../../../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../../../genindex.html" />
     <link rel="search" title="Search" href="../../../search.html" />
    
@@ -28,6 +26,8 @@
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
   <h1>Source code for joy.utils.pretty_print</h1><div class="highlight"><pre>
 <span class="sd">&#39;&#39;&#39;</span>
 <span class="c1"># (Kinda clunky and hacky.  This should be swapped out in favor of much</span>
 <span class="c1"># smarter stuff.)</span>
-<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span>
-<span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">object</span>
-<span class="kn">from</span> <span class="nn">traceback</span> <span class="k">import</span> <span class="n">print_exc</span>
-<span class="kn">from</span> <span class="nn">.stack</span> <span class="k">import</span> <span class="n">expression_to_string</span><span class="p">,</span> <span class="n">stack_to_string</span>
-<span class="kn">from</span> <span class="nn">..joy</span> <span class="k">import</span> <span class="n">joy</span>
-<span class="kn">from</span> <span class="nn">..library</span> <span class="k">import</span> <span class="n">inscribe</span><span class="p">,</span> <span class="n">FunctionWrapper</span>
+<span class="kn">from</span> <span class="nn">traceback</span> <span class="kn">import</span> <span class="n">print_exc</span>
+<span class="kn">from</span> <span class="nn">.stack</span> <span class="kn">import</span> <span class="n">expression_to_string</span><span class="p">,</span> <span class="n">stack_to_string</span>
+<span class="kn">from</span> <span class="nn">..joy</span> <span class="kn">import</span> <span class="n">joy</span>
+<span class="kn">from</span> <span class="nn">..library</span> <span class="kn">import</span> <span class="n">FunctionWrapper</span>
 
 
-<div class="viewcode-block" id="trace"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.trace">[docs]</a><span class="nd">@inscribe</span>
-<span class="nd">@FunctionWrapper</span>
+<div class="viewcode-block" id="trace"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.trace">[docs]</a><span class="nd">@FunctionWrapper</span>
 <span class="k">def</span> <span class="nf">trace</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="sd">&#39;&#39;&#39;Evaluate a Joy expression on a stack and print a trace.</span>
-
-<span class="sd">      This function is just like the `i` combinator but it also prints a</span>
-<span class="sd">      trace of the evaluation</span>
-
-<span class="sd">      :param stack stack: The stack.</span>
-<span class="sd">      :param stack expression: The expression to evaluate.</span>
-<span class="sd">      :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
-<span class="sd">      :rtype: (stack, (), dictionary)</span>
-
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">tp</span> <span class="o">=</span> <span class="n">TracePrinter</span><span class="p">()</span>
-       <span class="n">quote</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-       <span class="k">try</span><span class="p">:</span>
-               <span class="n">s</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">quote</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">tp</span><span class="o">.</span><span class="n">viewer</span><span class="p">)</span>
-       <span class="k">except</span><span class="p">:</span>
-               <span class="n">tp</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span>
-               <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;-&#39;</span> <span class="o">*</span> <span class="mi">73</span><span class="p">)</span>
-               <span class="k">raise</span>
-       <span class="k">else</span><span class="p">:</span>
-               <span class="n">tp</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span>
-       <span class="k">return</span> <span class="n">s</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">d</span></div>
+    <span class="sd">&#39;&#39;&#39;Evaluate a Joy expression on a stack and print a trace.</span>
+
+<span class="sd">    This function is just like the `i` combinator but it also prints a</span>
+<span class="sd">    trace of the evaluation</span>
+
+<span class="sd">    :param stack stack: The stack.</span>
+<span class="sd">    :param stack expression: The expression to evaluate.</span>
+<span class="sd">    :param dict dictionary: A ``dict`` mapping names to Joy functions.</span>
+<span class="sd">    :rtype: (stack, (), dictionary)</span>
+
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">tp</span> <span class="o">=</span> <span class="n">TracePrinter</span><span class="p">()</span>
+    <span class="n">quote</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="n">s</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">joy</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">quote</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">tp</span><span class="o">.</span><span class="n">viewer</span><span class="p">)</span>
+    <span class="k">except</span><span class="p">:</span>
+        <span class="n">tp</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span>
+        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;-&#39;</span> <span class="o">*</span> <span class="mi">73</span><span class="p">)</span>
+        <span class="k">raise</span>
+    <span class="k">else</span><span class="p">:</span>
+        <span class="n">tp</span><span class="o">.</span><span class="n">print_</span><span class="p">()</span>
+    <span class="k">return</span> <span class="n">s</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">d</span></div>
 
 
 <div class="viewcode-block" id="TracePrinter"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter">[docs]</a><span class="k">class</span> <span class="nc">TracePrinter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      This is what does the formatting.  You instantiate it and pass the ``viewer()``</span>
-<span class="sd">      method to the :py:func:`joy.joy.joy` function, then print it to see the</span>
-<span class="sd">      trace.</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-
-       <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-               <span class="bp">self</span><span class="o">.</span><span class="n">history</span> <span class="o">=</span> <span class="p">[]</span>
-
-<div class="viewcode-block" id="TracePrinter.viewer"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.viewer">[docs]</a>        <span class="k">def</span> <span class="nf">viewer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">):</span>
-               <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">              Record the current stack and expression in the TracePrinter&#39;s history.</span>
-<span class="sd">              Pass this method as the ``viewer`` argument to the :py:func:`joy.joy.joy` function.</span>
-
-<span class="sd">              :param stack quote: A stack.</span>
-<span class="sd">              :param stack expression: A stack.</span>
-<span class="sd">              &#39;&#39;&#39;</span>
-               <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span></div>
-
-       <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-               <span class="k">return</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">go</span><span class="p">())</span>
-
-<div class="viewcode-block" id="TracePrinter.go"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.go">[docs]</a>        <span class="k">def</span> <span class="nf">go</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-               <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">              Return a list of strings, one for each entry in the history, prefixed</span>
-<span class="sd">              with enough spaces to align all the interpreter dots.</span>
-
-<span class="sd">              This method is called internally by the ``__str__()`` method.</span>
-
-<span class="sd">              :rtype: list(str)</span>
-<span class="sd">              &#39;&#39;&#39;</span>
-               <span class="n">max_stack_length</span> <span class="o">=</span> <span class="mi">0</span>
-               <span class="n">lines</span> <span class="o">=</span> <span class="p">[]</span>
-               <span class="k">for</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">:</span>
-                       <span class="n">stack</span> <span class="o">=</span> <span class="n">stack_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">)</span>
-                       <span class="n">expression</span> <span class="o">=</span> <span class="n">expression_to_string</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
-                       <span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">stack</span><span class="p">)</span>
-                       <span class="k">if</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="n">max_stack_length</span><span class="p">:</span>
-                               <span class="n">max_stack_length</span> <span class="o">=</span> <span class="n">n</span>
-                       <span class="n">lines</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">n</span><span class="p">,</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> • </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span>
-               <span class="k">return</span> <span class="p">[</span>  <span class="c1"># Prefix spaces to line up &#39;•&#39;s.</span>
-                       <span class="p">(</span><span class="s1">&#39; &#39;</span> <span class="o">*</span> <span class="p">(</span><span class="n">max_stack_length</span> <span class="o">-</span> <span class="n">length</span><span class="p">)</span> <span class="o">+</span> <span class="n">line</span><span class="p">)</span>
-                       <span class="k">for</span> <span class="n">length</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span>
-                       <span class="p">]</span></div>
-
-       <span class="k">def</span> <span class="nf">print_</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-               <span class="k">try</span><span class="p">:</span>
-                       <span class="nb">print</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
-               <span class="k">except</span><span class="p">:</span>
-                       <span class="n">print_exc</span><span class="p">()</span>
-                       <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Exception while printing viewer.&#39;</span><span class="p">)</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    This is what does the formatting.  You instantiate it and pass the ``viewer()``</span>
+<span class="sd">    method to the :py:func:`joy.joy.joy` function, then print it to see the</span>
+<span class="sd">    trace.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">history</span> <span class="o">=</span> <span class="p">[]</span>
+
+<div class="viewcode-block" id="TracePrinter.viewer"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.viewer">[docs]</a>    <span class="k">def</span> <span class="nf">viewer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">        Record the current stack and expression in the TracePrinter&#39;s history.</span>
+<span class="sd">        Pass this method as the ``viewer`` argument to the :py:func:`joy.joy.joy` function.</span>
+
+<span class="sd">        :param stack quote: A stack.</span>
+<span class="sd">        :param stack expression: A stack.</span>
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">))</span></div>
+
+    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">go</span><span class="p">())</span>
+
+<div class="viewcode-block" id="TracePrinter.go"><a class="viewcode-back" href="../../../pretty.html#joy.utils.pretty_print.TracePrinter.go">[docs]</a>    <span class="k">def</span> <span class="nf">go</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">        Return a list of strings, one for each entry in the history, prefixed</span>
+<span class="sd">        with enough spaces to align all the interpreter dots.</span>
+
+<span class="sd">        This method is called internally by the ``__str__()`` method.</span>
+
+<span class="sd">        :rtype: list(str)</span>
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="n">max_stack_length</span> <span class="o">=</span> <span class="mi">0</span>
+        <span class="n">lines</span> <span class="o">=</span> <span class="p">[]</span>
+        <span class="k">for</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">:</span>
+            <span class="n">stack</span> <span class="o">=</span> <span class="n">stack_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">)</span>
+            <span class="n">expression</span> <span class="o">=</span> <span class="n">expression_to_string</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+            <span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">stack</span><span class="p">)</span>
+            <span class="k">if</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="n">max_stack_length</span><span class="p">:</span>
+                <span class="n">max_stack_length</span> <span class="o">=</span> <span class="n">n</span>
+            <span class="n">lines</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">n</span><span class="p">,</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> • </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">)))</span>
+        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)):</span>  <span class="c1"># Prefix spaces to line up &#39;•&#39;s.</span>
+            <span class="n">length</span><span class="p">,</span> <span class="n">line</span> <span class="o">=</span> <span class="n">lines</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
+            <span class="n">lines</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span>  <span class="p">(</span><span class="s1">&#39; &#39;</span> <span class="o">*</span> <span class="p">(</span><span class="n">max_stack_length</span> <span class="o">-</span> <span class="n">length</span><span class="p">)</span> <span class="o">+</span> <span class="n">line</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">lines</span></div>
+
+    <span class="k">def</span> <span class="nf">print_</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="nb">print</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
+        <span class="k">except</span><span class="p">:</span>
+            <span class="n">print_exc</span><span class="p">()</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Exception while printing viewer.&#39;</span><span class="p">)</span></div>
 </pre></div>
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../../../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../../../index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../../../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index f4de17c..cba3f00 100644 (file)
@@ -1,19 +1,17 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>joy.utils.stack &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../../../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../../../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../../../_static/jquery.js"></script>
-    <script type="text/javascript" src="../../../_static/underscore.js"></script>
-    <script type="text/javascript" src="../../../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
+    <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
+    <script src="../../../_static/jquery.js"></script>
+    <script src="../../../_static/underscore.js"></script>
+    <script src="../../../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../../../genindex.html" />
     <link rel="search" title="Search" href="../../../search.html" />
    
@@ -28,6 +26,8 @@
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
   <h1>Source code for joy.utils.stack</h1><div class="highlight"><pre>
@@ -76,8 +76,8 @@
 
 <span class="sd">For example::</span>
 
-<span class="sd">      def dup((head, tail)):</span>
-<span class="sd">              return head, (head, tail)</span>
+<span class="sd">    def dup((head, tail)):</span>
+<span class="sd">        return head, (head, tail)</span>
 
 <span class="sd">We replace the argument &quot;stack&quot; by the expected structure of the stack,</span>
 <span class="sd">in this case &quot;(head, tail)&quot;, and Python takes care of unpacking the</span>
@@ -89,9 +89,9 @@
 <span class="sd">web page, doesn&#39;t handle tuples in the function parameters.  And in Python 3, this</span>
 <span class="sd">syntax was removed entirely.  Instead you would have to write::</span>
 
-<span class="sd">      def dup(stack):</span>
-<span class="sd">              head, tail = stack</span>
-<span class="sd">              return head, (head, tail)</span>
+<span class="sd">    def dup(stack):</span>
+<span class="sd">        head, tail = stack</span>
+<span class="sd">        return head, (head, tail)</span>
 
 
 <span class="sd">We have two very simple functions, one to build up a stack from a Python</span>
 <span class="sd">.. _cons list: https://en.wikipedia.org/wiki/Cons#Lists</span>
 
 <span class="sd">&#39;&#39;&#39;</span>
+<span class="kn">from</span> <span class="nn">.errors</span> <span class="kn">import</span> <span class="n">NotAListError</span>
 
 
-<span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">map</span>
 <div class="viewcode-block" id="list_to_stack"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.list_to_stack">[docs]</a><span class="k">def</span> <span class="nf">list_to_stack</span><span class="p">(</span><span class="n">el</span><span class="p">,</span> <span class="n">stack</span><span class="o">=</span><span class="p">()):</span>
-       <span class="sd">&#39;&#39;&#39;Convert a Python list (or other sequence) to a Joy stack::</span>
+    <span class="sd">&#39;&#39;&#39;Convert a Python list (or other sequence) to a Joy stack::</span>
 
-<span class="sd">      [1, 2, 3] -&gt; (1, (2, (3, ())))</span>
+<span class="sd">    [1, 2, 3] -&gt; (1, (2, (3, ())))</span>
 
-<span class="sd">      :param list el: A Python list or other sequence (iterators and generators</span>
-<span class="sd">                       won&#39;t work because ``reverse()`` is called on ``el``.)</span>
-<span class="sd">      :param stack stack: A stack, optional, defaults to the empty stack.</span>
-<span class="sd">      :rtype: stack</span>
+<span class="sd">    :param list el: A Python list or other sequence (iterators and generators</span>
+<span class="sd">             won&#39;t work because ``reverse()`` is called on ``el``.)</span>
+<span class="sd">    :param stack stack: A stack, optional, defaults to the empty stack.</span>
+<span class="sd">    :rtype: stack</span>
 
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="n">el</span><span class="p">):</span>
-               <span class="n">stack</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">stack</span>
-       <span class="k">return</span> <span class="n">stack</span></div>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="n">el</span><span class="p">):</span>
+        <span class="n">stack</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="iter_stack"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.iter_stack">[docs]</a><span class="k">def</span> <span class="nf">iter_stack</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;Iterate through the items on the stack.</span>
+    <span class="sd">&#39;&#39;&#39;Iterate through the items on the stack.</span>
 
-<span class="sd">      :param stack stack: A stack.</span>
-<span class="sd">      :rtype: iterator</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">while</span> <span class="n">stack</span><span class="p">:</span>
-               <span class="n">item</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-               <span class="k">yield</span> <span class="n">item</span></div>
+<span class="sd">    :param stack stack: A stack.</span>
+<span class="sd">    :rtype: iterator</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">while</span> <span class="n">stack</span><span class="p">:</span>
+        <span class="n">item</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+        <span class="k">yield</span> <span class="n">item</span></div>
 
 
 <div class="viewcode-block" id="stack_to_string"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.stack_to_string">[docs]</a><span class="k">def</span> <span class="nf">stack_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Return a &quot;pretty print&quot; string for a stack.</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Return a &quot;pretty print&quot; string for a stack.</span>
 
-<span class="sd">      The items are written right-to-left::</span>
+<span class="sd">    The items are written right-to-left::</span>
 
-<span class="sd">              (top, (second, ...)) -&gt; &#39;... second top&#39;</span>
+<span class="sd">        (top, (second, ...)) -&gt; &#39;... second top&#39;</span>
 
-<span class="sd">      :param stack stack: A stack.</span>
-<span class="sd">      :rtype: str</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="n">f</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">stack</span><span class="p">:</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">stack</span><span class="p">)))</span>
-       <span class="k">return</span> <span class="n">_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span></div>
+<span class="sd">    :param stack stack: A stack.</span>
+<span class="sd">    :rtype: str</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="n">f</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">stack</span><span class="p">:</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">iter_stack</span><span class="p">(</span><span class="n">stack</span><span class="p">)))</span>
+    <span class="k">return</span> <span class="n">_to_string</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span></div>
 
 
 <div class="viewcode-block" id="expression_to_string"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.expression_to_string">[docs]</a><span class="k">def</span> <span class="nf">expression_to_string</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Return a &quot;pretty print&quot; string for a expression.</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Return a &quot;pretty print&quot; string for a expression.</span>
+
+<span class="sd">    The items are written left-to-right::</span>
+
+<span class="sd">        (top, (second, ...)) -&gt; &#39;top second ...&#39;</span>
+
+<span class="sd">    :param stack expression: A stack.</span>
+<span class="sd">    :rtype: str</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">return</span> <span class="n">_to_string</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">iter_stack</span><span class="p">)</span></div>
 
-<span class="sd">      The items are written left-to-right::</span>
 
-<span class="sd">              (top, (second, ...)) -&gt; &#39;top second ...&#39;</span>
+<span class="n">_JOY_BOOL_LITS</span> <span class="o">=</span> <span class="s1">&#39;false&#39;</span><span class="p">,</span> <span class="s1">&#39;true&#39;</span>
 
-<span class="sd">      :param stack expression: A stack.</span>
-<span class="sd">      :rtype: str</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">return</span> <span class="n">_to_string</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">iter_stack</span><span class="p">)</span></div>
+
+<span class="k">def</span> <span class="nf">_joy_repr</span><span class="p">(</span><span class="n">thing</span><span class="p">):</span>
+        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">thing</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span>
+                <span class="k">return</span> <span class="n">_JOY_BOOL_LITS</span><span class="p">[</span><span class="n">thing</span><span class="p">]</span>
+        <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="n">thing</span><span class="p">)</span>
 
 
 <span class="k">def</span> <span class="nf">_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>
-       <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span> <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="n">stack</span><span class="p">)</span>
-       <span class="k">if</span> <span class="ow">not</span> <span class="n">stack</span><span class="p">:</span> <span class="k">return</span> <span class="s1">&#39;&#39;</span>  <span class="c1"># shortcut</span>
-       <span class="k">return</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">_s</span><span class="p">,</span> <span class="n">f</span><span class="p">(</span><span class="n">stack</span><span class="p">)))</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span> <span class="k">return</span> <span class="n">_joy_repr</span><span class="p">(</span><span class="n">stack</span><span class="p">)</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">stack</span><span class="p">:</span> <span class="k">return</span> <span class="s1">&#39;&#39;</span>  <span class="c1"># shortcut</span>
+    <span class="k">return</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">_s</span><span class="p">,</span> <span class="n">f</span><span class="p">(</span><span class="n">stack</span><span class="p">)))</span>
 
 
 <span class="n">_s</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">s</span><span class="p">:</span> <span class="p">(</span>
-       <span class="s1">&#39;[</span><span class="si">%s</span><span class="s1">]&#39;</span> <span class="o">%</span> <span class="n">expression_to_string</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)</span>
-       <span class="k">else</span> <span class="nb">repr</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
-       <span class="p">)</span>
+    <span class="s1">&#39;[</span><span class="si">%s</span><span class="s1">]&#39;</span> <span class="o">%</span> <span class="n">expression_to_string</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
+        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)</span>
+    <span class="k">else</span> <span class="n">_joy_repr</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
+    <span class="p">)</span>
 
 
 <div class="viewcode-block" id="concat"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.concat">[docs]</a><span class="k">def</span> <span class="nf">concat</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="sd">&#39;&#39;&#39;Concatinate quote onto expression.</span>
+    <span class="sd">&#39;&#39;&#39;Concatinate quote onto expression.</span>
 
-<span class="sd">      In joy [1 2] [3 4] would become [1 2 3 4].</span>
+<span class="sd">    In joy [1 2] [3 4] would become [1 2 3 4].</span>
 
-<span class="sd">      :param stack quote: A stack.</span>
-<span class="sd">      :param stack expression: A stack.</span>
-<span class="sd">      :raises RuntimeError: if quote is larger than sys.getrecursionlimit().</span>
-<span class="sd">      :rtype: stack</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="c1"># This is the fastest implementation, but will trigger</span>
-       <span class="c1"># RuntimeError: maximum recursion depth exceeded</span>
-       <span class="c1"># on quotes longer than sys.getrecursionlimit().</span>
+<span class="sd">    :param stack quote: A stack.</span>
+<span class="sd">    :param stack expression: A stack.</span>
+<span class="sd">    :raises RuntimeError: if quote is larger than sys.getrecursionlimit().</span>
+<span class="sd">    :rtype: stack</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="c1"># This is the fastest implementation, but will trigger</span>
+    <span class="c1"># RuntimeError: maximum recursion depth exceeded</span>
+    <span class="c1"># on quotes longer than sys.getrecursionlimit().</span>
 
-       <span class="k">return</span> <span class="p">(</span><span class="n">quote</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">concat</span><span class="p">(</span><span class="n">quote</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">expression</span><span class="p">))</span> <span class="k">if</span> <span class="n">quote</span> <span class="k">else</span> <span class="n">expression</span></div>
+<span class="c1">##    return (quote[0], concat(quote[1], expression)) if quote else expression</span>
 
-       <span class="c1"># Original implementation.</span>
+    <span class="c1"># Original implementation.</span>
 
 <span class="c1">##  return list_to_stack(list(iter_stack(quote)), expression)</span>
 
-       <span class="c1"># In-lining is slightly faster (and won&#39;t break the</span>
-       <span class="c1"># recursion limit on long quotes.)</span>
-
-<span class="c1">##  temp = []</span>
-<span class="c1">##  while quote:</span>
-<span class="c1">##    item, quote = quote</span>
-<span class="c1">##    temp.append(item)</span>
-<span class="c1">##  for item in reversed(temp):</span>
-<span class="c1">##    expression = item, expression</span>
-<span class="c1">##  return expression</span>
-
+    <span class="c1"># In-lining is slightly faster (and won&#39;t break the</span>
+    <span class="c1"># recursion limit on long quotes.)</span>
+
+    <span class="n">temp</span> <span class="o">=</span> <span class="p">[]</span>
+    <span class="k">while</span> <span class="n">quote</span><span class="p">:</span>
+        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">quote</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
+            <span class="k">raise</span> <span class="n">NotAListError</span><span class="p">(</span><span class="s1">&#39;Not a list.&#39;</span><span class="p">)</span>
+        <span class="n">item</span><span class="p">,</span> <span class="n">quote</span> <span class="o">=</span> <span class="n">quote</span>
+        <span class="n">temp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
+    <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="n">temp</span><span class="p">):</span>
+        <span class="n">expression</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">expression</span>
+    <span class="k">return</span> <span class="n">expression</span></div>
+
+
+
+<div class="viewcode-block" id="dnd"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.dnd">[docs]</a><span class="k">def</span> <span class="nf">dnd</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">from_index</span><span class="p">,</span> <span class="n">to_index</span><span class="p">):</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Given a stack and two indices return a rearranged stack.</span>
+<span class="sd">    First remove the item at from_index and then insert it at to_index,</span>
+<span class="sd">    the second index is relative to the stack after removal of the item</span>
+<span class="sd">    at from_index.</span>
+
+<span class="sd">    This function reuses all of the items and as much of the stack as it</span>
+<span class="sd">    can.  It&#39;s meant to be used by remote clients to support drag-n-drop</span>
+<span class="sd">    rearranging of the stack from e.g. the StackListbox.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">assert</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">from_index</span>
+    <span class="k">assert</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">to_index</span>
+    <span class="k">if</span> <span class="n">from_index</span> <span class="o">==</span> <span class="n">to_index</span><span class="p">:</span>
+        <span class="k">return</span> <span class="n">stack</span>
+    <span class="n">head</span><span class="p">,</span> <span class="n">n</span> <span class="o">=</span> <span class="p">[],</span> <span class="n">from_index</span>
+    <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
+        <span class="n">item</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+        <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
+        <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="k">break</span>
+        <span class="n">head</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
+    <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">head</span><span class="p">)</span> <span class="o">==</span> <span class="n">from_index</span>
+    <span class="c1"># now we have two cases:</span>
+    <span class="n">diff</span> <span class="o">=</span> <span class="n">from_index</span> <span class="o">-</span> <span class="n">to_index</span>
+    <span class="k">if</span> <span class="n">diff</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
+        <span class="c1"># from &lt; to</span>
+        <span class="c1"># so the destination index is still in the stack</span>
+        <span class="k">while</span> <span class="n">diff</span><span class="p">:</span>
+            <span class="n">h</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+            <span class="n">head</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">h</span><span class="p">)</span>
+            <span class="n">diff</span> <span class="o">+=</span> <span class="mi">1</span>
+    <span class="k">else</span><span class="p">:</span>
+        <span class="c1"># from &gt; to</span>
+        <span class="c1"># so the destination is in the head list</span>
+        <span class="k">while</span> <span class="n">diff</span><span class="p">:</span>
+            <span class="n">stack</span> <span class="o">=</span> <span class="n">head</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="n">stack</span>
+            <span class="n">diff</span> <span class="o">-=</span> <span class="mi">1</span>
+    <span class="n">stack</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">stack</span>
+    <span class="k">while</span> <span class="n">head</span><span class="p">:</span>
+        <span class="n">stack</span> <span class="o">=</span> <span class="n">head</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">stack</span></div>
 
 
 <div class="viewcode-block" id="pick"><a class="viewcode-back" href="../../../stack.html#joy.utils.stack.pick">[docs]</a><span class="k">def</span> <span class="nf">pick</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
-       <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">      Return the nth item on the stack.</span>
-
-<span class="sd">      :param stack stack: A stack.</span>
-<span class="sd">      :param int n: An index into the stack.</span>
-<span class="sd">      :raises ValueError: if ``n`` is less than zero.</span>
-<span class="sd">      :raises IndexError: if ``n`` is equal to or greater than the length of ``stack``.</span>
-<span class="sd">      :rtype: whatever</span>
-<span class="sd">      &#39;&#39;&#39;</span>
-       <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
-               <span class="k">raise</span> <span class="ne">ValueError</span>
-       <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
-               <span class="k">try</span><span class="p">:</span>
-                       <span class="n">item</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
-               <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
-                       <span class="k">raise</span> <span class="ne">IndexError</span>
-               <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
-               <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
-                       <span class="k">break</span>
-       <span class="k">return</span> <span class="n">item</span></div>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    Return the nth item on the stack.</span>
+
+<span class="sd">    :param stack stack: A stack.</span>
+<span class="sd">    :param int n: An index into the stack.</span>
+<span class="sd">    :raises ValueError: if ``n`` is less than zero.</span>
+<span class="sd">    :raises IndexError: if ``n`` is equal to or greater than the length of ``stack``.</span>
+<span class="sd">    :rtype: whatever</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="ne">ValueError</span>
+    <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="n">item</span><span class="p">,</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
+        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">IndexError</span>
+        <span class="n">n</span> <span class="o">-=</span> <span class="mi">1</span>
+        <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
+            <span class="k">break</span>
+    <span class="k">return</span> <span class="n">item</span></div>
 </pre></div>
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../../../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../../../notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../../../index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../../../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index b765192..2b93e4f 100644 (file)
@@ -2,7 +2,7 @@
 Functions Grouped by, er, Function with Examples
 ------------------------------------------------
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import J, V
 
@@ -19,7 +19,7 @@ it's "off the shelf" technology.)
 ``clear``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 clear')
 
@@ -32,7 +32,7 @@ it's "off the shelf" technology.)
 ``dup`` ``dupd``
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 dup')
 
@@ -42,7 +42,7 @@ it's "off the shelf" technology.)
     1 2 3 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 dupd')
 
@@ -58,7 +58,7 @@ it's "off the shelf" technology.)
 (I may have these paired up wrong. I.e. ``disenstacken`` should be
 ``unstack`` and vice versa.)
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 enstacken') # Replace the stack with a quote of itself.
 
@@ -68,7 +68,7 @@ it's "off the shelf" technology.)
     [3 2 1]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('4 5 6 [3 2 1] disenstacken')  # Unpack a list onto the stack.
 
@@ -78,7 +78,7 @@ it's "off the shelf" technology.)
     4 5 6 3 2 1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 stack')  # Get the stack on the stack.
 
@@ -88,7 +88,7 @@ it's "off the shelf" technology.)
     1 2 3 [3 2 1]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 [4 5 6] unstack')  # Replace the stack with the list on top.
                                 # The items appear reversed but they are not,
@@ -103,7 +103,7 @@ it's "off the shelf" technology.)
 ``pop`` ``popd`` ``popop``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 pop')
 
@@ -113,7 +113,7 @@ it's "off the shelf" technology.)
     1 2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 popd')
 
@@ -123,7 +123,7 @@ it's "off the shelf" technology.)
     1 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 popop')
 
@@ -139,7 +139,7 @@ it's "off the shelf" technology.)
 The "down" and "up" refer to the movement of two of the top three items
 (displacing the third.)
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 roll<')
 
@@ -149,7 +149,7 @@ The "down" and "up" refer to the movement of two of the top three items
     2 3 1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 roll>')
 
@@ -162,7 +162,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``swap``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 swap')
 
@@ -175,7 +175,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``tuck`` ``over``
 ~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 tuck')
 
@@ -185,7 +185,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 3 2 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 over')
 
@@ -198,7 +198,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``unit`` ``quoted`` ``unquoted``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 unit')
 
@@ -208,7 +208,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 2 [3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 quoted')
 
@@ -218,7 +218,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 [2] 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 [2] 3 unquoted')
 
@@ -228,7 +228,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 2 3
 
 
-.. code:: ipython2
+.. code:: python
 
     V('1 [dup] 3 unquoted')  # Unquoting evaluates.  Be aware.
 
@@ -253,7 +253,7 @@ List words
 ``concat`` ``swoncat`` ``shunt``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [4 5 6] concat')
 
@@ -263,7 +263,7 @@ List words
     [1 2 3 4 5 6]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [4 5 6] swoncat')
 
@@ -273,7 +273,7 @@ List words
     [4 5 6 1 2 3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [4 5 6] shunt')
 
@@ -286,7 +286,7 @@ List words
 ``cons`` ``swons`` ``uncons``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 [2 3] cons')
 
@@ -296,7 +296,7 @@ List words
     [1 2 3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[2 3] 1 swons')
 
@@ -306,7 +306,7 @@ List words
     [1 2 3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] uncons')
 
@@ -319,7 +319,7 @@ List words
 ``first`` ``second`` ``third`` ``rest``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] first')
 
@@ -329,7 +329,7 @@ List words
     1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] second')
 
@@ -339,7 +339,7 @@ List words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] third')
 
@@ -349,7 +349,7 @@ List words
     3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] rest')
 
@@ -362,7 +362,7 @@ List words
 ``flatten``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[[1] [2 [3] 4] [5 6]] flatten')
 
@@ -377,7 +377,7 @@ List words
 
 ``at`` and ``getitem`` are the same function. ``of == swap at``
 
-.. code:: ipython2
+.. code:: python
 
     J('[10 11 12 13 14] 2 getitem')
 
@@ -387,7 +387,7 @@ List words
     12
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] 0 at')
 
@@ -397,7 +397,7 @@ List words
     1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('2 [1 2 3 4] of')
 
@@ -407,7 +407,7 @@ List words
     3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] 2 drop')
 
@@ -417,7 +417,7 @@ List words
     [3 4]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] 2 take')  # reverses the order
 
@@ -432,7 +432,7 @@ List words
 ``remove``
 ~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 1 4] 1 remove')
 
@@ -445,7 +445,7 @@ List words
 ``reverse``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] reverse')
 
@@ -458,7 +458,7 @@ List words
 ``size``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 1 1 1] size')
 
@@ -475,7 +475,7 @@ List words
 put the old stack on top of the new one. Think of it as a context
 switch. Niether of the lists/stacks change their order.
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 [4 5 6] swaack')
 
@@ -488,7 +488,7 @@ switch. Niether of the lists/stacks change their order.
 ``choice`` ``select``
 ~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 1 choice')
 
@@ -498,7 +498,7 @@ switch. Niether of the lists/stacks change their order.
     9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 0 choice')
 
@@ -508,7 +508,7 @@ switch. Niether of the lists/stacks change their order.
     23
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 9 7] 1 select')  # select is basically getitem, should retire it?
 
@@ -518,7 +518,7 @@ switch. Niether of the lists/stacks change their order.
     9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 9 7] 0 select')
 
@@ -531,7 +531,7 @@ switch. Niether of the lists/stacks change their order.
 ``zip``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [6 5 4] zip')
 
@@ -541,7 +541,7 @@ switch. Niether of the lists/stacks change their order.
     [[6 1] [5 2] [4 3]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [6 5 4] zip [sum] map')
 
@@ -557,7 +557,7 @@ Math words
 ``+`` ``add``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 +')
 
@@ -570,7 +570,7 @@ Math words
 ``-`` ``sub``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 -')
 
@@ -583,7 +583,7 @@ Math words
 ``*`` ``mul``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 *')
 
@@ -596,7 +596,7 @@ Math words
 ``/`` ``div`` ``floordiv`` ``truediv``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 /')
 
@@ -606,7 +606,7 @@ Math words
     2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 -9 truediv')
 
@@ -616,7 +616,7 @@ Math words
     -2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 div')
 
@@ -626,7 +626,7 @@ Math words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 floordiv')
 
@@ -636,7 +636,7 @@ Math words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 -9 div')
 
@@ -646,7 +646,7 @@ Math words
     -3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 -9 floordiv')
 
@@ -659,7 +659,7 @@ Math words
 ``%`` ``mod`` ``modulus`` ``rem`` ``remainder``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 %')
 
@@ -672,7 +672,7 @@ Math words
 ``neg``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 neg -5 neg')
 
@@ -685,7 +685,7 @@ Math words
 ``pow``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('2 10 pow')
 
@@ -698,7 +698,7 @@ Math words
 ``sqr`` ``sqrt``
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 sqr')
 
@@ -708,7 +708,7 @@ Math words
     529
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 sqrt')
 
@@ -721,7 +721,7 @@ Math words
 ``++`` ``succ`` ``--`` ``pred``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 ++')
 
@@ -731,7 +731,7 @@ Math words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 --')
 
@@ -744,7 +744,7 @@ Math words
 ``<<`` ``lshift`` ``>>`` ``rshift``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('8 1 <<')
 
@@ -754,7 +754,7 @@ Math words
     16
 
 
-.. code:: ipython2
+.. code:: python
 
     J('8 1 >>')
 
@@ -767,7 +767,7 @@ Math words
 ``average``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] average')
 
@@ -780,7 +780,7 @@ Math words
 ``range`` ``range_to_zero`` ``down_to_zero``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('5 range')
 
@@ -790,7 +790,7 @@ Math words
     [4 3 2 1 0]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('5 range_to_zero')
 
@@ -800,7 +800,7 @@ Math words
     [0 1 2 3 4 5]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('5 down_to_zero')
 
@@ -813,7 +813,7 @@ Math words
 ``product``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] product')
 
@@ -826,7 +826,7 @@ Math words
 ``sum``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] sum')
 
@@ -839,7 +839,7 @@ Math words
 ``min``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] min')
 
@@ -852,7 +852,7 @@ Math words
 ``gcd``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('45 30 gcd')
 
@@ -868,7 +868,7 @@ Math words
 If we represent fractions as a quoted pair of integers [q d] this word
 reduces them to their ... least common factors or whatever.
 
-.. code:: ipython2
+.. code:: python
 
     J('[45 30] least_fraction')
 
@@ -878,7 +878,7 @@ reduces them to their ... least common factors or whatever.
     [3 2]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 12] least_fraction')
 
@@ -896,7 +896,7 @@ Logic and Comparison
 
 Get the Boolean value of the item on the top of the stack.
 
-.. code:: ipython2
+.. code:: python
 
     J('23 truthy')
 
@@ -906,7 +906,7 @@ Get the Boolean value of the item on the top of the stack.
     True
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[] truthy')  # Python semantics.
 
@@ -916,7 +916,7 @@ Get the Boolean value of the item on the top of the stack.
     False
 
 
-.. code:: ipython2
+.. code:: python
 
     J('0 truthy')
 
@@ -930,7 +930,7 @@ Get the Boolean value of the item on the top of the stack.
 
     ? == dup truthy
 
-.. code:: ipython2
+.. code:: python
 
     V('23 ?')
 
@@ -944,7 +944,7 @@ Get the Boolean value of the item on the top of the stack.
     23 True . 
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[] ?')
 
@@ -954,7 +954,7 @@ Get the Boolean value of the item on the top of the stack.
     [] False
 
 
-.. code:: ipython2
+.. code:: python
 
     J('0 ?')
 
@@ -967,7 +967,7 @@ Get the Boolean value of the item on the top of the stack.
 ``&`` ``and``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 &')
 
@@ -980,7 +980,7 @@ Get the Boolean value of the item on the top of the stack.
 ``!=`` ``<>`` ``ne``
 ~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 !=')
 
@@ -996,7 +996,7 @@ Get the Boolean value of the item on the top of the stack.
 ``^`` ``xor``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 1 ^')
 
@@ -1006,7 +1006,7 @@ Get the Boolean value of the item on the top of the stack.
     0
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 0 ^')
 
@@ -1022,7 +1022,7 @@ Miscellaneous
 ``help``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[help] help')
 
@@ -1036,7 +1036,7 @@ Miscellaneous
 ``parse``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[parse] help')
 
@@ -1047,7 +1047,7 @@ Miscellaneous
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 "2 [3] dup" parse')
 
@@ -1062,7 +1062,7 @@ Miscellaneous
 
 Evaluate a quoted Joy sequence.
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 dup + +] run')
 
@@ -1078,7 +1078,7 @@ Combinators
 ``app1`` ``app2`` ``app3``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[app1] help')
 
@@ -1095,7 +1095,7 @@ Combinators
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 4 [sqr *] app1')
 
@@ -1105,7 +1105,7 @@ Combinators
     10 160
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 3 4 [sqr *] app2')
 
@@ -1115,7 +1115,7 @@ Combinators
     10 90 160
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[app2] help')
 
@@ -1131,7 +1131,7 @@ Combinators
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 2 3 4 [sqr *] app3')
 
@@ -1159,7 +1159,7 @@ Example, ``range``:
 
     range == [0 <=] [1 - dup] anamorphism
 
-.. code:: ipython2
+.. code:: python
 
     J('3 [0 <=] [1 - dup] anamorphism')
 
@@ -1172,7 +1172,7 @@ Example, ``range``:
 ``branch``
 ~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('3 4 1 [+] [*] branch')
 
@@ -1182,7 +1182,7 @@ Example, ``range``:
     12
 
 
-.. code:: ipython2
+.. code:: python
 
     J('3 4 0 [+] [*] branch')
 
@@ -1217,7 +1217,7 @@ in terms of ``app2``:
 
     cleave == [i] app2 [popd] dip
 
-.. code:: ipython2
+.. code:: python
 
     J('10 2 [+] [-] cleave')
 
@@ -1230,7 +1230,7 @@ in terms of ``app2``:
 ``dip`` ``dipd`` ``dipdd``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] dip')
 
@@ -1240,7 +1240,7 @@ in terms of ``app2``:
     1 2 7 5
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] dipd')
 
@@ -1250,7 +1250,7 @@ in terms of ``app2``:
     1 5 4 5
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] dipdd')
 
@@ -1270,7 +1270,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 
     n [Q] dupdip == n Q n
 
-.. code:: ipython2
+.. code:: python
 
     V('23 [++] dupdip *')  # N(N + 1)
 
@@ -1289,7 +1289,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``genrec`` ``primrec``
 ~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[genrec] help')
 
@@ -1343,7 +1343,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('3 [1 <=] [] [dup --] [i *] genrec')
 
@@ -1356,7 +1356,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``i``
 ~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     V('1 2 3 [+ +] i')
 
@@ -1380,7 +1380,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 
     [predicate] [then] [else] ifte
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 [1] [+] [*] ifte')
 
@@ -1390,7 +1390,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 [0] [+] [*] ifte')
 
@@ -1403,7 +1403,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``infra``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     V('1 2 3 [4 5 6] [* +] infra')
 
@@ -1426,7 +1426,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``loop``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[loop] help')
 
@@ -1445,7 +1445,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('3 dup [1 - dup] loop')
 
@@ -1477,7 +1477,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``map`` ``pam``
 ~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('10 [1 2 3] [*] map')
 
@@ -1487,7 +1487,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     10 [10 20 30]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 5 [[*][/][+][-]] pam')
 
@@ -1503,7 +1503,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 Run a quoted program enforcing
 `arity <https://en.wikipedia.org/wiki/Arity>`__.
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] nullary')
 
@@ -1513,7 +1513,7 @@ Run a quoted program enforcing
     1 2 3 4 5 9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] unary')
 
@@ -1523,7 +1523,7 @@ Run a quoted program enforcing
     1 2 3 4 9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] binary')  # + has arity 2 so this is technically pointless...
 
@@ -1533,7 +1533,7 @@ Run a quoted program enforcing
     1 2 3 9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] ternary')
 
@@ -1546,7 +1546,7 @@ Run a quoted program enforcing
 ``step``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[step] help')
 
@@ -1574,7 +1574,7 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('0 [1 2 3] [+] step')
 
@@ -1603,7 +1603,7 @@ Run a quoted program enforcing
 ``times``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     V('3 2 1 2 [+] times')
 
@@ -1627,7 +1627,7 @@ Run a quoted program enforcing
 ``b``
 ~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[b] help')
 
@@ -1641,7 +1641,7 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('1 2 [3] [4] b')
 
@@ -1665,7 +1665,7 @@ Run a quoted program enforcing
 
     [predicate] [body] while
 
-.. code:: ipython2
+.. code:: python
 
     J('3 [0 >] [dup --] while')
 
@@ -1678,7 +1678,7 @@ Run a quoted program enforcing
 ``x``
 ~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[x] help')
 
@@ -1693,7 +1693,7 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('1 [2] [i 3] x')  # Kind of a pointless example.
 
@@ -1720,7 +1720,7 @@ Implements `**Laws of Form**
 over quote-only datastructures (that is, datastructures that consist
 soley of containers, without strings or numbers or anything else.)
 
-.. code:: ipython2
+.. code:: python
 
     J('[] void')
 
@@ -1730,7 +1730,7 @@ soley of containers, without strings or numbers or anything else.)
     False
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[[]] void')
 
@@ -1740,7 +1740,7 @@ soley of containers, without strings or numbers or anything else.)
     True
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[[][[]]] void')
 
@@ -1750,7 +1750,7 @@ soley of containers, without strings or numbers or anything else.)
     True
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[[[]][[][]]] void')
 
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Categorical.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Categorical.rst.txt
new file mode 100644 (file)
index 0000000..979ec20
--- /dev/null
@@ -0,0 +1,17 @@
+
+***********************
+Categorical Programming
+***********************
+
+DRAFT
+
+`Categorical <https://en.wikipedia.org/wiki/Category_theory>`__  
+
+In Manfred von Thun's article `Joy compared with other functional languages <http://www.kevinalbrecht.com/code/joy-mirror/j08cnt.html>`__ he asks, "Could the language of categories be used for writing programs? Any lambda expression can be translated into a categorical expression, so the language of categories is expressively complete. But this does not make it a suitable language for writing programs. As it stands it is a very low-level language."
+
+In `Compiling to categories <http://conal.net/papers/compiling-to-categories/>`__ Conal Elliott give a taste of what this might mean.
+
+    It is well-known that the simply typed lambda-calculus is modeled by any cartesian closed category (CCC). This correspondence suggests giving typed functional programs a variety of interpretations, each corresponding to a different category. A convenient way to realize this idea is as a collection of meaning-preserving transformations added to an existing compiler, such as GHC for Haskell. This paper describes such an implementation and demonstrates its use for a variety of interpretations including hardware circuits, automatic differentiation, incremental computation, and interval analysis. Each such interpretation is a category easily defined in Haskell (outside of the compiler). The general technique appears to provide a compelling alternative to deeply embedded domain-specific languages.
+
+What he's doing is translating lambda forms into a kind of "point-free" style that is very close to Joy code (although more verbose) and then showing how to instantiate that code over different categories to get several different kinds of program out of the same code.
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Derivatives_of_Regular_Expressions.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Derivatives_of_Regular_Expressions.rst.txt
new file mode 100644 (file)
index 0000000..be09155
--- /dev/null
@@ -0,0 +1,946 @@
+∂RE
+===
+
+Brzozowski’s Derivatives of Regular Expressions
+-----------------------------------------------
+
+Legend:
+
+::
+
+   ∧ intersection
+   ∨ union
+   ∘ concatenation (see below)
+   ¬ complement
+   ϕ empty set (aka ∅)
+   λ singleton set containing just the empty string
+   I set of all letters in alphabet
+
+Derivative of a set ``R`` of strings and a string ``a``:
+
+::
+
+   ∂a(R)
+
+   ∂a(a) → λ
+   ∂a(λ) → ϕ
+   ∂a(ϕ) → ϕ
+   ∂a(¬a) → ϕ
+   ∂a(R*) → ∂a(R)∘R*
+   ∂a(¬R) → ¬∂a(R)
+   ∂a(R∘S) → ∂a(R)∘S ∨ δ(R)∘∂a(S)
+   ∂a(R ∧ S) → ∂a(R) ∧ ∂a(S)
+   ∂a(R ∨ S) → ∂a(R) ∨ ∂a(S)
+
+   ∂ab(R) = ∂b(∂a(R))
+
+Auxiliary predicate function ``δ`` (I call it ``nully``) returns either
+``λ`` if ``λ ⊆ R`` or ``ϕ`` otherwise:
+
+::
+
+   δ(a) → ϕ
+   δ(λ) → λ
+   δ(ϕ) → ϕ
+   δ(R*) → λ
+   δ(¬R) δ(R)≟ϕ → λ
+   δ(¬R) δ(R)≟λ → ϕ
+   δ(R∘S) → δ(R) ∧ δ(S)
+   δ(R ∧ S) → δ(R) ∧ δ(S)
+   δ(R ∨ S) → δ(R) ∨ δ(S)
+
+Some rules we will use later for “compaction”:
+
+::
+
+   R ∧ ϕ = ϕ ∧ R = ϕ
+
+   R ∧ I = I ∧ R = R
+
+   R ∨ ϕ = ϕ ∨ R = R
+
+   R ∨ I = I ∨ R = I
+
+   R∘ϕ = ϕ∘R = ϕ
+
+   R∘λ = λ∘R = R
+
+Concatination of sets: for two sets A and B the set A∘B is defined as:
+
+{a∘b for a in A for b in B}
+
+E.g.:
+
+{‘a’, ‘b’}∘{‘c’, ‘d’} → {‘ac’, ‘ad’, ‘bc’, ‘bd’}
+
+Implementation
+--------------
+
+.. code:: python
+
+    from functools import partial as curry
+    from itertools import product
+
+``ϕ`` and ``λ``
+~~~~~~~~~~~~~~~
+
+The empty set and the set of just the empty string.
+
+.. code:: python
+
+    phi = frozenset()   # ϕ
+    y = frozenset({''}) # λ
+
+Two-letter Alphabet
+~~~~~~~~~~~~~~~~~~~
+
+I’m only going to use two symbols (at first) becaase this is enough to
+illustrate the algorithm and because you can represent any other
+alphabet with two symbols (if you had to.)
+
+I chose the names ``O`` and ``l`` (uppercase “o” and lowercase “L”) to
+look like ``0`` and ``1`` (zero and one) respectively.
+
+.. code:: python
+
+    syms = O, l = frozenset({'0'}), frozenset({'1'})
+
+Representing Regular Expressions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+To represent REs in Python I’m going to use tagged tuples. A *regular
+expression* is one of:
+
+::
+
+   O
+   l
+   (KSTAR, R)
+   (NOT, R)
+   (AND, R, S)
+   (CONS, R, S)
+   (OR, R, S)
+
+Where ``R`` and ``S`` stand for *regular expressions*.
+
+.. code:: python
+
+    AND, CONS, KSTAR, NOT, OR = 'and cons * not or'.split()  # Tags are just strings.
+
+Because they are formed of ``frozenset``, ``tuple`` and ``str`` objects
+only, these datastructures are immutable.
+
+String Representation of RE Datastructures
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code:: python
+
+    def stringy(re):
+        '''
+        Return a nice string repr for a regular expression datastructure.
+        '''
+        if re == I: return '.'
+        if re in syms: return next(iter(re))
+        if re == y: return '^'
+        if re == phi: return 'X'
+    
+        assert isinstance(re, tuple), repr(re)
+        tag = re[0]
+    
+        if tag == KSTAR:
+            body = stringy(re[1])
+            if not body: return body
+            if len(body) > 1: return '(' + body + ")*"
+            return body + '*'
+    
+        if tag == NOT:
+            body = stringy(re[1])
+            if not body: return body
+            if len(body) > 1: return '(' + body + ")'"
+            return body + "'"
+    
+        r, s = stringy(re[1]), stringy(re[2])
+        if tag == CONS: return r + s
+        if tag == OR:   return '%s | %s' % (r, s)
+        if tag == AND:  return '(%s) & (%s)' % (r, s)
+    
+        raise ValueError
+
+``I``
+~~~~~
+
+Match anything. Often spelled “.”
+
+::
+
+   I = (0|1)*
+
+.. code:: python
+
+    I = (KSTAR, (OR, O, l))
+
+.. code:: python
+
+    print stringy(I)
+
+
+.. parsed-literal::
+
+    .
+
+
+``(.111.) & (.01 + 11*)'``
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The example expression from Brzozowski:
+
+::
+
+   (.111.) & (.01 + 11*)'
+      a    &  (b  +  c)'
+
+Note that it contains one of everything.
+
+.. code:: python
+
+    a = (CONS, I, (CONS, l, (CONS, l, (CONS, l, I))))
+    b = (CONS, I, (CONS, O, l))
+    c = (CONS, l, (KSTAR, l))
+    it = (AND, a, (NOT, (OR, b, c)))
+
+.. code:: python
+
+    print stringy(it)
+
+
+.. parsed-literal::
+
+    (.111.) & ((.01 | 11*)')
+
+
+``nully()``
+~~~~~~~~~~~
+
+Let’s get that auxiliary predicate function ``δ`` out of the way.
+
+.. code:: python
+
+    def nully(R):
+        '''
+        δ - Return λ if λ ⊆ R otherwise ϕ.
+        '''
+    
+        # δ(a) → ϕ
+        # δ(ϕ) → ϕ
+        if R in syms or R == phi:
+            return phi
+    
+        # δ(λ) → λ
+        if R == y:
+            return y
+    
+        tag = R[0]
+    
+        # δ(R*) → λ
+        if tag == KSTAR:
+            return y
+    
+        # δ(¬R) δ(R)≟ϕ → λ
+        # δ(¬R) δ(R)≟λ → ϕ
+        if tag == NOT:
+            return phi if nully(R[1]) else y
+    
+        # δ(R∘S) → δ(R) ∧ δ(S)
+        # δ(R ∧ S) → δ(R) ∧ δ(S)
+        # δ(R ∨ S) → δ(R) ∨ δ(S)
+        r, s = nully(R[1]), nully(R[2])
+        return r & s if tag in {AND, CONS} else r | s
+
+No “Compaction”
+~~~~~~~~~~~~~~~
+
+This is the straightforward version with no “compaction”. It works fine,
+but does waaaay too much work because the expressions grow each
+derivation.
+
+.. code:: python
+
+    def D(symbol):
+    
+        def derv(R):
+    
+            # ∂a(a) → λ
+            if R == {symbol}:
+                return y
+    
+            # ∂a(λ) → ϕ
+            # ∂a(ϕ) → ϕ
+            # ∂a(¬a) → ϕ
+            if R == y or R == phi or R in syms:
+                return phi
+            
+            tag = R[0]
+    
+            # ∂a(R*) → ∂a(R)∘R*
+            if tag == KSTAR:
+                return (CONS, derv(R[1]), R)
+    
+            # ∂a(¬R) → ¬∂a(R)
+            if tag == NOT:
+                return (NOT, derv(R[1]))
+    
+            r, s = R[1:]
+    
+            # ∂a(R∘S) → ∂a(R)∘S ∨ δ(R)∘∂a(S)
+            if tag == CONS:
+                A = (CONS, derv(r), s)  # A = ∂a(R)∘S
+                # A ∨ δ(R) ∘ ∂a(S)
+                # A ∨  λ   ∘ ∂a(S) → A ∨ ∂a(S)
+                # A ∨  ϕ   ∘ ∂a(S) → A ∨ ϕ → A
+                return (OR, A, derv(s)) if nully(r) else A
+    
+            # ∂a(R ∧ S) → ∂a(R) ∧ ∂a(S)
+            # ∂a(R ∨ S) → ∂a(R) ∨ ∂a(S)
+            return (tag, derv(r), derv(s))
+    
+        return derv
+
+Compaction Rules
+~~~~~~~~~~~~~~~~
+
+.. code:: python
+
+    def _compaction_rule(relation, one, zero, a, b):
+        return (
+            b if a == one else  # R*1 = 1*R = R
+            a if b == one else
+            zero if a == zero or b == zero else  # R*0 = 0*R = 0
+            (relation, a, b)
+            )
+
+An elegant symmetry.
+
+.. code:: python
+
+    # R ∧ I = I ∧ R = R
+    # R ∧ ϕ = ϕ ∧ R = ϕ
+    _and = curry(_compaction_rule, AND, I, phi)
+    
+    # R ∨ ϕ = ϕ ∨ R = R
+    # R ∨ I = I ∨ R = I
+    _or = curry(_compaction_rule, OR, phi, I)
+    
+    # R∘λ = λ∘R = R
+    # R∘ϕ = ϕ∘R = ϕ
+    _cons = curry(_compaction_rule, CONS, y, phi)
+
+Memoizing
+~~~~~~~~~
+
+We can save re-processing by remembering results we have already
+computed. RE datastructures are immutable and the ``derv()`` functions
+are *pure* so this is fine.
+
+.. code:: python
+
+    class Memo(object):
+    
+        def __init__(self, f):
+            self.f = f
+            self.calls = self.hits = 0
+            self.mem = {}
+    
+        def __call__(self, key):
+            self.calls += 1
+            try:
+                result = self.mem[key]
+                self.hits += 1
+            except KeyError:
+                result = self.mem[key] = self.f(key)
+            return result
+
+With “Compaction”
+~~~~~~~~~~~~~~~~~
+
+This version uses the rules above to perform compaction. It keeps the
+expressions from growing too large.
+
+.. code:: python
+
+    def D_compaction(symbol):
+    
+        @Memo
+        def derv(R):
+    
+            # ∂a(a) → λ
+            if R == {symbol}:
+                return y
+    
+            # ∂a(λ) → ϕ
+            # ∂a(ϕ) → ϕ
+            # ∂a(¬a) → ϕ
+            if R == y or R == phi or R in syms:
+                return phi
+    
+            tag = R[0]
+    
+            # ∂a(R*) → ∂a(R)∘R*
+            if tag == KSTAR:
+                return _cons(derv(R[1]), R)
+    
+            # ∂a(¬R) → ¬∂a(R)
+            if tag == NOT:
+                return (NOT, derv(R[1]))
+    
+            r, s = R[1:]
+    
+            # ∂a(R∘S) → ∂a(R)∘S ∨ δ(R)∘∂a(S)
+            if tag == CONS:
+                A = _cons(derv(r), s)  # A = ∂a(r)∘s
+                # A ∨ δ(R) ∘ ∂a(S)
+                # A ∨  λ   ∘ ∂a(S) → A ∨ ∂a(S)
+                # A ∨  ϕ   ∘ ∂a(S) → A ∨ ϕ → A
+                return _or(A, derv(s)) if nully(r) else A
+    
+            # ∂a(R ∧ S) → ∂a(R) ∧ ∂a(S)
+            # ∂a(R ∨ S) → ∂a(R) ∨ ∂a(S)
+            dr, ds = derv(r), derv(s)
+            return _and(dr, ds) if tag == AND else _or(dr, ds)
+    
+        return derv
+
+Let’s try it out…
+-----------------
+
+(FIXME: redo.)
+
+.. code:: python
+
+    o, z = D_compaction('0'), D_compaction('1')
+    REs = set()
+    N = 5
+    names = list(product(*(N * [(0, 1)])))
+    dervs = list(product(*(N * [(o, z)])))
+    for name, ds in zip(names, dervs):
+        R = it
+        ds = list(ds)
+        while ds:
+            R = ds.pop()(R)
+            if R == phi or R == I:
+                break
+            REs.add(R)
+    
+    print stringy(it) ; print
+    print o.hits, '/', o.calls
+    print z.hits, '/', z.calls
+    print
+    for s in sorted(map(stringy, REs), key=lambda n: (len(n), n)):
+        print s
+
+
+.. parsed-literal::
+
+    (.111.) & ((.01 | 11*)')
+    
+    92 / 122
+    92 / 122
+    
+    (.01)'
+    (.01 | 1)'
+    (.01 | ^)'
+    (.01 | 1*)'
+    (.111.) & ((.01 | 1)')
+    (.111. | 11.) & ((.01 | ^)')
+    (.111. | 11. | 1.) & ((.01)')
+    (.111. | 11.) & ((.01 | 1*)')
+    (.111. | 11. | 1.) & ((.01 | 1*)')
+
+
+Should match:
+
+::
+
+   (.111.) & ((.01 | 11*)')
+
+   92 / 122
+   92 / 122
+
+   (.01     )'
+   (.01 | 1 )'
+   (.01 | ^ )'
+   (.01 | 1*)'
+   (.111.)            & ((.01 | 1 )')
+   (.111. | 11.)      & ((.01 | ^ )')
+   (.111. | 11.)      & ((.01 | 1*)')
+   (.111. | 11. | 1.) & ((.01     )')
+   (.111. | 11. | 1.) & ((.01 | 1*)')
+
+Larger Alphabets
+----------------
+
+We could parse larger alphabets by defining patterns for e.g. each byte
+of the ASCII code. Or we can generalize this code. If you study the code
+above you’ll see that we never use the “set-ness” of the symbols ``O``
+and ``l``. The only time Python set operators (``&`` and ``|``) appear
+is in the ``nully()`` function, and there they operate on (recursively
+computed) outputs of that function, never ``O`` and ``l``.
+
+What if we try:
+
+::
+
+   (OR, O, l)
+
+   ∂1((OR, O, l))
+                               ∂a(R ∨ S) → ∂a(R) ∨ ∂a(S)
+   ∂1(O) ∨ ∂1(l)
+                               ∂a(¬a) → ϕ
+   ϕ ∨ ∂1(l)
+                               ∂a(a) → λ
+   ϕ ∨ λ
+                               ϕ ∨ R = R
+   λ
+
+And compare it to:
+
+::
+
+   {'0', '1')
+
+   ∂1({'0', '1'))
+                               ∂a(R ∨ S) → ∂a(R) ∨ ∂a(S)
+   ∂1({'0')) ∨ ∂1({'1'))
+                               ∂a(¬a) → ϕ
+   ϕ ∨ ∂1({'1'))
+                               ∂a(a) → λ
+   ϕ ∨ λ
+                               ϕ ∨ R = R
+   λ
+
+This suggests that we should be able to alter the functions above to
+detect sets and deal with them appropriately. Exercise for the Reader
+for now.
+
+State Machine
+-------------
+
+We can drive the regular expressions to flesh out the underlying state
+machine transition table.
+
+::
+
+   .111. & (.01 + 11*)'
+
+Says, “Three or more 1’s and not ending in 01 nor composed of all 1’s.”
+
+.. figure:: omg.svg
+   :alt: State Machine Graph
+
+   State Machine Graph
+
+Start at ``a`` and follow the transition arrows according to their
+labels. Accepting states have a double outline. (Graphic generated with
+`Dot from Graphviz <http://www.graphviz.org/>`__.) You’ll see that only
+paths that lead to one of the accepting states will match the regular
+expression. All other paths will terminate at one of the non-accepting
+states.
+
+There’s a happy path to ``g`` along 111:
+
+::
+
+   a→c→e→g
+
+After you reach ``g`` you’re stuck there eating 1’s until you see a 0,
+which takes you to the ``i→j→i|i→j→h→i`` “trap”. You can’t reach any
+other states from those two loops.
+
+If you see a 0 before you see 111 you will reach ``b``, which forms
+another “trap” with ``d`` and ``f``. The only way out is another happy
+path along 111 to ``h``:
+
+::
+
+   b→d→f→h
+
+Once you have reached ``h`` you can see as many 1’s or as many 0’ in a
+row and still be either still at ``h`` (for 1’s) or move to ``i`` (for
+0’s). If you find yourself at ``i`` you can see as many 0’s, or
+repetitions of 10, as there are, but if you see just a 1 you move to
+``j``.
+
+RE to FSM
+~~~~~~~~~
+
+So how do we get the state machine from the regular expression?
+
+It turns out that each RE is effectively a state, and each arrow points
+to the derivative RE in respect to the arrow’s symbol.
+
+If we label the initial RE ``a``, we can say:
+
+::
+
+   a --0--> ∂0(a)
+   a --1--> ∂1(a)
+
+And so on, each new unique RE is a new state in the FSM table.
+
+Here are the derived REs at each state:
+
+::
+
+   a = (.111.) & ((.01 | 11*)')
+   b = (.111.) & ((.01 | 1)')
+   c = (.111. | 11.) & ((.01 | 1*)')
+   d = (.111. | 11.) & ((.01 | ^)')
+   e = (.111. | 11. | 1.) & ((.01 | 1*)')
+   f = (.111. | 11. | 1.) & ((.01)')
+   g = (.01 | 1*)'
+   h = (.01)'
+   i = (.01 | 1)'
+   j = (.01 | ^)'
+
+You can see the one-way nature of the ``g`` state and the ``hij`` “trap”
+in the way that the ``.111.`` on the left-hand side of the ``&``
+disappears once it has been matched.
+
+.. code:: python
+
+    from collections import defaultdict
+    from pprint import pprint
+    from string import ascii_lowercase
+
+.. code:: python
+
+    d0, d1 = D_compaction('0'), D_compaction('1')
+
+``explore()``
+~~~~~~~~~~~~~
+
+.. code:: python
+
+    def explore(re):
+    
+        # Don't have more than 26 states...
+        names = defaultdict(iter(ascii_lowercase).next)
+    
+        table, accepting = dict(), set()
+    
+        to_check = {re}
+        while to_check:
+    
+            re = to_check.pop()
+            state_name = names[re]
+    
+            if (state_name, 0) in table:
+                continue
+    
+            if nully(re):
+                accepting.add(state_name)
+    
+            o, i = d0(re), d1(re)
+            table[state_name, 0] = names[o] ; to_check.add(o)
+            table[state_name, 1] = names[i] ; to_check.add(i)
+    
+        return table, accepting
+
+.. code:: python
+
+    table, accepting = explore(it)
+    table
+
+
+
+
+.. parsed-literal::
+
+    {('a', 0): 'b',
+     ('a', 1): 'c',
+     ('b', 0): 'b',
+     ('b', 1): 'd',
+     ('c', 0): 'b',
+     ('c', 1): 'e',
+     ('d', 0): 'b',
+     ('d', 1): 'f',
+     ('e', 0): 'b',
+     ('e', 1): 'g',
+     ('f', 0): 'b',
+     ('f', 1): 'h',
+     ('g', 0): 'i',
+     ('g', 1): 'g',
+     ('h', 0): 'i',
+     ('h', 1): 'h',
+     ('i', 0): 'i',
+     ('i', 1): 'j',
+     ('j', 0): 'i',
+     ('j', 1): 'h'}
+
+
+
+.. code:: python
+
+    accepting
+
+
+
+
+.. parsed-literal::
+
+    {'h', 'i'}
+
+
+
+Generate Diagram
+~~~~~~~~~~~~~~~~
+
+Once we have the FSM table and the set of accepting states we can
+generate the diagram above.
+
+.. code:: python
+
+    _template = '''\
+    digraph finite_state_machine {
+      rankdir=LR;
+      size="8,5"
+      node [shape = doublecircle]; %s;
+      node [shape = circle];
+    %s
+    }
+    '''
+    
+    def link(fr, nm, label):
+        return '  %s -> %s [ label = "%s" ];' % (fr, nm, label)
+    
+    
+    def make_graph(table, accepting):
+        return _template % (
+            ' '.join(accepting),
+            '\n'.join(
+              link(from_, to, char)
+              for (from_, char), (to) in sorted(table.iteritems())
+              )
+            )
+
+.. code:: python
+
+    print make_graph(table, accepting)
+
+
+.. parsed-literal::
+
+    digraph finite_state_machine {
+      rankdir=LR;
+      size="8,5"
+      node [shape = doublecircle]; i h;
+      node [shape = circle];
+      a -> b [ label = "0" ];
+      a -> c [ label = "1" ];
+      b -> b [ label = "0" ];
+      b -> d [ label = "1" ];
+      c -> b [ label = "0" ];
+      c -> e [ label = "1" ];
+      d -> b [ label = "0" ];
+      d -> f [ label = "1" ];
+      e -> b [ label = "0" ];
+      e -> g [ label = "1" ];
+      f -> b [ label = "0" ];
+      f -> h [ label = "1" ];
+      g -> i [ label = "0" ];
+      g -> g [ label = "1" ];
+      h -> i [ label = "0" ];
+      h -> h [ label = "1" ];
+      i -> i [ label = "0" ];
+      i -> j [ label = "1" ];
+      j -> i [ label = "0" ];
+      j -> h [ label = "1" ];
+    }
+    
+
+
+Drive a FSM
+~~~~~~~~~~~
+
+There are *lots* of FSM libraries already. Once you have the state
+transition table they should all be straightforward to use. State
+Machine code is very simple. Just for fun, here is an implementation in
+Python that imitates what “compiled” FSM code might look like in an
+“unrolled” form. Most FSM code uses a little driver loop and a table
+datastructure, the code below instead acts like JMP instructions
+(“jump”, or GOTO in higher-level-but-still-low-level languages) to
+hard-code the information in the table into a little patch of branches.
+
+Trampoline Function
+^^^^^^^^^^^^^^^^^^^
+
+Python has no GOTO statement but we can fake it with a “trampoline”
+function.
+
+.. code:: python
+
+    def trampoline(input_, jump_from, accepting):
+        I = iter(input_)
+        while True:
+            try:
+                bounce_to = jump_from(I)
+            except StopIteration:
+                return jump_from in accepting
+            jump_from = bounce_to
+
+Stream Functions
+^^^^^^^^^^^^^^^^
+
+Little helpers to process the iterator of our data (a “stream” of “1”
+and “0” characters, not bits.)
+
+.. code:: python
+
+    getch = lambda I: int(next(I))
+    
+    
+    def _1(I):
+        '''Loop on ones.'''
+        while getch(I): pass
+    
+    
+    def _0(I):
+        '''Loop on zeros.'''
+        while not getch(I): pass
+
+A Finite State Machine
+^^^^^^^^^^^^^^^^^^^^^^
+
+With those preliminaries out of the way, from the state table of
+``.111. & (.01 + 11*)'`` we can immediately write down state machine
+code. (You have to imagine that these are GOTO statements in C or
+branches in assembly and that the state names are branch destination
+labels.)
+
+.. code:: python
+
+    a = lambda I: c if getch(I) else b
+    b = lambda I: _0(I) or d
+    c = lambda I: e if getch(I) else b
+    d = lambda I: f if getch(I) else b
+    e = lambda I: g if getch(I) else b
+    f = lambda I: h if getch(I) else b
+    g = lambda I: _1(I) or i
+    h = lambda I: _1(I) or i
+    i = lambda I: _0(I) or j
+    j = lambda I: h if getch(I) else i
+
+Note that the implementations of ``h`` and ``g`` are identical ergo
+``h = g`` and we could eliminate one in the code but ``h`` is an
+accepting state and ``g`` isn’t.
+
+.. code:: python
+
+    def acceptable(input_):
+        return trampoline(input_, a, {h, i})
+
+.. code:: python
+
+    for n in range(2**5):
+        s = bin(n)[2:]
+        print '%05s' % s, acceptable(s)
+
+
+.. parsed-literal::
+
+        0 False
+        1 False
+       10 False
+       11 False
+      100 False
+      101 False
+      110 False
+      111 False
+     1000 False
+     1001 False
+     1010 False
+     1011 False
+     1100 False
+     1101 False
+     1110 True
+     1111 False
+    10000 False
+    10001 False
+    10010 False
+    10011 False
+    10100 False
+    10101 False
+    10110 False
+    10111 True
+    11000 False
+    11001 False
+    11010 False
+    11011 False
+    11100 True
+    11101 False
+    11110 True
+    11111 False
+
+
+Reversing the Derivatives to Generate Matching Strings
+------------------------------------------------------
+
+(UNFINISHED) Brzozowski also shewed how to go from the state machine to
+strings and expressions…
+
+Each of these states is just a name for a Brzozowskian RE, and so, other
+than the initial state ``a``, they can can be described in terms of the
+derivative-with-respect-to-N of some other state/RE:
+
+::
+
+   c = d1(a)
+   b = d0(a)
+   b = d0(c)
+   ...
+   i = d0(j)
+   j = d1(i)
+
+Consider:
+
+::
+
+   c = d1(a)
+   b = d0(c)
+
+Substituting:
+
+::
+
+   b = d0(d1(a))
+
+Unwrapping:
+
+::
+
+   b = d10(a)
+
+’’’
+
+::
+
+   j = d1(d0(j))
+
+Unwrapping:
+
+::
+
+   j = d1(d0(j)) = d01(j)
+
+We have a loop or “fixed point”.
+
+::
+
+   j = d01(j) = d0101(j) = d010101(j) = ...
+
+hmm…
+
+::
+
+   j = (01)*
+
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Developing.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Developing.rst.txt
new file mode 100644 (file)
index 0000000..556225a
--- /dev/null
@@ -0,0 +1,815 @@
+***************************
+Developing a Program in Joy
+***************************
+
+As an example of developing a program in Joy let's take the first problem from the Project Euler website.
+
+`Project Euler, first problem: "Multiples of 3 and 5" <https://projecteuler.net/problem=1>`__
+=============================================================================================
+
+
+    If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
+
+    Find the sum of all the multiples of 3 or 5 below 1000.
+
+.. code:: python
+
+    from notebook_preamble import J, V, define
+
+Sum a range filtered by a predicate
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Let's create a predicate that returns ``True`` if a number is a multiple
+of 3 or 5 and ``False`` otherwise.
+
+.. code:: python
+
+    define('P == [3 % not] dupdip 5 % not or')
+
+.. code:: python
+
+    V('80 P')
+
+
+.. parsed-literal::
+
+                 . 80 P
+              80 . P
+              80 . [3 % not] dupdip 5 % not or
+    80 [3 % not] . dupdip 5 % not or
+              80 . 3 % not 80 5 % not or
+            80 3 . % not 80 5 % not or
+               2 . not 80 5 % not or
+           False . 80 5 % not or
+        False 80 . 5 % not or
+      False 80 5 . % not or
+         False 0 . not or
+      False True . or
+            True . 
+
+
+Given the predicate function ``P`` a suitable program is:
+
+::
+
+    PE1 == 1000 range [P] filter sum
+
+This function generates a list of the integers from 0 to 999, filters
+that list by ``P``, and then sums the result.
+
+Logically this is fine, but pragmatically we are doing more work than we
+should be; we generate one thousand integers but actually use less than
+half of them. A better solution would be to generate just the multiples
+we want to sum, and to add them as we go rather than storing them and
+and summing them at the end.
+
+Generate just the multiples
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+At first I had the idea to use two counters and increase them by three
+and five, respectively. This way we only generate the terms that we
+actually want to sum. We have to proceed by incrementing the counter
+that is lower, or if they are equal, the three counter, and we have to
+take care not to double add numbers like 15 that are multiples of both
+three and five.
+
+This seemed a little clunky, so I tried a different approach.
+
+Consider the first few terms in the series:
+
+::
+
+    3 5 6 9 10 12 15 18 20 21 ...
+
+Subtract each number from the one after it (subtracting 0 from 3):
+
+::
+
+    3 5 6 9 10 12 15 18 20 21 24 25 27 30 ...
+    0 3 5 6  9 10 12 15 18 20 21 24 25 27 ...
+    -------------------------------------------
+    3 2 1 3  1  2  3  3  2  1  3  1  2  3 ...
+
+You get this lovely repeating palindromic sequence:
+
+::
+
+    3 2 1 3 1 2 3
+
+To make a counter that increments by factors of 3 and 5 you just add
+these differences to the counter one-by-one in a loop.
+
+To make use of this sequence to increment a counter and sum terms as we
+go we need a function that will accept the sum, the counter, and the
+next term to add, and that adds the term to the counter and a copy of
+the counter to the running sum. This function will do that:
+
+::
+
+    PE1.1 == + [+] dupdip
+
+.. code:: python
+
+    define('PE1.1 == + [+] dupdip')
+
+.. code:: python
+
+    V('0 0 3 PE1.1')
+
+
+.. parsed-literal::
+
+            . 0 0 3 PE1.1
+          0 . 0 3 PE1.1
+        0 0 . 3 PE1.1
+      0 0 3 . PE1.1
+      0 0 3 . + [+] dupdip
+        0 3 . [+] dupdip
+    0 3 [+] . dupdip
+        0 3 . + 3
+          3 . 3
+        3 3 . 
+
+
+.. code:: python
+
+    V('0 0 [3 2 1 3 1 2 3] [PE1.1] step')
+
+
+.. parsed-literal::
+
+                                . 0 0 [3 2 1 3 1 2 3] [PE1.1] step
+                              0 . 0 [3 2 1 3 1 2 3] [PE1.1] step
+                            0 0 . [3 2 1 3 1 2 3] [PE1.1] step
+            0 0 [3 2 1 3 1 2 3] . [PE1.1] step
+    0 0 [3 2 1 3 1 2 3] [PE1.1] . step
+                  0 0 3 [PE1.1] . i [2 1 3 1 2 3] [PE1.1] step
+                          0 0 3 . PE1.1 [2 1 3 1 2 3] [PE1.1] step
+                          0 0 3 . + [+] dupdip [2 1 3 1 2 3] [PE1.1] step
+                            0 3 . [+] dupdip [2 1 3 1 2 3] [PE1.1] step
+                        0 3 [+] . dupdip [2 1 3 1 2 3] [PE1.1] step
+                            0 3 . + 3 [2 1 3 1 2 3] [PE1.1] step
+                              3 . 3 [2 1 3 1 2 3] [PE1.1] step
+                            3 3 . [2 1 3 1 2 3] [PE1.1] step
+              3 3 [2 1 3 1 2 3] . [PE1.1] step
+      3 3 [2 1 3 1 2 3] [PE1.1] . step
+                  3 3 2 [PE1.1] . i [1 3 1 2 3] [PE1.1] step
+                          3 3 2 . PE1.1 [1 3 1 2 3] [PE1.1] step
+                          3 3 2 . + [+] dupdip [1 3 1 2 3] [PE1.1] step
+                            3 5 . [+] dupdip [1 3 1 2 3] [PE1.1] step
+                        3 5 [+] . dupdip [1 3 1 2 3] [PE1.1] step
+                            3 5 . + 5 [1 3 1 2 3] [PE1.1] step
+                              8 . 5 [1 3 1 2 3] [PE1.1] step
+                            8 5 . [1 3 1 2 3] [PE1.1] step
+                8 5 [1 3 1 2 3] . [PE1.1] step
+        8 5 [1 3 1 2 3] [PE1.1] . step
+                  8 5 1 [PE1.1] . i [3 1 2 3] [PE1.1] step
+                          8 5 1 . PE1.1 [3 1 2 3] [PE1.1] step
+                          8 5 1 . + [+] dupdip [3 1 2 3] [PE1.1] step
+                            8 6 . [+] dupdip [3 1 2 3] [PE1.1] step
+                        8 6 [+] . dupdip [3 1 2 3] [PE1.1] step
+                            8 6 . + 6 [3 1 2 3] [PE1.1] step
+                             14 . 6 [3 1 2 3] [PE1.1] step
+                           14 6 . [3 1 2 3] [PE1.1] step
+                 14 6 [3 1 2 3] . [PE1.1] step
+         14 6 [3 1 2 3] [PE1.1] . step
+                 14 6 3 [PE1.1] . i [1 2 3] [PE1.1] step
+                         14 6 3 . PE1.1 [1 2 3] [PE1.1] step
+                         14 6 3 . + [+] dupdip [1 2 3] [PE1.1] step
+                           14 9 . [+] dupdip [1 2 3] [PE1.1] step
+                       14 9 [+] . dupdip [1 2 3] [PE1.1] step
+                           14 9 . + 9 [1 2 3] [PE1.1] step
+                             23 . 9 [1 2 3] [PE1.1] step
+                           23 9 . [1 2 3] [PE1.1] step
+                   23 9 [1 2 3] . [PE1.1] step
+           23 9 [1 2 3] [PE1.1] . step
+                 23 9 1 [PE1.1] . i [2 3] [PE1.1] step
+                         23 9 1 . PE1.1 [2 3] [PE1.1] step
+                         23 9 1 . + [+] dupdip [2 3] [PE1.1] step
+                          23 10 . [+] dupdip [2 3] [PE1.1] step
+                      23 10 [+] . dupdip [2 3] [PE1.1] step
+                          23 10 . + 10 [2 3] [PE1.1] step
+                             33 . 10 [2 3] [PE1.1] step
+                          33 10 . [2 3] [PE1.1] step
+                    33 10 [2 3] . [PE1.1] step
+            33 10 [2 3] [PE1.1] . step
+                33 10 2 [PE1.1] . i [3] [PE1.1] step
+                        33 10 2 . PE1.1 [3] [PE1.1] step
+                        33 10 2 . + [+] dupdip [3] [PE1.1] step
+                          33 12 . [+] dupdip [3] [PE1.1] step
+                      33 12 [+] . dupdip [3] [PE1.1] step
+                          33 12 . + 12 [3] [PE1.1] step
+                             45 . 12 [3] [PE1.1] step
+                          45 12 . [3] [PE1.1] step
+                      45 12 [3] . [PE1.1] step
+              45 12 [3] [PE1.1] . step
+                45 12 3 [PE1.1] . i
+                        45 12 3 . PE1.1
+                        45 12 3 . + [+] dupdip
+                          45 15 . [+] dupdip
+                      45 15 [+] . dupdip
+                          45 15 . + 15
+                             60 . 15
+                          60 15 . 
+
+
+So one ``step`` through all seven terms brings the counter to 15 and the
+total to 60.
+
+How many multiples to sum?
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code:: python
+
+    1000 / 15
+
+
+
+
+.. parsed-literal::
+
+    66
+
+
+
+.. code:: python
+
+    66 * 15
+
+
+
+
+.. parsed-literal::
+
+    990
+
+
+
+.. code:: python
+
+    1000 - 990
+
+
+
+
+.. parsed-literal::
+
+    10
+
+
+
+We only want the terms *less than* 1000.
+
+.. code:: python
+
+    999 - 990
+
+
+
+
+.. parsed-literal::
+
+    9
+
+
+
+That means we want to run the full list of numbers sixty-six times to
+get to 990 and then the first four numbers 3 2 1 3 to get to 999.
+
+.. code:: python
+
+    define('PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop')
+
+.. code:: python
+
+    J('PE1')
+
+
+.. parsed-literal::
+
+    233168
+
+Packing the terms into an integer
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This form uses no extra storage and produces no unused summands. It's
+good but there's one more trick we can apply. The list of seven terms
+takes up at least seven bytes. But notice that all of the terms are less
+than four, and so each can fit in just two bits. We could store all
+seven terms in just fourteen bits and use masking and shifts to pick out
+each term as we go. This will use less space and save time loading whole
+integer terms from the list.
+
+::
+
+        3  2  1  3  1  2  3
+    0b 11 10 01 11 01 10 11 == 14811
+
+.. code:: python
+
+    0b11100111011011
+
+
+
+
+.. parsed-literal::
+
+    14811
+
+
+
+.. code:: python
+
+    define('PE1.2 == [3 & PE1.1] dupdip 2 >>')
+
+.. code:: python
+
+    V('0 0 14811 PE1.2')
+
+
+.. parsed-literal::
+
+                          . 0 0 14811 PE1.2
+                        0 . 0 14811 PE1.2
+                      0 0 . 14811 PE1.2
+                0 0 14811 . PE1.2
+                0 0 14811 . [3 & PE1.1] dupdip 2 >>
+    0 0 14811 [3 & PE1.1] . dupdip 2 >>
+                0 0 14811 . 3 & PE1.1 14811 2 >>
+              0 0 14811 3 . & PE1.1 14811 2 >>
+                    0 0 3 . PE1.1 14811 2 >>
+                    0 0 3 . + [+] dupdip 14811 2 >>
+                      0 3 . [+] dupdip 14811 2 >>
+                  0 3 [+] . dupdip 14811 2 >>
+                      0 3 . + 3 14811 2 >>
+                        3 . 3 14811 2 >>
+                      3 3 . 14811 2 >>
+                3 3 14811 . 2 >>
+              3 3 14811 2 . >>
+                 3 3 3702 . 
+
+
+.. code:: python
+
+    V('3 3 3702 PE1.2')
+
+
+.. parsed-literal::
+
+                         . 3 3 3702 PE1.2
+                       3 . 3 3702 PE1.2
+                     3 3 . 3702 PE1.2
+                3 3 3702 . PE1.2
+                3 3 3702 . [3 & PE1.1] dupdip 2 >>
+    3 3 3702 [3 & PE1.1] . dupdip 2 >>
+                3 3 3702 . 3 & PE1.1 3702 2 >>
+              3 3 3702 3 . & PE1.1 3702 2 >>
+                   3 3 2 . PE1.1 3702 2 >>
+                   3 3 2 . + [+] dupdip 3702 2 >>
+                     3 5 . [+] dupdip 3702 2 >>
+                 3 5 [+] . dupdip 3702 2 >>
+                     3 5 . + 5 3702 2 >>
+                       8 . 5 3702 2 >>
+                     8 5 . 3702 2 >>
+                8 5 3702 . 2 >>
+              8 5 3702 2 . >>
+                 8 5 925 . 
+
+
+.. code:: python
+
+    V('0 0 14811 7 [PE1.2] times pop')
+
+
+.. parsed-literal::
+
+                          . 0 0 14811 7 [PE1.2] times pop
+                        0 . 0 14811 7 [PE1.2] times pop
+                      0 0 . 14811 7 [PE1.2] times pop
+                0 0 14811 . 7 [PE1.2] times pop
+              0 0 14811 7 . [PE1.2] times pop
+      0 0 14811 7 [PE1.2] . times pop
+        0 0 14811 [PE1.2] . i 6 [PE1.2] times pop
+                0 0 14811 . PE1.2 6 [PE1.2] times pop
+                0 0 14811 . [3 & PE1.1] dupdip 2 >> 6 [PE1.2] times pop
+    0 0 14811 [3 & PE1.1] . dupdip 2 >> 6 [PE1.2] times pop
+                0 0 14811 . 3 & PE1.1 14811 2 >> 6 [PE1.2] times pop
+              0 0 14811 3 . & PE1.1 14811 2 >> 6 [PE1.2] times pop
+                    0 0 3 . PE1.1 14811 2 >> 6 [PE1.2] times pop
+                    0 0 3 . + [+] dupdip 14811 2 >> 6 [PE1.2] times pop
+                      0 3 . [+] dupdip 14811 2 >> 6 [PE1.2] times pop
+                  0 3 [+] . dupdip 14811 2 >> 6 [PE1.2] times pop
+                      0 3 . + 3 14811 2 >> 6 [PE1.2] times pop
+                        3 . 3 14811 2 >> 6 [PE1.2] times pop
+                      3 3 . 14811 2 >> 6 [PE1.2] times pop
+                3 3 14811 . 2 >> 6 [PE1.2] times pop
+              3 3 14811 2 . >> 6 [PE1.2] times pop
+                 3 3 3702 . 6 [PE1.2] times pop
+               3 3 3702 6 . [PE1.2] times pop
+       3 3 3702 6 [PE1.2] . times pop
+         3 3 3702 [PE1.2] . i 5 [PE1.2] times pop
+                 3 3 3702 . PE1.2 5 [PE1.2] times pop
+                 3 3 3702 . [3 & PE1.1] dupdip 2 >> 5 [PE1.2] times pop
+     3 3 3702 [3 & PE1.1] . dupdip 2 >> 5 [PE1.2] times pop
+                 3 3 3702 . 3 & PE1.1 3702 2 >> 5 [PE1.2] times pop
+               3 3 3702 3 . & PE1.1 3702 2 >> 5 [PE1.2] times pop
+                    3 3 2 . PE1.1 3702 2 >> 5 [PE1.2] times pop
+                    3 3 2 . + [+] dupdip 3702 2 >> 5 [PE1.2] times pop
+                      3 5 . [+] dupdip 3702 2 >> 5 [PE1.2] times pop
+                  3 5 [+] . dupdip 3702 2 >> 5 [PE1.2] times pop
+                      3 5 . + 5 3702 2 >> 5 [PE1.2] times pop
+                        8 . 5 3702 2 >> 5 [PE1.2] times pop
+                      8 5 . 3702 2 >> 5 [PE1.2] times pop
+                 8 5 3702 . 2 >> 5 [PE1.2] times pop
+               8 5 3702 2 . >> 5 [PE1.2] times pop
+                  8 5 925 . 5 [PE1.2] times pop
+                8 5 925 5 . [PE1.2] times pop
+        8 5 925 5 [PE1.2] . times pop
+          8 5 925 [PE1.2] . i 4 [PE1.2] times pop
+                  8 5 925 . PE1.2 4 [PE1.2] times pop
+                  8 5 925 . [3 & PE1.1] dupdip 2 >> 4 [PE1.2] times pop
+      8 5 925 [3 & PE1.1] . dupdip 2 >> 4 [PE1.2] times pop
+                  8 5 925 . 3 & PE1.1 925 2 >> 4 [PE1.2] times pop
+                8 5 925 3 . & PE1.1 925 2 >> 4 [PE1.2] times pop
+                    8 5 1 . PE1.1 925 2 >> 4 [PE1.2] times pop
+                    8 5 1 . + [+] dupdip 925 2 >> 4 [PE1.2] times pop
+                      8 6 . [+] dupdip 925 2 >> 4 [PE1.2] times pop
+                  8 6 [+] . dupdip 925 2 >> 4 [PE1.2] times pop
+                      8 6 . + 6 925 2 >> 4 [PE1.2] times pop
+                       14 . 6 925 2 >> 4 [PE1.2] times pop
+                     14 6 . 925 2 >> 4 [PE1.2] times pop
+                 14 6 925 . 2 >> 4 [PE1.2] times pop
+               14 6 925 2 . >> 4 [PE1.2] times pop
+                 14 6 231 . 4 [PE1.2] times pop
+               14 6 231 4 . [PE1.2] times pop
+       14 6 231 4 [PE1.2] . times pop
+         14 6 231 [PE1.2] . i 3 [PE1.2] times pop
+                 14 6 231 . PE1.2 3 [PE1.2] times pop
+                 14 6 231 . [3 & PE1.1] dupdip 2 >> 3 [PE1.2] times pop
+     14 6 231 [3 & PE1.1] . dupdip 2 >> 3 [PE1.2] times pop
+                 14 6 231 . 3 & PE1.1 231 2 >> 3 [PE1.2] times pop
+               14 6 231 3 . & PE1.1 231 2 >> 3 [PE1.2] times pop
+                   14 6 3 . PE1.1 231 2 >> 3 [PE1.2] times pop
+                   14 6 3 . + [+] dupdip 231 2 >> 3 [PE1.2] times pop
+                     14 9 . [+] dupdip 231 2 >> 3 [PE1.2] times pop
+                 14 9 [+] . dupdip 231 2 >> 3 [PE1.2] times pop
+                     14 9 . + 9 231 2 >> 3 [PE1.2] times pop
+                       23 . 9 231 2 >> 3 [PE1.2] times pop
+                     23 9 . 231 2 >> 3 [PE1.2] times pop
+                 23 9 231 . 2 >> 3 [PE1.2] times pop
+               23 9 231 2 . >> 3 [PE1.2] times pop
+                  23 9 57 . 3 [PE1.2] times pop
+                23 9 57 3 . [PE1.2] times pop
+        23 9 57 3 [PE1.2] . times pop
+          23 9 57 [PE1.2] . i 2 [PE1.2] times pop
+                  23 9 57 . PE1.2 2 [PE1.2] times pop
+                  23 9 57 . [3 & PE1.1] dupdip 2 >> 2 [PE1.2] times pop
+      23 9 57 [3 & PE1.1] . dupdip 2 >> 2 [PE1.2] times pop
+                  23 9 57 . 3 & PE1.1 57 2 >> 2 [PE1.2] times pop
+                23 9 57 3 . & PE1.1 57 2 >> 2 [PE1.2] times pop
+                   23 9 1 . PE1.1 57 2 >> 2 [PE1.2] times pop
+                   23 9 1 . + [+] dupdip 57 2 >> 2 [PE1.2] times pop
+                    23 10 . [+] dupdip 57 2 >> 2 [PE1.2] times pop
+                23 10 [+] . dupdip 57 2 >> 2 [PE1.2] times pop
+                    23 10 . + 10 57 2 >> 2 [PE1.2] times pop
+                       33 . 10 57 2 >> 2 [PE1.2] times pop
+                    33 10 . 57 2 >> 2 [PE1.2] times pop
+                 33 10 57 . 2 >> 2 [PE1.2] times pop
+               33 10 57 2 . >> 2 [PE1.2] times pop
+                 33 10 14 . 2 [PE1.2] times pop
+               33 10 14 2 . [PE1.2] times pop
+       33 10 14 2 [PE1.2] . times pop
+         33 10 14 [PE1.2] . i 1 [PE1.2] times pop
+                 33 10 14 . PE1.2 1 [PE1.2] times pop
+                 33 10 14 . [3 & PE1.1] dupdip 2 >> 1 [PE1.2] times pop
+     33 10 14 [3 & PE1.1] . dupdip 2 >> 1 [PE1.2] times pop
+                 33 10 14 . 3 & PE1.1 14 2 >> 1 [PE1.2] times pop
+               33 10 14 3 . & PE1.1 14 2 >> 1 [PE1.2] times pop
+                  33 10 2 . PE1.1 14 2 >> 1 [PE1.2] times pop
+                  33 10 2 . + [+] dupdip 14 2 >> 1 [PE1.2] times pop
+                    33 12 . [+] dupdip 14 2 >> 1 [PE1.2] times pop
+                33 12 [+] . dupdip 14 2 >> 1 [PE1.2] times pop
+                    33 12 . + 12 14 2 >> 1 [PE1.2] times pop
+                       45 . 12 14 2 >> 1 [PE1.2] times pop
+                    45 12 . 14 2 >> 1 [PE1.2] times pop
+                 45 12 14 . 2 >> 1 [PE1.2] times pop
+               45 12 14 2 . >> 1 [PE1.2] times pop
+                  45 12 3 . 1 [PE1.2] times pop
+                45 12 3 1 . [PE1.2] times pop
+        45 12 3 1 [PE1.2] . times pop
+          45 12 3 [PE1.2] . i pop
+                  45 12 3 . PE1.2 pop
+                  45 12 3 . [3 & PE1.1] dupdip 2 >> pop
+      45 12 3 [3 & PE1.1] . dupdip 2 >> pop
+                  45 12 3 . 3 & PE1.1 3 2 >> pop
+                45 12 3 3 . & PE1.1 3 2 >> pop
+                  45 12 3 . PE1.1 3 2 >> pop
+                  45 12 3 . + [+] dupdip 3 2 >> pop
+                    45 15 . [+] dupdip 3 2 >> pop
+                45 15 [+] . dupdip 3 2 >> pop
+                    45 15 . + 15 3 2 >> pop
+                       60 . 15 3 2 >> pop
+                    60 15 . 3 2 >> pop
+                  60 15 3 . 2 >> pop
+                60 15 3 2 . >> pop
+                  60 15 0 . pop
+                    60 15 . 
+
+
+And so we have at last:
+
+.. code:: python
+
+    define('PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop')
+
+.. code:: python
+
+    J('PE1')
+
+
+.. parsed-literal::
+
+    233168
+
+
+Let's refactor
+^^^^^^^^^^^^^^^
+
+::
+
+      14811 7 [PE1.2] times pop
+      14811 4 [PE1.2] times pop
+      14811 n [PE1.2] times pop
+    n 14811 swap [PE1.2] times pop
+
+.. code:: python
+
+    define('PE1.3 == 14811 swap [PE1.2] times pop')
+
+Now we can simplify the definition above:
+
+.. code:: python
+
+    define('PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop')
+
+.. code:: python
+
+    J('PE1')
+
+
+.. parsed-literal::
+
+    233168
+
+
+Here's our joy program all in one place. It doesn't make so much sense,
+but if you have read through the above description of how it was derived
+I hope it's clear.
+
+::
+
+    PE1.1 == + [+] dupdip
+    PE1.2 == [3 & PE1.1] dupdip 2 >>
+    PE1.3 == 14811 swap [PE1.2] times pop
+    PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop
+
+Generator Version
+=================
+
+It's a little clunky iterating sixty-six times though the seven numbers
+then four more. In the *Generator Programs* notebook we derive a
+generator that can be repeatedly driven by the ``x`` combinator to
+produce a stream of the seven numbers repeating over and over again.
+
+.. code:: python
+
+    define('PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]')
+
+.. code:: python
+
+    J('PE1.terms 21 [x] times')
+
+
+.. parsed-literal::
+
+    3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]
+
+
+We know from above that we need sixty-six times seven then four more
+terms to reach up to but not over one thousand.
+
+.. code:: python
+
+    J('7 66 * 4 +')
+
+
+.. parsed-literal::
+
+    466
+
+
+Here they are...
+~~~~~~~~~~~~~~~~
+
+.. code:: python
+
+    J('PE1.terms 466 [x] times pop')
+
+
+.. parsed-literal::
+
+    3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3
+
+
+...and they do sum to 999.
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code:: python
+
+    J('[PE1.terms 466 [x] times pop] run sum')
+
+
+.. parsed-literal::
+
+    999
+
+
+Now we can use ``PE1.1`` to accumulate the terms as we go, and then
+``pop`` the generator and the counter from the stack when we're done,
+leaving just the sum.
+
+.. code:: python
+
+    J('0 0 PE1.terms 466 [x [PE1.1] dip] times popop')
+
+
+.. parsed-literal::
+
+    233168
+
+
+A little further analysis renders iteration unnecessary.
+========================================================
+
+Consider finding the sum of the positive integers less than or equal to
+ten.
+
+.. code:: python
+
+    J('[10 9 8 7 6 5 4 3 2 1] sum')
+
+
+.. parsed-literal::
+
+    55
+
+
+Instead of summing them,
+`observe <https://en.wikipedia.org/wiki/File:Animated_proof_for_the_formula_giving_the_sum_of_the_first_integers_1%2B2%2B...%2Bn.gif>`__:
+
+::
+
+      10  9  8  7  6
+    +  1  2  3  4  5
+    ---- -- -- -- --
+      11 11 11 11 11
+      
+      11 * 5 = 55
+
+From the above example we can deduce that the sum of the first N
+positive integers is:
+
+::
+
+    (N + 1) * N / 2 
+
+(The formula also works for odd values of N, I'll leave that to you if
+you want to work it out or you can take my word for it.)
+
+.. code:: python
+
+    define('F == dup ++ * 2 floordiv')
+
+.. code:: python
+
+    V('10 F')
+
+
+.. parsed-literal::
+
+          . 10 F
+       10 . F
+       10 . dup ++ * 2 floordiv
+    10 10 . ++ * 2 floordiv
+    10 11 . * 2 floordiv
+      110 . 2 floordiv
+    110 2 . floordiv
+       55 . 
+
+
+Generalizing to Blocks of Terms
+-------------------------------
+
+We can apply the same reasoning to the PE1 problem.
+
+Between 0 and 990 inclusive there are sixty-six "blocks" of seven terms
+each, starting with:
+
+::
+
+    [3 5 6 9 10 12 15]
+
+And ending with:
+
+::
+
+    [978 980 981 984 985 987 990]
+
+If we reverse one of these two blocks and sum pairs...
+
+.. code:: python
+
+    J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip')
+
+
+.. parsed-literal::
+
+    [[978 15] [980 12] [981 10] [984 9] [985 6] [987 5] [990 3]]
+
+
+.. code:: python
+
+    J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map')
+
+
+.. parsed-literal::
+
+    [993 992 991 993 991 992 993]
+
+
+(Interesting that the sequence of seven numbers appears again in the
+rightmost digit of each term.)
+
+.. code:: python
+
+    J('[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum')
+
+
+.. parsed-literal::
+
+    6945
+
+
+Since there are sixty-six blocks and we are pairing them up, there must
+be thirty-three pairs, each of which sums to 6945. We also have these
+additional unpaired terms between 990 and 1000:
+
+::
+
+    993 995 996 999
+
+So we can give the "sum of all the multiples of 3 or 5 below 1000" like
+so:
+
+.. code:: python
+
+    J('6945 33 * [993 995 996 999] cons sum')
+
+
+.. parsed-literal::
+
+    233168
+
+
+It's worth noting, I think, that this same reasoning holds for any two
+numbers :math:`n` and :math:`m` the multiples of which we hope to sum.
+The multiples would have a cycle of differences of length :math:`k` and
+so we could compute the sum of :math:`Nk` multiples as above.
+
+The sequence of differences will always be a palidrome. Consider an
+interval spanning the least common multiple of :math:`n` and :math:`m`:
+
+::
+
+    |   |   |   |   |   |   |   |
+    |      |      |      |      |
+
+Here we have 4 and 7, and you can read off the sequence of differences
+directly from the diagram: 4 3 1 4 2 2 4 1 3 4.
+
+Geometrically, the actual values of :math:`n` and :math:`m` and their
+*lcm* don't matter, the pattern they make will always be symmetrical
+around its midpoint. The same reasoning holds for multiples of more than
+two numbers.
+
+The Simplest Program
+====================
+
+Of course, the simplest joy program for the first Project Euler problem
+is just:
+
+::
+
+    PE1 == 233168
+
+Fin.
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Generator_Programs.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Generator_Programs.rst.txt
new file mode 100644 (file)
index 0000000..a59df18
--- /dev/null
@@ -0,0 +1,635 @@
+Using ``x`` to Generate Values
+==============================
+
+Cf. jp-reprod.html
+
+.. code:: python
+
+    from notebook_preamble import J, V, define
+
+Consider the ``x`` combinator:
+
+::
+
+   x == dup i
+
+We can apply it to a quoted program consisting of some value ``a`` and
+some function ``B``:
+
+::
+
+   [a B] x
+   [a B] a B
+
+Let ``B`` function ``swap`` the ``a`` with the quote and run some
+function ``C`` on it to generate a new value ``b``:
+
+::
+
+   B == swap [C] dip
+
+   [a B] a B
+   [a B] a swap [C] dip
+   a [a B]      [C] dip
+   a C [a B]
+   b [a B]
+
+Now discard the quoted ``a`` with ``rest`` then ``cons`` ``b``:
+
+::
+
+   b [a B] rest cons
+   b [B]        cons
+   [b B]
+
+Altogether, this is the definition of ``B``:
+
+::
+
+   B == swap [C] dip rest cons
+
+We can make a generator for the Natural numbers (0, 1, 2, …) by using
+``0`` for ``a`` and ``[dup ++]`` for ``[C]``:
+
+::
+
+   [0 swap [dup ++] dip rest cons]
+
+Let’s try it:
+
+.. code:: python
+
+    V('[0 swap [dup ++] dip rest cons] x')
+
+
+.. parsed-literal::
+
+                                               . [0 swap [dup ++] dip rest cons] x
+               [0 swap [dup ++] dip rest cons] . x
+               [0 swap [dup ++] dip rest cons] . 0 swap [dup ++] dip rest cons
+             [0 swap [dup ++] dip rest cons] 0 . swap [dup ++] dip rest cons
+             0 [0 swap [dup ++] dip rest cons] . [dup ++] dip rest cons
+    0 [0 swap [dup ++] dip rest cons] [dup ++] . dip rest cons
+                                             0 . dup ++ [0 swap [dup ++] dip rest cons] rest cons
+                                           0 0 . ++ [0 swap [dup ++] dip rest cons] rest cons
+                                           0 1 . [0 swap [dup ++] dip rest cons] rest cons
+           0 1 [0 swap [dup ++] dip rest cons] . rest cons
+             0 1 [swap [dup ++] dip rest cons] . cons
+             0 [1 swap [dup ++] dip rest cons] . 
+
+
+After one application of ``x`` the quoted program contains ``1`` and
+``0`` is below it on the stack.
+
+.. code:: python
+
+    J('[0 swap [dup ++] dip rest cons] x x x x x pop')
+
+
+.. parsed-literal::
+
+    0 1 2 3 4
+
+
+``direco``
+----------
+
+.. code:: python
+
+    define('direco == dip rest cons')
+
+.. code:: python
+
+    V('[0 swap [dup ++] direco] x')
+
+
+.. parsed-literal::
+
+                                        . [0 swap [dup ++] direco] x
+               [0 swap [dup ++] direco] . x
+               [0 swap [dup ++] direco] . 0 swap [dup ++] direco
+             [0 swap [dup ++] direco] 0 . swap [dup ++] direco
+             0 [0 swap [dup ++] direco] . [dup ++] direco
+    0 [0 swap [dup ++] direco] [dup ++] . direco
+    0 [0 swap [dup ++] direco] [dup ++] . dip rest cons
+                                      0 . dup ++ [0 swap [dup ++] direco] rest cons
+                                    0 0 . ++ [0 swap [dup ++] direco] rest cons
+                                    0 1 . [0 swap [dup ++] direco] rest cons
+           0 1 [0 swap [dup ++] direco] . rest cons
+             0 1 [swap [dup ++] direco] . cons
+             0 [1 swap [dup ++] direco] . 
+
+
+Making Generators
+-----------------
+
+We want to define a function that accepts ``a`` and ``[C]`` and builds
+our quoted program:
+
+::
+
+            a [C] G
+   -------------------------
+      [a swap [C] direco]
+
+Working in reverse:
+
+::
+
+   [a swap   [C] direco] cons
+   a [swap   [C] direco] concat
+   a [swap] [[C] direco] swap
+   a [[C] direco] [swap]
+   a [C] [direco] cons [swap]
+
+Reading from the bottom up:
+
+::
+
+   G == [direco] cons [swap] swap concat cons
+   G == [direco] cons [swap] swoncat cons
+
+.. code:: python
+
+    define('G == [direco] cons [swap] swoncat cons')
+
+Let’s try it out:
+
+.. code:: python
+
+    J('0 [dup ++] G')
+
+
+.. parsed-literal::
+
+    [0 swap [dup ++] direco]
+
+
+.. code:: python
+
+    J('0 [dup ++] G x x x pop')
+
+
+.. parsed-literal::
+
+    0 1 2
+
+
+Powers of 2
+~~~~~~~~~~~
+
+.. code:: python
+
+    J('1 [dup 1 <<] G x x x x x x x x x pop')
+
+
+.. parsed-literal::
+
+    1 2 4 8 16 32 64 128 256
+
+
+``[x] times``
+~~~~~~~~~~~~~
+
+If we have one of these quoted programs we can drive it using ``times``
+with the ``x`` combinator.
+
+.. code:: python
+
+    J('23 [dup ++] G 5 [x] times')
+
+
+.. parsed-literal::
+
+    23 24 25 26 27 [28 swap [dup ++] direco]
+
+
+Generating Multiples of Three and Five
+--------------------------------------
+
+Look at the treatment of the Project Euler Problem One in the
+“Developing a Program” notebook and you’ll see that we might be
+interested in generating an endless cycle of:
+
+::
+
+   3 2 1 3 1 2 3
+
+To do this we want to encode the numbers as pairs of bits in a single
+int:
+
+::
+
+       3  2  1  3  1  2  3
+   0b 11 10 01 11 01 10 11 == 14811
+
+And pick them off by masking with 3 (binary 11) and then shifting the
+int right two bits.
+
+.. code:: python
+
+    define('PE1.1 == dup [3 &] dip 2 >>')
+
+.. code:: python
+
+    V('14811 PE1.1')
+
+
+.. parsed-literal::
+
+                      . 14811 PE1.1
+                14811 . PE1.1
+                14811 . dup [3 &] dip 2 >>
+          14811 14811 . [3 &] dip 2 >>
+    14811 14811 [3 &] . dip 2 >>
+                14811 . 3 & 14811 2 >>
+              14811 3 . & 14811 2 >>
+                    3 . 14811 2 >>
+              3 14811 . 2 >>
+            3 14811 2 . >>
+               3 3702 . 
+
+
+If we plug ``14811`` and ``[PE1.1]`` into our generator form…
+
+.. code:: python
+
+    J('14811 [PE1.1] G')
+
+
+.. parsed-literal::
+
+    [14811 swap [PE1.1] direco]
+
+
+…we get a generator that works for seven cycles before it reaches zero:
+
+.. code:: python
+
+    J('[14811 swap [PE1.1] direco] 7 [x] times')
+
+
+.. parsed-literal::
+
+    3 2 1 3 1 2 3 [0 swap [PE1.1] direco]
+
+
+Reset at Zero
+~~~~~~~~~~~~~
+
+We need a function that checks if the int has reached zero and resets it
+if so.
+
+.. code:: python
+
+    define('PE1.1.check == dup [pop 14811] [] branch')
+
+.. code:: python
+
+    J('14811 [PE1.1.check PE1.1] G')
+
+
+.. parsed-literal::
+
+    [14811 swap [PE1.1.check PE1.1] direco]
+
+
+.. code:: python
+
+    J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times')
+
+
+.. parsed-literal::
+
+    3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [PE1.1.check PE1.1] direco]
+
+
+(It would be more efficient to reset the int every seven cycles but
+that’s a little beyond the scope of this article. This solution does
+extra work, but not much, and we’re not using it “in production” as they
+say.)
+
+Run 466 times
+~~~~~~~~~~~~~
+
+In the PE1 problem we are asked to sum all the multiples of three and
+five less than 1000. It’s worked out that we need to use all seven
+numbers sixty-six times and then four more.
+
+.. code:: python
+
+    J('7 66 * 4 +')
+
+
+.. parsed-literal::
+
+    466
+
+
+If we drive our generator 466 times and sum the stack we get 999.
+
+.. code:: python
+
+    J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times')
+
+
+.. parsed-literal::
+
+    3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 [57 swap [PE1.1.check PE1.1] direco]
+
+
+.. code:: python
+
+    J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum')
+
+
+.. parsed-literal::
+
+    999
+
+
+Project Euler Problem One
+-------------------------
+
+.. code:: python
+
+    define('PE1.2 == + dup [+] dip')
+
+Now we can add ``PE1.2`` to the quoted program given to ``G``.
+
+.. code:: python
+
+    J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop')
+
+
+.. parsed-literal::
+
+    233168
+
+
+A generator for the Fibonacci Sequence.
+---------------------------------------
+
+Consider:
+
+::
+
+   [b a F] x
+   [b a F] b a F
+
+The obvious first thing to do is just add ``b`` and ``a``:
+
+::
+
+   [b a F] b a +
+   [b a F] b+a
+
+From here we want to arrive at:
+
+::
+
+   b [b+a b F]
+
+Let’s start with ``swons``:
+
+::
+
+   [b a F] b+a swons
+   [b+a b a F]
+
+Considering this quote as a stack:
+
+::
+
+   F a b b+a
+
+We want to get it to:
+
+::
+
+   F b b+a b
+
+So:
+
+::
+
+   F a b b+a popdd over
+   F b b+a b
+
+And therefore:
+
+::
+
+   [b+a b a F] [popdd over] infra
+   [b b+a b F]
+
+But we can just use ``cons`` to carry ``b+a`` into the quote:
+
+::
+
+   [b a F] b+a [popdd over] cons infra
+   [b a F] [b+a popdd over]      infra
+   [b b+a b F]
+
+Lastly:
+
+::
+
+   [b b+a b F] uncons
+   b [b+a b F]
+
+Putting it all together:
+
+::
+
+   F == + [popdd over] cons infra uncons
+   fib_gen == [1 1 F]
+
+.. code:: python
+
+    define('fib == + [popdd over] cons infra uncons')
+
+.. code:: python
+
+    define('fib_gen == [1 1 fib]')
+
+.. code:: python
+
+    J('fib_gen 10 [x] times')
+
+
+.. parsed-literal::
+
+    1 2 3 5 8 13 21 34 55 89 [144 89 fib]
+
+
+Project Euler Problem Two
+-------------------------
+
+   By considering the terms in the Fibonacci sequence whose values do
+   not exceed four million, find the sum of the even-valued terms.
+
+Now that we have a generator for the Fibonacci sequence, we need a
+function that adds a term in the sequence to a sum if it is even, and
+``pop``\ s it otherwise.
+
+.. code:: python
+
+    define('PE2.1 == dup 2 % [+] [pop] branch')
+
+And a predicate function that detects when the terms in the series
+“exceed four million”.
+
+.. code:: python
+
+    define('>4M == 4000000 >')
+
+Now it’s straightforward to define ``PE2`` as a recursive function that
+generates terms in the Fibonacci sequence until they exceed four million
+and sums the even ones.
+
+.. code:: python
+
+    define('PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec')
+
+.. code:: python
+
+    J('PE2')
+
+
+.. parsed-literal::
+
+    4613732
+
+
+Here’s the collected program definitions:
+
+::
+
+   fib == + swons [popdd over] infra uncons
+   fib_gen == [1 1 fib]
+
+   even == dup 2 %
+   >4M == 4000000 >
+
+   PE2.1 == even [+] [pop] branch
+   PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec
+
+Even-valued Fibonacci Terms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Using ``o`` for odd and ``e`` for even:
+
+::
+
+   o + o = e
+   e + e = e
+   o + e = o
+
+So the Fibonacci sequence considered in terms of just parity would be:
+
+::
+
+   o o e o o e o o e o o e o o e o o e
+   1 1 2 3 5 8 . . .
+
+Every third term is even.
+
+.. code:: python
+
+    J('[1 0 fib] x x x')  # To start the sequence with 1 1 2 3 instead of 1 2 3.
+
+
+.. parsed-literal::
+
+    1 1 2 [3 2 fib]
+
+
+Drive the generator three times and ``popop`` the two odd terms.
+
+.. code:: python
+
+    J('[1 0 fib] x x x [popop] dipd')
+
+
+.. parsed-literal::
+
+    2 [3 2 fib]
+
+
+.. code:: python
+
+    define('PE2.2 == x x x [popop] dipd')
+
+.. code:: python
+
+    J('[1 0 fib] 10 [PE2.2] times')
+
+
+.. parsed-literal::
+
+    2 8 34 144 610 2584 10946 46368 196418 832040 [1346269 832040 fib]
+
+
+Replace ``x`` with our new driver function ``PE2.2`` and start our
+``fib`` generator at ``1 0``.
+
+.. code:: python
+
+    J('0 [1 0 fib] PE2.2 [pop >4M] [popop] [[PE2.1] dip PE2.2] primrec')
+
+
+.. parsed-literal::
+
+    4613732
+
+
+How to compile these?
+---------------------
+
+You would probably start with a special version of ``G``, and perhaps
+modifications to the default ``x``?
+
+An Interesting Variation
+------------------------
+
+.. code:: python
+
+    define('codireco == cons dip rest cons')
+
+.. code:: python
+
+    V('[0 [dup ++] codireco] x')
+
+
+.. parsed-literal::
+
+                                     . [0 [dup ++] codireco] x
+               [0 [dup ++] codireco] . x
+               [0 [dup ++] codireco] . 0 [dup ++] codireco
+             [0 [dup ++] codireco] 0 . [dup ++] codireco
+    [0 [dup ++] codireco] 0 [dup ++] . codireco
+    [0 [dup ++] codireco] 0 [dup ++] . cons dip rest cons
+    [0 [dup ++] codireco] [0 dup ++] . dip rest cons
+                                     . 0 dup ++ [0 [dup ++] codireco] rest cons
+                                   0 . dup ++ [0 [dup ++] codireco] rest cons
+                                 0 0 . ++ [0 [dup ++] codireco] rest cons
+                                 0 1 . [0 [dup ++] codireco] rest cons
+           0 1 [0 [dup ++] codireco] . rest cons
+             0 1 [[dup ++] codireco] . cons
+             0 [1 [dup ++] codireco] . 
+
+
+.. code:: python
+
+    define('G == [codireco] cons cons')
+
+.. code:: python
+
+    J('230 [dup ++] G 5 [x] times pop')
+
+
+.. parsed-literal::
+
+    230 231 232 233 234
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Intro.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Intro.rst.txt
new file mode 100644 (file)
index 0000000..73704cf
--- /dev/null
@@ -0,0 +1,335 @@
+
+*******************
+Thun: Joy in Python
+*******************
+
+This implementation is meant as a tool for exploring the programming
+model and method of Joy. Python seems like a great implementation
+language for Joy for several reasons.
+
+* We can lean on the Python immutable types for our basic semantics and types: ints, floats, strings, and tuples, which enforces functional purity.
+* We get garbage collection for free.
+* Compilation via Cython.
+* Python is a "glue language" with loads of libraries which we can wrap in Joy functions.
+
+
+`Read-Eval-Print Loop (REPL) <https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop>`__
+====================================================================================================
+
+The main way to interact with the Joy interpreter is through a simple
+`REPL <https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop>`__
+that you start by running the package:
+
+::
+
+    $ python3 -m joy
+    Thun - Copyright © 2017 Simon Forman
+    This program comes with ABSOLUTELY NO WARRANTY; for details type "warranty".
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type "sharing" for details.
+    Type "words" to see a list of all words, and "[<name>] help" to print the
+    docs for a word.
+
+
+    <-top
+
+    joy? _
+
+The ``<-top`` marker points to the top of the (initially empty) stack.
+You can enter Joy notation at the prompt and a :doc:`trace of evaluation <../pretty>` will
+be printed followed by the stack and prompt again::
+
+    joy? 23 sqr 18 +
+
+    547 <-top
+
+    joy? 
+
+There is a `trace` combinator::
+
+    joy? 23 [sqr 18 +] trace
+        23 . sqr 18 +
+        23 . dup mul 18 +
+     23 23 . mul 18 +
+       529 . 18 +
+    529 18 . +
+       547 . 
+
+    547 <-top
+
+    joy? 
+
+
+The Stack
+=============
+
+In Joy, in addition to the types Boolean, integer, float, and string,
+there is a :doc:`single sequence type <../stack>` represented by enclosing a sequence of
+terms in brackets ``[...]``. This sequence type is used to represent
+both the stack and the expression. It is a `cons
+list <https://en.wikipedia.org/wiki/Cons#Lists>`__ made from Python
+tuples.
+
+
+Purely Functional Datastructures
+=================================
+
+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 `purely functional <https://en.wikipedia.org/wiki/Purely_functional_data_structure>`__.
+
+
+The ``joy()`` function
+=======================
+
+An Interpreter
+~~~~~~~~~~~~~~~~~
+
+The ``joy()`` interpreter function is extrememly simple. It accepts a stack, an
+expression, and a dictionary, and it iterates through the expression
+putting values onto the stack and delegating execution to functions which it
+looks up in the dictionary.
+
+
+`Continuation-Passing Style <https://en.wikipedia.org/wiki/Continuation-passing_style>`__
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+One day I thought, What happens if you rewrite Joy to use
+`CPS <https://en.wikipedia.org/wiki/Continuation-passing_style>`__? I
+made all the functions accept and return the expression as well as the
+stack and found that all the combinators could be rewritten to work by
+modifying the expression rather than making recursive calls to the
+``joy()`` function.
+
+
+View function
+~~~~~~~~~~~~~
+
+The ``joy()`` function accepts an optional ``viewer`` argument that
+is a function which it calls on
+each iteration passing the current stack and expression just before
+evaluation. This can be used for tracing, breakpoints, retrying after
+exceptions, or interrupting an evaluation and saving to disk or sending
+over the network to resume later. The stack and expression together
+contain all the state of the computation at each step.
+
+
+The ``TracePrinter``.
+~~~~~~~~~~~~~~~~~~~~~
+
+A ``viewer`` records each step of the evaluation of a Joy program. The
+``TracePrinter`` has a facility for printing out a trace of the
+evaluation, one line per step. Each step is aligned to the current
+interpreter position, signified by a period separating the stack on the
+left from the pending expression ("continuation") on the right.
+
+
+Parser
+======
+
+The parser is extremely simple.  The undocumented ``re.Scanner`` class
+does the tokenizing and then the parser builds the tuple
+structure out of the tokens. There's no Abstract Syntax Tree or anything
+like that.
+
+
+Symbols
+~~~~~~~~~~~~~
+
+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 *could* define recursive functions, er, recusively, without ``genrec`` or other recursion combinators  ``foo == ... foo ...`` but don't do that.
+
+
+Token Regular Expressions
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+    123   1.2   'single quotes'  "double quotes"   function
+
+TBD (look in the :module: joy.parser  module.)
+
+
+Examples
+~~~~~~~~~~~
+
+.. code:: python
+
+    joy.parser.text_to_expression('1 2 3 4 5')  # A simple sequence.
+
+
+.. parsed-literal::
+
+    (1, (2, (3, (4, (5, ())))))
+
+
+.. code:: python
+
+    joy.parser.text_to_expression('[1 2 3] 4 5')  # Three items, the first is a list with three items
+
+
+.. parsed-literal::
+
+    ((1, (2, (3, ()))), (4, (5, ())))
+
+
+.. code:: python
+
+    joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888')  # A mixed bag. cons is
+                                                                     # a Symbol, no lookup at
+                                                                     # parse-time.  Haiku docs.
+
+
+
+.. parsed-literal::
+
+    (1, (23, (('four', ((-5.0, ()), (cons, ()))), (8888, ()))))
+
+
+
+.. code:: python
+
+    joy.parser.text_to_expression('[][][][][]')  # Five empty lists.
+
+
+
+
+.. parsed-literal::
+
+    ((), ((), ((), ((), ((), ())))))
+
+
+
+.. code:: python
+
+    joy.parser.text_to_expression('[[[[[]]]]]')  # Five nested lists.
+
+
+
+
+.. parsed-literal::
+
+    ((((((), ()), ()), ()), ()), ())
+
+
+
+Library
+=======
+
+The Joy library of functions (aka commands, or "words" after Forth
+usage) encapsulates all the actual functionality (no pun intended) of
+the Joy system. There are simple functions such as addition ``add`` (or
+``+``, the library module supports aliases), and combinators which
+provide control-flow and higher-order operations.
+
+Many of the functions are defined in Python, like ``dip``:
+
+.. code:: python
+
+    print inspect.getsource(joy.library.dip)
+
+
+.. parsed-literal::
+
+    def dip(stack, expression, dictionary):
+      (quote, (x, stack)) = stack
+      expression = x, expression
+      return stack, concat(quote, expression), dictionary
+    
+
+Some functions are defined in equations in terms of other functions.
+When the interpreter executes a definition function that function just
+pushes its body expression onto the pending expression (the
+continuation) and returns control to the interpreter.
+
+.. code:: python
+
+    print joy.library.definitions
+
+
+.. parsed-literal::
+
+    second == rest first
+    third == rest rest first
+    product == 1 swap [*] step
+    swons == swap cons
+    swoncat == swap concat
+    flatten == [] swap [concat] step
+    unit == [] cons
+    quoted == [unit] dip
+    unquoted == [i] dip
+    enstacken == stack [clear] dip
+    disenstacken == ? [uncons ?] loop pop
+    ? == dup truthy
+    dinfrirst == dip infra first
+    nullary == [stack] dinfrirst
+    unary == [stack [pop] dip] dinfrirst
+    binary == [stack [popop] dip] dinfrirst
+    ternary == [stack [popop pop] dip] dinfrirst
+    pam == [i] map
+    run == [] swap infra
+    sqr == dup mul
+    size == 0 swap [pop ++] step
+    cleave == [i] app2 [popd] dip
+    average == [sum 1.0 *] [size] cleave /
+    gcd == 1 [tuck modulus dup 0 >] loop pop
+    least_fraction == dup [gcd] infra [div] concat map
+    *fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons
+    *fraction0 == concat [[swap] dip * [*] dip] infra
+    down_to_zero == [0 >] [dup --] while
+    range_to_zero == unit [down_to_zero] infra
+    anamorphism == [pop []] swap [dip swons] genrec
+    range == [0 <=] [1 - dup] anamorphism
+    while == swap [nullary] cons dup dipd concat loop
+    dudipd == dup dipd
+    primrec == [i] genrec
+    
+
+
+Currently, there's no function to add new definitions to the dictionary
+from "within" Joy code itself. Adding new definitions remains a
+meta-interpreter action. You have to do it yourself, in Python, and wash
+your hands afterward.
+
+It would be simple enough to define one, but it would open the door to
+*name binding* and break the idea that all state is captured in the
+stack and expression. There's an implicit *standard dictionary* that
+defines the actual semantics of the syntactic stack and expression
+datastructures (which only contain symbols, not the actual functions.
+Pickle some and see for yourself.)
+
+"There should be only one."
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Which brings me to talking about one of my hopes and dreams for this
+notation: "There should be only one." What I mean is that there should
+be one universal standard dictionary of commands, and all bespoke work
+done in a UI for purposes takes place by direct interaction and macros.
+There would be a *Grand Refactoring* biannually (two years, not six
+months, that's semi-annually) where any new definitions factored out of
+the usage and macros of the previous time, along with new algorithms and
+such, were entered into the dictionary and posted to e.g. IPFS.
+
+Code should not burgeon wildly, as it does today. The variety of code
+should map more-or-less to the well-factored variety of human
+computably-solvable problems. There shouldn't be dozens of chat apps, JS
+frameworks, programming languages. It's a waste of time, a `fractal
+"thundering herd"
+attack <https://en.wikipedia.org/wiki/Thundering_herd_problem>`__ on
+human mentality.
+
+Literary Code Library
+~~~~~~~~~~~~~~~~~~~~~
+
+If you read over the other notebooks you'll see that developing code in
+Joy is a lot like doing simple mathematics, and the descriptions of the
+code resemble math papers. The code also works the first time, no bugs.
+If you have any experience programming at all, you are probably
+skeptical, as I was, but it seems to work: deriving code mathematically
+seems to lead to fewer errors.
+
+But my point now is that this great ratio of textual explanation to wind
+up with code that consists of a few equations and could fit on an index
+card is highly desirable. Less code has fewer errors. The structure of
+Joy engenders a kind of thinking that seems to be very effective for
+developing structured processes.
+
+There seems to be an elegance and power to the notation.
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Newton-Raphson.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Newton-Raphson.rst.txt
new file mode 100644 (file)
index 0000000..b580502
--- /dev/null
@@ -0,0 +1,257 @@
+`Newton's method <https://en.wikipedia.org/wiki/Newton%27s_method>`__
+=====================================================================
+
+Let's use the Newton-Raphson method for finding the root of an equation
+to write a function that can compute the square root of a number.
+
+Cf. `"Why Functional Programming Matters" by John
+Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__
+
+.. code:: python
+
+    from notebook_preamble import J, V, define
+
+A Generator for Approximations
+------------------------------
+
+To make a generator that generates successive approximations let’s start
+by assuming an initial approximation and then derive the function that
+computes the next approximation:
+
+::
+
+       a F
+    ---------
+        a'
+
+A Function to Compute the Next Approximation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This is the equation for computing the next approximate value of the
+square root:
+
+:math:`a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}`
+
+::
+
+    a n over / + 2 /
+    a n a    / + 2 /
+    a n/a      + 2 /
+    a+n/a        2 /
+    (a+n/a)/2
+
+The function we want has the argument ``n`` in it:
+
+::
+
+    F == n over / + 2 /
+
+Make it into a Generator
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Our generator would be created by:
+
+::
+
+    a [dup F] make_generator
+
+With n as part of the function F, but n is the input to the sqrt
+function we’re writing. If we let 1 be the initial approximation:
+
+::
+
+    1 n 1 / + 2 /
+    1 n/1   + 2 /
+    1 n     + 2 /
+    n+1       2 /
+    (n+1)/2
+
+The generator can be written as:
+
+::
+
+    23 1 swap  [over / + 2 /] cons [dup] swoncat make_generator
+    1 23       [over / + 2 /] cons [dup] swoncat make_generator
+    1       [23 over / + 2 /]      [dup] swoncat make_generator
+    1   [dup 23 over / + 2 /]                    make_generator
+
+.. code:: python
+
+    define('gsra 1 swap [over / + 2 /] cons [dup] swoncat make_generator')
+
+.. code:: python
+
+    J('23 gsra')
+
+
+.. parsed-literal::
+
+    [1 [dup 23 over / + 2 /] codireco]
+
+
+Let's drive the generator a few time (with the ``x`` combinator) and
+square the approximation to see how well it works...
+
+.. code:: python
+
+    J('23 gsra 6 [x popd] times first sqr')
+
+
+.. parsed-literal::
+
+    23.0000000001585
+
+
+Finding Consecutive Approximations within a Tolerance
+-----------------------------------------------------
+
+From `"Why Functional Programming Matters" by John
+Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__:
+
+    The remainder of a square root finder is a function *within*, which
+    takes a tolerance and a list of approximations and looks down the
+    list for two successive approximations that differ by no more than
+    the given tolerance.
+
+(And note that by “list” he means a lazily-evaluated list.)
+
+Using the *output* ``[a G]`` of the above generator for square root
+approximations, and further assuming that the first term a has been
+generated already and epsilon ε is handy on the stack...
+
+::
+
+       a [b G] ε within
+    ---------------------- a b - abs ε <=
+          b
+
+
+       a [b G] ε within
+    ---------------------- a b - abs ε >
+       b [c G] ε within
+
+Predicate
+~~~~~~~~~
+
+::
+
+    a [b G]             ε [first - abs] dip <=
+    a [b G] first - abs ε                   <=
+    a b           - abs ε                   <=
+    a-b             abs ε                   <=
+    abs(a-b)            ε                   <=
+    (abs(a-b)<=ε)
+
+.. code:: python
+
+    define('_within_P [first - abs] dip <=')
+
+Base-Case
+~~~~~~~~~
+
+::
+
+    a [b G] ε roll< popop first
+      [b G] ε a     popop first
+      [b G]               first
+       b
+
+.. code:: python
+
+    define('_within_B roll< popop first')
+
+Recur
+~~~~~
+
+::
+
+    a [b G] ε R0 [within] R1
+
+1. Discard a.
+2. Use ``x`` combinator to generate next term from ``G``.
+3. Run ``within`` with ``i`` (it is a "tail-recursive" function.)
+
+Pretty straightforward:
+
+::
+
+    a [b G]        ε R0           [within] R1
+    a [b G]        ε [popd x] dip [within] i
+    a [b G] popd x ε              [within] i
+      [b G]      x ε              [within] i
+    b [c G]        ε              [within] i
+    b [c G]        ε               within
+
+    b [c G] ε within
+
+.. code:: python
+
+    define('_within_R [popd x] dip')
+
+Setting up
+~~~~~~~~~~
+
+The recursive function we have defined so far needs a slight preamble:
+``x`` to prime the generator and the epsilon value to use:
+
+::
+
+    [a G] x ε ...
+    a [b G] ε ...
+
+.. code:: python
+
+    define('within x 0.000000001 [_within_P] [_within_B] [_within_R] tailrec')
+    define('sqrt gsra within')
+
+Try it out...
+
+.. code:: python
+
+    J('36 sqrt')
+
+
+.. parsed-literal::
+
+    6.0
+
+
+.. code:: python
+
+    J('23 sqrt')
+
+
+.. parsed-literal::
+
+    4.795831523312719
+
+
+Check it.
+
+.. code:: python
+
+    4.795831523312719**2
+
+
+
+
+.. parsed-literal::
+
+    22.999999999999996
+
+
+
+.. code:: python
+
+    from math import sqrt
+    
+    sqrt(23)
+
+
+
+
+.. parsed-literal::
+
+    4.795831523312719
+
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/NoUpdates.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/NoUpdates.rst.txt
new file mode 100644 (file)
index 0000000..f58bc8f
--- /dev/null
@@ -0,0 +1,22 @@
+
+**************
+No Updates
+**************
+
+DRAFT
+
+1. Joy doesn't need to change.
+
+  A. The interpreter doesn't need to change, ``viewer`` function can customize mainloop.  Or use a sub-interpreter (Joy in Joy.)  The base interpreter remains static.
+  B. Once a function has been named and defined *never change that name*.  It's just not allowed.  If you need to change a function ``foo`` you have to call it ``foo_II`` or something.  Once a function (name mapped to behavior) is released to the public *that's it*, it's done.
+  C. The language evolves by adding new definitions and refactoring, always choosing new names for new functions.
+
+2. Following `Semantic Versioning`_ there will never be a version 2.0.
+
+  A. `Major version must be incremented if any backwards incompatible changes are introduced to the public API. <https://semver.org/#spec-item-8>`__
+  B. We never implement any backwards incompatible changes, so...
+  C. We could see e.g. Thun version 1.273.3!
+
+
+.. _Semantic Versioning: https://semver.org
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Ordered_Binary_Trees.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Ordered_Binary_Trees.rst.txt
new file mode 100644 (file)
index 0000000..a625ac3
--- /dev/null
@@ -0,0 +1,1639 @@
+Treating Trees I: Ordered Binary Trees
+======================================
+
+Although any expression in Joy can be considered to describe a
+`tree <https://en.wikipedia.org/wiki/Tree_structure>`__ with the quotes
+as compound nodes and the non-quote values as leaf nodes, in this page I
+want to talk about `ordered binary
+trees <https://en.wikipedia.org/wiki/Binary_search_tree>`__ and how to
+make and use them.
+
+The basic structure, in a `crude type
+notation <https://en.wikipedia.org/wiki/Algebraic_data_type>`__, is:
+
+::
+
+   Tree :: [] | [key value Tree Tree]
+
+That says that a Tree is either the empty quote ``[]`` or a quote with
+four items: a key, a value, and two Trees representing the left and
+right branches of the tree.
+
+We’re going to derive some recursive functions to work with such
+datastructures:
+
+::
+
+   Tree-add
+   Tree-delete
+   Tree-get
+   Tree-iter
+   Tree-iter-order
+
+Once these functions are defined we have a new “type” to work with, and
+the Sufficiently Smart Compiler can be modified to use an optimized
+implementation under the hood. (Where does the “type” come from? It has
+a contingent existence predicated on the disciplined use of these
+functions on otherwise undistinguished Joy datastructures.)
+
+.. code:: python
+
+    from notebook_preamble import D, J, V, define, DefinitionWrapper
+
+Adding Nodes to the Tree
+------------------------
+
+Let’s consider adding nodes to a Tree structure.
+
+::
+
+      Tree value key Tree-add
+   -----------------------------
+               Tree′
+
+Adding to an empty node.
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+If the current node is ``[]`` then you just return
+``[key value [] []]``:
+
+::
+
+   Tree-add == [popop not] [[pop] dipd Tree-new] [R0] [R1] genrec
+
+``Tree-new``
+^^^^^^^^^^^^
+
+Where ``Tree-new`` is defined as:
+
+::
+
+      value key Tree-new
+   ------------------------
+      [key value [] []]
+
+Example:
+
+::
+
+   value key swap [[] []] cons cons
+   key value      [[] []] cons cons
+   key      [value [] []]      cons
+        [key value [] []]
+
+Definition:
+
+::
+
+   Tree-new == swap [[] []] cons cons
+
+.. code:: python
+
+    define('Tree-new == swap [[] []] cons cons')
+
+.. code:: python
+
+    J('"v" "k" Tree-new')
+
+
+.. parsed-literal::
+
+    ['k' 'v' [] []]
+
+
+(As an implementation detail, the ``[[] []]`` literal used in the
+definition of ``Tree-new`` will be reused to supply the *constant* tail
+for *all* new nodes produced by it. This is one of those cases where you
+get amortized storage “for free” by using `persistent
+datastructures <https://en.wikipedia.org/wiki/Persistent_data_structure>`__.
+Because the tail, which is ``((), ((), ()))`` in Python, is immutable
+and embedded in the definition body for ``Tree-new``, all new nodes can
+reuse it as their own tail without fear that some other code somewhere
+will change it.)
+
+Adding to a non-empty node.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We now have to derive ``R0`` and ``R1``, consider:
+
+::
+
+   [key_n value_n left right] value key R0 [Tree-add] R1
+
+In this case, there are three possibilites: the key can be greater or
+less than or equal to the node’s key. In two of those cases we will need
+to apply a copy of ``Tree-add``, so ``R0`` is pretty much out of the
+picture.
+
+::
+
+   [R0] == []
+
+A predicate to compare keys.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+::
+
+   [key_n value_n left right] value key [BTree-add] R1
+
+The first thing we need to do is compare the the key we’re adding to the
+node key and ``branch`` accordingly:
+
+::
+
+   [key_n value_n left right] value key [BTree-add] [P] [T] [E] ifte
+
+That would suggest something like:
+
+::
+
+   [key_n value_n left right] value key [BTree-add] P
+   [key_n value_n left right] value key [BTree-add] pop roll> pop first >
+   [key_n value_n left right] value key                 roll> pop first >
+   key [key_n value_n left right] value                 roll> pop first >
+   key key_n                                                            >
+   Boolean
+
+Let’s abstract the predicate just a little to let us specify the
+comparison operator:
+
+::
+
+   P > == pop roll> pop first >
+   P < == pop roll> pop first <
+   P   == pop roll> pop first
+
+.. code:: python
+
+    define('P == pop roll> pop first')
+
+.. code:: python
+
+    J('["old_key" 23 [] []] 17 "new_key" ["..."] P')
+
+
+.. parsed-literal::
+
+    'new_key' 'old_key'
+
+
+If the key we’re adding is greater than the node’s key.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Here the parentheses are meant to signify that the expression is not
+literal, the code in the parentheses is meant to have been evaluated:
+
+::
+
+      [key_n value_n left right] value key [Tree-add] T
+   -------------------------------------------------------
+      [key_n value_n left (Tree-add key value right)]
+
+So how do we do this? We’re going to want to use ``infra`` on some
+function ``K`` that has the key and value to work with, as well as the
+quoted copy of ``Tree-add`` to apply somehow. Considering the node as a
+stack:
+
+::
+
+      right left value_n key_n value key [Tree-add] K
+   -----------------------------------------------------
+      right value key Tree-add left value_n key_n
+
+Pretty easy:
+
+::
+
+   right left value_n key_n value key [Tree-add] cons cons dipdd
+   right left value_n key_n [value key Tree-add]           dipdd
+   right value key Tree-add left value_n key_n
+
+So:
+
+::
+
+   K == cons cons dipdd
+
+Looking at it from the point-of-view of the node as node again:
+
+::
+
+   [key_n value_n left right] [value key [Tree-add] K] infra
+
+Expand ``K`` and evaluate a little:
+
+::
+
+   [key_n value_n left right] [value key [Tree-add] K] infra
+   [key_n value_n left right] [value key [Tree-add] cons cons dipdd] infra
+   [key_n value_n left right] [[value key Tree-add]           dipdd] infra
+
+Then, working backwards:
+
+::
+
+   [key_n value_n left right] [[value key Tree-add]           dipdd]      infra
+   [key_n value_n left right] [value key Tree-add]           [dipdd] cons infra
+   [key_n value_n left right] value key [Tree-add] cons cons [dipdd] cons infra
+
+And so ``T`` is just:
+
+::
+
+   T == cons cons [dipdd] cons infra
+
+.. code:: python
+
+    define('T == cons cons [dipdd] cons infra')
+
+.. code:: python
+
+    J('["old_k" "old_value" "left" "right"] "new_value" "new_key" ["Tree-add"] T')
+
+
+.. parsed-literal::
+
+    ['old_k' 'old_value' 'left' 'Tree-add' 'new_key' 'new_value' 'right']
+
+
+If the key we’re adding is less than the node’s key.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This is very very similar to the above:
+
+::
+
+   [key_n value_n left right] value key [Tree-add] E
+   [key_n value_n left right] value key [Tree-add] [P <] [Te] [Ee] ifte
+
+.. code:: python
+
+    define('E == [P <] [Te] [Ee] ifte')
+
+In this case ``Te`` works that same as ``T`` but on the left child tree
+instead of the right, so the only difference is that it must use
+``dipd`` instead of ``dipdd``:
+
+::
+
+   Te == cons cons [dipd] cons infra
+
+.. code:: python
+
+    define('Te == cons cons [dipd] cons infra')
+
+.. code:: python
+
+    J('["old_k" "old_value" "left" "right"] "new_value" "new_key" ["Tree-add"] Te')
+
+
+.. parsed-literal::
+
+    ['old_k' 'old_value' 'Tree-add' 'new_key' 'new_value' 'left' 'right']
+
+
+Else the keys must be equal.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This means we must find:
+
+::
+
+      [key old_value left right] new_value key [Tree-add] Ee
+   ------------------------------------------------------------
+      [key new_value left right]
+
+This is another easy one:
+
+::
+
+   Ee == pop swap roll< rest rest cons cons
+
+Example:
+
+::
+
+   [key old_value left right] new_value key [Tree-add] pop swap roll< rest rest cons cons
+   [key old_value left right] new_value key                swap roll< rest rest cons cons
+   [key old_value left right] key new_value                     roll< rest rest cons cons
+   key new_value [key old_value left right]                           rest rest cons cons
+   key new_value [              left right]                                     cons cons
+                 [key new_value left right]
+
+.. code:: python
+
+    define('Ee == pop swap roll< rest rest cons cons')
+
+.. code:: python
+
+    J('["k" "old_value" "left" "right"] "new_value" "k" ["Tree-add"] Ee')
+
+
+.. parsed-literal::
+
+    ['k' 'new_value' 'left' 'right']
+
+
+Now we can define ``Tree-add``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+   Tree-add == [popop not] [[pop] dipd Tree-new] [] [[P >] [T] [E] ifte] genrec
+
+Putting it all together:
+
+::
+
+   Tree-new == swap [[] []] cons cons
+   P == pop roll> pop first
+   T == cons cons [dipdd] cons infra
+   Te == cons cons [dipd] cons infra
+   Ee == pop swap roll< rest rest cons cons
+   E == [P <] [Te] [Ee] ifte
+   R == [P >] [T] [E] ifte
+
+   Tree-add == [popop not] [[pop] dipd Tree-new] [] [R] genrec
+
+.. code:: python
+
+    define('Tree-add == [popop not] [[pop] dipd Tree-new] [] [[P >] [T] [E] ifte] genrec')
+
+Examples
+~~~~~~~~
+
+.. code:: python
+
+    J('[] 23 "b" Tree-add')  # Initial
+
+
+.. parsed-literal::
+
+    ['b' 23 [] []]
+
+
+.. code:: python
+
+    J('["b" 23 [] []] 88 "c" Tree-add')  # Greater than
+
+
+.. parsed-literal::
+
+    ['b' 23 [] ['c' 88 [] []]]
+
+
+.. code:: python
+
+    J('["b" 23 [] []] 88 "a" Tree-add')  # Less than
+
+
+.. parsed-literal::
+
+    ['b' 23 ['a' 88 [] []] []]
+
+
+.. code:: python
+
+    J('["b" 23 [] []] 88 "b" Tree-add')  # Equal to
+
+
+.. parsed-literal::
+
+    ['b' 88 [] []]
+
+
+.. code:: python
+
+    J('[] 23 "b" Tree-add 88 "a" Tree-add 44 "c" Tree-add')  # Series.
+
+
+.. parsed-literal::
+
+    ['b' 23 ['a' 88 [] []] ['c' 44 [] []]]
+
+
+.. code:: python
+
+    J('[] [[23 "b"] [88 "a"] [44 "c"]] [i Tree-add] step')
+
+
+.. parsed-literal::
+
+    ['b' 23 ['a' 88 [] []] ['c' 44 [] []]]
+
+
+Interlude: ``cmp`` combinator
+-----------------------------
+
+Instead of mucking about with nested ``ifte`` combinators let’s use
+``cmp`` which takes two values and three quoted programs on the stack
+and runs one of the three depending on the results of comparing the two
+values:
+
+::
+
+      a b [G] [E] [L] cmp
+   ------------------------- a > b
+           G
+
+      a b [G] [E] [L] cmp
+   ------------------------- a = b
+               E
+
+      a b [G] [E] [L] cmp
+   ------------------------- a < b
+                   L
+
+.. code:: python
+
+    J("1 0 ['G'] ['E'] ['L'] cmp")
+
+
+.. parsed-literal::
+
+    'G'
+
+
+.. code:: python
+
+    J("1 1 ['G'] ['E'] ['L'] cmp")
+
+
+.. parsed-literal::
+
+    'E'
+
+
+.. code:: python
+
+    J("0 1 ['G'] ['E'] ['L'] cmp")
+
+
+.. parsed-literal::
+
+    'L'
+
+
+Redefine ``Tree-add``
+~~~~~~~~~~~~~~~~~~~~~
+
+We need a new non-destructive predicate ``P``:
+
+::
+
+      [node_key node_value left right] value key [Tree-add] P
+   ------------------------------------------------------------------------
+      [node_key node_value left right] value key [Tree-add] key node_key
+
+Let’s start with ``over`` to get a copy of the key and then apply some
+function ``Q`` with the ``nullary`` combinator so it can dig out the
+node key (by throwing everything else away):
+
+::
+
+   P == over [Q] nullary
+
+   [node_key node_value left right] value key [Tree-add] over [Q] nullary
+   [node_key node_value left right] value key [Tree-add] key  [Q] nullary
+
+And ``Q`` would be:
+
+::
+
+   Q == popop popop first
+
+   [node_key node_value left right] value key [Tree-add] key Q
+   [node_key node_value left right] value key [Tree-add] key popop popop first
+   [node_key node_value left right] value key                      popop first
+   [node_key node_value left right]                                      first
+    node_key
+
+Or just:
+
+::
+
+   P == over [popop popop first] nullary
+
+.. code:: python
+
+    define('P == over [popop popop first] nullary')
+
+Using ``cmp`` to simplify `our code above at
+``R1`` <#Adding-to-a-non-empty-node.>`__:
+
+::
+
+   [node_key node_value left right] value key [Tree-add] R1
+   [node_key node_value left right] value key [Tree-add] P [T] [E] [Te] cmp
+
+The line above becomes one of the three lines below:
+
+::
+
+   [node_key node_value left right] value key [Tree-add] T
+   [node_key node_value left right] value key [Tree-add] E
+   [node_key node_value left right] value key [Tree-add] Te
+
+The definition is a little longer but, I think, more elegant and easier
+to understand:
+
+::
+
+   Tree-add == [popop not] [[pop] dipd Tree-new] [] [P [T] [Ee] [Te] cmp] genrec
+
+.. code:: python
+
+    define('Tree-add == [popop not] [[pop] dipd Tree-new] [] [P [T] [Ee] [Te] cmp] genrec')
+
+.. code:: python
+
+    J('[] 23 "b" Tree-add 88 "a" Tree-add 44 "c" Tree-add')  # Still works.
+
+
+.. parsed-literal::
+
+    ['b' 23 ['a' 88 [] []] ['c' 44 [] []]]
+
+
+A Function to Traverse this Structure
+-------------------------------------
+
+Let’s take a crack at writing a function that can recursively iterate or
+traverse these trees.
+
+Base case ``[]``
+~~~~~~~~~~~~~~~~
+
+The stopping predicate just has to detect the empty list:
+
+::
+
+   Tree-iter == [not] [E] [R0] [R1] genrec
+
+And since there’s nothing at this node, we just ``pop`` it:
+
+::
+
+   Tree-iter == [not] [pop] [R0] [R1] genrec
+
+Node case ``[key value left right]``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Now we need to figure out ``R0`` and ``R1``:
+
+::
+
+   Tree-iter == [not] [pop] [R0]           [R1] genrec
+             == [not] [pop] [R0 [Tree-iter] R1] ifte
+
+Let’s look at it *in situ*:
+
+::
+
+   [key value left right] R0 [Tree-iter] R1
+
+Processing the current node.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+``R0`` is almost certainly going to use ``dup`` to make a copy of the
+node and then ``dip`` on some function to process the copy with it:
+
+::
+
+   [key value left right] [F] dupdip                 [Tree-iter] R1
+   [key value left right]  F  [key value left right] [Tree-iter] R1
+
+For example, if we’re getting all the keys ``F`` would be ``first``:
+
+::
+
+   R0 == [first] dupdip
+
+   [key value left right] [first] dupdip                 [Tree-iter] R1
+   [key value left right]  first  [key value left right] [Tree-iter] R1
+   key                            [key value left right] [Tree-iter] R1
+
+Recur
+^^^^^
+
+Now ``R1`` needs to apply ``[Tree-iter]`` to ``left`` and ``right``. If
+we drop the key and value from the node using ``rest`` twice we are left
+with an interesting situation:
+
+::
+
+   key [key value left right] [Tree-iter] R1
+   key [key value left right] [Tree-iter] [rest rest] dip
+   key [key value left right] rest rest [Tree-iter]
+   key [left right] [Tree-iter]
+
+Hmm, will ``step`` do?
+
+::
+
+   key [left right] [Tree-iter] step
+   key left Tree-iter [right] [Tree-iter] step
+   key left-keys [right] [Tree-iter] step
+   key left-keys right Tree-iter
+   key left-keys right-keys
+
+Neat. So:
+
+::
+
+   R1 == [rest rest] dip step
+
+Putting it together
+~~~~~~~~~~~~~~~~~~~
+
+We have:
+
+::
+
+   Tree-iter == [not] [pop] [[F] dupdip] [[rest rest] dip step] genrec
+
+When I was reading this over I realized ``rest rest`` could go in
+``R0``:
+
+::
+
+   Tree-iter == [not] [pop] [[F] dupdip rest rest] [step] genrec
+
+(And ``[step] genrec`` is such a cool and suggestive combinator!)
+
+Parameterizing the ``F`` per-node processing function.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+                   [F] Tree-iter
+   ------------------------------------------------------
+      [not] [pop] [[F] dupdip rest rest] [step] genrec
+
+Working backward:
+
+::
+
+   [not] [pop] [[F] dupdip rest rest]            [step] genrec
+   [not] [pop] [F]       [dupdip rest rest] cons [step] genrec
+   [F] [not] [pop] roll< [dupdip rest rest] cons [step] genrec
+
+``Tree-iter``
+~~~~~~~~~~~~~
+
+::
+
+   Tree-iter == [not] [pop] roll< [dupdip rest rest] cons [step] genrec
+
+.. code:: python
+
+    define('Tree-iter == [not] [pop] roll< [dupdip rest rest] cons [step] genrec')
+
+Examples
+~~~~~~~~
+
+.. code:: python
+
+    J('[] [foo] Tree-iter')  #  It doesn't matter what F is as it won't be used.
+
+
+.. parsed-literal::
+
+    
+
+
+.. code:: python
+
+    J("['b' 23 ['a' 88 [] []] ['c' 44 [] []]] [first] Tree-iter")
+
+
+.. parsed-literal::
+
+    'b' 'a' 'c'
+
+
+.. code:: python
+
+    J("['b' 23 ['a' 88 [] []] ['c' 44 [] []]] [second] Tree-iter")
+
+
+.. parsed-literal::
+
+    23 88 44
+
+
+Interlude: A Set-like Datastructure
+-----------------------------------
+
+We can use this to make a set-like datastructure by just setting values
+to e.g. 0 and ignoring them. It’s set-like in that duplicate items added
+to it will only occur once within it, and we can query it in
+`:math:`O(\log_2 N)` <https://en.wikipedia.org/wiki/Binary_search_tree#cite_note-2>`__
+time.
+
+.. code:: python
+
+    J('[] [3 9 5 2 8 6 7 8 4] [0 swap Tree-add] step')
+
+
+.. parsed-literal::
+
+    [3 0 [2 0 [] []] [9 0 [5 0 [4 0 [] []] [8 0 [6 0 [] [7 0 [] []]] []]] []]]
+
+
+.. code:: python
+
+    define('to_set == [] swap [0 swap Tree-add] step')
+
+.. code:: python
+
+    J('[3 9 5 2 8 6 7 8 4] to_set')
+
+
+.. parsed-literal::
+
+    [3 0 [2 0 [] []] [9 0 [5 0 [4 0 [] []] [8 0 [6 0 [] [7 0 [] []]] []]] []]]
+
+
+And with that we can write a little program ``unique`` to remove
+duplicate items from a list.
+
+.. code:: python
+
+    define('unique == [to_set [first] Tree-iter] cons run')
+
+.. code:: python
+
+    J('[3 9 3 5 2 9 8 8 8 6 2 7 8 4 3] unique')  # Filter duplicate items.
+
+
+.. parsed-literal::
+
+    [7 6 8 4 5 9 2 3]
+
+
+A Version of ``Tree-iter`` that does In-Order Traversal
+-------------------------------------------------------
+
+If you look back to the `non-empty case of the ``Tree-iter``
+function <#Node-case-%5Bkey-value-left-right%5D>`__ we can design a
+variant that first processes the left child, then the current node, then
+the right child. This will allow us to traverse the tree in sort order.
+
+::
+
+   Tree-iter-order == [not] [pop] [R0] [R1] genrec
+
+To define ``R0`` and ``R1`` it helps to look at them as they will appear
+when they run:
+
+::
+
+   [key value left right] R0 [BTree-iter-order] R1
+
+Process the left child.
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Staring at this for a bit suggests ``dup third`` to start:
+
+::
+
+   [key value left right] R0        [Tree-iter-order] R1
+   [key value left right] dup third [Tree-iter-order] R1
+   [key value left right] left      [Tree-iter-order] R1
+
+Now maybe:
+
+::
+
+   [key value left right] left [Tree-iter-order] [cons dip] dupdip
+   [key value left right] left [Tree-iter-order]  cons dip [Tree-iter-order]
+   [key value left right] [left Tree-iter-order]       dip [Tree-iter-order]
+   left Tree-iter-order [key value left right]             [Tree-iter-order]
+
+Process the current node.
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+So far, so good. Now we need to process the current node’s values:
+
+::
+
+   left Tree-iter-order [key value left right] [Tree-iter-order] [[F] dupdip] dip
+   left Tree-iter-order [key value left right] [F] dupdip [Tree-iter-order]
+   left Tree-iter-order [key value left right] F [key value left right] [Tree-iter-order]
+
+If ``F`` needs items from the stack below the left stuff it should have
+``cons``\ ’d them before beginning maybe? For functions like ``first``
+it works fine as-is.
+
+::
+
+   left Tree-iter-order [key value left right] first [key value left right] [Tree-iter-order]
+   left Tree-iter-order key [key value left right] [Tree-iter-order]
+
+Process the right child.
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+First ditch the rest of the node and get the right child:
+
+::
+
+   left Tree-iter-order key [key value left right] [Tree-iter-order] [rest rest rest first] dip
+   left Tree-iter-order key right [Tree-iter-order]
+
+Then, of course, we just need ``i`` to run ``Tree-iter-order`` on the
+right side:
+
+::
+
+   left Tree-iter-order key right [Tree-iter-order] i
+   left Tree-iter-order key right Tree-iter-order
+
+Defining ``Tree-iter-order``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The result is a little awkward:
+
+::
+
+   R1 == [cons dip] dupdip [[F] dupdip] dip [rest rest rest first] dip i
+
+Let’s do a little semantic factoring:
+
+::
+
+   fourth == rest rest rest first
+
+   proc_left == [cons dip] dupdip
+   proc_current == [[F] dupdip] dip
+   proc_right == [fourth] dip i
+
+   Tree-iter-order == [not] [pop] [dup third] [proc_left proc_current proc_right] genrec
+
+Now we can sort sequences.
+
+.. code:: python
+
+    #define('Tree-iter-order == [not] [pop] [dup third] [[cons dip] dupdip [[first] dupdip] dip [rest rest rest first] dip i] genrec')
+    
+    
+    DefinitionWrapper.add_definitions('''
+    
+    fourth == rest rest rest first
+    
+    proc_left == [cons dip] dupdip
+    proc_current == [[first] dupdip] dip
+    proc_right == [fourth] dip i
+    
+    Tree-iter-order == [not] [pop] [dup third] [proc_left proc_current proc_right] genrec
+    
+    ''', D)
+    
+    
+
+
+.. code:: python
+
+    J('[3 9 5 2 8 6 7 8 4] to_set Tree-iter-order')
+
+
+.. parsed-literal::
+
+    2 3 4 5 6 7 8 9
+
+
+Parameterizing the ``[F]`` function is left as an exercise for the
+reader.
+
+Getting values by key
+---------------------
+
+Let’s derive a function that accepts a tree and a key and returns the
+value associated with that key.
+
+::
+
+      tree key Tree-get
+   -----------------------
+           value
+
+But what do we do if the key isn’t in the tree? In Python we might raise
+a ``KeyError`` but I’d like to avoid exceptions in Joy if possible, and
+here I think it’s possible. (Division by zero is an example of where I
+think it’s probably better to let Python crash Joy. Sometimes the
+machinery fails and you have to “stop the line”, I think.)
+
+Let’s pass the buck to the caller by making the base case a given, you
+have to decide for yourself what ``[E]`` should be.
+
+::
+
+      tree key [E] Tree-get
+   ---------------------------- key in tree
+              value
+
+      tree key [E] Tree-get
+   ---------------------------- key not in tree
+            [] key E
+
+The base case ``[]``
+~~~~~~~~~~~~~~~~~~~~
+
+As before, the stopping predicate just has to detect the empty list:
+
+::
+
+   Tree-get == [pop not] [E] [R0] [R1] genrec
+
+So we define:
+
+::
+
+   Tree-get == [pop not] swap [R0] [R1] genrec
+
+Note that this ``Tree-get`` creates a slightly different function than
+itself and *that function* does the actual recursion. This kind of
+higher-level programming is unusual in most languages but natural in
+Joy.
+
+::
+
+   tree key [E] [pop not] swap [R0] [R1] genrec
+   tree key [pop not] [E] [R0] [R1] genrec
+
+The anonymous specialized recursive function that will do the real work.
+
+::
+
+   [pop not] [E] [R0] [R1] genrec
+
+Node case ``[key value left right]``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Now we need to figure out ``R0`` and ``R1``:
+
+::
+
+   [key value left right] key R0 [BTree-get] R1
+
+We want to compare the search key with the key in the node, and if they
+are the same return the value, otherwise recur on one of the child
+nodes. So it’s very similar to the above funtion, with ``[R0] == []``
+and ``R1 == P [T>] [E] [T<] cmp``:
+
+::
+
+   [key value left right] key [BTree-get] P [T>] [E] [T<] cmp
+
+Predicate
+^^^^^^^^^
+
+::
+
+   P == over [get-node-key] nullary
+   get-node-key == pop popop first
+
+The only difference is that ``get-node-key`` does one less ``pop``
+because there’s no value to discard.
+
+Branches
+^^^^^^^^
+
+Now we have to derive the branches:
+
+::
+
+   [key_n value_n left right] key [BTree-get] T>
+   [key_n value_n left right] key [BTree-get] E
+   [key_n value_n left right] key [BTree-get] T<
+
+Greater than and less than
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The cases of ``T>`` and ``T<`` are similar to above but instead of using
+``infra`` we have to discard the rest of the structure:
+
+::
+
+      [key_n value_n left right] key [BTree-get] T>
+   ---------------------------------------------------
+                          right  key  BTree-get
+
+And:
+
+::
+
+      [key_n value_n left right] key [BTree-get] T<
+   ---------------------------------------------------
+                     left        key  BTree-get
+
+So:
+
+::
+
+   T> == [fourth] dipd i
+   T< == [third] dipd i
+
+E.g.:
+
+::
+
+   [key_n value_n left right]        key [BTree-get] [fourth] dipd i
+   [key_n value_n left right] fourth key [BTree-get]               i
+                       right         key [BTree-get]               i
+                       right         key  BTree-get
+
+Equal keys
+^^^^^^^^^^
+
+Return the node’s value:
+
+::
+
+   [key_n value_n left right] key [BTree-get] E == value_n
+
+   E == popop second
+
+``Tree-get``
+~~~~~~~~~~~~
+
+So:
+
+::
+
+   fourth == rest rest rest first
+   get-node-key == pop popop first
+   P == over [get-node-key] nullary
+   T> == [fourth] dipd i
+   T< == [third] dipd i
+   E == popop second
+
+   Tree-get == [pop not] swap [] [P [T>] [E] [T<] cmp] genrec
+
+.. code:: python
+
+    # I don't want to deal with name conflicts with the above so I'm inlining everything here.
+    # The original Joy system has "hide" which is a meta-command which allows you to use named
+    # definitions that are only in scope for a given definition.  I don't want to implement
+    # that (yet) so...
+    
+    
+    define('''
+    Tree-get == [pop not] swap [] [
+      over [pop popop first] nullary
+      [[fourth] dipd i]
+      [popop second]
+      [[third] dipd i]
+      cmp
+      ] genrec
+    ''')
+
+.. code:: python
+
+    J('["gary" 23 [] []] "mike" [popd " not in tree" +] Tree-get')
+
+
+.. parsed-literal::
+
+    'mike not in tree'
+
+
+.. code:: python
+
+    J('["gary" 23 [] []] "gary" [popop "err"] Tree-get')
+
+
+.. parsed-literal::
+
+    23
+
+
+.. code:: python
+
+    J('''
+    
+        [] [[0 'a'] [1 'b'] [2 'c']] [i Tree-add] step
+    
+        'c' [popop 'not found'] Tree-get
+    
+    ''')
+
+
+.. parsed-literal::
+
+    2
+
+
+.. code:: python
+
+    J('''
+    
+        [] [[0 'a'] [1 'b'] [2 'c']] [i Tree-add] step
+    
+        'd' [popop 'not found'] Tree-get
+    
+    ''')
+
+
+.. parsed-literal::
+
+    'not found'
+
+
+Tree-delete
+-----------
+
+Now let’s write a function that can return a tree datastructure with a
+key, value pair deleted:
+
+::
+
+      tree key Tree-delete
+   ---------------------------
+             tree
+
+If the key is not in tree it just returns the tree unchanged.
+
+Base case
+~~~~~~~~~
+
+Same as above.
+
+::
+
+   Tree-Delete == [pop not] [pop] [R0] [R1] genrec
+
+Recur
+~~~~~
+
+Now we get to figure out the recursive case. We need the node’s key to
+compare and we need to carry the key into recursive branches. Let ``D``
+be shorthand for ``Tree-Delete``:
+
+::
+
+   D == Tree-Delete == [pop not] [pop] [R0] [R1] genrec
+
+   [node_key node_value left right] key R0                   [D] R1
+   [node_key node_value left right] key over  first swap dup [D] cons R1′
+   [node_key node_value left right] key [...] first swap dup [D] cons R1′
+   [node_key node_value left right] key node_key    swap dup [D] cons R1′
+   [node_key node_value left right] node_key key         dup [D] cons R1′
+   [node_key node_value left right] node_key key key         [D] cons R1′
+   [node_key node_value left right] node_key key         [key D]      R1′
+
+And then:
+
+::
+
+   [node_key node_value left right] node_key key [key D] R1′
+   [node_key node_value left right] node_key key [key D] roll> [T>] [E] [T<] cmp
+   [node_key node_value left right] node_key key [key D] roll> [T>] [E] [T<] cmp
+   [node_key node_value left right] [key D] node_key key       [T>] [E] [T<] cmp
+
+So:
+
+::
+
+   R0 == over first swap dup
+   R1 == cons roll> [T>] [E] [T<] cmp
+
+Compare Keys
+~~~~~~~~~~~~
+
+The last line above:
+
+::
+
+   [node_key node_value left right] [key D] node_key key [T>] [E] [T<] cmp
+
+Then becomes one of these three:
+
+::
+
+   [node_key node_value left right] [key D] T>
+   [node_key node_value left right] [key D] E
+   [node_key node_value left right] [key D] T<
+
+Greater than case and less than case
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+      [node_key node_value left right] [F] T>
+   -------------------------------------------------
+      [node_key node_value (left F) right]
+
+
+      [node_key node_value left right] [F] T<
+   -------------------------------------------------
+      [node_key node_value left (right F)]
+
+First, treating the node as a stack:
+
+::
+
+   right left       node_value node_key [key D] dipd
+   right left key D node_value node_key
+   right left'      node_value node_key
+
+Ergo:
+
+::
+
+   [node_key node_value left right] [key D] [dipd] cons infra
+
+So:
+
+::
+
+   T> == [dipd] cons infra
+   T< == [dipdd] cons infra
+
+The else case
+~~~~~~~~~~~~~
+
+We have found the node in the tree where ``key`` equals ``node_key``. We
+need to replace the current node with something
+
+::
+
+      [node_key node_value left right] [key D] E
+   ------------------------------------------------
+                       tree
+
+We have to handle three cases, so let’s use ``cond``.
+
+One or more child nodes are ``[]``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The first two cases are symmetrical: if we only have one non-empty child
+node return it. If both child nodes are empty return an empty node.
+
+::
+
+   E == [
+       [[pop third not] pop fourth]
+       [[pop fourth not] pop third]
+       [default]
+   ] cond
+
+Both child nodes are non-empty.
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If both child nodes are non-empty, we find the highest node in our lower
+sub-tree, take its key and value to replace (delete) our own, then get
+rid of it by recursively calling delete() on our lower sub-node with our
+new key.
+
+(We could also find the lowest node in our higher sub-tree and take its
+key and value and delete it. I only implemented one of these two
+symmetrical options. Over a lot of deletions this might make the tree
+more unbalanced. Oh well.)
+
+The initial structure of the default function:
+
+::
+
+   default == [E′] cons infra
+
+   [node_key node_value left right] [key D] default
+   [node_key node_value left right] [key D] [E′] cons infra
+   [node_key node_value left right] [[key D] E′]      infra
+
+   right left node_value node_key [key D] E′
+
+First things first, we no longer need this node’s key and value:
+
+::
+
+   right left node_value node_key [key D] roll> popop E″
+   right left [key D] node_value node_key       popop E″
+   right left [key D]                                 E″
+
+We have to we find the highest (right-most) node in our lower (left) sub-tree:
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+::
+
+   right left [key D] E″
+
+Ditch the key:
+
+::
+
+   right left [key D] rest E‴
+   right left     [D]      E‴
+
+Find the right-most node:
+
+::
+
+   right left        [D] [dup W] dip E⁗
+   right left dup  W [D]             E⁗
+   right left left W [D]             E⁗
+
+Consider:
+
+::
+
+   left W
+
+We know left is not empty:
+
+::
+
+   [L_key L_value L_left L_right] W
+
+We want to keep extracting the right node as long as it is not empty:
+
+::
+
+   W.rightmost == [P] [B] while
+
+   left W.rightmost W′
+
+The predicate:
+
+::
+
+   [L_key L_value L_left L_right] P
+   [L_key L_value L_left L_right] fourth
+                         L_right
+
+This can run on ``[]`` so must be guarded:
+
+::
+
+   ?fourth ==  [] [fourth] [] ifte
+
+( if_not_empty == [] swap [] ifte ?fourth == [fourth] if_not_empty )
+
+The body is just ``fourth``:
+
+::
+
+   left [?fourth] [fourth] while W′
+   rightest                      W′
+
+So:
+
+::
+
+   W.rightmost == [?fourth] [fourth] while
+
+Found right-most node in our left sub-tree
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+We know rightest is not empty:
+
+::
+
+   [R_key R_value R_left R_right] W′
+   [R_key R_value R_left R_right] W′
+   [R_key R_value R_left R_right] uncons uncons pop
+   R_key [R_value R_left R_right]        uncons pop
+   R_key R_value [R_left R_right]               pop
+   R_key R_value
+
+So:
+
+::
+
+   W == [?fourth] [fourth] while uncons uncons pop
+
+And:
+
+::
+
+   right left left W        [D] E⁗
+   right left R_key R_value [D] E⁗
+
+Replace current node key and value, recursively delete rightmost
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Final stretch. We want to end up with something like:
+
+::
+
+   right left [R_key D] i R_value R_key
+   right left  R_key D    R_value R_key
+   right left′            R_value R_key
+
+If we adjust our definition of ``W`` to include ``over`` at the end:
+
+::
+
+   W == [fourth] [fourth] while uncons uncons pop over
+
+That will give us:
+
+::
+
+   right left R_key R_value R_key [D] E⁗
+
+   right left         R_key R_value R_key [D] cons dipd E⁗′
+   right left         R_key R_value [R_key D]      dipd E⁗′
+   right left R_key D R_key R_value                     E⁗′
+   right left′        R_key R_value                     E⁗′
+   right left′        R_key R_value                     swap
+   right left′ R_value R_key
+
+So:
+
+::
+
+   E′ == roll> popop E″
+
+   E″ == rest E‴
+
+   E‴ == [dup W] dip E⁗
+
+   E⁗ == cons dipdd swap
+
+Substituting:
+
+::
+
+   W == [fourth] [fourth] while uncons uncons pop over
+   E′ == roll> popop rest [dup W] dip cons dipd swap
+   E == [
+       [[pop third not] pop fourth]
+       [[pop fourth not] pop third]
+       [[E′] cons infra]
+   ] cond
+
+Minor rearrangement, move ``dup`` into ``W``:
+
+::
+
+   W == dup [fourth] [fourth] while uncons uncons pop over
+   E′ == roll> popop rest [W] dip cons dipd swap
+   E == [
+       [[pop third not] pop fourth]
+       [[pop fourth not] pop third]
+       [[E′] cons infra]
+   ] cond
+
+Refactoring
+~~~~~~~~~~~
+
+::
+
+   W.rightmost == [fourth] [fourth] while
+   W.unpack == uncons uncons pop
+   W == dup W.rightmost W.unpack over
+   E.clear_stuff == roll> popop rest
+   E.delete == cons dipd
+   E.0 == E.clear_stuff [W] dip E.delete swap
+   E == [
+       [[pop third not] pop fourth]
+       [[pop fourth not] pop third]
+       [[E.0] cons infra]
+   ] cond
+   T> == [dipd] cons infra
+   T< == [dipdd] cons infra
+   R0 == over first swap dup
+   R1 == cons roll> [T>] [E] [T<] cmp
+   BTree-Delete == [pop not] swap [R0] [R1] genrec
+
+By the standards of the code I’ve written so far, this is a *huge* Joy
+program.
+
+.. code:: python
+
+    DefinitionWrapper.add_definitions('''
+    first_two == uncons uncons pop
+    fourth == rest rest rest first
+    ?fourth == [] [fourth] [] ifte
+    W.rightmost == [?fourth] [fourth] while
+    E.clear_stuff == roll> popop rest
+    E.delete == cons dipd
+    W == dup W.rightmost first_two over
+    E.0 == E.clear_stuff [W] dip E.delete swap
+    E == [[[pop third not] pop fourth] [[pop fourth not] pop third] [[E.0] cons infra]] cond
+    T> == [dipd] cons infra
+    T< == [dipdd] cons infra
+    R0 == over first swap dup
+    R1 == cons roll> [T>] [E] [T<] cmp
+    Tree-Delete == [pop not] [pop] [R0] [R1] genrec
+    ''', D)
+
+.. code:: python
+
+    J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'c' Tree-Delete ")
+
+
+.. parsed-literal::
+
+    ['a' 23 [] ['b' 88 [] []]]
+
+
+.. code:: python
+
+    J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'b' Tree-Delete ")
+
+
+.. parsed-literal::
+
+    ['a' 23 [] ['c' 44 [] []]]
+
+
+.. code:: python
+
+    J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'a' Tree-Delete ")
+
+
+.. parsed-literal::
+
+    ['b' 88 [] ['c' 44 [] []]]
+
+
+.. code:: python
+
+    J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'der' Tree-Delete ")
+
+
+.. parsed-literal::
+
+    ['a' 23 [] ['b' 88 [] ['c' 44 [] []]]]
+
+
+.. code:: python
+
+    J('[] [4 2 3 1 6 7 5 ] [0 swap Tree-add] step')
+
+
+.. parsed-literal::
+
+    [4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]]
+
+
+.. code:: python
+
+    J("[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 3 Tree-Delete ")
+
+
+.. parsed-literal::
+
+    [4 0 [2 0 [1 0 [] []] []] [6 0 [5 0 [] []] [7 0 [] []]]]
+
+
+.. code:: python
+
+    J("[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 4 Tree-Delete ")
+
+
+.. parsed-literal::
+
+    [3 0 [2 0 [1 0 [] []] []] [6 0 [5 0 [] []] [7 0 [] []]]]
+
+
+Appendix: The source code.
+--------------------------
+
+::
+
+   fourth == rest_two rest first
+   ?fourth == [] [fourth] [] ifte
+   first_two == uncons uncons pop
+   ccons == cons cons
+   cinf == cons infra
+   rest_two == rest rest
+
+   _Tree_T> == [dipd] cinf
+   _Tree_T< == [dipdd] cinf
+
+   _Tree_add_P == over [popop popop first] nullary
+   _Tree_add_T> == ccons _Tree_T<
+   _Tree_add_T< == ccons _Tree_T>
+   _Tree_add_Ee == pop swap roll< rest_two ccons
+   _Tree_add_R == _Tree_add_P [_Tree_add_T>] [_Tree_add_Ee] [_Tree_add_T<] cmp
+   _Tree_add_E == [pop] dipd Tree-new
+
+   _Tree_iter_order_left == [cons dip] dupdip
+   _Tree_iter_order_current == [[F] dupdip] dip
+   _Tree_iter_order_right == [fourth] dip i
+   _Tree_iter_order_R == _Tree_iter_order_left _Tree_iter_order_current _Tree_iter_order_right
+
+   _Tree_get_P == over [pop popop first] nullary
+   _Tree_get_T> == [fourth] dipd i
+   _Tree_get_T< == [third] dipd i
+   _Tree_get_E == popop second
+   _Tree_get_R == _Tree_get_P [_Tree_get_T>] [_Tree_get_E] [_Tree_get_T<] cmp
+
+   _Tree_delete_rightmost == [?fourth] [fourth] while
+   _Tree_delete_clear_stuff == roll> popop rest
+   _Tree_delete_del == dip cons dipd swap
+   _Tree_delete_W == dup _Tree_delete_rightmost first_two over
+   _Tree_delete_E.0 == _Tree_delete_clear_stuff [_Tree_delete_W] _Tree_delete_del
+   _Tree_delete_E == [[[pop third not] pop fourth] [[pop fourth not] pop third] [[_Tree_delete_E.0] cinf]] cond
+   _Tree_delete_R0 == over first swap dup
+   _Tree_delete_R1 == cons roll> [_Tree_T>] [_Tree_delete_E] [_Tree_T<] cmp
+
+   Tree-new == swap [[] []] ccons
+   Tree-add == [popop not] [_Tree_add_E] [] [_Tree_add_R] genrec
+   Tree-iter == [not] [pop] roll< [dupdip rest_two] cons [step] genrec
+   Tree-iter-order == [not] [pop] [dup third] [_Tree_iter_order_R] genrec
+   Tree-get == [pop not] swap [] [_Tree_get_R] genrec
+   Tree-delete == [pop not] [pop] [_Tree_delete_R0] [_Tree_delete_R1] genrec
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Quadratic.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Quadratic.rst.txt
new file mode 100644 (file)
index 0000000..5afb8e2
--- /dev/null
@@ -0,0 +1,158 @@
+.. code:: python
+
+    from notebook_preamble import J, V, define
+
+`Quadratic formula <https://en.wikipedia.org/wiki/Quadratic_formula>`__
+=======================================================================
+
+Cf.
+`jp-quadratic.html <http://www.kevinalbrecht.com/code/joy-mirror/jp-quadratic.html>`__
+
+::
+
+      -b ± sqrt(b^2 - 4 * a * c)
+   --------------------------------
+               2 * a
+
+:math:`\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}`
+
+Write a straightforward program with variable names.
+----------------------------------------------------
+
+This math translates to Joy code in a straightforward manner. We are
+going to use named variables to keep track of the arguments, then write
+a definition without them.
+
+``-b``
+~~~~~~
+
+::
+
+   b neg
+
+``sqrt(b^2 - 4 * a * c)``
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+   b sqr 4 a c * * - sqrt
+
+``/2a``
+~~~~~~~
+
+::
+
+   a 2 * /
+
+``±``
+~~~~~
+
+There is a function ``pm`` that accepts two values on the stack and
+replaces them with their sum and difference.
+
+::
+
+   pm == [+] [-] cleave popdd
+
+Putting Them Together
+~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+   b neg b sqr 4 a c * * - sqrt pm a 2 * [/] cons app2
+
+We use ``app2`` to compute both roots by using a quoted program
+``[2a /]`` built with ``cons``.
+
+Derive a definition.
+--------------------
+
+Working backwards we use ``dip`` and ``dipd`` to extract the code from
+the variables:
+
+::
+
+   b             neg  b      sqr 4 a c   * * - sqrt pm a    2 * [/] cons app2
+   b            [neg] dupdip sqr 4 a c   * * - sqrt pm a    2 * [/] cons app2
+   b a c       [[neg] dupdip sqr 4] dipd * * - sqrt pm a    2 * [/] cons app2
+   b a c a    [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2
+   b a c over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2
+
+The three arguments are to the left, so we can “chop off” everything to
+the right and say it’s the definition of the ``quadratic`` function:
+
+.. code:: python
+
+    define('quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2')
+
+Let’s try it out:
+
+.. code:: python
+
+    J('3 1 1 quadratic')
+
+
+.. parsed-literal::
+
+    -0.3819660112501051 -2.618033988749895
+
+
+If you look at the Joy evaluation trace you can see that the first few
+lines are the ``dip`` and ``dipd`` combinators building the main program
+by incorporating the values on the stack. Then that program runs and you
+get the results. This is pretty typical of Joy code.
+
+.. code:: python
+
+    V('-5 1 4 quadratic')
+
+
+.. parsed-literal::
+
+                                                       . -5 1 4 quadratic
+                                                    -5 . 1 4 quadratic
+                                                  -5 1 . 4 quadratic
+                                                -5 1 4 . quadratic
+                                                -5 1 4 . over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2
+                                              -5 1 4 1 . [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2
+    -5 1 4 1 [[[neg] dupdip sqr 4] dipd * * - sqrt pm] . dip 2 * [/] cons app2
+                                                -5 1 4 . [[neg] dupdip sqr 4] dipd * * - sqrt pm 1 2 * [/] cons app2
+                           -5 1 4 [[neg] dupdip sqr 4] . dipd * * - sqrt pm 1 2 * [/] cons app2
+                                                    -5 . [neg] dupdip sqr 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                              -5 [neg] . dupdip sqr 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                                    -5 . neg -5 sqr 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                                     5 . -5 sqr 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                                  5 -5 . sqr 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                                  5 -5 . dup mul 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                               5 -5 -5 . mul 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                                  5 25 . 4 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                                5 25 4 . 1 4 * * - sqrt pm 1 2 * [/] cons app2
+                                              5 25 4 1 . 4 * * - sqrt pm 1 2 * [/] cons app2
+                                            5 25 4 1 4 . * * - sqrt pm 1 2 * [/] cons app2
+                                              5 25 4 4 . * - sqrt pm 1 2 * [/] cons app2
+                                               5 25 16 . - sqrt pm 1 2 * [/] cons app2
+                                                   5 9 . sqrt pm 1 2 * [/] cons app2
+                                                 5 3.0 . pm 1 2 * [/] cons app2
+                                               8.0 2.0 . 1 2 * [/] cons app2
+                                             8.0 2.0 1 . 2 * [/] cons app2
+                                           8.0 2.0 1 2 . * [/] cons app2
+                                             8.0 2.0 2 . [/] cons app2
+                                         8.0 2.0 2 [/] . cons app2
+                                         8.0 2.0 [2 /] . app2
+                                           [8.0] [2 /] . infra first [2.0] [2 /] infra first
+                                                   8.0 . 2 / [] swaack first [2.0] [2 /] infra first
+                                                 8.0 2 . / [] swaack first [2.0] [2 /] infra first
+                                                   4.0 . [] swaack first [2.0] [2 /] infra first
+                                                4.0 [] . swaack first [2.0] [2 /] infra first
+                                                 [4.0] . first [2.0] [2 /] infra first
+                                                   4.0 . [2.0] [2 /] infra first
+                                             4.0 [2.0] . [2 /] infra first
+                                       4.0 [2.0] [2 /] . infra first
+                                                   2.0 . 2 / [4.0] swaack first
+                                                 2.0 2 . / [4.0] swaack first
+                                                   1.0 . [4.0] swaack first
+                                             1.0 [4.0] . swaack first
+                                             4.0 [1.0] . first
+                                               4.0 1.0 . 
+
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Recursion_Combinators.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Recursion_Combinators.rst.txt
new file mode 100644 (file)
index 0000000..2298cfd
--- /dev/null
@@ -0,0 +1,692 @@
+.. code:: python
+
+    from notebook_preamble import D, DefinitionWrapper, J, V, define
+
+Recursion Combinators
+=====================
+
+This article describes the ``genrec`` combinator, how to use it, and
+several generic specializations.
+
+::
+
+                         [if] [then] [rec1] [rec2] genrec
+   ---------------------------------------------------------------------
+      [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
+
+From “Recursion Theory and Joy” (j05cmp.html) by Manfred von Thun:
+
+   “The genrec combinator takes four program parameters in addition to
+   whatever data parameters it needs. Fourth from the top is an if-part,
+   followed by a then-part. If the if-part yields true, then the
+   then-part is executed and the combinator terminates. The other two
+   parameters are the rec1-part and the rec2-part. If the if-part yields
+   false, the rec1-part is executed. Following that the four program
+   parameters and the combinator are again pushed onto the stack bundled
+   up in a quoted form. Then the rec2-part is executed, where it will
+   find the bundled form. Typically it will then execute the bundled
+   form, either with i or with app2, or some other combinator.”
+
+Designing Recursive Functions
+-----------------------------
+
+The way to design one of these is to fix your base case and test and
+then treat ``R1`` and ``R2`` as an else-part “sandwiching” a quotation
+of the whole function.
+
+For example, given a (general recursive) function ``F``:
+
+::
+
+   F == [I] [T] [R1]   [R2] genrec
+     == [I] [T] [R1 [F] R2] ifte
+
+If the ``[I]`` predicate is false you must derive ``R1`` and ``R2``
+from:
+
+::
+
+   ... R1 [F] R2
+
+Set the stack arguments in front and figure out what ``R1`` and ``R2``
+have to do to apply the quoted ``[F]`` in the proper way.
+
+Primitive Recursive Functions
+-----------------------------
+
+Primitive recursive functions are those where ``R2 == i``.
+
+::
+
+   P == [I] [T] [R] primrec
+     == [I] [T] [R [P] i] ifte
+     == [I] [T] [R P] ifte
+
+`Hylomorphism <https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29>`__
+------------------------------------------------------------------------------------
+
+A
+`hylomorphism <https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29>`__
+is a recursive function ``H :: A -> C`` that converts a value of type
+``A`` into a value of type ``C`` by means of:
+
+-  A generator ``G :: A -> (B, A)``
+-  A combiner ``F :: (B, C) -> C``
+-  A predicate ``P :: A -> Bool`` to detect the base case
+-  A base case value ``c :: C``
+-  Recursive calls (zero or more); it has a “call stack in the form of a
+   cons list”.
+
+It may be helpful to see this function implemented in imperative Python
+code.
+
+.. code:: python
+
+    def hylomorphism(c, F, P, G):
+        '''Return a hylomorphism function H.'''
+    
+        def H(a):
+            if P(a):
+                result = c
+            else:
+                b, aa = G(a)
+                result = F(b, H(aa))  # b is stored in the stack frame during recursive call to H().
+            return result
+    
+        return H
+
+Cf. `“Bananas, Lenses, & Barbed
+Wire” <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125>`__
+
+Note that during evaluation of ``H()`` the intermediate ``b`` values are
+stored in the Python call stack. This is what is meant by “call stack in
+the form of a cons list”.
+
+Hylomorphism in Joy
+-------------------
+
+We can define a combinator ``hylomorphism`` that will make a
+hylomorphism combinator ``H`` from constituent parts.
+
+::
+
+   H == [P] c [G] [F] hylomorphism
+
+The function ``H`` is recursive, so we start with ``ifte`` and set the
+else-part to some function ``J`` that will contain a quoted copy of
+``H``. (The then-part just discards the leftover ``a`` and replaces it
+with the base case value ``c``.)
+
+::
+
+   H == [P] [pop c] [J] ifte
+
+The else-part ``J`` gets just the argument ``a`` on the stack.
+
+::
+
+   a J
+   a G              The first thing to do is use the generator G
+   aa b             which produces b and a new aa
+   aa b [H] dip     we recur with H on the new aa
+   aa H b F         and run F on the result.
+
+This gives us a definition for ``J``.
+
+::
+
+   J == G [H] dip F
+
+Plug it in and convert to genrec.
+
+::
+
+   H == [P] [pop c] [G [H] dip F] ifte
+   H == [P] [pop c] [G]   [dip F] genrec
+
+This is the form of a hylomorphism in Joy, which nicely illustrates that
+it is a simple specialization of the general recursion combinator.
+
+::
+
+   H == [P] c [G] [F] hylomorphism == [P] [pop c] [G] [dip F] genrec
+
+Derivation of ``hylomorphism`` combinator
+-----------------------------------------
+
+Now we just need to derive a definition that builds the ``genrec``
+arguments out of the pieces given to the ``hylomorphism`` combinator.
+
+::
+
+      [P]      c  [G]     [F] hylomorphism
+   ------------------------------------------
+      [P] [pop c] [G] [dip F] genrec
+
+Working in reverse:
+
+-  Use ``swoncat`` twice to decouple ``[c]`` and ``[F]``.
+-  Use ``unit`` to dequote ``c``.
+-  Use ``dipd`` to untangle ``[unit [pop] swoncat]`` from the givens.
+
+So:
+
+::
+
+   H == [P] [pop c]              [G]                  [dip F] genrec
+        [P] [c]    [pop] swoncat [G]        [F] [dip] swoncat genrec
+        [P] c unit [pop] swoncat [G]        [F] [dip] swoncat genrec
+        [P] c [G] [F] [unit [pop] swoncat] dipd [dip] swoncat genrec
+
+At this point all of the arguments (givens) to the hylomorphism are to
+the left so we have a definition for ``hylomorphism``:
+
+::
+
+   hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec
+
+.. code:: python
+
+    define('hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec')
+
+Example: Finding `Triangular Numbers <https://en.wikipedia.org/wiki/Triangular_number>`__
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Let’s write a function that, given a positive integer, returns the sum
+of all positive integers less than that one. (In this case the types
+``A``, ``B`` and ``C`` are all ``int``.)
+
+To sum a range of integers from 0 to *n* - 1:
+
+-  ``[P]`` is ``[1 <=]``
+-  ``c`` is ``0``
+-  ``[G]`` is ``[-- dup]``
+-  ``[F]`` is ``[+]``
+
+.. code:: python
+
+    define('triangular_number == [1 <=] 0 [-- dup] [+] hylomorphism')
+
+Let’s try it:
+
+.. code:: python
+
+    J('5 triangular_number')
+
+
+.. parsed-literal::
+
+    10
+
+
+.. code:: python
+
+    J('[0 1 2 3 4 5 6] [triangular_number] map')
+
+
+.. parsed-literal::
+
+    [0 0 1 3 6 10 15]
+
+
+Four Specializations
+--------------------
+
+There are at least four kinds of recursive combinator, depending on two
+choices. The first choice is whether the combiner function ``F`` should
+be evaluated during the recursion or pushed into the pending expression
+to be “collapsed” at the end. The second choice is whether the combiner
+needs to operate on the current value of the datastructure or the
+generator’s output, in other words, whether ``F`` or ``G`` should run
+first in the recursive branch.
+
+::
+
+   H1 ==        [P] [pop c] [G             ] [dip F] genrec
+   H2 == c swap [P] [pop]   [G [F]    dip  ] [i]     genrec
+   H3 ==        [P] [pop c] [  [G] dupdip  ] [dip F] genrec
+   H4 == c swap [P] [pop]   [  [F] dupdip G] [i]     genrec
+
+The working of the generator function ``G`` differs slightly for each.
+Consider the recursive branches:
+
+::
+
+   ... a G [H1] dip F                w/ a G == a′ b
+
+   ... c a G [F] dip H2                 a G == b  a′
+
+   ... a [G] dupdip [H3] dip F          a G == a′
+
+   ... c a [F] dupdip G H4              a G == a′
+
+The following four sections illustrate how these work, omitting the
+predicate evaluation.
+
+``H1``
+~~~~~~
+
+::
+
+   H1 == [P] [pop c] [G] [dip F] genrec
+
+Iterate n times.
+
+::
+
+   ... a  G [H1] dip F
+   ... a′ b [H1] dip F
+   ... a′ H1 b F
+   ... a′ G [H1] dip F b F
+   ... a″ b′ [H1] dip F b F
+   ... a″ H1 b′ F b F
+   ... a″ G [H1] dip F b′ F b F
+   ... a‴ b″ [H1] dip F b′ F b F
+   ... a‴ H1 b″ F b′ F b F
+   ... a‴ pop c b″ F b′ F b F
+   ... c b″ F b′ F b F
+   ... d      b′ F b F
+   ... d′          b F
+   ... d″
+
+This form builds up a pending expression (continuation) that contains
+the intermediate results along with the pending combiner functions. When
+the base case is reached the last term is replaced by the identity value
+``c`` and the continuation “collapses” into the final result using the
+combiner ``F``.
+
+``H2``
+~~~~~~
+
+When you can start with the identity value ``c`` on the stack and the
+combiner ``F`` can operate as you go using the intermediate results
+immediately rather than queuing them up, use this form. An important
+difference is that the generator function must return its results in the
+reverse order.
+
+::
+
+   H2 == c swap [P] [pop] [G [F] dip] primrec
+
+   ... c a G  [F] dip H2
+   ... c b a′ [F] dip H2
+   ... c b F a′ H2
+   ... d     a′ H2
+   ... d a′ G  [F] dip H2
+   ... d b′ a″ [F] dip H2
+   ... d b′ F a″ H2
+   ... d′     a″ H2
+   ... d′ a″ G  [F] dip H2
+   ... d′ b″ a‴ [F] dip H2
+   ... d′ b″ F a‴ H2
+   ... d″      a‴ H2
+   ... d″ a‴ pop
+   ... d″
+
+``H3``
+~~~~~~
+
+If you examine the traces above you’ll see that the combiner ``F`` only
+gets to operate on the results of ``G``, it never “sees” the first value
+``a``. If the combiner and the generator both need to work on the
+current value then ``dup`` must be used, and the generator must produce
+one item instead of two (the b is instead the duplicate of a.)
+
+::
+
+   H3 == [P] [pop c] [[G] dupdip] [dip F] genrec
+
+   ... a [G] dupdip [H3] dip F
+   ... a  G  a      [H3] dip F
+   ... a′    a      [H3] dip F
+   ... a′ H3 a               F
+   ... a′ [G] dupdip [H3] dip F a F
+   ... a′  G  a′     [H3] dip F a F
+   ... a″     a′     [H3] dip F a F
+   ... a″ H3  a′              F a F
+   ... a″ [G] dupdip [H3] dip F a′ F a F
+   ... a″  G    a″   [H3] dip F a′ F a F
+   ... a‴       a″   [H3] dip F a′ F a F
+   ... a‴ H3    a″            F a′ F a F
+   ... a‴ pop c a″ F a′ F a F
+   ...        c a″ F a′ F a F
+   ...        d      a′ F a F
+   ...        d′          a F
+   ...        d″
+
+``H4``
+~~~~~~
+
+And, last but not least, if you can combine as you go, starting with
+``c``, and the combiner ``F`` needs to work on the current item, this is
+the form:
+
+::
+
+   H4 == c swap [P] [pop] [[F] dupdip G] primrec
+
+   ... c  a  [F] dupdip G H4
+   ... c  a   F  a      G H4
+   ... d         a      G H4
+   ... d  a′              H4
+   ... d  a′ [F] dupdip G H4
+   ... d  a′  F  a′     G H4
+   ... d′        a′     G H4
+   ... d′ a″              H4
+   ... d′ a″ [F] dupdip G H4
+   ... d′ a″  F  a″     G H4
+   ... d″        a″     G H4
+   ... d″ a‴              H4
+   ... d″ a‴ pop
+   ... d″
+
+Anamorphism
+-----------
+
+An anamorphism can be defined as a hylomorphism that uses ``[]`` for
+``c`` and ``swons`` for ``F``. An anamorphic function builds a list of
+values.
+
+::
+
+   A == [P] [] [G] [swons] hylomorphism
+
+``range`` et. al.
+~~~~~~~~~~~~~~~~~
+
+An example of an anamorphism is the ``range`` function which generates the list of integers from 0 to *n* - 1 given *n*.
+
+Each of the above variations can be used to make four slightly different
+``range`` functions.
+
+``range`` with ``H1``
+^^^^^^^^^^^^^^^^^^^^^
+
+::
+
+   H1 == [P]    [pop c]  [G]      [dip F]     genrec
+      == [0 <=] [pop []] [-- dup] [dip swons] genrec
+
+.. code:: python
+
+    define('range == [0 <=] [] [-- dup] [swons] hylomorphism')
+
+.. code:: python
+
+    J('5 range')
+
+
+.. parsed-literal::
+
+    [4 3 2 1 0]
+
+
+``range`` with ``H2``
+^^^^^^^^^^^^^^^^^^^^^
+
+::
+
+   H2 == c  swap [P]    [pop] [G      [F]     dip] primrec
+      == [] swap [0 <=] [pop] [-- dup [swons] dip] primrec
+
+.. code:: python
+
+    define('range_reverse == [] swap [0 <=] [pop] [-- dup [swons] dip] primrec')
+
+.. code:: python
+
+    J('5 range_reverse')
+
+
+.. parsed-literal::
+
+    [0 1 2 3 4]
+
+
+``range`` with ``H3``
+^^^^^^^^^^^^^^^^^^^^^
+
+::
+
+   H3 == [P]    [pop c]  [[G]  dupdip] [dip F]     genrec
+      == [0 <=] [pop []] [[--] dupdip] [dip swons] genrec
+
+.. code:: python
+
+    define('ranger == [0 <=] [pop []] [[--] dupdip] [dip swons] genrec')
+
+.. code:: python
+
+    J('5 ranger')
+
+
+.. parsed-literal::
+
+    [5 4 3 2 1]
+
+
+``range`` with ``H4``
+^^^^^^^^^^^^^^^^^^^^^
+
+::
+
+   H4 == c  swap [P]    [pop] [[F]     dupdip G ] primrec
+      == [] swap [0 <=] [pop] [[swons] dupdip --] primrec
+
+.. code:: python
+
+    define('ranger_reverse == [] swap [0 <=] [pop] [[swons] dupdip --] primrec')
+
+.. code:: python
+
+    J('5 ranger_reverse')
+
+
+.. parsed-literal::
+
+    [1 2 3 4 5]
+
+
+Hopefully this illustrates the workings of the variations. For more
+insight you can run the cells using the ``V()`` function instead of the
+``J()`` function to get a trace of the Joy evaluation.
+
+Catamorphism
+------------
+
+A catamorphism can be defined as a hylomorphism that uses
+``[uncons swap]`` for ``[G]`` and ``[[] =]`` (or just ``[not]``) for the
+predicate ``[P]``. A catamorphic function tears down a list term-by-term
+and makes some new value.
+
+::
+
+   C == [not] c [uncons swap] [F] hylomorphism
+
+.. code:: python
+
+    define('swuncons == uncons swap')  # Awkward name.
+
+An example of a catamorphism is the sum function.
+
+::
+
+   sum == [not] 0 [swuncons] [+] hylomorphism
+
+.. code:: python
+
+    define('sum == [not] 0 [swuncons] [+] hylomorphism')
+
+.. code:: python
+
+    J('[5 4 3 2 1] sum')
+
+
+.. parsed-literal::
+
+    15
+
+
+The ``step`` combinator
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``step`` combinator will usually be better to use than
+``catamorphism``.
+
+.. code:: python
+
+    J('[step] help')
+
+
+.. parsed-literal::
+
+    Run a quoted program on each item in a sequence.
+    ::
+    
+            ... [] [Q] . step
+         -----------------------
+                   ... .
+    
+    
+           ... [a] [Q] . step
+        ------------------------
+                 ... a . Q
+    
+    
+         ... [a b c] [Q] . step
+      ----------------------------------------
+                   ... a . Q [b c] [Q] step
+    
+    The step combinator executes the quotation on each member of the list
+    on top of the stack.
+    
+
+
+.. code:: python
+
+    define('sum == 0 swap [+] step')
+
+.. code:: python
+
+    J('[5 4 3 2 1] sum')
+
+
+.. parsed-literal::
+
+    15
+
+
+Example: Factorial Function
+---------------------------
+
+For the Factorial function:
+
+::
+
+   H4 == c swap [P] [pop] [[F] dupdip G] primrec
+
+With:
+
+::
+
+   c == 1
+   F == *
+   G == --
+   P == 1 <=
+
+.. code:: python
+
+    define('factorial == 1 swap [1 <=] [pop] [[*] dupdip --] primrec')
+
+.. code:: python
+
+    J('5 factorial')
+
+
+.. parsed-literal::
+
+    120
+
+
+Example: ``tails``
+------------------
+
+An example of a paramorphism for lists given in the `“Bananas…”
+paper <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125>`__
+is ``tails`` which returns the list of “tails” of a list.
+
+::
+
+       [1 2 3] tails
+   --------------------
+      [[] [3] [2 3]]
+
+We can build as we go, and we want ``F`` to run after ``G``, so we use
+pattern ``H2``:
+
+::
+
+   H2 == c swap [P] [pop] [G [F] dip] primrec
+
+We would use:
+
+::
+
+   c == []
+   F == swons
+   G == rest dup
+   P == not
+
+.. code:: python
+
+    define('tails == [] swap [not] [pop] [rest dup [swons] dip] primrec')
+
+.. code:: python
+
+    J('[1 2 3] tails')
+
+
+.. parsed-literal::
+
+    [[] [3] [2 3]]
+
+
+Conclusion: Patterns of Recursion
+---------------------------------
+
+Our story so far…
+
+Hylo-, Ana-, Cata-
+~~~~~~~~~~~~~~~~~~
+
+::
+
+   H == [P  ] [pop c ] [G          ] [dip F        ] genrec
+   A == [P  ] [pop []] [G          ] [dip swap cons] genrec
+   C == [not] [pop c ] [uncons swap] [dip F        ] genrec
+
+Para-, ?-, ?-
+~~~~~~~~~~~~~
+
+::
+
+   P == c  swap [P  ] [pop] [[F        ] dupdip G          ] primrec
+   ? == [] swap [P  ] [pop] [[swap cons] dupdip G          ] primrec
+   ? == c  swap [not] [pop] [[F        ] dupdip uncons swap] primrec
+
+Appendix: Fun with Symbols
+--------------------------
+
+::
+
+   |[ (c, F), (G, P) ]| == (|c, F|) • [(G, P)]
+
+`“Bananas, Lenses, & Barbed
+Wire” <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125>`__
+
+::
+
+   (|...|)  [(...)]  [<...>]
+
+I think they are having slightly too much fun with the symbols. However,
+“Too much is always better than not enough.”
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Replacing.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Replacing.rst.txt
new file mode 100644 (file)
index 0000000..02ecb3b
--- /dev/null
@@ -0,0 +1,147 @@
+Replacing Functions in the Dictionary
+=====================================
+
+For now, there is no way to define new functions from within the Joy
+language. All functions (and the interpreter) all accept and return a
+dictionary parameter (in addition to the stack and expression) so that
+we can implement e.g. a function that adds new functions to the
+dictionary. However, there’s no function that does that. Adding a new
+function to the dictionary is a meta-interpreter action, you have to do
+it in Python, not Joy.
+
+.. code:: python
+
+    from notebook_preamble import D, J, V
+
+A long trace
+------------
+
+.. code:: python
+
+    V('[23 18] average')
+
+
+.. parsed-literal::
+
+                                      . [23 18] average
+                              [23 18] . average
+                              [23 18] . [sum 1.0 *] [size] cleave /
+                  [23 18] [sum 1.0 *] . [size] cleave /
+           [23 18] [sum 1.0 *] [size] . cleave /
+           [23 18] [sum 1.0 *] [size] . [i] app2 [popd] dip /
+       [23 18] [sum 1.0 *] [size] [i] . app2 [popd] dip /
+    [23 18] [[sum 1.0 *] [23 18]] [i] . infra first [[size] [23 18]] [i] infra first [popd] dip /
+                  [23 18] [sum 1.0 *] . i [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                              [23 18] . sum 1.0 * [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                                   41 . 1.0 * [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                               41 1.0 . * [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                                 41.0 . [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                       41.0 [[23 18]] . swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                       [23 18] [41.0] . first [[size] [23 18]] [i] infra first [popd] dip /
+                         [23 18] 41.0 . [[size] [23 18]] [i] infra first [popd] dip /
+        [23 18] 41.0 [[size] [23 18]] . [i] infra first [popd] dip /
+    [23 18] 41.0 [[size] [23 18]] [i] . infra first [popd] dip /
+                       [23 18] [size] . i [41.0 [23 18]] swaack first [popd] dip /
+                              [23 18] . size [41.0 [23 18]] swaack first [popd] dip /
+                              [23 18] . 0 swap [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                            [23 18] 0 . swap [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                            0 [23 18] . [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                   0 [23 18] [pop ++] . step [41.0 [23 18]] swaack first [popd] dip /
+                        0 23 [pop ++] . i [18] [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                                 0 23 . pop ++ [18] [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                                    0 . ++ [18] [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                                    1 . [18] [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                               1 [18] . [pop ++] step [41.0 [23 18]] swaack first [popd] dip /
+                      1 [18] [pop ++] . step [41.0 [23 18]] swaack first [popd] dip /
+                        1 18 [pop ++] . i [41.0 [23 18]] swaack first [popd] dip /
+                                 1 18 . pop ++ [41.0 [23 18]] swaack first [popd] dip /
+                                    1 . ++ [41.0 [23 18]] swaack first [popd] dip /
+                                    2 . [41.0 [23 18]] swaack first [popd] dip /
+                     2 [41.0 [23 18]] . swaack first [popd] dip /
+                     [23 18] 41.0 [2] . first [popd] dip /
+                       [23 18] 41.0 2 . [popd] dip /
+                [23 18] 41.0 2 [popd] . dip /
+                         [23 18] 41.0 . popd 2 /
+                                 41.0 . 2 /
+                               41.0 2 . /
+                                 20.5 . 
+
+
+Replacing ``size`` with a Python version
+----------------------------------------
+
+Both ``sum`` and ``size`` each convert a sequence to a single value.
+
+::
+
+    sum == 0 swap [+] step
+   size == 0 swap [pop ++] step
+
+An efficient ``sum`` function is already in the library. But for
+``size`` we can use a “compiled” version hand-written in Python to speed
+up evaluation and make the trace more readable.
+
+.. code:: python
+
+    from joy.library import SimpleFunctionWrapper
+    from joy.utils.stack import iter_stack
+    
+    
+    @SimpleFunctionWrapper
+    def size(stack):
+        '''Return the size of the sequence on the stack.'''
+        sequence, stack = stack
+        n = 0
+        for _ in iter_stack(sequence):
+            n += 1
+        return n, stack
+
+Now we replace the old version in the dictionary with the new version,
+and re-evaluate the expression.
+
+.. code:: python
+
+    D['size'] = size
+
+A shorter trace
+---------------
+
+You can see that ``size`` now executes in a single step.
+
+.. code:: python
+
+    V('[23 18] average')
+
+
+.. parsed-literal::
+
+                                      . [23 18] average
+                              [23 18] . average
+                              [23 18] . [sum 1.0 *] [size] cleave /
+                  [23 18] [sum 1.0 *] . [size] cleave /
+           [23 18] [sum 1.0 *] [size] . cleave /
+           [23 18] [sum 1.0 *] [size] . [i] app2 [popd] dip /
+       [23 18] [sum 1.0 *] [size] [i] . app2 [popd] dip /
+    [23 18] [[sum 1.0 *] [23 18]] [i] . infra first [[size] [23 18]] [i] infra first [popd] dip /
+                  [23 18] [sum 1.0 *] . i [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                              [23 18] . sum 1.0 * [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                                   41 . 1.0 * [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                               41 1.0 . * [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                                 41.0 . [[23 18]] swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                       41.0 [[23 18]] . swaack first [[size] [23 18]] [i] infra first [popd] dip /
+                       [23 18] [41.0] . first [[size] [23 18]] [i] infra first [popd] dip /
+                         [23 18] 41.0 . [[size] [23 18]] [i] infra first [popd] dip /
+        [23 18] 41.0 [[size] [23 18]] . [i] infra first [popd] dip /
+    [23 18] 41.0 [[size] [23 18]] [i] . infra first [popd] dip /
+                       [23 18] [size] . i [41.0 [23 18]] swaack first [popd] dip /
+                              [23 18] . size [41.0 [23 18]] swaack first [popd] dip /
+                                    2 . [41.0 [23 18]] swaack first [popd] dip /
+                     2 [41.0 [23 18]] . swaack first [popd] dip /
+                     [23 18] 41.0 [2] . first [popd] dip /
+                       [23 18] 41.0 2 . [popd] dip /
+                [23 18] 41.0 2 [popd] . dip /
+                         [23 18] 41.0 . popd 2 /
+                                 41.0 . 2 /
+                               41.0 2 . /
+                                 20.5 . 
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/The_Four_Operations.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/The_Four_Operations.rst.txt
new file mode 100644 (file)
index 0000000..b345b0e
--- /dev/null
@@ -0,0 +1,336 @@
+The Four Fundamental Operations of Definite Action
+==================================================
+
+All definite actions (computer program) can be defined by four
+fundamental patterns of combination:
+
+1. Sequence
+2. Branch
+3. Loop
+4. Parallel
+
+Sequence
+--------
+
+Do one thing after another. In joy this is represented by putting two
+symbols together, juxtaposition:
+
+::
+
+   foo bar
+
+Operations have inputs and outputs. The outputs of ``foo`` must be
+compatible in “arity”, type, and shape with the inputs of ``bar``.
+
+Branch
+------
+
+Do one thing or another.
+
+::
+
+   boolean [F] [T] branch
+
+
+      t [F] [T] branch
+   ----------------------
+             T
+
+
+      f [F] [T] branch
+   ----------------------
+         F
+
+
+   branch == unit cons swap pick i
+
+   boolean [F] [T] branch
+   boolean [F] [T] unit cons swap pick i
+   boolean [F] [[T]] cons swap pick i
+   boolean [[F] [T]] swap pick i
+   [[F] [T]] boolean pick i
+   [F-or-T] i
+
+Given some branch function ``G``:
+
+::
+
+   G == [F] [T] branch
+
+Used in a sequence like so:
+
+::
+
+   foo G bar
+
+The inputs and outputs of ``F`` and ``T`` must be compatible with the
+outputs for ``foo`` and the inputs of ``bar``, respectively.
+
+::
+
+   foo F bar
+
+   foo T bar
+
+``ifte``
+~~~~~~~~
+
+Often it will be easier on the programmer to write branching code with
+the predicate specified in a quote. The ``ifte`` combinator provides
+this (``T`` for “then” and ``E`` for “else”):
+
+::
+
+   [P] [T] [E] ifte
+
+Defined in terms of ``branch``:
+
+::
+
+   ifte == [nullary not] dip branch
+
+In this case, ``P`` must be compatible with the stack and return a
+Boolean value, and ``T`` and ``E`` both must be compatible with the
+preceeding and following functions, as described above for ``F`` and
+``T``. (Note that in the current implementation we are depending on
+Python for the underlying semantics, so the Boolean value doesn’t *have*
+to be Boolean because Python’s rules for “truthiness” will be used to
+evaluate it. I reflect this in the structure of the stack effect comment
+of ``branch``, it will only accept Boolean values, and in the definition
+of ``ifte`` above by including ``not`` in the quote, which also has the
+effect that the subject quotes are in the proper order for ``branch``.)
+
+Loop
+----
+
+Do one thing zero or more times.
+
+::
+
+   boolean [Q] loop
+
+
+      t [Q] loop
+   ----------------
+      Q [Q] loop
+
+
+      ... f [Q] loop
+   --------------------
+      ...
+
+The ``loop`` combinator generates a copy of itself in the true branch.
+This is the hallmark of recursive defintions. In Thun there is no
+equivalent to conventional loops. (There is, however, the ``x``
+combinator, defined as ``x == dup i``, which permits recursive
+constructs that do not need to be directly self-referential, unlike
+``loop`` and ``genrec``.)
+
+::
+
+   loop == [] swap [dup dip loop] cons branch
+
+   boolean [Q] loop
+   boolean [Q] [] swap [dup dip loop] cons branch
+   boolean [] [Q] [dup dip loop] cons branch
+   boolean [] [[Q] dup dip loop] branch
+
+In action the false branch does nothing while the true branch does:
+
+::
+
+   t [] [[Q] dup dip loop] branch
+         [Q] dup dip loop
+         [Q] [Q] dip loop
+         Q [Q] loop
+
+Because ``loop`` expects and consumes a Boolean value, the ``Q``
+function must be compatible with the previous stack *and itself* with a
+boolean flag for the next iteration:
+
+::
+
+   Q == G b
+
+   Q [Q] loop
+   G b [Q] loop
+   G Q [Q] loop
+   G G b [Q] loop
+   G G Q [Q] loop
+   G G G b [Q] loop
+   G G G
+
+``while``
+~~~~~~~~~
+
+Keep doing ``B`` *while* some predicate ``P`` is true. This is
+convenient as the predicate function is made nullary automatically and
+the body function can be designed without regard to leaving a Boolean
+flag for the next iteration:
+
+::
+
+               [P] [B] while
+   --------------------------------------
+      [P] nullary [B [P] nullary] loop
+
+
+   while == swap [nullary] cons dup dipd concat loop
+
+
+   [P] [B] while
+   [P] [B] swap [nullary] cons dup dipd concat loop
+   [B] [P] [nullary] cons dup dipd concat loop
+   [B] [[P] nullary] dup dipd concat loop
+   [B] [[P] nullary] [[P] nullary] dipd concat loop
+   [P] nullary [B] [[P] nullary] concat loop
+   [P] nullary [B [P] nullary] loop
+
+Parallel
+--------
+
+The *parallel* operation indicates that two (or more) functions *do not
+interfere* with each other and so can run in parallel. The main
+difficulty in this sort of thing is orchestrating the recombining
+(“join” or “wait”) of the results of the functions after they finish.
+
+The current implementaions and the following definitions *are not
+actually parallel* (yet), but there is no reason they couldn’t be
+reimplemented in terms of e.g. Python threads. I am not concerned with
+performance of the system just yet, only the elegance of the code it
+allows us to write.
+
+``cleave``
+~~~~~~~~~~
+
+Joy has a few parallel combinators, the main one being ``cleave``:
+
+::
+
+                  ... x [A] [B] cleave
+   ---------------------------------------------------------
+      ... [x ...] [A] infra first [x ...] [B] infra first
+   ---------------------------------------------------------
+                      ... a b
+
+The ``cleave`` combinator expects a value and two quotes and it executes
+each quote in “separate universes” such that neither can affect the
+other, then it takes the first item from the stack in each universe and
+replaces the value and quotes with their respective results.
+
+(I think this corresponds to the “fork” operator, the little
+upward-pointed triangle, that takes two functions ``A :: x -> a`` and
+``B :: x -> b`` and returns a function ``F :: x -> (a, b)``, in Conal
+Elliott’s “Compiling to Categories” paper, et. al.)
+
+Just a thought, if you ``cleave`` two jobs and one requires more time to
+finish than the other you’d like to be able to assign resources
+accordingly so that they both finish at the same time.
+
+“Apply” Functions
+~~~~~~~~~~~~~~~~~
+
+There are also ``app2`` and ``app3`` which run a single quote on more
+than one value:
+
+::
+
+                    ... y x [Q] app2
+    ---------------------------------------------------------
+       ... [y ...] [Q] infra first [x ...] [Q] infra first
+
+
+           ... z y x [Q] app3
+    ---------------------------------
+       ... [z ...] [Q] infra first
+           [y ...] [Q] infra first
+           [x ...] [Q] infra first
+
+Because the quoted program can be ``i`` we can define ``cleave`` in
+terms of ``app2``:
+
+::
+
+   cleave == [i] app2 [popd] dip
+
+(I’m not sure why ``cleave`` was specified to take that value, I may
+make a combinator that does the same thing but without expecting a
+value.)
+
+::
+
+   clv == [i] app2
+
+      [A] [B] clv
+   ------------------
+        a b
+
+``map``
+~~~~~~~
+
+The common ``map`` function in Joy should also be though of as a
+*parallel* operator:
+
+::
+
+   [a b c ...] [Q] map
+
+There is no reason why the implementation of ``map`` couldn’t distribute
+the ``Q`` function over e.g. a pool of worker CPUs.
+
+``pam``
+~~~~~~~
+
+One of my favorite combinators, the ``pam`` combinator is just:
+
+::
+
+   pam == [i] map
+
+This can be used to run any number of programs separately on the current
+stack and combine their (first) outputs in a result list.
+
+::
+
+      [[A] [B] [C] ...] [i] map
+   -------------------------------
+      [ a   b   c  ...]
+
+Handling Other Kinds of Join
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``cleave`` operators and others all have pretty brutal join
+semantics: everything works and we always wait for every
+sub-computation. We can imagine a few different potentially useful
+patterns of “joining” results from parallel combinators.
+
+first-to-finish
+^^^^^^^^^^^^^^^
+
+Thinking about variations of ``pam`` there could be one that only
+returns the first result of the first-to-finish sub-program, or the
+stack could be replaced by its output stack.
+
+The other sub-programs would be cancelled.
+
+“Fulminators”
+^^^^^^^^^^^^^
+
+Also known as “Futures” or “Promises” (by *everybody* else. “Fulinators”
+is what I was going to call them when I was thinking about implementing
+them in Thun.)
+
+The runtime could be amended to permit “thunks” representing the results
+of in-progress computations to be left on the stack and picked up by
+subsequent functions. These would themselves be able to leave behind
+more “thunks”, the values of which depend on the eventual resolution of
+the values of the previous thunks.
+
+In this way you can create “chains” (and more complex shapes) out of
+normal-looking code that consist of a kind of call-graph interspersed
+with “asyncronous” … events?
+
+In any case, until I can find a rigorous theory that shows that this
+sort of thing works perfectly in Joy code I’m not going to worry about
+it. (And I think the Categories can deal with it anyhow? Incremental
+evaluation, yeah?)
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Treestep.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Treestep.rst.txt
new file mode 100644 (file)
index 0000000..7f273d8
--- /dev/null
@@ -0,0 +1,620 @@
+Treating Trees II: ``treestep``
+===============================
+
+Let’s consider a tree structure, similar to one described `“Why
+functional programming matters” by John
+Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__,
+that consists of a node value followed by zero or more child trees. (The
+asterisk is meant to indicate the `Kleene
+star <https://en.wikipedia.org/wiki/Kleene_star>`__.)
+
+::
+
+   tree = [] | [node tree*]
+
+In the spirit of ``step`` we are going to define a combinator
+``treestep`` which expects a tree and three additional items: a
+base-case function ``[B]``, and two quoted programs ``[N]`` and ``[C]``.
+
+::
+
+   tree [B] [N] [C] treestep
+
+If the current tree node is empty then just execute ``B``:
+
+::
+
+      [] [B] [N] [C] treestep
+   ---------------------------
+      []  B
+
+Otherwise, evaluate ``N`` on the node value, ``map`` the whole function
+(abbreviated here as ``K``) over the child trees recursively, and then
+combine the result with ``C``.
+
+::
+
+      [node tree*] [B] [N] [C] treestep
+   --------------------------------------- w/ K == [B] [N] [C] treestep
+          node N [tree*] [K] map C
+
+(Later on we’ll experiment with making ``map`` part of ``C`` so you can
+use other combinators.)
+
+Derive the recursive function.
+------------------------------
+
+We can begin to derive it by finding the ``ifte`` stage that ``genrec``
+will produce.
+
+::
+
+   K == [not] [B] [R0]   [R1] genrec
+     == [not] [B] [R0 [K] R1] ifte
+
+So we just have to derive ``J``:
+
+::
+
+   J == R0 [K] R1
+
+The behavior of ``J`` is to accept a (non-empty) tree node and arrive at
+the desired outcome.
+
+::
+
+          [node tree*] J
+   ------------------------------
+      node N [tree*] [K] map C
+
+So ``J`` will have some form like:
+
+::
+
+   J == ... [N] ... [K] ... [C] ...
+
+Let’s dive in. First, unquote the node and ``dip`` ``N``.
+
+::
+
+   [node tree*] uncons [N] dip
+   node [tree*]        [N] dip
+   node N [tree*]
+
+Next, ``map`` ``K`` over the child trees and combine with ``C``.
+
+::
+
+   node N [tree*] [K] map C
+   node N [tree*] [K] map C
+   node N [K.tree*]       C
+
+So:
+
+::
+
+   J == uncons [N] dip [K] map C
+
+Plug it in and convert to ``genrec``:
+
+::
+
+   K == [not] [B] [J                       ] ifte
+     == [not] [B] [uncons [N] dip [K] map C] ifte
+     == [not] [B] [uncons [N] dip]   [map C] genrec
+
+Extract the givens to parameterize the program.
+-----------------------------------------------
+
+Working backwards:
+
+::
+
+   [not] [B]          [uncons [N] dip]                  [map C] genrec
+   [B] [not] swap     [uncons [N] dip]                  [map C] genrec
+   [B]                [uncons [N] dip] [[not] swap] dip [map C] genrec
+                                       ^^^^^^^^^^^^^^^^
+   [B] [[N] dip]      [uncons] swoncat [[not] swap] dip [map C] genrec
+   [B] [N] [dip] cons [uncons] swoncat [[not] swap] dip [map C] genrec
+           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Extract a couple of auxiliary definitions:
+
+::
+
+   TS.0 == [[not] swap] dip
+   TS.1 == [dip] cons [uncons] swoncat
+
+::
+
+   [B] [N] TS.1 TS.0 [map C]                         genrec
+   [B] [N]           [map C]         [TS.1 TS.0] dip genrec
+   [B] [N] [C]         [map] swoncat [TS.1 TS.0] dip genrec
+
+The givens are all to the left so we have our definition.
+
+(alternate) Extract the givens to parameterize the program.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Working backwards:
+
+::
+
+   [not] [B]           [uncons [N] dip]            [map C] genrec
+   [not] [B] [N]       [dip] cons [uncons] swoncat [map C] genrec
+   [B] [N] [not] roll> [dip] cons [uncons] swoncat [map C] genrec
+           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Define ``treestep``
+-------------------
+
+.. code:: python
+
+    from notebook_preamble import D, J, V, define, DefinitionWrapper
+
+.. code:: python
+
+    DefinitionWrapper.add_definitions('''
+    
+        _treestep_0 == [[not] swap] dip
+        _treestep_1 == [dip] cons [uncons] swoncat
+        treegrind == [_treestep_1 _treestep_0] dip genrec
+        treestep == [map] swoncat treegrind
+    
+    ''', D)
+
+Examples
+--------
+
+Consider trees, the nodes of which are integers. We can find the sum of
+all nodes in a tree with this function:
+
+::
+
+   sumtree == [pop 0] [] [sum +] treestep
+
+.. code:: python
+
+    define('sumtree == [pop 0] [] [sum +] treestep')
+
+Running this function on an empty tree value gives zero:
+
+::
+
+      [] [pop 0] [] [sum +] treestep
+   ------------------------------------
+              0
+
+.. code:: python
+
+    J('[] sumtree')  # Empty tree.
+
+
+.. parsed-literal::
+
+    0
+
+
+Running it on a non-empty node:
+
+::
+
+   [n tree*]  [pop 0] [] [sum +] treestep
+   n [tree*] [[pop 0] [] [sum +] treestep] map sum +
+   n [ ... ]                                   sum +
+   n m                                             +
+   n+m
+
+.. code:: python
+
+    J('[23] sumtree')  # No child trees.
+
+
+.. parsed-literal::
+
+    23
+
+
+.. code:: python
+
+    J('[23 []] sumtree')  # Child tree, empty.
+
+
+.. parsed-literal::
+
+    23
+
+
+.. code:: python
+
+    J('[23 [2 [4]] [3]] sumtree')  # Non-empty child trees.
+
+
+.. parsed-literal::
+
+    32
+
+
+.. code:: python
+
+    J('[23 [2 [8] [9]] [3] [4 []]] sumtree')  # Etc...
+
+
+.. parsed-literal::
+
+    49
+
+
+.. code:: python
+
+    J('[23 [2 [8] [9]] [3] [4 []]] [pop 0] [] [cons sum] treestep')  # Alternate "spelling".
+
+
+.. parsed-literal::
+
+    49
+
+
+.. code:: python
+
+    J('[23 [2 [8] [9]] [3] [4 []]] [] [pop 23] [cons] treestep')  # Replace each node.
+
+
+.. parsed-literal::
+
+    [23 [23 [23] [23]] [23] [23 []]]
+
+
+.. code:: python
+
+    J('[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep')
+
+
+.. parsed-literal::
+
+    [1 [1 [1] [1]] [1] [1 []]]
+
+
+.. code:: python
+
+    J('[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep sumtree')
+
+
+.. parsed-literal::
+
+    6
+
+
+.. code:: python
+
+    J('[23 [2 [8] [9]] [3] [4 []]] [pop 0] [pop 1] [sum +] treestep')  # Combine replace and sum into one function.
+
+
+.. parsed-literal::
+
+    6
+
+
+.. code:: python
+
+    J('[4 [3 [] [7]]] [pop 0] [pop 1] [sum +] treestep')  # Combine replace and sum into one function.
+
+
+.. parsed-literal::
+
+    3
+
+
+Redefining the Ordered Binary Tree in terms of ``treestep``.
+------------------------------------------------------------
+
+::
+
+   Tree = [] | [[key value] left right]
+
+What kind of functions can we write for this with our ``treestep``?
+
+The pattern for processing a non-empty node is:
+
+::
+
+   node N [tree*] [K] map C
+
+Plugging in our BTree structure:
+
+::
+
+   [key value] N [left right] [K] map C
+
+Traversal
+~~~~~~~~~
+
+::
+
+   [key value] first [left right] [K] map i
+   key [value]       [left right] [K] map i
+   key               [left right] [K] map i
+   key               [lkey rkey ]         i
+   key                lkey rkey
+
+This doesn’t quite work:
+
+.. code:: python
+
+    J('[[3 0] [[2 0] [][]] [[9 0] [[5 0] [[4 0] [][]] [[8 0] [[6 0] [] [[7 0] [][]]][]]][]]] ["B"] [first] [i] treestep')
+
+
+.. parsed-literal::
+
+    3 'B' 'B'
+
+
+Doesn’t work because ``map`` extracts the ``first`` item of whatever its
+mapped function produces. We have to return a list, rather than
+depositing our results directly on the stack.
+
+::
+
+   [key value] N     [left right] [K] map C
+
+   [key value] first [left right] [K] map flatten cons
+   key               [left right] [K] map flatten cons
+   key               [[lk] [rk] ]         flatten cons
+   key               [ lk   rk  ]                 cons
+                     [key  lk   rk  ]
+
+So:
+
+::
+
+   [] [first] [flatten cons] treestep
+
+.. code:: python
+
+    J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [first] [flatten cons] treestep')
+
+
+.. parsed-literal::
+
+    [3 2 9 5 4 8 6 7]
+
+
+There we go.
+
+In-order traversal
+~~~~~~~~~~~~~~~~~~
+
+From here:
+
+::
+
+   key [[lk] [rk]] C
+   key [[lk] [rk]] i
+   key  [lk] [rk] roll<
+   [lk] [rk] key swons concat
+   [lk] [key rk]       concat
+   [lk   key rk]
+
+So:
+
+::
+
+   [] [i roll< swons concat] [first] treestep
+
+.. code:: python
+
+    J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [uncons pop] [i roll< swons concat] treestep')
+
+
+.. parsed-literal::
+
+    [2 3 4 5 6 7 8 9]
+
+
+With ``treegrind``?
+-------------------
+
+The ``treegrind`` function doesn’t include the ``map`` combinator, so
+the ``[C]`` function must arrange to use some combinator on the quoted
+recursive copy ``[K]``. With this function, the pattern for processing a
+non-empty node is:
+
+::
+
+   node N [tree*] [K] C
+
+Plugging in our BTree structure:
+
+::
+
+   [key value] N [left right] [K] C
+
+.. code:: python
+
+    J('[["key" "value"] ["left"] ["right"] ] ["B"] ["N"] ["C"] treegrind')
+
+
+.. parsed-literal::
+
+    ['key' 'value'] 'N' [['left'] ['right']] [[not] ['B'] [uncons ['N'] dip] ['C'] genrec] 'C'
+
+
+``treegrind`` with ``step``
+---------------------------
+
+Iteration through the nodes
+
+.. code:: python
+
+    J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] ["N"] [step] treegrind')
+
+
+.. parsed-literal::
+
+    [3 0] 'N' [2 0] 'N' [9 0] 'N' [5 0] 'N' [4 0] 'N' [8 0] 'N' [6 0] 'N' [7 0] 'N'
+
+
+Sum the nodes’ keys.
+
+.. code:: python
+
+    J('0 [[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] [first +] [step] treegrind')
+
+
+.. parsed-literal::
+
+    44
+
+
+Rebuild the tree using ``map`` (imitating ``treestep``.)
+
+.. code:: python
+
+    J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [[100 +] infra] [map cons] treegrind')
+
+
+.. parsed-literal::
+
+    [[103 0] [[102 0] [] []] [[109 0] [[105 0] [[104 0] [] []] [[108 0] [[106 0] [] [[107 0] [] []]] []]] []]]
+
+
+Do we have the flexibility to reimplement ``Tree-get``?
+-------------------------------------------------------
+
+I think we do:
+
+::
+
+   [B] [N] [C] treegrind
+
+We’ll start by saying that the base-case (the key is not in the tree) is
+user defined, and the per-node function is just the query key literal:
+
+::
+
+   [B] [query_key] [C] treegrind
+
+This means we just have to define ``C`` from:
+
+::
+
+   [key value] query_key [left right] [K] C
+
+Let’s try ``cmp``:
+
+::
+
+   C == P [T>] [E] [T<] cmp
+
+   [key value] query_key [left right] [K] P [T>] [E] [T<] cmp
+
+The predicate ``P``
+~~~~~~~~~~~~~~~~~~~
+
+Seems pretty easy (we must preserve the value in case the keys are
+equal):
+
+::
+
+   [key value] query_key [left right] [K] P
+   [key value] query_key [left right] [K] roll<
+   [key value] [left right] [K] query_key       [roll< uncons swap] dip
+
+   [key value] [left right] [K] roll< uncons swap query_key
+   [left right] [K] [key value]       uncons swap query_key
+   [left right] [K] key [value]              swap query_key
+   [left right] [K] [value] key                   query_key
+
+   P == roll< [roll< uncons swap] dip
+
+(Possibly with a swap at the end? Or just swap ``T<`` and ``T>``.)
+
+So now:
+
+::
+
+   [left right] [K] [value] key query_key [T>] [E] [T<] cmp
+
+Becomes one of these three:
+
+::
+
+   [left right] [K] [value] T>
+   [left right] [K] [value] E
+   [left right] [K] [value] T<
+
+``E``
+~~~~~
+
+Easy.
+
+::
+
+   E == roll> popop first
+
+``T<`` and ``T>``
+~~~~~~~~~~~~~~~~~
+
+::
+
+   T< == pop [first] dip i
+   T> == pop [second] dip i
+
+Putting it together
+-------------------
+
+::
+
+   T> == pop [first] dip i
+   T< == pop [second] dip i
+   E == roll> popop first
+   P == roll< [roll< uncons swap] dip
+
+   Tree-get == [P [T>] [E] [T<] cmp] treegrind
+
+To me, that seems simpler than the ``genrec`` version.
+
+.. code:: python
+
+    DefinitionWrapper.add_definitions('''
+    
+        T> == pop [first] dip i
+        T< == pop [second] dip i
+        E == roll> popop first
+        P == roll< [roll< uncons swap] dip
+    
+        Tree-get == [P [T>] [E] [T<] cmp] treegrind
+    
+    ''', D)
+
+.. code:: python
+
+    J('''\
+    
+    [[3 13] [[2 12] [] []] [[9 19] [[5 15] [[4 14] [] []] [[8 18] [[6 16] [] [[7 17] [] []]] []]] []]]
+    
+    [] [5] Tree-get
+    
+    ''')
+
+
+.. parsed-literal::
+
+    15
+
+
+.. code:: python
+
+    J('''\
+    
+    [[3 13] [[2 12] [] []] [[9 19] [[5 15] [[4 14] [] []] [[8 18] [[6 16] [] [[7 17] [] []]] []]] []]]
+    
+    [pop "nope"] [25] Tree-get
+    
+    ''')
+
+
+.. parsed-literal::
+
+    'nope'
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/TypeChecking.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/TypeChecking.rst.txt
new file mode 100644 (file)
index 0000000..4e70a1a
--- /dev/null
@@ -0,0 +1,171 @@
+Type Checking
+=============
+
+.. code:: python
+
+    import logging, sys
+    
+    logging.basicConfig(
+      format='%(message)s',
+      stream=sys.stdout,
+      level=logging.INFO,
+      )
+
+.. code:: python
+
+    from joy.utils.types import (
+        doc_from_stack_effect, 
+        infer,
+        reify,
+        unify,
+        FUNCTIONS,
+        JoyTypeError,
+    )
+
+.. code:: python
+
+    D = FUNCTIONS.copy()
+    del D['product']
+    globals().update(D)
+
+An Example
+----------
+
+.. code:: python
+
+    fi, fo = infer(pop, swap, rolldown, rrest, ccons)[0]
+
+
+.. parsed-literal::
+
+     25 (--) ∘ pop swap rolldown rrest ccons
+     28 (a1 --) ∘ swap rolldown rrest ccons
+     31 (a3 a2 a1 -- a2 a3) ∘ rolldown rrest ccons
+     34 (a4 a3 a2 a1 -- a2 a3 a4) ∘ rrest ccons
+     37 ([a4 a5 ...1] a3 a2 a1 -- a2 a3 [...1]) ∘ ccons
+     40 ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1]) ∘ 
+
+
+.. code:: python
+
+    print doc_from_stack_effect(fi, fo)
+
+
+.. parsed-literal::
+
+    ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1])
+
+
+.. code:: python
+
+    from joy.parser import text_to_expression
+    from joy.utils.stack import stack_to_string
+
+
+.. code:: python
+
+    e = text_to_expression('0 1 2 [3 4]')  # reverse order
+    print stack_to_string(e)
+
+
+.. parsed-literal::
+
+    [3 4] 2 1 0
+
+
+.. code:: python
+
+    u = unify(e, fi)[0]
+    u
+
+
+
+
+.. parsed-literal::
+
+    {a1: 0, a2: 1, a3: 2, a4: 3, a5: 4, s2: (), s1: ()}
+
+
+
+.. code:: python
+
+    g = reify(u, (fi, fo))
+    print doc_from_stack_effect(*g)
+
+
+.. parsed-literal::
+
+    (... [3 4 ] 2 1 0 -- ... [1 2 ])
+
+
+Unification Works “in Reverse”
+------------------------------
+
+.. code:: python
+
+    e = text_to_expression('[2 3]')
+
+.. code:: python
+
+    u = unify(e, fo)[0]  # output side, not input side
+    u
+
+
+
+
+.. parsed-literal::
+
+    {a2: 2, a3: 3, s2: (), s1: ()}
+
+
+
+.. code:: python
+
+    g = reify(u, (fi, fo))
+    print doc_from_stack_effect(*g)
+
+
+.. parsed-literal::
+
+    (... [a4 a5 ] 3 2 a1 -- ... [2 3 ])
+
+
+Failing a Check
+---------------
+
+.. code:: python
+
+    fi, fo = infer(dup, mul)[0]
+
+
+.. parsed-literal::
+
+     25 (--) ∘ dup mul
+     28 (a1 -- a1 a1) ∘ mul
+     31 (f1 -- f2) ∘ 
+     31 (i1 -- i2) ∘ 
+
+
+.. code:: python
+
+    e = text_to_expression('"two"')
+    print stack_to_string(e)
+
+
+.. parsed-literal::
+
+    'two'
+
+
+.. code:: python
+
+    try:
+        unify(e, fi)
+    except JoyTypeError, err:
+        print err
+
+
+.. parsed-literal::
+
+    Cannot unify 'two' and f1.
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Types.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Types.rst.txt
new file mode 100644 (file)
index 0000000..8ca737d
--- /dev/null
@@ -0,0 +1,2968 @@
+The Blissful Elegance of Typing Joy
+===================================
+
+This notebook presents a simple type inferencer for Joy code. It can
+infer the stack effect of most Joy expressions. It’s built largely by
+means of existing ideas and research. (A great overview of the existing
+knowledge is a talk `“Type Inference in Stack-Based Programming
+Languages” <http://prl.ccs.neu.edu/blog/2017/03/10/type-inference-in-stack-based-programming-languages/>`__
+given by Rob Kleffner on or about 2017-03-10 as part of a course on the
+history of programming languages.)
+
+The notebook starts with a simple inferencer based on the work of Jaanus
+Pöial which we then progressively elaborate to cover more Joy semantics.
+Along the way we write a simple “compiler” that emits Python code for
+what I like to call Yin functions. (Yin functions are those that only
+rearrange values in stacks, as opposed to Yang functions that actually
+work on the values themselves.)
+
+Part I: Pöial’s Rules
+---------------------
+
+`“Typing Tools for Typeless Stack Languages” by Jaanus
+Pöial <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.212.6026>`__
+
+::
+
+   @INPROCEEDINGS{Pöial06typingtools,
+       author = {Jaanus Pöial},
+       title = {Typing tools for typeless stack languages},
+       booktitle = {In 23rd Euro-Forth Conference},
+       year = {2006},
+       pages = {40--46}
+   }
+
+First Rule
+~~~~~~~~~~
+
+This rule deals with functions (and literals) that put items on the
+stack ``(-- d)``:
+
+::
+
+      (a -- b)∘(-- d)
+   ---------------------
+        (a -- b d)
+
+Second Rule
+~~~~~~~~~~~
+
+This rule deals with functions that consume items from the stack
+``(a --)``:
+
+::
+
+      (a --)∘(c -- d)
+   ---------------------
+        (c a -- d)
+
+Third Rule
+~~~~~~~~~~
+
+The third rule is actually two rules. These two rules deal with
+composing functions when the second one will consume one of items the
+first one produces. The two types must be
+`unified <https://en.wikipedia.org/wiki/Robinson's_unification_algorithm>`__
+or a type conflict declared.
+
+::
+
+      (a -- b t[i])∘(c u[j] -- d)   t <= u (t is subtype of u)
+   -------------------------------
+      (a -- b     )∘(c      -- d)   t[i] == t[k] == u[j]
+                                            ^
+
+      (a -- b t[i])∘(c u[j] -- d)   u <= t (u is subtype of t)
+   -------------------------------
+      (a -- b     )∘(c      -- d)   t[i] == u[k] == u[j]
+
+Let’s work through some examples by hand to develop an intuition for the
+algorithm.
+
+There’s a function in one of the other notebooks.
+
+::
+
+   F == pop swap roll< rest rest cons cons
+
+It’s all “stack chatter” and list manipulation so we should be able to
+deduce its type.
+
+Stack Effect Comments
+~~~~~~~~~~~~~~~~~~~~~
+
+Joy function types will be represented by Forth-style stack effect
+comments. I’m going to use numbers instead of names to keep track of the
+stack arguments. (A little bit like `De Bruijn
+index <https://en.wikipedia.org/wiki/De_Bruijn_index>`__, at least it
+reminds me of them):
+
+::
+
+   pop (1 --)
+
+   swap (1 2 -- 2 1)
+
+   roll< (1 2 3 -- 2 3 1)
+
+These commands alter the stack but don’t “look at” the values so these
+numbers represent an “Any type”.
+
+``pop swap``
+~~~~~~~~~~~~
+
+::
+
+   (1 --) (1 2 -- 2 1)
+
+Here we encounter a complication. The argument numbers need to be made
+unique among both sides. For this let’s change ``pop`` to use 0:
+
+::
+
+   (0 --) (1 2 -- 2 1)
+
+Following the second rule:
+
+::
+
+   (1 2 0 -- 2 1)
+
+``pop∘swap roll<``
+~~~~~~~~~~~~~~~~~~
+
+::
+
+   (1 2 0 -- 2 1) (1 2 3 -- 2 3 1)
+
+Let’s re-label them:
+
+::
+
+   (1a 2a 0a -- 2a 1a) (1b 2b 3b -- 2b 3b 1b)
+
+Now we follow the rules.
+
+We must unify ``1a`` and ``3b``, and ``2a`` and ``2b``, replacing the
+terms in the forms:
+
+::
+
+   (1a 2a 0a -- 2a 1a) (1b 2b 3b -- 2b 3b 1b)
+                                               w/  {1a: 3b}
+   (3b 2a 0a -- 2a   ) (1b 2b    -- 2b 3b 1b)
+                                               w/  {2a: 2b}
+   (3b 2b 0a --      ) (1b       -- 2b 3b 1b)
+
+Here we must apply the second rule:
+
+::
+
+      (3b 2b 0a --) (1b -- 2b 3b 1b)
+   -----------------------------------
+        (1b 3b 2b 0a -- 2b 3b 1b)
+
+Now we de-label the type, uh, labels:
+
+::
+
+   (1b 3b 2b 0a -- 2b 3b 1b)
+
+   w/ {
+       1b: 1,
+       3b: 2,
+       2b: 3,
+       0a: 0,
+       }
+
+   (1 2 3 0 -- 3 2 1)
+
+And now we have the stack effect comment for ``pop∘swap∘roll<``.
+
+Compiling ``pop∘swap∘roll<``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The simplest way to “compile” this function would be something like:
+
+.. code:: python
+
+    def poswrd(s, e, d):
+        return rolldown(*swap(*pop(s, e, d)))
+
+However, internally this function would still be allocating tuples
+(stack cells) and doing other unnecesssary work.
+
+Looking ahead for a moment, from the stack effect comment:
+
+::
+
+   (1 2 3 0 -- 3 2 1)
+
+We should be able to directly write out a Python function like:
+
+.. code:: python
+
+    def poswrd(stack):
+        (_, (a, (b, (c, stack)))) = stack
+        return (c, (b, (a, stack)))
+
+This eliminates the internal work of the first version. Because this
+function only rearranges the stack and doesn’t do any actual processing
+on the stack items themselves all the information needed to implement it
+is in the stack effect comment.
+
+Functions on Stacks
+~~~~~~~~~~~~~~~~~~~
+
+These are slightly tricky.
+
+::
+
+   rest ( [1 ...] -- [...] )
+
+   cons ( 1 [...] -- [1 ...] )
+
+``pop∘swap∘roll< rest``
+~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+   (1 2 3 0 -- 3 2 1) ([1 ...] -- [...])
+
+Re-label (instead of adding left and right tags I’m just taking the next
+available index number for the right-side stack effect comment):
+
+::
+
+   (1 2 3 0 -- 3 2 1) ([4 ...] -- [...])
+
+Unify and update:
+
+::
+
+   (1       2 3 0 -- 3 2 1) ([4 ...] -- [...])
+                                                w/ {1: [4 ...]}
+   ([4 ...] 2 3 0 -- 3 2  ) (        -- [...])
+
+Apply the first rule:
+
+::
+
+      ([4 ...] 2 3 0 -- 3 2) (-- [...])
+   ---------------------------------------
+        ([4 ...] 2 3 0 -- 3 2 [...])
+
+And there we are.
+
+``pop∘swap∘roll<∘rest rest``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Let’s do it again.
+
+::
+
+   ([4 ...] 2 3 0 -- 3 2 [...]) ([1 ...] -- [...])
+
+Re-label (the tails of the lists on each side each get their own label):
+
+::
+
+   ([4 .0.] 2 3 0 -- 3 2 [.0.]) ([5 .1.] -- [.1.])
+
+Unify and update (note the opening square brackets have been omited in
+the substitution dict, this is deliberate and I’ll explain below):
+
+::
+
+   ([4 .0.]   2 3 0 -- 3 2 [.0.]  ) ([5 .1.] -- [.1.])
+                                                       w/ { .0.] : 5 .1.] }
+   ([4 5 .1.] 2 3 0 -- 3 2 [5 .1.]) ([5 .1.] -- [.1.])
+
+How do we find ``.0.]`` in ``[4 .0.]`` and replace it with ``5 .1.]``
+getting the result ``[4 5 .1.]``? This might seem hard, but because the
+underlying structure of the Joy list is a cons-list in Python it’s
+actually pretty easy. I’ll explain below.
+
+Next we unify and find our two terms are the same already: ``[5 .1.]``:
+
+::
+
+   ([4 5 .1.] 2 3 0 -- 3 2 [5 .1.]) ([5 .1.] -- [.1.])
+
+Giving us:
+
+::
+
+   ([4 5 .1.] 2 3 0 -- 3 2) (-- [.1.])
+
+From here we apply the first rule and get:
+
+::
+
+   ([4 5 .1.] 2 3 0 -- 3 2 [.1.])
+
+Cleaning up the labels:
+
+::
+
+   ([4 5 ...] 2 3 1 -- 3 2 [...])
+
+This is the stack effect of ``pop∘swap∘roll<∘rest∘rest``.
+
+``pop∘swap∘roll<∘rest∘rest cons``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+   ([4 5 ...] 2 3 1 -- 3 2 [...]) (1 [...] -- [1 ...])
+
+Re-label:
+
+::
+
+   ([4 5 .1.] 2 3 1 -- 3 2 [.1.]) (6 [.2.] -- [6 .2.])
+
+Unify:
+
+::
+
+   ([4 5 .1.] 2 3 1 -- 3 2 [.1.]) (6 [.2.] -- [6 .2.])
+                                                        w/ { .1.] : .2.] }
+   ([4 5 .2.] 2 3 1 -- 3 2      ) (6       -- [6 .2.])
+                                                        w/ {2: 6}
+   ([4 5 .2.] 6 3 1 -- 3        ) (        -- [6 .2.])
+
+First rule:
+
+::
+
+   ([4 5 .2.] 6 3 1 -- 3 [6 .2.])
+
+Re-label:
+
+::
+
+   ([4 5 ...] 2 3 1 -- 3 [2 ...])
+
+Done.
+
+``pop∘swap∘roll<∘rest∘rest∘cons cons``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+One more time.
+
+::
+
+   ([4 5 ...] 2 3 1 -- 3 [2 ...]) (1 [...] -- [1 ...])
+
+Re-label:
+
+::
+
+   ([4 5 .1.] 2 3 1 -- 3 [2 .1.]) (6 [.2.] -- [6 .2.])
+
+Unify:
+
+::
+
+   ([4 5 .1.] 2 3 1 -- 3 [2 .1.]) (6 [.2.] -- [6 .2.]  )
+                                                          w/ { .2.] : 2 .1.] }
+   ([4 5 .1.] 2 3 1 -- 3        ) (6       -- [6 2 .1.])
+                                                          w/ {3: 6}
+   ([4 5 .1.] 2 6 1 --          ) (        -- [6 2 .1.])
+
+First or second rule:
+
+::
+
+   ([4 5 .1.] 2 6 1 -- [6 2 .1.])
+
+Clean up the labels:
+
+::
+
+   ([4 5 ...] 2 3 1 -- [3 2 ...])
+
+And there you have it, the stack effect for
+``pop∘swap∘roll<∘rest∘rest∘cons∘cons``.
+
+::
+
+   ([4 5 ...] 2 3 1 -- [3 2 ...])
+
+From this stack effect comment it should be possible to construct the
+following Python code:
+
+.. code:: python
+
+    def F(stack):
+        (_, (d, (c, ((a, (b, S0)), stack)))) = stack
+        return (d, (c, S0)), stack
+
+Part II: Implementation
+-----------------------
+
+Representing Stack Effect Comments in Python
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+I’m going to use pairs of tuples of type descriptors, which will be
+integers or tuples of type descriptors:
+
+.. code:: python
+
+    roll_dn = (1, 2, 3), (2, 3, 1)
+    
+    pop = (1,), ()
+    
+    swap = (1, 2), (2, 1)
+
+``compose()``
+~~~~~~~~~~~~~
+
+.. code:: python
+
+    def compose(f, g):
+    
+        (f_in, f_out), (g_in, g_out) = f, g
+    
+        # First rule.
+        #
+        #       (a -- b) (-- d)
+        #    ---------------------
+        #         (a -- b d)
+    
+        if not g_in:
+    
+            fg_in, fg_out = f_in, f_out + g_out
+    
+        # Second rule.
+        #
+        #       (a --) (c -- d)
+        #    ---------------------
+        #         (c a -- d)
+    
+        elif not f_out:
+    
+            fg_in, fg_out = g_in + f_in, g_out
+    
+        else: # Unify, update, recur.
+    
+            fo, gi = f_out[-1], g_in[-1]
+    
+            s = unify(gi, fo)
+    
+            if s == False:  # s can also be the empty dict, which is ok.
+                raise TypeError('Cannot unify %r and %r.' % (fo, gi))
+    
+            f_g = (f_in, f_out[:-1]), (g_in[:-1], g_out)
+    
+            if s: f_g = update(s, f_g)
+    
+            fg_in, fg_out = compose(*f_g)
+    
+        return fg_in, fg_out
+
+``unify()``
+~~~~~~~~~~~
+
+.. code:: python
+
+    def unify(u, v, s=None):
+        if s is None:
+            s = {}
+    
+        if isinstance(u, int):
+            s[u] = v
+        elif isinstance(v, int):
+            s[v] = u
+        else:
+            s = False
+    
+        return s
+
+``update()``
+~~~~~~~~~~~~
+
+.. code:: python
+
+    def update(s, term):
+        if not isinstance(term, tuple):
+            return s.get(term, term)
+        return tuple(update(s, inner) for inner in term)
+
+``relabel()``
+~~~~~~~~~~~~~
+
+.. code:: python
+
+    def relabel(left, right):
+        return left, _1000(right)
+    
+    def _1000(right):
+        if not isinstance(right, tuple):
+            return 1000 + right
+        return tuple(_1000(n) for n in right)
+    
+    relabel(pop, swap)
+
+
+
+
+.. parsed-literal::
+
+    (((1,), ()), ((1001, 1002), (1002, 1001)))
+
+
+
+``delabel()``
+~~~~~~~~~~~~~
+
+.. code:: python
+
+    def delabel(f):
+        s = {u: i for i, u in enumerate(sorted(_unique(f)))}
+        return update(s, f)
+    
+    def _unique(f, seen=None):
+        if seen is None:
+            seen = set()
+        if not isinstance(f, tuple):
+            seen.add(f)
+        else:
+            for inner in f:
+                _unique(inner, seen)
+        return seen
+    
+    delabel(relabel(pop, swap))
+
+
+
+
+.. parsed-literal::
+
+    (((0,), ()), ((1, 2), (2, 1)))
+
+
+
+``C()``
+~~~~~~~
+
+At last we put it all together in a function ``C()`` that accepts two
+stack effect comments and returns their composition (or raises and
+exception if they can’t be composed due to type conflicts.)
+
+.. code:: python
+
+    def C(f, g):
+        f, g = relabel(f, g)
+        fg = compose(f, g)
+        return delabel(fg)
+
+Let’s try it out.
+
+.. code:: python
+
+    C(pop, swap)
+
+
+
+
+.. parsed-literal::
+
+    ((1, 2, 0), (2, 1))
+
+
+
+.. code:: python
+
+    C(C(pop, swap), roll_dn)
+
+
+
+
+.. parsed-literal::
+
+    ((3, 1, 2, 0), (2, 1, 3))
+
+
+
+.. code:: python
+
+    C(swap, roll_dn)
+
+
+
+
+.. parsed-literal::
+
+    ((2, 0, 1), (1, 0, 2))
+
+
+
+.. code:: python
+
+    C(pop, C(swap, roll_dn))
+
+
+
+
+.. parsed-literal::
+
+    ((3, 1, 2, 0), (2, 1, 3))
+
+
+
+.. code:: python
+
+    poswrd = reduce(C, (pop, swap, roll_dn))
+    poswrd
+
+
+
+
+.. parsed-literal::
+
+    ((3, 1, 2, 0), (2, 1, 3))
+
+
+
+Stack Functions
+~~~~~~~~~~~~~~~
+
+Here’s that trick to represent functions like ``rest`` and ``cons`` that
+manipulate stacks. We use a cons-list of tuples and give the tails their
+own numbers. Then everything above already works.
+
+.. code:: python
+
+    rest = ((1, 2),), (2,)
+    
+    cons = (1, 2), ((1, 2),)
+
+.. code:: python
+
+    C(poswrd, rest)
+
+
+
+
+.. parsed-literal::
+
+    (((3, 4), 1, 2, 0), (2, 1, 4))
+
+
+
+Compare this to the stack effect comment we wrote above:
+
+::
+
+   ((  (3, 4), 1, 2, 0 ), ( 2, 1,   4  ))
+   (   [4 ...] 2  3  0  --  3  2  [...])
+
+The translation table, if you will, would be:
+
+::
+
+   {
+   3: 4,
+   4: ...],
+   1: 2,
+   2: 3,
+   0: 0,
+   }
+
+.. code:: python
+
+    F = reduce(C, (pop, swap, roll_dn, rest, rest, cons, cons))
+    
+    F
+
+
+
+
+.. parsed-literal::
+
+    (((3, (4, 5)), 1, 2, 0), ((2, (1, 5)),))
+
+
+
+Compare with the stack effect comment and you can see it works fine:
+
+::
+
+   ([4 5 ...] 2 3 1 -- [3 2 ...])
+     3 4  5   1 2 0     2 1  5
+
+Dealing with ``cons`` and ``uncons``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+However, if we try to compose e.g. ``cons`` and ``uncons`` it won’t
+work:
+
+.. code:: python
+
+    uncons = ((1, 2),), (1, 2)
+
+.. code:: python
+
+    try:
+        C(cons, uncons)
+    except Exception, e:
+        print e
+
+
+.. parsed-literal::
+
+    Cannot unify (1, 2) and (1001, 1002).
+
+
+``unify()`` version 2
+^^^^^^^^^^^^^^^^^^^^^
+
+The problem is that the ``unify()`` function as written doesn’t handle
+the case when both terms are tuples. We just have to add a clause to
+deal with this recursively:
+
+.. code:: python
+
+    def unify(u, v, s=None):
+        if s is None:
+            s = {}
+        elif s:
+            u = update(s, u)
+            v = update(s, v)
+    
+        if isinstance(u, int):
+            s[u] = v
+    
+        elif isinstance(v, int):
+            s[v] = u
+    
+        elif isinstance(u, tuple) and isinstance(v, tuple):
+    
+            if len(u) != 2 or len(v) != 2:
+                # Not a type error, caller passed in a bad value.
+                raise ValueError(repr((u, v)))  # FIXME this message sucks.
+    
+            (a, b), (c, d) = u, v
+            s = unify(a, c, s)
+            if s != False:
+                s = unify(b, d, s)
+        else:
+            s = False
+    
+        return s
+
+.. code:: python
+
+    C(cons, uncons)
+
+
+
+
+.. parsed-literal::
+
+    ((0, 1), (0, 1))
+
+
+
+Part III: Compiling Yin Functions
+---------------------------------
+
+Now consider the Python function we would like to derive:
+
+.. code:: python
+
+    def F_python(stack):
+        (_, (d, (c, ((a, (b, S0)), stack)))) = stack
+        return (d, (c, S0)), stack
+
+And compare it to the input stack effect comment tuple we just computed:
+
+.. code:: python
+
+    F[0]
+
+
+
+
+.. parsed-literal::
+
+    ((3, (4, 5)), 1, 2, 0)
+
+
+
+The stack-de-structuring tuple has nearly the same form as our input
+stack effect comment tuple, just in the reverse order:
+
+::
+
+   (_, (d, (c, ((a, (b, S0)), stack))))
+
+Remove the punctuation:
+
+::
+
+    _   d   c   (a, (b, S0))
+
+Reverse the order and compare:
+
+::
+
+    (a, (b, S0))   c   d   _
+   ((3, (4, 5 )),  1,  2,  0)
+
+Eh?
+
+And the return tuple
+
+.. code:: python
+
+    F[1]
+
+
+
+
+.. parsed-literal::
+
+    ((2, (1, 5)),)
+
+
+
+is similar to the output stack effect comment tuple:
+
+::
+
+   ((d, (c, S0)), stack)
+   ((2, (1, 5 )),      )
+
+This should make it pretty easy to write a Python function that accepts
+the stack effect comment tuples and returns a new Python function
+(either as a string of code or a function object ready to use) that
+performs the semantics of that Joy function (described by the stack
+effect.)
+
+Python Identifiers
+~~~~~~~~~~~~~~~~~~
+
+We want to substitute Python identifiers for the integers. I’m going to
+repurpose ``joy.parser.Symbol`` class for this:
+
+.. code:: python
+
+    from collections import defaultdict
+    from joy.parser import Symbol
+    
+    
+    def _names_for():
+        I = iter(xrange(1000))
+        return lambda: Symbol('a%i' % next(I))
+    
+    
+    def identifiers(term, s=None):
+        if s is None:
+            s = defaultdict(_names_for())
+        if isinstance(term, int):
+            return s[term]
+        return tuple(identifiers(inner, s) for inner in term)
+
+``doc_from_stack_effect()``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+As a convenience I’ve implemented a function to convert the Python stack
+effect comment tuples to reasonable text format. There are some details
+in how this code works that related to stuff later in the notebook, so
+you should skip it for now and read it later if you’re interested.
+
+.. code:: python
+
+    def doc_from_stack_effect(inputs, outputs):
+        return '(%s--%s)' % (
+            ' '.join(map(_to_str, inputs + ('',))),
+            ' '.join(map(_to_str, ('',) + outputs))
+        )
+    
+    
+    def _to_str(term):
+        if not isinstance(term, tuple):
+            try:
+                t = term.prefix == 's'
+            except AttributeError:
+                return str(term)
+            return '[.%i.]' % term.number if t else str(term)
+    
+        a = []
+        while term and isinstance(term, tuple):
+            item, term = term
+            a.append(_to_str(item))
+    
+        try:
+            n = term.number
+        except AttributeError:
+            n = term
+        else:
+            if term.prefix != 's':
+                raise ValueError('Stack label: %s' % (term,))
+    
+        a.append('.%s.' % (n,))
+        return '[%s]' % ' '.join(a)
+
+``compile_()``
+~~~~~~~~~~~~~~
+
+Now we can write a compiler function to emit Python source code. (The
+underscore suffix distiguishes it from the built-in ``compile()``
+function.)
+
+.. code:: python
+
+    def compile_(name, f, doc=None):
+        if doc is None:
+            doc = doc_from_stack_effect(*f)
+        inputs, outputs = identifiers(f)
+        i = o = Symbol('stack')
+        for term in inputs:
+            i = term, i
+        for term in outputs:
+            o = term, o
+        return '''def %s(stack):
+        """%s"""
+        %s = stack
+        return %s''' % (name, doc, i, o)
+
+Here it is in action:
+
+.. code:: python
+
+    source = compile_('F', F)
+    
+    print source
+
+
+.. parsed-literal::
+
+    def F(stack):
+        """([3 4 .5.] 1 2 0 -- [2 1 .5.])"""
+        (a5, (a4, (a3, ((a0, (a1, a2)), stack)))) = stack
+        return ((a4, (a3, a2)), stack)
+
+
+Compare:
+
+.. code:: python
+
+    def F_python(stack):
+        (_, (d, (c, ((a, (b, S0)), stack)))) = stack
+        return ((d, (c, S0)), stack)
+
+Next steps:
+
+.. code:: python
+
+    L = {}
+    
+    eval(compile(source, '__main__', 'single'), {}, L)
+    
+    L['F']
+
+
+
+
+.. parsed-literal::
+
+    <function F>
+
+
+
+Let’s try it out:
+
+.. code:: python
+
+    from notebook_preamble import D, J, V
+    from joy.library import SimpleFunctionWrapper
+
+.. code:: python
+
+    D['F'] = SimpleFunctionWrapper(L['F'])
+
+.. code:: python
+
+    J('[4 5 ...] 2 3 1 F')
+
+
+.. parsed-literal::
+
+    [3 2 ...]
+
+
+With this, we have a partial Joy compiler that works on the subset of
+Joy functions that manipulate stacks (both what I call “stack chatter”
+and the ones that manipulate stacks on the stack.)
+
+I’m probably going to modify the definition wrapper code to detect
+definitions that can be compiled by this partial compiler and do it
+automatically. It might be a reasonable idea to detect sequences of
+compilable functions in definitions that have uncompilable functions in
+them and just compile those. However, if your library is well-factored
+this might be less helpful.
+
+Compiling Library Functions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We can use ``compile_()`` to generate many primitives in the library
+from their stack effect comments:
+
+.. code:: python
+
+    def defs():
+    
+        rolldown = (1, 2, 3), (2, 3, 1)
+    
+        rollup = (1, 2, 3), (3, 1, 2)
+    
+        pop = (1,), ()
+    
+        swap = (1, 2), (2, 1)
+    
+        rest = ((1, 2),), (2,)
+        
+        rrest = C(rest, rest)
+    
+        cons = (1, 2), ((1, 2),)
+    
+        uncons = ((1, 2),), (1, 2)
+        
+        swons = C(swap, cons)
+    
+        return locals()
+
+.. code:: python
+
+    for name, stack_effect_comment in sorted(defs().items()):
+        print
+        print compile_(name, stack_effect_comment)
+        print
+
+
+.. parsed-literal::
+
+    
+    def cons(stack):
+        """(1 2 -- [1 .2.])"""
+        (a1, (a0, stack)) = stack
+        return ((a0, a1), stack)
+    
+    
+    def pop(stack):
+        """(1 --)"""
+        (a0, stack) = stack
+        return stack
+    
+    
+    def rest(stack):
+        """([1 .2.] -- 2)"""
+        ((a0, a1), stack) = stack
+        return (a1, stack)
+    
+    
+    def rolldown(stack):
+        """(1 2 3 -- 2 3 1)"""
+        (a2, (a1, (a0, stack))) = stack
+        return (a0, (a2, (a1, stack)))
+    
+    
+    def rollup(stack):
+        """(1 2 3 -- 3 1 2)"""
+        (a2, (a1, (a0, stack))) = stack
+        return (a1, (a0, (a2, stack)))
+    
+    
+    def rrest(stack):
+        """([0 1 .2.] -- 2)"""
+        ((a0, (a1, a2)), stack) = stack
+        return (a2, stack)
+    
+    
+    def swap(stack):
+        """(1 2 -- 2 1)"""
+        (a1, (a0, stack)) = stack
+        return (a0, (a1, stack))
+    
+    
+    def swons(stack):
+        """(0 1 -- [1 .0.])"""
+        (a1, (a0, stack)) = stack
+        return ((a1, a0), stack)
+    
+    
+    def uncons(stack):
+        """([1 .2.] -- 1 2)"""
+        ((a0, a1), stack) = stack
+        return (a1, (a0, stack))
+    
+
+
+Part IV: Types and Subtypes of Arguments
+----------------------------------------
+
+So far we have dealt with types of functions, those dealing with simple
+stack manipulation. Let’s extend our machinery to deal with types of
+arguments.
+
+“Number” Type
+~~~~~~~~~~~~~
+
+Consider the definition of ``sqr``:
+
+::
+
+   sqr == dup mul
+
+The ``dup`` function accepts one *anything* and returns two of that:
+
+::
+
+   dup (1 -- 1 1)
+
+And ``mul`` accepts two “numbers” (we’re ignoring ints vs. floats
+vs. complex, etc., for now) and returns just one:
+
+::
+
+   mul (n n -- n)
+
+So we’re composing:
+
+::
+
+   (1 -- 1 1)∘(n n -- n)
+
+The rules say we unify 1 with ``n``:
+
+::
+
+      (1 -- 1 1)∘(n n -- n)
+   ---------------------------  w/  {1: n}
+      (1 -- 1  )∘(n   -- n)
+
+This involves detecting that “Any type” arguments can accept “numbers”.
+If we were composing these functions the other way round this is still
+the case:
+
+::
+
+      (n n -- n)∘(1 -- 1 1)
+   ---------------------------  w/  {1: n}
+      (n n --  )∘(  -- n n) 
+
+The important thing here is that the mapping is going the same way in
+both cases, from the “any” integer to the number
+
+Distinguishing Numbers
+~~~~~~~~~~~~~~~~~~~~~~
+
+We should also mind that the number that ``mul`` produces is not
+(necessarily) the same as either of its inputs, which are not
+(necessarily) the same as each other:
+
+::
+
+   mul (n2 n1 -- n3)
+
+
+      (1  -- 1  1)∘(n2 n1 -- n3)
+   --------------------------------  w/  {1: n2}
+      (n2 -- n2  )∘(n2    -- n3)
+
+
+      (n2 n1 -- n3)∘(1 -- 1  1 )
+   --------------------------------  w/  {1: n3}
+      (n2 n1 --   )∘(  -- n3 n3) 
+
+Distinguishing Types
+~~~~~~~~~~~~~~~~~~~~
+
+So we need separate domains of “any” numbers and “number” numbers, and
+we need to be able to ask the order of these domains. Now the notes on
+the right side of rule three make more sense, eh?
+
+::
+
+      (a -- b t[i])∘(c u[j] -- d)   t <= u (t is subtype of u)
+   -------------------------------
+      (a -- b     )∘(c      -- d)   t[i] == t[k] == u[j]
+                                            ^
+
+      (a -- b t[i])∘(c u[j] -- d)   u <= t (u is subtype of t)
+   -------------------------------
+      (a -- b     )∘(c      -- d)   t[i] == u[k] == u[j]
+
+The indices ``i``, ``k``, and ``j`` are the number part of our labels
+and ``t`` and ``u`` are the domains.
+
+By creative use of Python’s “double underscore” methods we can define a
+Python class hierarchy of Joy types and use the ``issubclass()`` method
+to establish domain ordering, as well as other handy behaviour that will
+make it fairly easy to reuse most of the code above.
+
+.. code:: python
+
+    class AnyJoyType(object):
+    
+        prefix = 'a'
+    
+        def __init__(self, number):
+            self.number = number
+    
+        def __repr__(self):
+            return self.prefix + str(self.number)
+    
+        def __eq__(self, other):
+            return (
+                isinstance(other, self.__class__)
+                and other.prefix == self.prefix
+                and other.number == self.number
+            )
+    
+        def __ge__(self, other):
+            return issubclass(other.__class__, self.__class__)
+    
+        def __add__(self, other):
+            return self.__class__(self.number + other)
+        __radd__ = __add__
+        
+        def __hash__(self):
+            return hash(repr(self))
+    
+    
+    class NumberJoyType(AnyJoyType): prefix = 'n'
+    class FloatJoyType(NumberJoyType): prefix = 'f'
+    class IntJoyType(FloatJoyType): prefix = 'i'
+    
+    
+    class StackJoyType(AnyJoyType):
+        prefix = 's'
+    
+    
+    _R = range(10)
+    A = map(AnyJoyType, _R)
+    N = map(NumberJoyType, _R)
+    S = map(StackJoyType, _R)
+
+Mess with it a little:
+
+.. code:: python
+
+    from itertools import permutations
+
+“Any” types can be specialized to numbers and stacks, but not vice
+versa:
+
+.. code:: python
+
+    for a, b in permutations((A[0], N[0], S[0]), 2):
+        print a, '>=', b, '->', a >= b
+
+
+.. parsed-literal::
+
+    a0 >= n0 -> True
+    a0 >= s0 -> True
+    n0 >= a0 -> False
+    n0 >= s0 -> False
+    s0 >= a0 -> False
+    s0 >= n0 -> False
+
+
+Our crude `Numerical
+Tower <https://en.wikipedia.org/wiki/Numerical_tower>`__ of *numbers* >
+*floats* > *integers* works as well (but we’re not going to use it yet):
+
+.. code:: python
+
+    for a, b in permutations((A[0], N[0], FloatJoyType(0), IntJoyType(0)), 2):
+        print a, '>=', b, '->', a >= b
+
+
+.. parsed-literal::
+
+    a0 >= n0 -> True
+    a0 >= f0 -> True
+    a0 >= i0 -> True
+    n0 >= a0 -> False
+    n0 >= f0 -> True
+    n0 >= i0 -> True
+    f0 >= a0 -> False
+    f0 >= n0 -> False
+    f0 >= i0 -> True
+    i0 >= a0 -> False
+    i0 >= n0 -> False
+    i0 >= f0 -> False
+
+
+Typing ``sqr``
+~~~~~~~~~~~~~~
+
+.. code:: python
+
+    dup = (A[1],), (A[1], A[1])
+    
+    mul = (N[1], N[2]), (N[3],)
+
+.. code:: python
+
+    dup
+
+
+
+
+.. parsed-literal::
+
+    ((a1,), (a1, a1))
+
+
+
+.. code:: python
+
+    mul
+
+
+
+
+.. parsed-literal::
+
+    ((n1, n2), (n3,))
+
+
+
+Modifying the Inferencer
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Re-labeling still works fine:
+
+.. code:: python
+
+    foo = relabel(dup, mul)
+    
+    foo
+
+
+
+
+.. parsed-literal::
+
+    (((a1,), (a1, a1)), ((n1001, n1002), (n1003,)))
+
+
+
+``delabel()`` version 2
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``delabel()`` function needs an overhaul. It now has to keep track
+of how many labels of each domain it has “seen”.
+
+.. code:: python
+
+    from collections import Counter
+    
+    
+    def delabel(f, seen=None, c=None):
+        if seen is None:
+            assert c is None
+            seen, c = {}, Counter()
+    
+        try:
+            return seen[f]
+        except KeyError:
+            pass
+    
+        if not isinstance(f, tuple):
+            seen[f] = f.__class__(c[f.prefix] + 1)
+            c[f.prefix] += 1
+            return seen[f]
+    
+        return tuple(delabel(inner, seen, c) for inner in f)
+
+.. code:: python
+
+    delabel(foo)
+
+
+
+
+.. parsed-literal::
+
+    (((a1,), (a1, a1)), ((n1, n2), (n3,)))
+
+
+
+``unify()`` version 3
+^^^^^^^^^^^^^^^^^^^^^
+
+.. code:: python
+
+    def unify(u, v, s=None):
+        if s is None:
+            s = {}
+        elif s:
+            u = update(s, u)
+            v = update(s, v)
+    
+        if u == v:
+            return s
+    
+        if isinstance(u, AnyJoyType) and isinstance(v, AnyJoyType):
+            if u >= v:
+                s[u] = v
+                return s
+            if v >= u:
+                s[v] = u
+                return s
+            raise TypeError('Cannot unify %r and %r.' % (u, v))
+    
+        if isinstance(u, tuple) and isinstance(v, tuple):
+            if len(u) != len(v) != 2:
+                raise TypeError(repr((u, v)))
+            for uu, vv in zip(u, v):
+                s = unify(uu, vv, s)
+                if s == False: # (instead of a substitution dict.)
+                    break
+            return s
+     
+        if isinstance(v, tuple):
+            if not stacky(u):
+                raise TypeError('Cannot unify %r and %r.' % (u, v))
+            s[u] = v
+            return s
+    
+        if isinstance(u, tuple):
+            if not stacky(v):
+                raise TypeError('Cannot unify %r and %r.' % (v, u))
+            s[v] = u
+            return s
+    
+        return False
+    
+    
+    def stacky(thing):
+        return thing.__class__ in {AnyJoyType, StackJoyType}
+
+Rewrite the stack effect comments:
+
+.. code:: python
+
+    def defs():
+    
+        rolldown = (A[1], A[2], A[3]), (A[2], A[3], A[1])
+    
+        rollup = (A[1], A[2], A[3]), (A[3], A[1], A[2])
+    
+        pop = (A[1],), ()
+    
+        popop = (A[2], A[1],), ()
+    
+        popd = (A[2], A[1],), (A[1],)
+    
+        popdd = (A[3], A[2], A[1],), (A[2], A[1],)
+    
+        swap = (A[1], A[2]), (A[2], A[1])
+    
+        rest = ((A[1], S[1]),), (S[1],)
+    
+        rrest = C(rest, rest)
+    
+        cons = (A[1], S[1]), ((A[1], S[1]),)
+    
+        ccons = C(cons, cons)
+    
+        uncons = ((A[1], S[1]),), (A[1], S[1])
+    
+        swons = C(swap, cons)
+    
+        dup = (A[1],), (A[1], A[1])
+    
+        dupd = (A[2], A[1]), (A[2], A[2], A[1])
+    
+        mul = (N[1], N[2]), (N[3],)
+        
+        sqrt = C(dup, mul)
+    
+        first = ((A[1], S[1]),), (A[1],)
+    
+        second = C(rest, first)
+    
+        third = C(rest, second)
+    
+        tuck = (A[2], A[1]), (A[1], A[2], A[1])
+    
+        over = (A[2], A[1]), (A[2], A[1], A[2])
+        
+        succ = pred = (N[1],), (N[2],)
+        
+        divmod_ = pm = (N[2], N[1]), (N[4], N[3])
+    
+        return locals()
+
+.. code:: python
+
+    DEFS = defs()
+
+.. code:: python
+
+    for name, stack_effect_comment in sorted(DEFS.items()):
+        print name, '=', doc_from_stack_effect(*stack_effect_comment)
+
+
+.. parsed-literal::
+
+    ccons = (a1 a2 [.1.] -- [a1 a2 .1.])
+    cons = (a1 [.1.] -- [a1 .1.])
+    divmod_ = (n2 n1 -- n4 n3)
+    dup = (a1 -- a1 a1)
+    dupd = (a2 a1 -- a2 a2 a1)
+    first = ([a1 .1.] -- a1)
+    mul = (n1 n2 -- n3)
+    over = (a2 a1 -- a2 a1 a2)
+    pm = (n2 n1 -- n4 n3)
+    pop = (a1 --)
+    popd = (a2 a1 -- a1)
+    popdd = (a3 a2 a1 -- a2 a1)
+    popop = (a2 a1 --)
+    pred = (n1 -- n2)
+    rest = ([a1 .1.] -- [.1.])
+    rolldown = (a1 a2 a3 -- a2 a3 a1)
+    rollup = (a1 a2 a3 -- a3 a1 a2)
+    rrest = ([a1 a2 .1.] -- [.1.])
+    second = ([a1 a2 .1.] -- a2)
+    sqrt = (n1 -- n2)
+    succ = (n1 -- n2)
+    swap = (a1 a2 -- a2 a1)
+    swons = ([.1.] a1 -- [a1 .1.])
+    third = ([a1 a2 a3 .1.] -- a3)
+    tuck = (a2 a1 -- a1 a2 a1)
+    uncons = ([a1 .1.] -- a1 [.1.])
+
+
+.. code:: python
+
+    globals().update(DEFS)
+
+Compose ``dup`` and ``mul``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code:: python
+
+    C(dup, mul)
+
+
+
+
+.. parsed-literal::
+
+    ((n1,), (n2,))
+
+
+
+Revisit the ``F`` function, works fine.
+
+.. code:: python
+
+    F = reduce(C, (pop, swap, rolldown, rest, rest, cons, cons))
+    F
+
+
+
+
+.. parsed-literal::
+
+    (((a1, (a2, s1)), a3, a4, a5), ((a4, (a3, s1)),))
+
+
+
+.. code:: python
+
+    print doc_from_stack_effect(*F)
+
+
+.. parsed-literal::
+
+    ([a1 a2 .1.] a3 a4 a5 -- [a4 a3 .1.])
+
+
+Some otherwise inefficient functions are no longer to be feared. We can
+also get the effect of combinators in some limited cases.
+
+.. code:: python
+
+    def neato(*funcs):
+        print doc_from_stack_effect(*reduce(C, funcs))
+
+.. code:: python
+
+    # e.g. [swap] dip
+    neato(rollup, swap, rolldown)
+
+
+.. parsed-literal::
+
+    (a1 a2 a3 -- a2 a1 a3)
+
+
+.. code:: python
+
+    # e.g. [popop] dipd
+    neato(popdd, rolldown, pop)
+
+
+.. parsed-literal::
+
+    (a1 a2 a3 a4 -- a3 a4)
+
+
+.. code:: python
+
+    # Reverse the order of the top three items.
+    neato(rollup, swap)
+
+
+.. parsed-literal::
+
+    (a1 a2 a3 -- a3 a2 a1)
+
+
+``compile_()`` version 2
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Because the type labels represent themselves as valid Python identifiers
+the ``compile_()`` function doesn’t need to generate them anymore:
+
+.. code:: python
+
+    def compile_(name, f, doc=None):
+        inputs, outputs = f
+        if doc is None:
+            doc = doc_from_stack_effect(inputs, outputs)
+        i = o = Symbol('stack')
+        for term in inputs:
+            i = term, i
+        for term in outputs:
+            o = term, o
+        return '''def %s(stack):
+        """%s"""
+        %s = stack
+        return %s''' % (name, doc, i, o)
+
+.. code:: python
+
+    print compile_('F', F)
+
+
+.. parsed-literal::
+
+    def F(stack):
+        """([a1 a2 .1.] a3 a4 a5 -- [a4 a3 .1.])"""
+        (a5, (a4, (a3, ((a1, (a2, s1)), stack)))) = stack
+        return ((a4, (a3, s1)), stack)
+
+
+But it cannot magically create new functions that involve e.g. math and
+such. Note that this is *not* a ``sqr`` function implementation:
+
+.. code:: python
+
+    print compile_('sqr', C(dup, mul))
+
+
+.. parsed-literal::
+
+    def sqr(stack):
+        """(n1 -- n2)"""
+        (n1, stack) = stack
+        return (n2, stack)
+
+
+(Eventually I should come back around to this becuase it’s not tooo
+difficult to exend this code to be able to compile e.g.
+``n2 = mul(n1, n1)`` for ``mul`` with the right variable names and
+insert it in the right place. It requires a little more support from the
+library functions, in that we need to know to call ``mul()`` the Python
+function for ``mul`` the Joy function, but since *most* of the math
+functions (at least) are already wrappers it should be straightforward.)
+
+``compilable()``
+^^^^^^^^^^^^^^^^
+
+The functions that *can* be compiled are the ones that have only
+``AnyJoyType`` and ``StackJoyType`` labels in their stack effect
+comments. We can write a function to check that:
+
+.. code:: python
+
+    from itertools import imap
+    
+    
+    def compilable(f):
+        return isinstance(f, tuple) and all(imap(compilable, f)) or stacky(f)
+
+.. code:: python
+
+    for name, stack_effect_comment in sorted(defs().items()):
+        if compilable(stack_effect_comment):
+            print name, '=', doc_from_stack_effect(*stack_effect_comment)
+
+
+.. parsed-literal::
+
+    ccons = (a1 a2 [.1.] -- [a1 a2 .1.])
+    cons = (a1 [.1.] -- [a1 .1.])
+    dup = (a1 -- a1 a1)
+    dupd = (a2 a1 -- a2 a2 a1)
+    first = ([a1 .1.] -- a1)
+    over = (a2 a1 -- a2 a1 a2)
+    pop = (a1 --)
+    popd = (a2 a1 -- a1)
+    popdd = (a3 a2 a1 -- a2 a1)
+    popop = (a2 a1 --)
+    rest = ([a1 .1.] -- [.1.])
+    rolldown = (a1 a2 a3 -- a2 a3 a1)
+    rollup = (a1 a2 a3 -- a3 a1 a2)
+    rrest = ([a1 a2 .1.] -- [.1.])
+    second = ([a1 a2 .1.] -- a2)
+    swap = (a1 a2 -- a2 a1)
+    swons = ([.1.] a1 -- [a1 .1.])
+    third = ([a1 a2 a3 .1.] -- a3)
+    tuck = (a2 a1 -- a1 a2 a1)
+    uncons = ([a1 .1.] -- a1 [.1.])
+
+
+Part V: Functions that use the Stack
+------------------------------------
+
+Consider the ``stack`` function which grabs the whole stack, quotes it,
+and puts it on itself:
+
+::
+
+   stack (...     -- ... [...]        )
+   stack (... a   -- ... a [a ...]    )
+   stack (... b a -- ... b a [a b ...])
+
+We would like to represent this in Python somehow. To do this we use a
+simple, elegant trick.
+
+::
+
+   stack         S   -- (         S,           S)
+   stack     (a, S)  -- (     (a, S),      (a, S))
+   stack (a, (b, S)) -- ( (a, (b, S)), (a, (b, S)))
+
+Instead of representing the stack effect comments as a single tuple
+(with N items in it) we use the same cons-list structure to hold the
+sequence and ``unify()`` the whole comments.
+
+``stack∘uncons``
+~~~~~~~~~~~~~~~~
+
+Let’s try composing ``stack`` and ``uncons``. We want this result:
+
+::
+
+   stack∘uncons (... a -- ... a a [...])
+
+The stack effects are:
+
+::
+
+   stack = S -- (S, S)
+
+   uncons = ((a, Z), S) -- (Z, (a, S))
+
+Unifying:
+
+::
+
+     S    -- (S, S) ∘ ((a, Z), S) -- (Z, (a,   S   ))
+                                                       w/ { S: (a, Z) }
+   (a, Z) --        ∘             -- (Z, (a, (a, Z)))
+
+So:
+
+::
+
+   stack∘uncons == (a, Z) -- (Z, (a, (a, Z)))
+
+It works.
+
+``stack∘uncons∘uncons``
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Let’s try ``stack∘uncons∘uncons``:
+
+::
+
+   (a, S     ) -- (S,      (a, (a, S     ))) ∘ ((b, Z),  S`             ) -- (Z, (b,   S`   ))
+
+                                                                                   w/ { S: (b, Z) }
+                                                                                   
+   (a, (b, Z)) -- ((b, Z), (a, (a, (b, Z)))) ∘ ((b, Z),  S`             ) -- (Z, (b,   S`   ))
+
+                                                                                   w/ { S`: (a, (a, (b, Z))) }
+                                                                                   
+   (a, (b, Z)) -- ((b, Z), (a, (a, (b, Z)))) ∘ ((b, Z), (a, (a, (b, Z)))) -- (Z, (b, (a, (a, (b, Z)))))
+
+   (a, (b, Z)) -- (Z, (b, (a, (a, (b, Z)))))
+
+It works.
+
+``compose()`` version 2
+^^^^^^^^^^^^^^^^^^^^^^^
+
+This function has to be modified to use the new datastructures and it is
+no longer recursive, instead recursion happens as part of unification.
+Further, the first and second of Pöial’s rules are now handled
+automatically by the unification algorithm. (One easy way to see this is
+that now an empty stack effect comment is represented by a
+``StackJoyType`` instance which is not “falsey” and so neither of the
+first two rules’ ``if`` clauses will ever be ``True``. Later on I change
+the “truthiness” of ``StackJoyType`` to false to let e.g.
+``joy.utils.stack.concat`` work with our stack effect comment cons-list
+tuples.)
+
+.. code:: python
+
+    def compose(f, g):
+        (f_in, f_out), (g_in, g_out) = f, g
+        s = unify(g_in, f_out)
+        if s == False:  # s can also be the empty dict, which is ok.
+            raise TypeError('Cannot unify %r and %r.' % (f_out, g_in))
+        return update(s, (f_in, g_out))
+
+I don’t want to rewrite all the defs myself, so I’ll write a little
+conversion function instead. This is programmer’s laziness.
+
+.. code:: python
+
+    def sequence_to_stack(seq, stack=StackJoyType(23)):
+        for item in seq: stack = item, stack
+        return stack
+    
+    NEW_DEFS = {
+        name: (sequence_to_stack(i), sequence_to_stack(o))
+        for name, (i, o) in DEFS.iteritems()
+    }
+    NEW_DEFS['stack'] = S[0], (S[0], S[0])
+    NEW_DEFS['swaack'] = (S[1], S[0]), (S[0], S[1])
+    globals().update(NEW_DEFS)
+
+.. code:: python
+
+    C(stack, uncons)
+
+
+
+
+.. parsed-literal::
+
+    ((a1, s1), (s1, (a1, (a1, s1))))
+
+
+
+.. code:: python
+
+    reduce(C, (stack, uncons, uncons))
+
+
+
+
+.. parsed-literal::
+
+    ((a1, (a2, s1)), (s1, (a2, (a1, (a1, (a2, s1))))))
+
+
+
+The display function should be changed too.
+
+``doc_from_stack_effect()`` version 2
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Clunky junk, but it will suffice for now.
+
+.. code:: python
+
+    def doc_from_stack_effect(inputs, outputs):
+        switch = [False]  # Do we need to display the '...' for the rest of the main stack?
+        i, o = _f(inputs, switch), _f(outputs, switch)
+        if switch[0]:
+            i.append('...')
+            o.append('...')
+        return '(%s--%s)' % (
+            ' '.join(reversed([''] + i)),
+            ' '.join(reversed(o + [''])),
+        )
+    
+    
+    def _f(term, switch):
+        a = []
+        while term and isinstance(term, tuple):
+            item, term = term
+            a.append(item)
+        assert isinstance(term, StackJoyType), repr(term)
+        a = [_to_str(i, term, switch) for i in a]
+        return a
+    
+    
+    def _to_str(term, stack, switch):
+        if not isinstance(term, tuple):
+            if term == stack:
+                switch[0] = True
+                return '[...]'
+            return (
+                '[.%i.]' % term.number
+                if isinstance(term, StackJoyType)
+                else str(term)
+            )
+    
+        a = []
+        while term and isinstance(term, tuple):
+            item, term = term
+            a.append(_to_str(item, stack, switch))
+        assert isinstance(term, StackJoyType), repr(term)
+        if term == stack:
+            switch[0] = True
+            end = '...'
+        else:
+            end = '.%i.' % term.number
+        a.append(end)
+        return '[%s]' % ' '.join(a)
+
+.. code:: python
+
+    for name, stack_effect_comment in sorted(NEW_DEFS.items()):
+        print name, '=', doc_from_stack_effect(*stack_effect_comment)
+
+
+.. parsed-literal::
+
+    ccons = (a1 a2 [.1.] -- [a1 a2 .1.])
+    cons = (a1 [.1.] -- [a1 .1.])
+    divmod_ = (n2 n1 -- n4 n3)
+    dup = (a1 -- a1 a1)
+    dupd = (a2 a1 -- a2 a2 a1)
+    first = ([a1 .1.] -- a1)
+    mul = (n1 n2 -- n3)
+    over = (a2 a1 -- a2 a1 a2)
+    pm = (n2 n1 -- n4 n3)
+    pop = (a1 --)
+    popd = (a2 a1 -- a1)
+    popdd = (a3 a2 a1 -- a2 a1)
+    popop = (a2 a1 --)
+    pred = (n1 -- n2)
+    rest = ([a1 .1.] -- [.1.])
+    rolldown = (a1 a2 a3 -- a2 a3 a1)
+    rollup = (a1 a2 a3 -- a3 a1 a2)
+    rrest = ([a1 a2 .1.] -- [.1.])
+    second = ([a1 a2 .1.] -- a2)
+    sqrt = (n1 -- n2)
+    stack = (... -- ... [...])
+    succ = (n1 -- n2)
+    swaack = ([.1.] -- [.0.])
+    swap = (a1 a2 -- a2 a1)
+    swons = ([.1.] a1 -- [a1 .1.])
+    third = ([a1 a2 a3 .1.] -- a3)
+    tuck = (a2 a1 -- a1 a2 a1)
+    uncons = ([a1 .1.] -- a1 [.1.])
+
+
+.. code:: python
+
+    print ; print doc_from_stack_effect(*stack)
+    print ; print doc_from_stack_effect(*C(stack, uncons))
+    print ; print doc_from_stack_effect(*reduce(C, (stack, uncons, uncons)))
+    print ; print doc_from_stack_effect(*reduce(C, (stack, uncons, cons)))
+
+
+.. parsed-literal::
+
+    
+    (... -- ... [...])
+    
+    (... a1 -- ... a1 a1 [...])
+    
+    (... a2 a1 -- ... a2 a1 a1 a2 [...])
+    
+    (... a1 -- ... a1 [a1 ...])
+
+
+.. code:: python
+
+    print doc_from_stack_effect(*C(ccons, stack))
+
+
+.. parsed-literal::
+
+    (... a2 a1 [.1.] -- ... [a2 a1 .1.] [[a2 a1 .1.] ...])
+
+
+.. code:: python
+
+    Q = C(ccons, stack)
+    
+    Q
+
+
+
+
+.. parsed-literal::
+
+    ((s1, (a1, (a2, s2))), (((a2, (a1, s1)), s2), ((a2, (a1, s1)), s2)))
+
+
+
+``compile_()`` version 3
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+This makes the ``compile_()`` function pretty simple as the stack effect
+comments are now already in the form needed for the Python code:
+
+.. code:: python
+
+    def compile_(name, f, doc=None):
+        i, o = f
+        if doc is None:
+            doc = doc_from_stack_effect(i, o)
+        return '''def %s(stack):
+        """%s"""
+        %s = stack
+        return %s''' % (name, doc, i, o)
+
+.. code:: python
+
+    print compile_('Q', Q)
+
+
+.. parsed-literal::
+
+    def Q(stack):
+        """(... a2 a1 [.1.] -- ... [a2 a1 .1.] [[a2 a1 .1.] ...])"""
+        (s1, (a1, (a2, s2))) = stack
+        return (((a2, (a1, s1)), s2), ((a2, (a1, s1)), s2))
+
+
+
+
+
+
+
+.. code:: python
+
+    unstack = (S[1], S[0]), S[1]
+    enstacken = S[0], (S[0], S[1])
+
+.. code:: python
+
+    print doc_from_stack_effect(*unstack)
+
+
+.. parsed-literal::
+
+    ([.1.] --)
+
+
+.. code:: python
+
+    print doc_from_stack_effect(*enstacken)
+
+
+.. parsed-literal::
+
+    (-- [.0.])
+
+
+.. code:: python
+
+    print doc_from_stack_effect(*C(cons, unstack))
+
+
+.. parsed-literal::
+
+    (a1 [.1.] -- a1)
+
+
+.. code:: python
+
+    print doc_from_stack_effect(*C(cons, enstacken))
+
+
+.. parsed-literal::
+
+    (a1 [.1.] -- [[a1 .1.] .2.])
+
+
+.. code:: python
+
+    C(cons, unstack)
+
+
+
+
+.. parsed-literal::
+
+    ((s1, (a1, s2)), (a1, s1))
+
+
+
+
+Part VI: Multiple Stack Effects
+-------------------------------
+
+…
+
+.. code:: python
+
+    class IntJoyType(NumberJoyType): prefix = 'i'
+    
+    
+    F = map(FloatJoyType, _R)
+    I = map(IntJoyType, _R)
+
+.. code:: python
+
+    muls = [
+         ((I[2], (I[1], S[0])), (I[3], S[0])),
+         ((F[2], (I[1], S[0])), (F[3], S[0])),
+         ((I[2], (F[1], S[0])), (F[3], S[0])),
+         ((F[2], (F[1], S[0])), (F[3], S[0])),
+    ]
+
+.. code:: python
+
+    for f in muls:
+        print doc_from_stack_effect(*f)
+
+
+.. parsed-literal::
+
+    (i1 i2 -- i3)
+    (i1 f2 -- f3)
+    (f1 i2 -- f3)
+    (f1 f2 -- f3)
+
+
+.. code:: python
+
+    for f in muls:
+        try:
+            e = C(dup, f)
+        except TypeError:
+            continue
+        print doc_from_stack_effect(*dup), doc_from_stack_effect(*f), doc_from_stack_effect(*e)
+
+
+.. parsed-literal::
+
+    (a1 -- a1 a1) (i1 i2 -- i3) (i1 -- i2)
+    (a1 -- a1 a1) (f1 f2 -- f3) (f1 -- f2)
+
+
+.. code:: python
+
+    from itertools import product
+    
+    
+    def meta_compose(F, G):
+        for f, g in product(F, G):
+            try:
+                yield C(f, g)
+            except TypeError:
+                pass
+    
+    
+    def MC(F, G):
+        return sorted(set(meta_compose(F, G)))
+
+.. code:: python
+
+    for f in MC([dup], [mul]):
+        print doc_from_stack_effect(*f)
+
+
+.. parsed-literal::
+
+    (n1 -- n2)
+
+
+.. code:: python
+
+    for f in MC([dup], muls):
+        print doc_from_stack_effect(*f)
+
+
+.. parsed-literal::
+
+    (f1 -- f2)
+    (i1 -- i2)
+
+
+Representing an Unbounded Sequence of Types
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We can borrow a trick from `Brzozowski’s Derivatives of Regular
+Expressions <https://en.wikipedia.org/wiki/Brzozowski_derivative>`__ to
+invent a new type of type variable, a “sequence type” (I think this is
+what they mean in the literature by that term…) or “`Kleene
+Star <https://en.wikipedia.org/wiki/Kleene_star>`__” type. I’m going to
+represent it as a type letter and the asterix, so a sequence of zero or
+more ``AnyJoyType`` variables would be:
+
+::
+
+   A*
+
+The ``A*`` works by splitting the universe into two alternate histories:
+
+::
+
+   A* -> 0 | A A*
+
+The Kleene star variable disappears in one universe, and in the other it
+turns into an ``AnyJoyType`` variable followed by itself again. We have
+to return all universes (represented by their substitution dicts, the
+“unifiers”) that don’t lead to type conflicts.
+
+Consider unifying two stacks (the lowercase letters are any type
+variables of the kinds we have defined so far):
+
+::
+
+   [a A* b .0.] U [c d .1.]
+                             w/ {c: a}
+   [  A* b .0.] U [  d .1.]
+
+Now we have to split universes to unify ``A*``. In the first universe it
+disappears:
+
+::
+
+   [b .0.] U [d .1.]
+                      w/ {d: b, .1.: .0.} 
+        [] U []
+
+While in the second it spawns an ``A``, which we will label ``e``:
+
+::
+
+   [e A* b .0.] U [d .1.]
+                           w/ {d: e}
+   [  A* b .0.] U [  .1.]
+                           w/ {.1.: A* b .0.}
+   [  A* b .0.] U [  A* b .0.]
+
+Giving us two unifiers:
+
+::
+
+   {c: a,  d: b,  .1.:      .0.}
+   {c: a,  d: e,  .1.: A* b .0.}
+
+.. code:: python
+
+    class KleeneStar(object):
+    
+        kind = AnyJoyType
+    
+        def __init__(self, number):
+            self.number = number
+            self.count = 0
+            self.prefix = repr(self)
+    
+        def __repr__(self):
+            return '%s%i*' % (self.kind.prefix, self.number)
+    
+        def another(self):
+            self.count += 1
+            return self.kind(10000 * self.number + self.count)
+    
+        def __eq__(self, other):
+            return (
+                isinstance(other, self.__class__)
+                and other.number == self.number
+            )
+    
+        def __ge__(self, other):
+            return self.kind >= other.kind
+    
+        def __add__(self, other):
+            return self.__class__(self.number + other)
+        __radd__ = __add__
+        
+        def __hash__(self):
+            return hash(repr(self))
+    
+    class AnyStarJoyType(KleeneStar): kind = AnyJoyType
+    class NumberStarJoyType(KleeneStar): kind = NumberJoyType
+    #class FloatStarJoyType(KleeneStar): kind = FloatJoyType
+    #class IntStarJoyType(KleeneStar): kind = IntJoyType
+    class StackStarJoyType(KleeneStar): kind = StackJoyType
+    
+    
+    As = map(AnyStarJoyType, _R)
+    Ns = map(NumberStarJoyType, _R)
+    Ss = map(StackStarJoyType, _R)
+
+``unify()`` version 4
+^^^^^^^^^^^^^^^^^^^^^
+
+Can now return multiple results…
+
+.. code:: python
+
+    def unify(u, v, s=None):
+        if s is None:
+            s = {}
+        elif s:
+            u = update(s, u)
+            v = update(s, v)
+    
+        if u == v:
+            return s,
+    
+        if isinstance(u, AnyJoyType) and isinstance(v, AnyJoyType):
+            if u >= v:
+                s[u] = v
+                return s,
+            if v >= u:
+                s[v] = u
+                return s,
+            raise TypeError('Cannot unify %r and %r.' % (u, v))
+    
+        if isinstance(u, tuple) and isinstance(v, tuple):
+            if len(u) != len(v) != 2:
+                raise TypeError(repr((u, v)))
+                
+            a, b = v
+            if isinstance(a, KleeneStar):
+                # Two universes, in one the Kleene star disappears and unification
+                # continues without it...
+                s0 = unify(u, b)
+                
+                # In the other it spawns a new variable.
+                s1 = unify(u, (a.another(), v))
+                
+                t = s0 + s1
+                for sn in t:
+                    sn.update(s)
+                return t
+    
+            a, b = u
+            if isinstance(a, KleeneStar):
+                s0 = unify(v, b)
+                s1 = unify(v, (a.another(), u))
+                t = s0 + s1
+                for sn in t:
+                    sn.update(s)
+                return t
+    
+            ses = unify(u[0], v[0], s)
+            results = ()
+            for sn in ses:
+                results += unify(u[1], v[1], sn)
+            return results
+     
+        if isinstance(v, tuple):
+            if not stacky(u):
+                raise TypeError('Cannot unify %r and %r.' % (u, v))
+            s[u] = v
+            return s,
+    
+        if isinstance(u, tuple):
+            if not stacky(v):
+                raise TypeError('Cannot unify %r and %r.' % (v, u))
+            s[v] = u
+            return s,
+    
+        return ()
+    
+    
+    def stacky(thing):
+        return thing.__class__ in {AnyJoyType, StackJoyType}
+
+.. code:: python
+
+    a = (As[1], S[1])
+    a
+
+
+
+
+.. parsed-literal::
+
+    (a1*, s1)
+
+
+
+.. code:: python
+
+    b = (A[1], S[2])
+    b
+
+
+
+
+.. parsed-literal::
+
+    (a1, s2)
+
+
+
+.. code:: python
+
+    for result in unify(b, a):
+        print result, '->', update(result, a), update(result, b)
+
+
+.. parsed-literal::
+
+    {s1: (a1, s2)} -> (a1*, (a1, s2)) (a1, s2)
+    {a1: a10001, s2: (a1*, s1)} -> (a1*, s1) (a10001, (a1*, s1))
+
+
+.. code:: python
+
+    for result in unify(a, b):
+        print result, '->', update(result, a), update(result, b)
+
+
+.. parsed-literal::
+
+    {s1: (a1, s2)} -> (a1*, (a1, s2)) (a1, s2)
+    {a1: a10002, s2: (a1*, s1)} -> (a1*, s1) (a10002, (a1*, s1))
+
+
+::
+
+   (a1*, s1)       [a1*]       (a1, s2)        [a1]
+
+   (a1*, (a1, s2)) [a1* a1]    (a1, s2)        [a1]
+
+   (a1*, s1)       [a1*]       (a2, (a1*, s1)) [a2 a1*]
+
+.. code:: python
+
+    sum_ = ((Ns[1], S[1]), S[0]), (N[0], S[0])
+    
+    print doc_from_stack_effect(*sum_)
+
+
+.. parsed-literal::
+
+    ([n1* .1.] -- n0)
+
+
+.. code:: python
+
+    f = (N[1], (N[2], (N[3], S[1]))), S[0]
+    
+    print doc_from_stack_effect(S[0], f)
+
+
+.. parsed-literal::
+
+    (-- [n1 n2 n3 .1.])
+
+
+.. code:: python
+
+    for result in unify(sum_[0], f):
+        print result, '->', update(result, sum_[1])
+
+
+.. parsed-literal::
+
+    {s1: (n1, (n2, (n3, s1)))} -> (n0, s0)
+    {n1: n10001, s1: (n2, (n3, s1))} -> (n0, s0)
+    {n1: n10001, s1: (n3, s1), n2: n10002} -> (n0, s0)
+    {n1: n10001, s1: (n1*, s1), n3: n10003, n2: n10002} -> (n0, s0)
+
+
+``compose()`` version 3
+^^^^^^^^^^^^^^^^^^^^^^^
+
+This function has to be modified to yield multiple results.
+
+.. code:: python
+
+    def compose(f, g):
+        (f_in, f_out), (g_in, g_out) = f, g
+        s = unify(g_in, f_out)
+        if not s:
+            raise TypeError('Cannot unify %r and %r.' % (f_out, g_in))
+        for result in s:
+            yield update(result, (f_in, g_out))
+
+
+
+.. code:: python
+
+    def meta_compose(F, G):
+        for f, g in product(F, G):
+            try:
+                for result in C(f, g):
+                    yield result
+            except TypeError:
+                pass
+    
+    
+    def C(f, g):
+        f, g = relabel(f, g)
+        for fg in compose(f, g):
+            yield delabel(fg)
+
+.. code:: python
+
+    for f in MC([dup], muls):
+        print doc_from_stack_effect(*f)
+
+
+.. parsed-literal::
+
+    (f1 -- f2)
+    (i1 -- i2)
+
+
+.. code:: python
+
+    
+    
+    for f in MC([dup], [sum_]):
+        print doc_from_stack_effect(*f)
+
+
+.. parsed-literal::
+
+    ([n1* .1.] -- [n1* .1.] n1)
+
+
+.. code:: python
+
+    
+    
+    for f in MC([cons], [sum_]):
+        print doc_from_stack_effect(*f)
+
+
+.. parsed-literal::
+
+    (a1 [.1.] -- n1)
+    (n1 [n1* .1.] -- n2)
+
+
+.. code:: python
+
+    sum_ = (((N[1], (Ns[1], S[1])), S[0]), (N[0], S[0]))
+    print doc_from_stack_effect(*cons),
+    print doc_from_stack_effect(*sum_),
+    
+    for f in MC([cons], [sum_]):
+        print doc_from_stack_effect(*f)
+
+
+.. parsed-literal::
+
+    (a1 [.1.] -- [a1 .1.]) ([n1 n1* .1.] -- n0) (n1 [n1* .1.] -- n2)
+
+
+.. code:: python
+
+    a = (A[4], (As[1], (A[3], S[1])))
+    a
+
+
+
+
+.. parsed-literal::
+
+    (a4, (a1*, (a3, s1)))
+
+
+
+.. code:: python
+
+    b = (A[1], (A[2], S[2]))
+    b
+
+
+
+
+.. parsed-literal::
+
+    (a1, (a2, s2))
+
+
+
+.. code:: python
+
+    for result in unify(b, a):
+        print result
+
+
+.. parsed-literal::
+
+    {a1: a4, s2: s1, a2: a3}
+    {a1: a4, s2: (a1*, (a3, s1)), a2: a10003}
+
+
+.. code:: python
+
+    for result in unify(a, b):
+        print result
+
+
+.. parsed-literal::
+
+    {s2: s1, a2: a3, a4: a1}
+    {s2: (a1*, (a3, s1)), a2: a10004, a4: a1}
+
+
+Part VII: Typing Combinators
+----------------------------
+
+In order to compute the stack effect of combinators you kinda have to
+have the quoted programs they expect available. In the most general
+case, the ``i`` combinator, you can’t say anything about its stack
+effect other than it expects one quote:
+
+::
+
+   i (... [.1.] -- ... .1.)
+
+Or
+
+::
+
+   i (... [A* .1.] -- ... A*)
+
+Consider the type of:
+
+::
+
+   [cons] dip
+
+Obviously it would be:
+
+::
+
+   (a1 [..1] a2 -- [a1 ..1] a2)
+
+``dip`` itself could have:
+
+::
+
+   (a1 [..1] -- ... then what?
+
+Without any information about the contents of the quote we can’t say
+much about the result.
+
+Hybrid Inferencer/Interpreter
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+I think there’s a way forward. If we convert our list (of terms we are
+composing) into a stack structure we can use it as a *Joy expression*,
+then we can treat the *output half* of a function’s stack effect comment
+as a Joy interpreter stack, and just execute combinators directly. We
+can hybridize the compostition function with an interpreter to evaluate
+combinators, compose non-combinator functions, and put type variables on
+the stack. For combinators like ``branch`` that can have more than one
+stack effect we have to “split universes” again and return both.
+
+Joy Types for Functions
+^^^^^^^^^^^^^^^^^^^^^^^
+
+We need a type variable for Joy functions that can go in our expressions
+and be used by the hybrid inferencer/interpreter. They have to store a
+name and a list of stack effects.
+
+.. code:: python
+
+    class FunctionJoyType(AnyJoyType):
+    
+        def __init__(self, name, sec, number):
+            self.name = name
+            self.stack_effects = sec
+            self.number = number
+    
+        def __add__(self, other):
+            return self
+        __radd__ = __add__
+    
+        def __repr__(self):
+            return self.name
+
+Specialized for Simple Functions and Combinators
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+For non-combinator functions the stack effects list contains stack
+effect comments (represented by pairs of cons-lists as described above.)
+
+.. code:: python
+
+    class SymbolJoyType(FunctionJoyType):
+        prefix = 'F'
+
+For combinators the list contains Python functions.
+
+.. code:: python
+
+    class CombinatorJoyType(FunctionJoyType):
+    
+        prefix = 'C'
+    
+        def __init__(self, name, sec, number, expect=None):
+            super(CombinatorJoyType, self).__init__(name, sec, number)
+            self.expect = expect
+    
+        def enter_guard(self, f):
+            if self.expect is None:
+                return f
+            g = self.expect, self.expect
+            new_f = list(compose(f, g, ()))
+            assert len(new_f) == 1, repr(new_f)
+            return new_f[0][1]
+
+For simple combinators that have only one effect (like ``dip``) you only
+need one function and it can be the combinator itself.
+
+.. code:: python
+
+    import joy.library
+    
+    dip = CombinatorJoyType('dip', [joy.library.dip], 23)
+
+For combinators that can have more than one effect (like ``branch``) you
+have to write functions that each implement the action of one of the
+effects.
+
+.. code:: python
+
+    def branch_true(stack, expression, dictionary):
+        (then, (else_, (flag, stack))) = stack
+        return stack, concat(then, expression), dictionary
+    
+    def branch_false(stack, expression, dictionary):
+        (then, (else_, (flag, stack))) = stack
+        return stack, concat(else_, expression), dictionary
+    
+    branch = CombinatorJoyType('branch', [branch_true, branch_false], 100)
+
+You can also provide an optional stack effect, input-side only, that
+will then be used as an identity function (that accepts and returns
+stacks that match the “guard” stack effect) which will be used to guard
+against type mismatches going into the evaluation of the combinator.
+
+``infer()``
+^^^^^^^^^^^
+
+With those in place, we can define a function that accepts a sequence of
+Joy type variables, including ones representing functions (not just
+values), and attempts to grind out all the possible stack effects of
+that expression.
+
+One tricky thing is that type variables *in the expression* have to be
+updated along with the stack effects after doing unification or we risk
+losing useful information. This was a straightforward, if awkward,
+modification to the call structure of ``meta_compose()`` et. al.
+
+.. code:: python
+
+    ID = S[0], S[0]  # Identity function.
+    
+    
+    def infer(*expression):
+        return sorted(set(_infer(list_to_stack(expression))))
+    
+    
+    def _infer(e, F=ID):
+        _log_it(e, F)
+        if not e:
+            return [F]
+    
+        n, e = e
+    
+        if isinstance(n, SymbolJoyType):
+            eFG = meta_compose([F], n.stack_effects, e)
+            res = flatten(_infer(e, Fn) for e, Fn in eFG)
+    
+        elif isinstance(n, CombinatorJoyType):
+            fi, fo = n.enter_guard(F)
+            res = flatten(_interpret(f, fi, fo, e) for f in n.stack_effects)
+    
+        elif isinstance(n, Symbol):
+            assert n not in FUNCTIONS, repr(n)
+            func = joy.library._dictionary[n]
+            res = _interpret(func, F[0], F[1], e)
+    
+        else:
+            fi, fo = F
+            res = _infer(e, (fi, (n, fo)))
+    
+        return res
+    
+    
+    def _interpret(f, fi, fo, e):
+        new_fo, ee, _ = f(fo, e, {})
+        ee = update(FUNCTIONS, ee)  # Fix Symbols.
+        new_F = fi, new_fo
+        return _infer(ee, new_F)
+    
+    
+    def _log_it(e, F):
+        _log.info(
+            u'%3i %s ∘ %s',
+            len(inspect_stack()),
+            doc_from_stack_effect(*F),
+            expression_to_string(e),
+            )
+
+Work in Progress
+^^^^^^^^^^^^^^^^
+
+And that brings us to current Work-In-Progress. The mixed-mode
+inferencer/interpreter ``infer()`` function seems to work well. There
+are details I should document, and the rest of the code in the ``types``
+module (FIXME link to its docs here!) should be explained… There is
+cruft to convert the definitions in ``DEFS`` to the new
+``SymbolJoyType`` objects, and some combinators. Here is an example of
+output from the current code :
+
+.. code:: python
+
+    1/0  # (Don't try to run this cell!  It's not going to work.  This is "read only" code heh..)
+    
+    logging.basicConfig(format='%(message)s', stream=sys.stdout, level=logging.INFO)
+    
+    globals().update(FUNCTIONS)
+    
+    h = infer((pred, s2), (mul, s3), (div, s4), (nullary, (bool, s5)), dipd, branch)
+    
+    print '-' * 40
+    
+    for fi, fo in h:
+        print doc_from_stack_effect(fi, fo)
+
+
+::
+
+
+    ---------------------------------------------------------------------------
+
+    ZeroDivisionError                         Traceback (most recent call last)
+
+    <ipython-input-1-9a9d60354c35> in <module>()
+    ----> 1 1/0  # (Don't try to run this cell!  It's not going to work.  This is "read only" code heh..)
+          2 
+          3 logging.basicConfig(format='%(message)s', stream=sys.stdout, level=logging.INFO)
+          4 
+          5 globals().update(FUNCTIONS)
+
+
+    ZeroDivisionError: integer division or modulo by zero
+
+
+The numbers at the start of the lines are the current depth of the
+Python call stack. They’re followed by the current computed stack effect
+(initialized to ``ID``) then the pending expression (the inference of
+the stack effect of which is the whole object of the current example.)
+
+In this example we are implementing (and inferring) ``ifte`` as
+``[nullary bool] dipd branch`` which shows off a lot of the current
+implementation in action.
+
+::
+
+     7 (--) ∘ [pred] [mul] [div] [nullary bool] dipd branch
+     8 (-- [pred ...2]) ∘ [mul] [div] [nullary bool] dipd branch
+     9 (-- [pred ...2] [mul ...3]) ∘ [div] [nullary bool] dipd branch
+    10 (-- [pred ...2] [mul ...3] [div ...4]) ∘ [nullary bool] dipd branch
+    11 (-- [pred ...2] [mul ...3] [div ...4] [nullary bool ...5]) ∘ dipd branch
+    15 (-- [pred ...5]) ∘ nullary bool [mul] [div] branch
+    19 (-- [pred ...2]) ∘ [stack] dinfrirst bool [mul] [div] branch
+    20 (-- [pred ...2] [stack ]) ∘ dinfrirst bool [mul] [div] branch
+    22 (-- [pred ...2] [stack ]) ∘ dip infra first bool [mul] [div] branch
+    26 (--) ∘ stack [pred] infra first bool [mul] [div] branch
+    29 (... -- ... [...]) ∘ [pred] infra first bool [mul] [div] branch
+    30 (... -- ... [...] [pred ...1]) ∘ infra first bool [mul] [div] branch
+    34 (--) ∘ pred s1 swaack first bool [mul] [div] branch
+    37 (n1 -- n2) ∘ [n1] swaack first bool [mul] [div] branch
+    38 (... n1 -- ... n2 [n1 ...]) ∘ swaack first bool [mul] [div] branch
+    41 (... n1 -- ... n1 [n2 ...]) ∘ first bool [mul] [div] branch
+    44 (n1 -- n1 n2) ∘ bool [mul] [div] branch
+    47 (n1 -- n1 b1) ∘ [mul] [div] branch
+    48 (n1 -- n1 b1 [mul ...1]) ∘ [div] branch
+    49 (n1 -- n1 b1 [mul ...1] [div ...2]) ∘ branch
+    53 (n1 -- n1) ∘ div
+    56 (f2 f1 -- f3) ∘ 
+    56 (i1 f1 -- f2) ∘ 
+    56 (f1 i1 -- f2) ∘ 
+    56 (i2 i1 -- f1) ∘ 
+    53 (n1 -- n1) ∘ mul
+    56 (f2 f1 -- f3) ∘ 
+    56 (i1 f1 -- f2) ∘ 
+    56 (f1 i1 -- f2) ∘ 
+    56 (i2 i1 -- i3) ∘ 
+   ----------------------------------------
+   (f2 f1 -- f3)
+   (i1 f1 -- f2)
+   (f1 i1 -- f2)
+   (i2 i1 -- f1)
+   (i2 i1 -- i3)
+
+Conclusion
+----------
+
+We built a simple type inferencer, and a kind of crude “compiler” for a
+subset of Joy functions. Then we built a more powerful inferencer that
+actually does some evaluation and explores branching code paths
+
+Work remains to be done:
+
+-  the rest of the library has to be covered
+-  figure out how to deal with ``loop`` and ``genrec``, etc..
+-  extend the types to check values (see the appendix)
+-  other kinds of “higher order” type variables, OR, AND, etc..
+-  maybe rewrite in Prolog for great good?
+-  definitions
+
+   -  don’t permit composition of functions that don’t compose
+   -  auto-compile compilable functions
+
+-  Compiling more than just the Yin functions.
+-  getting better visibility (than Python debugger.)
+-  DOOOOCS!!!! Lots of docs!
+
+   -  docstrings all around
+   -  improve this notebook (it kinda falls apart at the end
+      narratively. I went off and just started writing code to see if it
+      would work. It does, but now I have to come back and describe here
+      what I did.
+
+Appendix: Joy in the Logical Paradigm
+-------------------------------------
+
+For *type checking* to work the type label classes have to be modified
+to let ``T >= t`` succeed, where e.g. ``T`` is ``IntJoyType`` and ``t``
+is ``int``. If you do that you can take advantage of the *logical
+relational* nature of the stack effect comments to “compute in reverse”
+as it were. There’s a working demo of this at the end of the ``types``
+module. But if you’re interested in all that you should just use Prolog!
+
+Anyhow, type *checking* is a few easy steps away.
+
+.. code:: python
+
+    def _ge(self, other):
+        return (issubclass(other.__class__, self.__class__)
+                or hasattr(self, 'accept')
+                and isinstance(other, self.accept))
+    
+    AnyJoyType.__ge__ = _ge
+    AnyJoyType.accept = tuple, int, float, long, str, unicode, bool, Symbol
+    StackJoyType.accept = tuple
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/Zipper.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/Zipper.rst.txt
new file mode 100644 (file)
index 0000000..c44343a
--- /dev/null
@@ -0,0 +1,352 @@
+Traversing Datastructures with Zippers
+======================================
+
+This notebook is about using the “zipper” with joy datastructures. See
+the `Zipper wikipedia
+entry <https://en.wikipedia.org/wiki/Zipper_%28data_structure%29>`__ or
+the original paper: `“FUNCTIONAL PEARL The Zipper” by Gérard
+Huet <https://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/huet-zipper.pdf>`__
+
+Given a datastructure on the stack we can navigate through it, modify
+it, and rebuild it using the “zipper” technique.
+
+.. code:: python
+
+    from notebook_preamble import J, V, define
+
+Trees
+-----
+
+In Joypy there aren’t any complex datastructures, just ints, floats,
+strings, Symbols (strings that are names of functions) and sequences
+(aka lists, aka quoted literals, aka aggregates, etc…), but we can build
+`trees <https://en.wikipedia.org/wiki/Tree_%28data_structure%29>`__ out
+of sequences.
+
+.. code:: python
+
+    J('[1 [2 [3 4 25 6] 7] 8]')
+
+
+.. parsed-literal::
+
+    [1 [2 [3 4 25 6] 7] 8]
+
+
+Zipper in Joy
+-------------
+
+Zippers work by keeping track of the current item, the already-seen
+items, and the yet-to-be seen items as you traverse a datastructure (the
+datastructure used to keep track of these items is the zipper.)
+
+In Joy we can do this with the following words:
+
+::
+
+   z-down == [] swap uncons swap
+   z-up == swons swap shunt
+   z-right == [swons] cons dip uncons swap
+   z-left == swons [uncons swap] dip swap
+
+Let’s use them to change 25 into 625. The first time a word is used I
+show the trace so you can see how it works. If we were going to use
+these a lot it would make sense to write Python versions for efficiency,
+but see below.
+
+.. code:: python
+
+    define('z-down == [] swap uncons swap')
+    define('z-up == swons swap shunt')
+    define('z-right == [swons] cons dip uncons swap')
+    define('z-left == swons [uncons swap] dip swap')
+
+.. code:: python
+
+    V('[1 [2 [3 4 25 6] 7] 8] z-down')
+
+
+.. parsed-literal::
+
+                              . [1 [2 [3 4 25 6] 7] 8] z-down
+       [1 [2 [3 4 25 6] 7] 8] . z-down
+       [1 [2 [3 4 25 6] 7] 8] . [] swap uncons swap
+    [1 [2 [3 4 25 6] 7] 8] [] . swap uncons swap
+    [] [1 [2 [3 4 25 6] 7] 8] . uncons swap
+    [] 1 [[2 [3 4 25 6] 7] 8] . swap
+    [] [[2 [3 4 25 6] 7] 8] 1 . 
+
+
+.. code:: python
+
+    V('[] [[2 [3 4 25 6] 7] 8] 1 z-right')
+
+
+.. parsed-literal::
+
+                                      . [] [[2 [3 4 25 6] 7] 8] 1 z-right
+                                   [] . [[2 [3 4 25 6] 7] 8] 1 z-right
+              [] [[2 [3 4 25 6] 7] 8] . 1 z-right
+            [] [[2 [3 4 25 6] 7] 8] 1 . z-right
+            [] [[2 [3 4 25 6] 7] 8] 1 . [swons] cons dip uncons swap
+    [] [[2 [3 4 25 6] 7] 8] 1 [swons] . cons dip uncons swap
+    [] [[2 [3 4 25 6] 7] 8] [1 swons] . dip uncons swap
+                                   [] . 1 swons [[2 [3 4 25 6] 7] 8] uncons swap
+                                 [] 1 . swons [[2 [3 4 25 6] 7] 8] uncons swap
+                                 [] 1 . swap cons [[2 [3 4 25 6] 7] 8] uncons swap
+                                 1 [] . cons [[2 [3 4 25 6] 7] 8] uncons swap
+                                  [1] . [[2 [3 4 25 6] 7] 8] uncons swap
+             [1] [[2 [3 4 25 6] 7] 8] . uncons swap
+             [1] [2 [3 4 25 6] 7] [8] . swap
+             [1] [8] [2 [3 4 25 6] 7] . 
+
+
+.. code:: python
+
+    J('[1] [8] [2 [3 4 25 6] 7] z-down')
+
+
+.. parsed-literal::
+
+    [1] [8] [] [[3 4 25 6] 7] 2
+
+
+.. code:: python
+
+    J('[1] [8] [] [[3 4 25 6] 7] 2 z-right')
+
+
+.. parsed-literal::
+
+    [1] [8] [2] [7] [3 4 25 6]
+
+
+.. code:: python
+
+    J('[1] [8] [2] [7] [3 4 25 6] z-down')
+
+
+.. parsed-literal::
+
+    [1] [8] [2] [7] [] [4 25 6] 3
+
+
+.. code:: python
+
+    J('[1] [8] [2] [7] [] [4 25 6] 3 z-right')
+
+
+.. parsed-literal::
+
+    [1] [8] [2] [7] [3] [25 6] 4
+
+
+.. code:: python
+
+    J('[1] [8] [2] [7] [3] [25 6] 4 z-right')
+
+
+.. parsed-literal::
+
+    [1] [8] [2] [7] [4 3] [6] 25
+
+
+.. code:: python
+
+    J('[1] [8] [2] [7] [4 3] [6] 25 sqr')
+
+
+.. parsed-literal::
+
+    [1] [8] [2] [7] [4 3] [6] 625
+
+
+.. code:: python
+
+    V('[1] [8] [2] [7] [4 3] [6] 625 z-up')
+
+
+.. parsed-literal::
+
+                                  . [1] [8] [2] [7] [4 3] [6] 625 z-up
+                              [1] . [8] [2] [7] [4 3] [6] 625 z-up
+                          [1] [8] . [2] [7] [4 3] [6] 625 z-up
+                      [1] [8] [2] . [7] [4 3] [6] 625 z-up
+                  [1] [8] [2] [7] . [4 3] [6] 625 z-up
+            [1] [8] [2] [7] [4 3] . [6] 625 z-up
+        [1] [8] [2] [7] [4 3] [6] . 625 z-up
+    [1] [8] [2] [7] [4 3] [6] 625 . z-up
+    [1] [8] [2] [7] [4 3] [6] 625 . swons swap shunt
+    [1] [8] [2] [7] [4 3] [6] 625 . swap cons swap shunt
+    [1] [8] [2] [7] [4 3] 625 [6] . cons swap shunt
+    [1] [8] [2] [7] [4 3] [625 6] . swap shunt
+    [1] [8] [2] [7] [625 6] [4 3] . shunt
+      [1] [8] [2] [7] [3 4 625 6] . 
+
+
+.. code:: python
+
+    J('[1] [8] [2] [7] [3 4 625 6] z-up')
+
+
+.. parsed-literal::
+
+    [1] [8] [2 [3 4 625 6] 7]
+
+
+.. code:: python
+
+    J('[1] [8] [2 [3 4 625 6] 7] z-up')
+
+
+.. parsed-literal::
+
+    [1 [2 [3 4 625 6] 7] 8]
+
+
+``dip`` and ``infra``
+---------------------
+
+In Joy we have the ``dip`` and ``infra`` combinators which can “target”
+or “address” any particular item in a Joy tree structure.
+
+.. code:: python
+
+    V('[1 [2 [3 4 25 6] 7] 8] [[[[[[sqr] dipd] infra] dip] infra] dip] infra')
+
+
+.. parsed-literal::
+
+                                                                    . [1 [2 [3 4 25 6] 7] 8] [[[[[[sqr] dipd] infra] dip] infra] dip] infra
+                                             [1 [2 [3 4 25 6] 7] 8] . [[[[[[sqr] dipd] infra] dip] infra] dip] infra
+    [1 [2 [3 4 25 6] 7] 8] [[[[[[sqr] dipd] infra] dip] infra] dip] . infra
+                                               8 [2 [3 4 25 6] 7] 1 . [[[[[sqr] dipd] infra] dip] infra] dip [] swaack
+            8 [2 [3 4 25 6] 7] 1 [[[[[sqr] dipd] infra] dip] infra] . dip [] swaack
+                                                 8 [2 [3 4 25 6] 7] . [[[[sqr] dipd] infra] dip] infra 1 [] swaack
+                      8 [2 [3 4 25 6] 7] [[[[sqr] dipd] infra] dip] . infra 1 [] swaack
+                                                     7 [3 4 25 6] 2 . [[[sqr] dipd] infra] dip [8] swaack 1 [] swaack
+                                7 [3 4 25 6] 2 [[[sqr] dipd] infra] . dip [8] swaack 1 [] swaack
+                                                       7 [3 4 25 6] . [[sqr] dipd] infra 2 [8] swaack 1 [] swaack
+                                          7 [3 4 25 6] [[sqr] dipd] . infra 2 [8] swaack 1 [] swaack
+                                                           6 25 4 3 . [sqr] dipd [7] swaack 2 [8] swaack 1 [] swaack
+                                                     6 25 4 3 [sqr] . dipd [7] swaack 2 [8] swaack 1 [] swaack
+                                                               6 25 . sqr 4 3 [7] swaack 2 [8] swaack 1 [] swaack
+                                                               6 25 . dup mul 4 3 [7] swaack 2 [8] swaack 1 [] swaack
+                                                            6 25 25 . mul 4 3 [7] swaack 2 [8] swaack 1 [] swaack
+                                                              6 625 . 4 3 [7] swaack 2 [8] swaack 1 [] swaack
+                                                            6 625 4 . 3 [7] swaack 2 [8] swaack 1 [] swaack
+                                                          6 625 4 3 . [7] swaack 2 [8] swaack 1 [] swaack
+                                                      6 625 4 3 [7] . swaack 2 [8] swaack 1 [] swaack
+                                                      7 [3 4 625 6] . 2 [8] swaack 1 [] swaack
+                                                    7 [3 4 625 6] 2 . [8] swaack 1 [] swaack
+                                                7 [3 4 625 6] 2 [8] . swaack 1 [] swaack
+                                                8 [2 [3 4 625 6] 7] . 1 [] swaack
+                                              8 [2 [3 4 625 6] 7] 1 . [] swaack
+                                           8 [2 [3 4 625 6] 7] 1 [] . swaack
+                                            [1 [2 [3 4 625 6] 7] 8] . 
+
+
+If you read the trace carefully you’ll see that about half of it is the
+``dip`` and ``infra`` combinators de-quoting programs and “digging” into
+the subject datastructure. Instead of maintaining temporary results on
+the stack they are pushed into the pending expression (continuation).
+When ``sqr`` has run the rest of the pending expression rebuilds the
+datastructure.
+
+``Z``
+-----
+
+Imagine a function ``Z`` that accepts a sequence of ``dip`` and
+``infra`` combinators, a quoted program ``[Q]``, and a datastructure to
+work on. It would effectively execute the quoted program as if it had
+been embedded in a nested series of quoted programs, e.g.:
+
+::
+
+      [...] [Q] [dip dip infra dip infra dip infra] Z
+   -------------------------------------------------------------
+      [...] [[[[[[[Q] dip] dip] infra] dip] infra] dip] infra
+      
+
+The ``Z`` function isn’t hard to make.
+
+.. code:: python
+
+    define('Z == [[] cons cons] step i')
+
+Here it is in action in a simplified scenario.
+
+.. code:: python
+
+    V('1 [2 3 4] Z')
+
+
+.. parsed-literal::
+
+                                 . 1 [2 3 4] Z
+                               1 . [2 3 4] Z
+                       1 [2 3 4] . Z
+                       1 [2 3 4] . [[] cons cons] step i
+        1 [2 3 4] [[] cons cons] . step i
+              1 2 [[] cons cons] . i [3 4] [[] cons cons] step i
+                             1 2 . [] cons cons [3 4] [[] cons cons] step i
+                          1 2 [] . cons cons [3 4] [[] cons cons] step i
+                           1 [2] . cons [3 4] [[] cons cons] step i
+                           [1 2] . [3 4] [[] cons cons] step i
+                     [1 2] [3 4] . [[] cons cons] step i
+      [1 2] [3 4] [[] cons cons] . step i
+          [1 2] 3 [[] cons cons] . i [4] [[] cons cons] step i
+                         [1 2] 3 . [] cons cons [4] [[] cons cons] step i
+                      [1 2] 3 [] . cons cons [4] [[] cons cons] step i
+                       [1 2] [3] . cons [4] [[] cons cons] step i
+                       [[1 2] 3] . [4] [[] cons cons] step i
+                   [[1 2] 3] [4] . [[] cons cons] step i
+    [[1 2] 3] [4] [[] cons cons] . step i
+      [[1 2] 3] 4 [[] cons cons] . i i
+                     [[1 2] 3] 4 . [] cons cons i
+                  [[1 2] 3] 4 [] . cons cons i
+                   [[1 2] 3] [4] . cons i
+                   [[[1 2] 3] 4] . i
+                                 . [[1 2] 3] 4
+                       [[1 2] 3] . 4
+                     [[1 2] 3] 4 . 
+
+
+And here it is doing the main thing.
+
+.. code:: python
+
+    J('[1 [2 [3 4 25 6] 7] 8] [sqr] [dip dip infra dip infra dip infra] Z')
+
+
+.. parsed-literal::
+
+    [1 [2 [3 4 625 6] 7] 8]
+
+
+Addressing
+----------
+
+Because we are only using two combinators we could replace the list with
+a string made from only two characters.
+
+::
+
+      [...] [Q] 'ddididi' Zstr
+   -------------------------------------------------------------
+      [...] [[[[[[[Q] dip] dip] infra] dip] infra] dip] infra
+
+The string can be considered a name or address for an item in the
+subject datastructure.
+
+Determining the right “path” for an item in a tree.
+---------------------------------------------------
+
+It’s easy to read off (in reverse) the right sequence of “d” and “i”
+from the subject datastructure:
+
+::
+
+   [ n [ n [ n n x ...
+   i d i d i d d Bingo!
+
diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/index.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/index.rst.txt
new file mode 100644 (file)
index 0000000..c14aafa
--- /dev/null
@@ -0,0 +1,26 @@
+
+Essays about Programming in Joy
+===============================
+
+These essays are adapted from Jupyter notebooks.  I hope to have those hosted somewhere where people can view them "live" and interact with them, possibly on MS Azure.  For now, Sphinx does such a great job rendering the HTML that I am copying over some notebooks in ReST format and hand-editing them into these documents.
+
+.. toctree::
+   :glob:
+   :maxdepth: 2
+
+   Developing
+   Quadratic
+   Replacing
+   Recursion_Combinators
+   Ordered_Binary_Trees
+   Treestep
+   Generator_Programs
+   Newton-Raphson
+   Zipper
+   Types
+   TypeChecking
+   NoUpdates
+   Categorical
+   The_Four_Operations
+   Derivatives_of_Regular_Expressions
+
diff --git a/docs/sphinx_docs/_build/html/_sources/types.rst.txt b/docs/sphinx_docs/_build/html/_sources/types.rst.txt
new file mode 100644 (file)
index 0000000..5491f3a
--- /dev/null
@@ -0,0 +1,153 @@
+
+Type Inference of Joy Expressions
+=================================
+
+UPDATE: May 2020 - I removed the type inference code in `joy.utils.types`
+but you can find it in the `v0.4.0` tag here:
+https://osdn.net/projects/joypy/scm/hg/Joypy/tags
+
+
+Two kinds of type inference are provided, a simple inferencer that can
+handle functions that have a single stack effect (aka "type signature")
+and that can generate Python code for a limited subset of those
+functions, and a more complex inferencer/interpreter hybrid that can
+infer the stack effects of most Joy expressions, including multiple stack
+effects, unbounded sequences of values, and combinators (if enough
+information is available.)
+
+
+``joy.utils.types``
+-------------------
+
+
+Curently (asterix after name indicates a function that can be
+auto-compiled to Python)::
+
+    _Tree_add_Ee = ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1]) *
+    _Tree_delete_R0 = ([a2 ...1] a1 -- [a2 ...1] a2 a1 a1) *
+    _Tree_delete_clear_stuff = (a3 a2 [a1 ...1] -- [...1]) *
+    _Tree_get_E = ([a3 a4 ...1] a2 a1 -- a4) *
+    add = (n1 n2 -- n3)  
+    and = (b1 b2 -- b3)  
+    bool = (a1 -- b1)  
+    ccons = (a2 a1 [...1] -- [a2 a1 ...1]) *
+    cons = (a1 [...0] -- [a1 ...0]) *
+    div = (n1 n2 -- n3)  
+    divmod = (n2 n1 -- n4 n3)  
+    dup = (a1 -- a1 a1) *
+    dupd = (a2 a1 -- a2 a2 a1) *
+    dupdd = (a3 a2 a1 -- a3 a3 a2 a1) *
+    eq = (n1 n2 -- b1)  
+    first = ([a1 ...1] -- a1) *
+    first_two = ([a1 a2 ...1] -- a1 a2) *
+    floordiv = (n1 n2 -- n3)  
+    fourth = ([a1 a2 a3 a4 ...1] -- a4) *
+    ge = (n1 n2 -- b1)  
+    gt = (n1 n2 -- b1)  
+    le = (n1 n2 -- b1)  
+    lshift = (n1 n2 -- n3)  
+    lt = (n1 n2 -- b1)  
+    modulus = (n1 n2 -- n3)  
+    mul = (n1 n2 -- n3)  
+    ne = (n1 n2 -- b1)  
+    neg = (n1 -- n2)  
+    not = (a1 -- b1)  
+    over = (a2 a1 -- a2 a1 a2) *
+    pm = (n2 n1 -- n4 n3)  
+    pop = (a1 --) *
+    popd = (a2 a1 -- a1) *
+    popdd = (a3 a2 a1 -- a2 a1) *
+    popop = (a2 a1 --) *
+    popopd = (a3 a2 a1 -- a1) *
+    popopdd = (a4 a3 a2 a1 -- a2 a1) *
+    pow = (n1 n2 -- n3)  
+    pred = (n1 -- n2)  
+    rest = ([a1 ...0] -- [...0]) *
+    rolldown = (a1 a2 a3 -- a2 a3 a1) *
+    rollup = (a1 a2 a3 -- a3 a1 a2) *
+    rrest = ([a1 a2 ...1] -- [...1]) *
+    rshift = (n1 n2 -- n3)  
+    second = ([a1 a2 ...1] -- a2) *
+    sqrt = (n1 -- n2)  
+    stack = (... -- ... [...]) *
+    stuncons = (... a1 -- ... a1 a1 [...]) *
+    stununcons = (... a2 a1 -- ... a2 a1 a1 a2 [...]) *
+    sub = (n1 n2 -- n3)  
+    succ = (n1 -- n2)  
+    swaack = ([...1] -- [...0]) *
+    swap = (a1 a2 -- a2 a1) *
+    swons = ([...1] a1 -- [a1 ...1]) *
+    third = ([a1 a2 a3 ...1] -- a3) *
+    truediv = (n1 n2 -- n3)  
+    tuck = (a2 a1 -- a1 a2 a1) *
+    uncons = ([a1 ...0] -- a1 [...0]) *
+    unit = (a1 -- [a1 ]) *
+    unswons = ([a1 ...1] -- [...1] a1) *
+
+
+Example output of the ``infer()`` function.  The first number on each
+line is the depth of the Python stack.  It goes down when the function
+backtracks.  The next thing on each line is the currently-computed stack
+effect so far.  It starts with the empty "identity function" and proceeds
+through the expression, which is the rest of each line.  The function
+acts like an interpreter but instead of executing the terms of the
+expression it composes them, but for combinators it *does* execute them,
+using the output side of the stack effect as the stack.  This seems to
+work fine.  With proper definitions for the behavior of the combinators
+that can have more than one effect (like ``branch`` or ``loop``) the
+``infer()`` function seems to be able to handle anything I throw at it so
+far.
+
+::
+
+      7 (--) ∘ pop swap rolldown rest rest cons cons
+     10 (a1 --) ∘ swap rolldown rest rest cons cons
+     13 (a3 a2 a1 -- a2 a3) ∘ rolldown rest rest cons cons
+     16 (a4 a3 a2 a1 -- a2 a3 a4) ∘ rest rest cons cons
+     19 ([a4 ...1] a3 a2 a1 -- a2 a3 [...1]) ∘ rest cons cons
+     22 ([a4 a5 ...1] a3 a2 a1 -- a2 a3 [...1]) ∘ cons cons
+     25 ([a4 a5 ...1] a3 a2 a1 -- a2 [a3 ...1]) ∘ cons
+     28 ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1]) ∘ 
+    ----------------------------------------
+    ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1])
+
+
+Here's another example (implementing ``ifte``) using some combinators::
+
+      7 (--) ∘ [pred] [mul] [div] [nullary bool] dipd branch
+      8 (-- [pred ...2]) ∘ [mul] [div] [nullary bool] dipd branch
+      9 (-- [pred ...2] [mul ...3]) ∘ [div] [nullary bool] dipd branch
+     10 (-- [pred ...2] [mul ...3] [div ...4]) ∘ [nullary bool] dipd branch
+     11 (-- [pred ...2] [mul ...3] [div ...4] [nullary bool ...5]) ∘ dipd branch
+     15 (-- [pred ...5]) ∘ nullary bool [mul] [div] branch
+     19 (-- [pred ...2]) ∘ [stack] dinfrirst bool [mul] [div] branch
+     20 (-- [pred ...2] [stack ]) ∘ dinfrirst bool [mul] [div] branch
+     22 (-- [pred ...2] [stack ]) ∘ dip infra first bool [mul] [div] branch
+     26 (--) ∘ stack [pred] infra first bool [mul] [div] branch
+     29 (... -- ... [...]) ∘ [pred] infra first bool [mul] [div] branch
+     30 (... -- ... [...] [pred ...1]) ∘ infra first bool [mul] [div] branch
+     34 (--) ∘ pred s1 swaack first bool [mul] [div] branch
+     37 (n1 -- n2) ∘ [n1] swaack first bool [mul] [div] branch
+     38 (... n1 -- ... n2 [n1 ...]) ∘ swaack first bool [mul] [div] branch
+     41 (... n1 -- ... n1 [n2 ...]) ∘ first bool [mul] [div] branch
+     44 (n1 -- n1 n2) ∘ bool [mul] [div] branch
+     47 (n1 -- n1 b1) ∘ [mul] [div] branch
+     48 (n1 -- n1 b1 [mul ...1]) ∘ [div] branch
+     49 (n1 -- n1 b1 [mul ...1] [div ...2]) ∘ branch
+     53 (n1 -- n1) ∘ div
+     56 (f2 f1 -- f3) ∘ 
+     56 (i1 f1 -- f2) ∘ 
+     56 (f1 i1 -- f2) ∘ 
+     56 (i2 i1 -- f1) ∘ 
+     53 (n1 -- n1) ∘ mul
+     56 (f2 f1 -- f3) ∘ 
+     56 (i1 f1 -- f2) ∘ 
+     56 (f1 i1 -- f2) ∘ 
+     56 (i2 i1 -- i3) ∘ 
+    ----------------------------------------
+    (f2 f1 -- f3)
+    (i1 f1 -- f2)
+    (f1 i1 -- f2)
+    (i2 i1 -- f1)
+    (i2 i1 -- i3)
+
index be65b13..0eddaeb 100644 (file)
@@ -1,61 +1,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 @import url("basic.css");
 
 /* -- page layout ----------------------------------------------------------- */
 
 body {
-    font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif;
+    font-family: Georgia, serif;
     font-size: 17px;
     background-color: #fff;
     color: #000;
@@ -159,7 +107,7 @@ div.sphinxsidebarwrapper p.blurb {
 
 div.sphinxsidebar h3,
 div.sphinxsidebar h4 {
-    font-family: 'Garamond', 'Georgia', serif;
+    font-family: Georgia, serif;
     color: #444;
     font-size: 24px;
     font-weight: normal;
@@ -203,7 +151,7 @@ div.sphinxsidebar ul li.toctree-l2 > a {
 
 div.sphinxsidebar input {
     border: 1px solid #CCC;
-    font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif;
+    font-family: Georgia, serif;
     font-size: 1em;
 }
 
@@ -218,6 +166,19 @@ div.sphinxsidebar hr {
     width: 50%;
 }
 
+div.sphinxsidebar .badge {
+    border-bottom: none;
+}
+
+div.sphinxsidebar .badge:hover {
+    border-bottom: none;
+}
+
+/* To address an issue with donation coming after search */
+div.sphinxsidebar h3.donation {
+    margin-top: 10px;
+}
+
 /* -- body styles ----------------------------------------------------------- */
 
 a {
@@ -236,7 +197,7 @@ div.body h3,
 div.body h4,
 div.body h5,
 div.body h6 {
-    font-family: 'Garamond', 'Georgia', serif;
+    font-family: Georgia, serif;
     font-weight: normal;
     margin: 30px 0px 10px 0px;
     padding: 0;
@@ -277,7 +238,7 @@ div.admonition tt.xref, div.admonition code.xref, div.admonition a tt {
 }
 
 div.admonition p.admonition-title {
-    font-family: 'Garamond', 'Georgia', serif;
+    font-family: Georgia, serif;
     font-weight: normal;
     font-size: 24px;
     margin: 0 0 10px 0;
@@ -366,7 +327,7 @@ p.admonition-title:after {
 }
 
 pre, tt, code {
-    font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
+    font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
     font-size: 0.9em;
 }
 
@@ -690,4 +651,51 @@ table.docutils.citation, table.docutils.citation td, table.docutils.citation th
   -moz-box-shadow: none;
   -webkit-box-shadow: none;
   box-shadow: none;
+}
+
+
+/* relbar */
+
+.related {
+    line-height: 30px;
+    width: 100%;
+    font-size: 0.9rem;
+}
+
+.related.top {
+    border-bottom: 1px solid #EEE;
+    margin-bottom: 20px;
+}
+
+.related.bottom {
+    border-top: 1px solid #EEE;
+}
+
+.related ul {
+    padding: 0;
+    margin: 0;
+    list-style: none;
+}
+
+.related li {
+    display: inline;
+}
+
+nav#rellinks {
+    float: right;
+}
+
+nav#rellinks li+li:before {
+    content: "|";
+}
+
+nav#breadcrumbs li+li:before {
+    content: "\00BB";
+}
+
+/* Hide certain items when printing */
+@media print {
+    div.related {
+        display: none;
+    }
 }
\ No newline at end of file
index 19ced10..603f6a8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Sphinx stylesheet -- basic theme.
  *
- * :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
  * :license: BSD, see LICENSE for details.
  *
  */
@@ -15,6 +15,12 @@ div.clearer {
     clear: both;
 }
 
+div.section::after {
+    display: block;
+    content: '';
+    clear: left;
+}
+
 /* -- relbar ---------------------------------------------------------------- */
 
 div.related {
@@ -81,6 +87,10 @@ div.sphinxsidebar input {
     font-size: 1em;
 }
 
+div.sphinxsidebar #searchbox form.search {
+    overflow: hidden;
+}
+
 div.sphinxsidebar #searchbox input[type="text"] {
     float: left;
     width: 80%;
@@ -120,7 +130,7 @@ ul.search li a {
     font-weight: bold;
 }
 
-ul.search li div.context {
+ul.search li p.context {
     color: #888;
     margin: 2px 0 0 30px;
     text-align: left;
@@ -227,6 +237,16 @@ a.headerlink {
     visibility: hidden;
 }
 
+a.brackets:before,
+span.brackets > a:before{
+    content: "[";
+}
+
+a.brackets:after,
+span.brackets > a:after {
+    content: "]";
+}
+
 h1:hover > a.headerlink,
 h2:hover > a.headerlink,
 h3:hover > a.headerlink,
@@ -257,19 +277,25 @@ p.rubric {
     font-weight: bold;
 }
 
-img.align-left, .figure.align-left, object.align-left {
+img.align-left, figure.align-left, .figure.align-left, object.align-left {
     clear: left;
     float: left;
     margin-right: 1em;
 }
 
-img.align-right, .figure.align-right, object.align-right {
+img.align-right, figure.align-right, .figure.align-right, object.align-right {
     clear: right;
     float: right;
     margin-left: 1em;
 }
 
-img.align-center, .figure.align-center, object.align-center {
+img.align-center, figure.align-center, .figure.align-center, object.align-center {
+  display: block;
+  margin-left: auto;
+  margin-right: auto;
+}
+
+img.align-default, figure.align-default, .figure.align-default {
   display: block;
   margin-left: auto;
   margin-right: auto;
@@ -283,30 +309,41 @@ img.align-center, .figure.align-center, object.align-center {
     text-align: center;
 }
 
+.align-default {
+    text-align: center;
+}
+
 .align-right {
     text-align: right;
 }
 
 /* -- sidebars -------------------------------------------------------------- */
 
-div.sidebar {
+div.sidebar,
+aside.sidebar {
     margin: 0 0 0.5em 1em;
     border: 1px solid #ddb;
-    padding: 7px 7px 0 7px;
+    padding: 7px;
     background-color: #ffe;
     width: 40%;
     float: right;
+    clear: right;
+    overflow-x: auto;
 }
 
 p.sidebar-title {
     font-weight: bold;
 }
 
+div.admonition, div.topic, blockquote {
+    clear: left;
+}
+
 /* -- topics ---------------------------------------------------------------- */
 
 div.topic {
     border: 1px solid #ccc;
-    padding: 7px 7px 0 7px;
+    padding: 7px;
     margin: 10px 0 10px 0;
 }
 
@@ -328,10 +365,6 @@ div.admonition dt {
     font-weight: bold;
 }
 
-div.admonition dl {
-    margin-bottom: 0;
-}
-
 p.admonition-title {
     margin: 0px 10px 5px 0px;
     font-weight: bold;
@@ -342,9 +375,30 @@ div.body p.centered {
     margin-top: 25px;
 }
 
+/* -- content of sidebars/topics/admonitions -------------------------------- */
+
+div.sidebar > :last-child,
+aside.sidebar > :last-child,
+div.topic > :last-child,
+div.admonition > :last-child {
+    margin-bottom: 0;
+}
+
+div.sidebar::after,
+aside.sidebar::after,
+div.topic::after,
+div.admonition::after,
+blockquote::after {
+    display: block;
+    content: '';
+    clear: both;
+}
+
 /* -- tables ---------------------------------------------------------------- */
 
 table.docutils {
+    margin-top: 10px;
+    margin-bottom: 10px;
     border: 0;
     border-collapse: collapse;
 }
@@ -354,6 +408,11 @@ table.align-center {
     margin-right: auto;
 }
 
+table.align-default {
+    margin-left: auto;
+    margin-right: auto;
+}
+
 table caption span.caption-number {
     font-style: italic;
 }
@@ -387,22 +446,34 @@ table.citation td {
     border-bottom: none;
 }
 
+th > :first-child,
+td > :first-child {
+    margin-top: 0px;
+}
+
+th > :last-child,
+td > :last-child {
+    margin-bottom: 0px;
+}
+
 /* -- figures --------------------------------------------------------------- */
 
-div.figure {
+div.figure, figure {
     margin: 0.5em;
     padding: 0.5em;
 }
 
-div.figure p.caption {
+div.figure p.caption, figcaption {
     padding: 0.3em;
 }
 
-div.figure p.caption span.caption-number {
+div.figure p.caption span.caption-number,
+figcaption span.caption-number {
     font-style: italic;
 }
 
-div.figure p.caption span.caption-text {
+div.figure p.caption span.caption-text,
+figcaption span.caption-text {
 }
 
 /* -- field list styles ----------------------------------------------------- */
@@ -427,6 +498,74 @@ table.field-list td, table.field-list th {
     hyphens: manual;
 }
 
+/* -- hlist styles ---------------------------------------------------------- */
+
+table.hlist {
+    margin: 1em 0;
+}
+
+table.hlist td {
+    vertical-align: top;
+}
+
+/* -- object description styles --------------------------------------------- */
+
+.sig {
+       font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
+}
+
+.sig-name, code.descname {
+    background-color: transparent;
+    font-weight: bold;
+}
+
+.sig-name {
+       font-size: 1.1em;
+}
+
+code.descname {
+    font-size: 1.2em;
+}
+
+.sig-prename, code.descclassname {
+    background-color: transparent;
+}
+
+.optional {
+    font-size: 1.3em;
+}
+
+.sig-paren {
+    font-size: larger;
+}
+
+.sig-param.n {
+       font-style: italic;
+}
+
+/* C++ specific styling */
+
+.sig-inline.c-texpr,
+.sig-inline.cpp-texpr {
+       font-family: unset;
+}
+
+.sig.c   .k, .sig.c   .kt,
+.sig.cpp .k, .sig.cpp .kt {
+       color: #0033B3;
+}
+
+.sig.c   .m,
+.sig.cpp .m {
+       color: #1750EB;
+}
+
+.sig.c   .s, .sig.c   .sc,
+.sig.cpp .s, .sig.cpp .sc {
+       color: #067D17;
+}
+
+
 /* -- other body styles ----------------------------------------------------- */
 
 ol.arabic {
@@ -449,11 +588,78 @@ ol.upperroman {
     list-style: upper-roman;
 }
 
+:not(li) > ol > li:first-child > :first-child,
+:not(li) > ul > li:first-child > :first-child {
+    margin-top: 0px;
+}
+
+:not(li) > ol > li:last-child > :last-child,
+:not(li) > ul > li:last-child > :last-child {
+    margin-bottom: 0px;
+}
+
+ol.simple ol p,
+ol.simple ul p,
+ul.simple ol p,
+ul.simple ul p {
+    margin-top: 0;
+}
+
+ol.simple > li:not(:first-child) > p,
+ul.simple > li:not(:first-child) > p {
+    margin-top: 0;
+}
+
+ol.simple p,
+ul.simple p {
+    margin-bottom: 0;
+}
+
+dl.footnote > dt,
+dl.citation > dt {
+    float: left;
+    margin-right: 0.5em;
+}
+
+dl.footnote > dd,
+dl.citation > dd {
+    margin-bottom: 0em;
+}
+
+dl.footnote > dd:after,
+dl.citation > dd:after {
+    content: "";
+    clear: both;
+}
+
+dl.field-list {
+    display: grid;
+    grid-template-columns: fit-content(30%) auto;
+}
+
+dl.field-list > dt {
+    font-weight: bold;
+    word-break: break-word;
+    padding-left: 0.5em;
+    padding-right: 5px;
+}
+
+dl.field-list > dt:after {
+    content: ":";
+}
+
+dl.field-list > dd {
+    padding-left: 0.5em;
+    margin-top: 0em;
+    margin-left: 0em;
+    margin-bottom: 0em;
+}
+
 dl {
     margin-bottom: 15px;
 }
 
-dd p {
+dd > :first-child {
     margin-top: 0px;
 }
 
@@ -467,6 +673,11 @@ dd {
     margin-left: 30px;
 }
 
+dl > dd:last-child,
+dl > dd:last-child > :last-child {
+    margin-bottom: 0;
+}
+
 dt:target, span.highlighted {
     background-color: #fbe54e;
 }
@@ -480,14 +691,6 @@ dl.glossary dt {
     font-size: 1.1em;
 }
 
-.optional {
-    font-size: 1.3em;
-}
-
-.sig-paren {
-    font-size: larger;
-}
-
 .versionmodified {
     font-style: italic;
 }
@@ -526,6 +729,13 @@ dl.glossary dt {
     font-style: oblique;
 }
 
+.classifier:before {
+    font-style: normal;
+    margin: 0 0.5em;
+    content: ":";
+    display: inline-block;
+}
+
 abbr, acronym {
     border-bottom: dotted 1px;
     cursor: help;
@@ -538,6 +748,10 @@ pre {
     overflow-y: hidden;  /* fixes display issues on Chrome browsers */
 }
 
+pre, div[class*="highlight-"] {
+    clear: both;
+}
+
 span.pre {
     -moz-hyphens: none;
     -ms-hyphens: none;
@@ -545,22 +759,57 @@ span.pre {
     hyphens: none;
 }
 
+div[class*="highlight-"] {
+    margin: 1em 0;
+}
+
 td.linenos pre {
-    padding: 5px 0px;
     border: 0;
     background-color: transparent;
     color: #aaa;
 }
 
 table.highlighttable {
-    margin-left: 0.5em;
+    display: block;
+}
+
+table.highlighttable tbody {
+    display: block;
+}
+
+table.highlighttable tr {
+    display: flex;
 }
 
 table.highlighttable td {
-    padding: 0 0.5em 0 0.5em;
+    margin: 0;
+    padding: 0;
+}
+
+table.highlighttable td.linenos {
+    padding-right: 0.5em;
+}
+
+table.highlighttable td.code {
+    flex: 1;
+    overflow: hidden;
+}
+
+.highlight .hll {
+    display: block;
+}
+
+div.highlight pre,
+table.highlighttable pre {
+    margin: 0;
+}
+
+div.code-block-caption + div {
+    margin-top: 0;
 }
 
 div.code-block-caption {
+    margin-top: 1em;
     padding: 2px 5px;
     font-size: small;
 }
@@ -569,8 +818,14 @@ div.code-block-caption code {
     background-color: transparent;
 }
 
-div.code-block-caption + div > div.highlight > pre {
-    margin-top: 0;
+table.highlighttable td.linenos,
+span.linenos,
+div.highlight span.gp {  /* gp: Generic.Prompt */
+  user-select: none;
+  -webkit-user-select: text; /* Safari fallback only */
+  -webkit-user-select: none; /* Chrome/Safari */
+  -moz-user-select: none; /* Firefox */
+  -ms-user-select: none; /* IE10+ */
 }
 
 div.code-block-caption span.caption-number {
@@ -582,21 +837,7 @@ div.code-block-caption span.caption-text {
 }
 
 div.literal-block-wrapper {
-    padding: 1em 1em 0;
-}
-
-div.literal-block-wrapper div.highlight {
-    margin: 0;
-}
-
-code.descname {
-    background-color: transparent;
-    font-weight: bold;
-    font-size: 1.2em;
-}
-
-code.descclassname {
-    background-color: transparent;
+    margin: 1em 0;
 }
 
 code.xref, a code {
@@ -637,8 +878,7 @@ span.eqno {
 }
 
 span.eqno a.headerlink {
-    position: relative;
-    left: 0px;
+    position: absolute;
     z-index: 1;
 }
 
index d892892..8cbf1b1 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Sphinx JavaScript utilities for all documentation.
  *
- * :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
  * :license: BSD, see LICENSE for details.
  *
  */
@@ -29,9 +29,14 @@ if (!window.console || !console.firebug) {
 
 /**
  * small helper function to urldecode strings
+ *
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
  */
 jQuery.urldecode = function(x) {
-  return decodeURIComponent(x).replace(/\+/g, ' ');
+  if (!x) {
+    return x
+  }
+  return decodeURIComponent(x.replace(/\+/g, ' '));
 };
 
 /**
@@ -87,14 +92,13 @@ jQuery.fn.highlightText = function(text, className) {
           node.nextSibling));
         node.nodeValue = val.substr(0, pos);
         if (isInSVG) {
-          var bbox = span.getBBox();
           var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
-                 rect.x.baseVal.value = bbox.x;
+          var bbox = node.parentElement.getBBox();
+          rect.x.baseVal.value = bbox.x;
           rect.y.baseVal.value = bbox.y;
           rect.width.baseVal.value = bbox.width;
           rect.height.baseVal.value = bbox.height;
           rect.setAttribute('class', className);
-          var parentOfText = node.parentNode.parentNode;
           addItems.push({
               "parent": node.parentNode,
               "target": rect});
@@ -150,7 +154,9 @@ var Documentation = {
     this.fixFirefoxAnchorBug();
     this.highlightSearchWords();
     this.initIndexTable();
-    
+    if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
+      this.initOnKeyListeners();
+    }
   },
 
   /**
@@ -282,10 +288,12 @@ var Documentation = {
   },
 
   initOnKeyListeners: function() {
-    $(document).keyup(function(event) {
+    $(document).keydown(function(event) {
       var activeElementType = document.activeElement.tagName;
-      // don't navigate when in search box or textarea
-      if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
+      // don't navigate when in search box, textarea, dropdown or button
+      if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
+          && activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey
+          && !event.shiftKey) {
         switch (event.keyCode) {
           case 37: // left
             var prevHref = $('link[rel="prev"]').prop('href');
@@ -293,12 +301,14 @@ var Documentation = {
               window.location.href = prevHref;
               return false;
             }
+            break;
           case 39: // right
             var nextHref = $('link[rel="next"]').prop('href');
             if (nextHref) {
               window.location.href = nextHref;
               return false;
             }
+            break;
         }
       }
     });
@@ -310,4 +320,4 @@ _ = Documentation.gettext;
 
 $(document).ready(function() {
   Documentation.init();
-});
\ No newline at end of file
+});
index c4f2ca7..e9b7668 100644 (file)
@@ -1,9 +1,12 @@
 var DOCUMENTATION_OPTIONS = {
-    URL_ROOT: '',
+    URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
     VERSION: '0.4.1',
     LANGUAGE: 'None',
     COLLAPSE_INDEX: false,
+    BUILDER: 'html',
     FILE_SUFFIX: '.html',
+    LINK_SUFFIX: '.html',
     HAS_SOURCE: true,
-    SOURCELINK_SUFFIX: '.txt'
+    SOURCELINK_SUFFIX: '.txt',
+    NAVIGATION_WITH_KEYS: false
 };
\ No newline at end of file
diff --git a/docs/sphinx_docs/_build/html/_static/jquery-3.5.1.js b/docs/sphinx_docs/_build/html/_static/jquery-3.5.1.js
new file mode 100644 (file)
index 0000000..5093733
--- /dev/null
@@ -0,0 +1,10872 @@
+/*!
+ * jQuery JavaScript Library v3.5.1
+ * https://jquery.com/
+ *
+ * Includes Sizzle.js
+ * https://sizzlejs.com/
+ *
+ * Copyright JS Foundation and other contributors
+ * Released under the MIT license
+ * https://jquery.org/license
+ *
+ * Date: 2020-05-04T22:49Z
+ */
+( function( global, factory ) {
+
+       "use strict";
+
+       if ( typeof module === "object" && typeof module.exports === "object" ) {
+
+               // For CommonJS and CommonJS-like environments where a proper `window`
+               // is present, execute the factory and get jQuery.
+               // For environments that do not have a `window` with a `document`
+               // (such as Node.js), expose a factory as module.exports.
+               // This accentuates the need for the creation of a real `window`.
+               // e.g. var jQuery = require("jquery")(window);
+               // See ticket #14549 for more info.
+               module.exports = global.document ?
+                       factory( global, true ) :
+                       function( w ) {
+                               if ( !w.document ) {
+                                       throw new Error( "jQuery requires a window with a document" );
+                               }
+                               return factory( w );
+                       };
+       } else {
+               factory( global );
+       }
+
+// Pass this if window is not defined yet
+} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
+
+// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
+// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
+// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
+// enough that all such attempts are guarded in a try block.
+"use strict";
+
+var arr = [];
+
+var getProto = Object.getPrototypeOf;
+
+var slice = arr.slice;
+
+var flat = arr.flat ? function( array ) {
+       return arr.flat.call( array );
+} : function( array ) {
+       return arr.concat.apply( [], array );
+};
+
+
+var push = arr.push;
+
+var indexOf = arr.indexOf;
+
+var class2type = {};
+
+var toString = class2type.toString;
+
+var hasOwn = class2type.hasOwnProperty;
+
+var fnToString = hasOwn.toString;
+
+var ObjectFunctionString = fnToString.call( Object );
+
+var support = {};
+
+var isFunction = function isFunction( obj ) {
+
+      // Support: Chrome <=57, Firefox <=52
+      // In some browsers, typeof returns "function" for HTML <object> elements
+      // (i.e., `typeof document.createElement( "object" ) === "function"`).
+      // We don't want to classify *any* DOM node as a function.
+      return typeof obj === "function" && typeof obj.nodeType !== "number";
+  };
+
+
+var isWindow = function isWindow( obj ) {
+               return obj != null && obj === obj.window;
+       };
+
+
+var document = window.document;
+
+
+
+       var preservedScriptAttributes = {
+               type: true,
+               src: true,
+               nonce: true,
+               noModule: true
+       };
+
+       function DOMEval( code, node, doc ) {
+               doc = doc || document;
+
+               var i, val,
+                       script = doc.createElement( "script" );
+
+               script.text = code;
+               if ( node ) {
+                       for ( i in preservedScriptAttributes ) {
+
+                               // Support: Firefox 64+, Edge 18+
+                               // Some browsers don't support the "nonce" property on scripts.
+                               // On the other hand, just using `getAttribute` is not enough as
+                               // the `nonce` attribute is reset to an empty string whenever it
+                               // becomes browsing-context connected.
+                               // See https://github.com/whatwg/html/issues/2369
+                               // See https://html.spec.whatwg.org/#nonce-attributes
+                               // The `node.getAttribute` check was added for the sake of
+                               // `jQuery.globalEval` so that it can fake a nonce-containing node
+                               // via an object.
+                               val = node[ i ] || node.getAttribute && node.getAttribute( i );
+                               if ( val ) {
+                                       script.setAttribute( i, val );
+                               }
+                       }
+               }
+               doc.head.appendChild( script ).parentNode.removeChild( script );
+       }
+
+
+function toType( obj ) {
+       if ( obj == null ) {
+               return obj + "";
+       }
+
+       // Support: Android <=2.3 only (functionish RegExp)
+       return typeof obj === "object" || typeof obj === "function" ?
+               class2type[ toString.call( obj ) ] || "object" :
+               typeof obj;
+}
+/* global Symbol */
+// Defining this global in .eslintrc.json would create a danger of using the global
+// unguarded in another place, it seems safer to define global only for this module
+
+
+
+var
+       version = "3.5.1",
+
+       // Define a local copy of jQuery
+       jQuery = function( selector, context ) {
+
+               // The jQuery object is actually just the init constructor 'enhanced'
+               // Need init if jQuery is called (just allow error to be thrown if not included)
+               return new jQuery.fn.init( selector, context );
+       };
+
+jQuery.fn = jQuery.prototype = {
+
+       // The current version of jQuery being used
+       jquery: version,
+
+       constructor: jQuery,
+
+       // The default length of a jQuery object is 0
+       length: 0,
+
+       toArray: function() {
+               return slice.call( this );
+       },
+
+       // Get the Nth element in the matched element set OR
+       // Get the whole matched element set as a clean array
+       get: function( num ) {
+
+               // Return all the elements in a clean array
+               if ( num == null ) {
+                       return slice.call( this );
+               }
+
+               // Return just the one element from the set
+               return num < 0 ? this[ num + this.length ] : this[ num ];
+       },
+
+       // Take an array of elements and push it onto the stack
+       // (returning the new matched element set)
+       pushStack: function( elems ) {
+
+               // Build a new jQuery matched element set
+               var ret = jQuery.merge( this.constructor(), elems );
+
+               // Add the old object onto the stack (as a reference)
+               ret.prevObject = this;
+
+               // Return the newly-formed element set
+               return ret;
+       },
+
+       // Execute a callback for every element in the matched set.
+       each: function( callback ) {
+               return jQuery.each( this, callback );
+       },
+
+       map: function( callback ) {
+               return this.pushStack( jQuery.map( this, function( elem, i ) {
+                       return callback.call( elem, i, elem );
+               } ) );
+       },
+
+       slice: function() {
+               return this.pushStack( slice.apply( this, arguments ) );
+       },
+
+       first: function() {
+               return this.eq( 0 );
+       },
+
+       last: function() {
+               return this.eq( -1 );
+       },
+
+       even: function() {
+               return this.pushStack( jQuery.grep( this, function( _elem, i ) {
+                       return ( i + 1 ) % 2;
+               } ) );
+       },
+
+       odd: function() {
+               return this.pushStack( jQuery.grep( this, function( _elem, i ) {
+                       return i % 2;
+               } ) );
+       },
+
+       eq: function( i ) {
+               var len = this.length,
+                       j = +i + ( i < 0 ? len : 0 );
+               return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
+       },
+
+       end: function() {
+               return this.prevObject || this.constructor();
+       },
+
+       // For internal use only.
+       // Behaves like an Array's method, not like a jQuery method.
+       push: push,
+       sort: arr.sort,
+       splice: arr.splice
+};
+
+jQuery.extend = jQuery.fn.extend = function() {
+       var options, name, src, copy, copyIsArray, clone,
+               target = arguments[ 0 ] || {},
+               i = 1,
+               length = arguments.length,
+               deep = false;
+
+       // Handle a deep copy situation
+       if ( typeof target === "boolean" ) {
+               deep = target;
+
+               // Skip the boolean and the target
+               target = arguments[ i ] || {};
+               i++;
+       }
+
+       // Handle case when target is a string or something (possible in deep copy)
+       if ( typeof target !== "object" && !isFunction( target ) ) {
+               target = {};
+       }
+
+       // Extend jQuery itself if only one argument is passed
+       if ( i === length ) {
+               target = this;
+               i--;
+       }
+
+       for ( ; i < length; i++ ) {
+
+               // Only deal with non-null/undefined values
+               if ( ( options = arguments[ i ] ) != null ) {
+
+                       // Extend the base object
+                       for ( name in options ) {
+                               copy = options[ name ];
+
+                               // Prevent Object.prototype pollution
+                               // Prevent never-ending loop
+                               if ( name === "__proto__" || target === copy ) {
+                                       continue;
+                               }
+
+                               // Recurse if we're merging plain objects or arrays
+                               if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
+                                       ( copyIsArray = Array.isArray( copy ) ) ) ) {
+                                       src = target[ name ];
+
+                                       // Ensure proper type for the source value
+                                       if ( copyIsArray && !Array.isArray( src ) ) {
+                                               clone = [];
+                                       } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
+                                               clone = {};
+                                       } else {
+                                               clone = src;
+                                       }
+                                       copyIsArray = false;
+
+                                       // Never move original objects, clone them
+                                       target[ name ] = jQuery.extend( deep, clone, copy );
+
+                               // Don't bring in undefined values
+                               } else if ( copy !== undefined ) {
+                                       target[ name ] = copy;
+                               }
+                       }
+               }
+       }
+
+       // Return the modified object
+       return target;
+};
+
+jQuery.extend( {
+
+       // Unique for each copy of jQuery on the page
+       expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
+
+       // Assume jQuery is ready without the ready module
+       isReady: true,
+
+       error: function( msg ) {
+               throw new Error( msg );
+       },
+
+       noop: function() {},
+
+       isPlainObject: function( obj ) {
+               var proto, Ctor;
+
+               // Detect obvious negatives
+               // Use toString instead of jQuery.type to catch host objects
+               if ( !obj || toString.call( obj ) !== "[object Object]" ) {
+                       return false;
+               }
+
+               proto = getProto( obj );
+
+               // Objects with no prototype (e.g., `Object.create( null )`) are plain
+               if ( !proto ) {
+                       return true;
+               }
+
+               // Objects with prototype are plain iff they were constructed by a global Object function
+               Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
+               return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
+       },
+
+       isEmptyObject: function( obj ) {
+               var name;
+
+               for ( name in obj ) {
+                       return false;
+               }
+               return true;
+       },
+
+       // Evaluates a script in a provided context; falls back to the global one
+       // if not specified.
+       globalEval: function( code, options, doc ) {
+               DOMEval( code, { nonce: options && options.nonce }, doc );
+       },
+
+       each: function( obj, callback ) {
+               var length, i = 0;
+
+               if ( isArrayLike( obj ) ) {
+                       length = obj.length;
+                       for ( ; i < length; i++ ) {
+                               if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+                                       break;
+                               }
+                       }
+               } else {
+                       for ( i in obj ) {
+                               if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+                                       break;
+                               }
+                       }
+               }
+
+               return obj;
+       },
+
+       // results is for internal usage only
+       makeArray: function( arr, results ) {
+               var ret = results || [];
+
+               if ( arr != null ) {
+                       if ( isArrayLike( Object( arr ) ) ) {
+                               jQuery.merge( ret,
+                                       typeof arr === "string" ?
+                                       [ arr ] : arr
+                               );
+                       } else {
+                               push.call( ret, arr );
+                       }
+               }
+
+               return ret;
+       },
+
+       inArray: function( elem, arr, i ) {
+               return arr == null ? -1 : indexOf.call( arr, elem, i );
+       },
+
+       // Support: Android <=4.0 only, PhantomJS 1 only
+       // push.apply(_, arraylike) throws on ancient WebKit
+       merge: function( first, second ) {
+               var len = +second.length,
+                       j = 0,
+                       i = first.length;
+
+               for ( ; j < len; j++ ) {
+                       first[ i++ ] = second[ j ];
+               }
+
+               first.length = i;
+
+               return first;
+       },
+
+       grep: function( elems, callback, invert ) {
+               var callbackInverse,
+                       matches = [],
+                       i = 0,
+                       length = elems.length,
+                       callbackExpect = !invert;
+
+               // Go through the array, only saving the items
+               // that pass the validator function
+               for ( ; i < length; i++ ) {
+                       callbackInverse = !callback( elems[ i ], i );
+                       if ( callbackInverse !== callbackExpect ) {
+                               matches.push( elems[ i ] );
+                       }
+               }
+
+               return matches;
+       },
+
+       // arg is for internal usage only
+       map: function( elems, callback, arg ) {
+               var length, value,
+                       i = 0,
+                       ret = [];
+
+               // Go through the array, translating each of the items to their new values
+               if ( isArrayLike( elems ) ) {
+                       length = elems.length;
+                       for ( ; i < length; i++ ) {
+                               value = callback( elems[ i ], i, arg );
+
+                               if ( value != null ) {
+                                       ret.push( value );
+                               }
+                       }
+
+               // Go through every key on the object,
+               } else {
+                       for ( i in elems ) {
+                               value = callback( elems[ i ], i, arg );
+
+                               if ( value != null ) {
+                                       ret.push( value );
+                               }
+                       }
+               }
+
+               // Flatten any nested arrays
+               return flat( ret );
+       },
+
+       // A global GUID counter for objects
+       guid: 1,
+
+       // jQuery.support is not used in Core but other projects attach their
+       // properties to it so it needs to exist.
+       support: support
+} );
+
+if ( typeof Symbol === "function" ) {
+       jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
+}
+
+// Populate the class2type map
+jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
+function( _i, name ) {
+       class2type[ "[object " + name + "]" ] = name.toLowerCase();
+} );
+
+function isArrayLike( obj ) {
+
+       // Support: real iOS 8.2 only (not reproducible in simulator)
+       // `in` check used to prevent JIT error (gh-2145)
+       // hasOwn isn't used here due to false negatives
+       // regarding Nodelist length in IE
+       var length = !!obj && "length" in obj && obj.length,
+               type = toType( obj );
+
+       if ( isFunction( obj ) || isWindow( obj ) ) {
+               return false;
+       }
+
+       return type === "array" || length === 0 ||
+               typeof length === "number" && length > 0 && ( length - 1 ) in obj;
+}
+var Sizzle =
+/*!
+ * Sizzle CSS Selector Engine v2.3.5
+ * https://sizzlejs.com/
+ *
+ * Copyright JS Foundation and other contributors
+ * Released under the MIT license
+ * https://js.foundation/
+ *
+ * Date: 2020-03-14
+ */
+( function( window ) {
+var i,
+       support,
+       Expr,
+       getText,
+       isXML,
+       tokenize,
+       compile,
+       select,
+       outermostContext,
+       sortInput,
+       hasDuplicate,
+
+       // Local document vars
+       setDocument,
+       document,
+       docElem,
+       documentIsHTML,
+       rbuggyQSA,
+       rbuggyMatches,
+       matches,
+       contains,
+
+       // Instance-specific data
+       expando = "sizzle" + 1 * new Date(),
+       preferredDoc = window.document,
+       dirruns = 0,
+       done = 0,
+       classCache = createCache(),
+       tokenCache = createCache(),
+       compilerCache = createCache(),
+       nonnativeSelectorCache = createCache(),
+       sortOrder = function( a, b ) {
+               if ( a === b ) {
+                       hasDuplicate = true;
+               }
+               return 0;
+       },
+
+       // Instance methods
+       hasOwn = ( {} ).hasOwnProperty,
+       arr = [],
+       pop = arr.pop,
+       pushNative = arr.push,
+       push = arr.push,
+       slice = arr.slice,
+
+       // Use a stripped-down indexOf as it's faster than native
+       // https://jsperf.com/thor-indexof-vs-for/5
+       indexOf = function( list, elem ) {
+               var i = 0,
+                       len = list.length;
+               for ( ; i < len; i++ ) {
+                       if ( list[ i ] === elem ) {
+                               return i;
+                       }
+               }
+               return -1;
+       },
+
+       booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
+               "ismap|loop|multiple|open|readonly|required|scoped",
+
+       // Regular expressions
+
+       // http://www.w3.org/TR/css3-selectors/#whitespace
+       whitespace = "[\\x20\\t\\r\\n\\f]",
+
+       // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
+       identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
+               "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
+
+       // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
+       attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
+
+               // Operator (capture 2)
+               "*([*^$|!~]?=)" + whitespace +
+
+               // "Attribute values must be CSS identifiers [capture 5]
+               // or strings [capture 3 or capture 4]"
+               "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
+               whitespace + "*\\]",
+
+       pseudos = ":(" + identifier + ")(?:\\((" +
+
+               // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
+               // 1. quoted (capture 3; capture 4 or capture 5)
+               "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
+
+               // 2. simple (capture 6)
+               "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
+
+               // 3. anything else (capture 2)
+               ".*" +
+               ")\\)|)",
+
+       // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+       rwhitespace = new RegExp( whitespace + "+", "g" ),
+       rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
+               whitespace + "+$", "g" ),
+
+       rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+       rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
+               "*" ),
+       rdescend = new RegExp( whitespace + "|>" ),
+
+       rpseudo = new RegExp( pseudos ),
+       ridentifier = new RegExp( "^" + identifier + "$" ),
+
+       matchExpr = {
+               "ID": new RegExp( "^#(" + identifier + ")" ),
+               "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
+               "TAG": new RegExp( "^(" + identifier + "|[*])" ),
+               "ATTR": new RegExp( "^" + attributes ),
+               "PSEUDO": new RegExp( "^" + pseudos ),
+               "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
+                       whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
+                       whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+               "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
+
+               // For use in libraries implementing .is()
+               // We use this for POS matching in `select`
+               "needsContext": new RegExp( "^" + whitespace +
+                       "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
+                       "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
+       },
+
+       rhtml = /HTML$/i,
+       rinputs = /^(?:input|select|textarea|button)$/i,
+       rheader = /^h\d$/i,
+
+       rnative = /^[^{]+\{\s*\[native \w/,
+
+       // Easily-parseable/retrievable ID or TAG or CLASS selectors
+       rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
+
+       rsibling = /[+~]/,
+
+       // CSS escapes
+       // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
+       runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
+       funescape = function( escape, nonHex ) {
+               var high = "0x" + escape.slice( 1 ) - 0x10000;
+
+               return nonHex ?
+
+                       // Strip the backslash prefix from a non-hex escape sequence
+                       nonHex :
+
+                       // Replace a hexadecimal escape sequence with the encoded Unicode code point
+                       // Support: IE <=11+
+                       // For values outside the Basic Multilingual Plane (BMP), manually construct a
+                       // surrogate pair
+                       high < 0 ?
+                               String.fromCharCode( high + 0x10000 ) :
+                               String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
+       },
+
+       // CSS string/identifier serialization
+       // https://drafts.csswg.org/cssom/#common-serializing-idioms
+       rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
+       fcssescape = function( ch, asCodePoint ) {
+               if ( asCodePoint ) {
+
+                       // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
+                       if ( ch === "\0" ) {
+                               return "\uFFFD";
+                       }
+
+                       // Control characters and (dependent upon position) numbers get escaped as code points
+                       return ch.slice( 0, -1 ) + "\\" +
+                               ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
+               }
+
+               // Other potentially-special ASCII characters get backslash-escaped
+               return "\\" + ch;
+       },
+
+       // Used for iframes
+       // See setDocument()
+       // Removing the function wrapper causes a "Permission Denied"
+       // error in IE
+       unloadHandler = function() {
+               setDocument();
+       },
+
+       inDisabledFieldset = addCombinator(
+               function( elem ) {
+                       return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
+               },
+               { dir: "parentNode", next: "legend" }
+       );
+
+// Optimize for push.apply( _, NodeList )
+try {
+       push.apply(
+               ( arr = slice.call( preferredDoc.childNodes ) ),
+               preferredDoc.childNodes
+       );
+
+       // Support: Android<4.0
+       // Detect silently failing push.apply
+       // eslint-disable-next-line no-unused-expressions
+       arr[ preferredDoc.childNodes.length ].nodeType;
+} catch ( e ) {
+       push = { apply: arr.length ?
+
+               // Leverage slice if possible
+               function( target, els ) {
+                       pushNative.apply( target, slice.call( els ) );
+               } :
+
+               // Support: IE<9
+               // Otherwise append directly
+               function( target, els ) {
+                       var j = target.length,
+                               i = 0;
+
+                       // Can't trust NodeList.length
+                       while ( ( target[ j++ ] = els[ i++ ] ) ) {}
+                       target.length = j - 1;
+               }
+       };
+}
+
+function Sizzle( selector, context, results, seed ) {
+       var m, i, elem, nid, match, groups, newSelector,
+               newContext = context && context.ownerDocument,
+
+               // nodeType defaults to 9, since context defaults to document
+               nodeType = context ? context.nodeType : 9;
+
+       results = results || [];
+
+       // Return early from calls with invalid selector or context
+       if ( typeof selector !== "string" || !selector ||
+               nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
+
+               return results;
+       }
+
+       // Try to shortcut find operations (as opposed to filters) in HTML documents
+       if ( !seed ) {
+               setDocument( context );
+               context = context || document;
+
+               if ( documentIsHTML ) {
+
+                       // If the selector is sufficiently simple, try using a "get*By*" DOM method
+                       // (excepting DocumentFragment context, where the methods don't exist)
+                       if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
+
+                               // ID selector
+                               if ( ( m = match[ 1 ] ) ) {
+
+                                       // Document context
+                                       if ( nodeType === 9 ) {
+                                               if ( ( elem = context.getElementById( m ) ) ) {
+
+                                                       // Support: IE, Opera, Webkit
+                                                       // TODO: identify versions
+                                                       // getElementById can match elements by name instead of ID
+                                                       if ( elem.id === m ) {
+                                                               results.push( elem );
+                                                               return results;
+                                                       }
+                                               } else {
+                                                       return results;
+                                               }
+
+                                       // Element context
+                                       } else {
+
+                                               // Support: IE, Opera, Webkit
+                                               // TODO: identify versions
+                                               // getElementById can match elements by name instead of ID
+                                               if ( newContext && ( elem = newContext.getElementById( m ) ) &&
+                                                       contains( context, elem ) &&
+                                                       elem.id === m ) {
+
+                                                       results.push( elem );
+                                                       return results;
+                                               }
+                                       }
+
+                               // Type selector
+                               } else if ( match[ 2 ] ) {
+                                       push.apply( results, context.getElementsByTagName( selector ) );
+                                       return results;
+
+                               // Class selector
+                               } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
+                                       context.getElementsByClassName ) {
+
+                                       push.apply( results, context.getElementsByClassName( m ) );
+                                       return results;
+                               }
+                       }
+
+                       // Take advantage of querySelectorAll
+                       if ( support.qsa &&
+                               !nonnativeSelectorCache[ selector + " " ] &&
+                               ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
+
+                               // Support: IE 8 only
+                               // Exclude object elements
+                               ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
+
+                               newSelector = selector;
+                               newContext = context;
+
+                               // qSA considers elements outside a scoping root when evaluating child or
+                               // descendant combinators, which is not what we want.
+                               // In such cases, we work around the behavior by prefixing every selector in the
+                               // list with an ID selector referencing the scope context.
+                               // The technique has to be used as well when a leading combinator is used
+                               // as such selectors are not recognized by querySelectorAll.
+                               // Thanks to Andrew Dupont for this technique.
+                               if ( nodeType === 1 &&
+                                       ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
+
+                                       // Expand context for sibling selectors
+                                       newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
+                                               context;
+
+                                       // We can use :scope instead of the ID hack if the browser
+                                       // supports it & if we're not changing the context.
+                                       if ( newContext !== context || !support.scope ) {
+
+                                               // Capture the context ID, setting it first if necessary
+                                               if ( ( nid = context.getAttribute( "id" ) ) ) {
+                                                       nid = nid.replace( rcssescape, fcssescape );
+                                               } else {
+                                                       context.setAttribute( "id", ( nid = expando ) );
+                                               }
+                                       }
+
+                                       // Prefix every selector in the list
+                                       groups = tokenize( selector );
+                                       i = groups.length;
+                                       while ( i-- ) {
+                                               groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
+                                                       toSelector( groups[ i ] );
+                                       }
+                                       newSelector = groups.join( "," );
+                               }
+
+                               try {
+                                       push.apply( results,
+                                               newContext.querySelectorAll( newSelector )
+                                       );
+                                       return results;
+                               } catch ( qsaError ) {
+                                       nonnativeSelectorCache( selector, true );
+                               } finally {
+                                       if ( nid === expando ) {
+                                               context.removeAttribute( "id" );
+                                       }
+                               }
+                       }
+               }
+       }
+
+       // All others
+       return select( selector.replace( rtrim, "$1" ), context, results, seed );
+}
+
+/**
+ * Create key-value caches of limited size
+ * @returns {function(string, object)} Returns the Object data after storing it on itself with
+ *     property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
+ *     deleting the oldest entry
+ */
+function createCache() {
+       var keys = [];
+
+       function cache( key, value ) {
+
+               // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
+               if ( keys.push( key + " " ) > Expr.cacheLength ) {
+
+                       // Only keep the most recent entries
+                       delete cache[ keys.shift() ];
+               }
+               return ( cache[ key + " " ] = value );
+       }
+       return cache;
+}
+
+/**
+ * Mark a function for special use by Sizzle
+ * @param {Function} fn The function to mark
+ */
+function markFunction( fn ) {
+       fn[ expando ] = true;
+       return fn;
+}
+
+/**
+ * Support testing using an element
+ * @param {Function} fn Passed the created element and returns a boolean result
+ */
+function assert( fn ) {
+       var el = document.createElement( "fieldset" );
+
+       try {
+               return !!fn( el );
+       } catch ( e ) {
+               return false;
+       } finally {
+
+               // Remove from its parent by default
+               if ( el.parentNode ) {
+                       el.parentNode.removeChild( el );
+               }
+
+               // release memory in IE
+               el = null;
+       }
+}
+
+/**
+ * Adds the same handler for all of the specified attrs
+ * @param {String} attrs Pipe-separated list of attributes
+ * @param {Function} handler The method that will be applied
+ */
+function addHandle( attrs, handler ) {
+       var arr = attrs.split( "|" ),
+               i = arr.length;
+
+       while ( i-- ) {
+               Expr.attrHandle[ arr[ i ] ] = handler;
+       }
+}
+
+/**
+ * Checks document order of two siblings
+ * @param {Element} a
+ * @param {Element} b
+ * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
+ */
+function siblingCheck( a, b ) {
+       var cur = b && a,
+               diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
+                       a.sourceIndex - b.sourceIndex;
+
+       // Use IE sourceIndex if available on both nodes
+       if ( diff ) {
+               return diff;
+       }
+
+       // Check if b follows a
+       if ( cur ) {
+               while ( ( cur = cur.nextSibling ) ) {
+                       if ( cur === b ) {
+                               return -1;
+                       }
+               }
+       }
+
+       return a ? 1 : -1;
+}
+
+/**
+ * Returns a function to use in pseudos for input types
+ * @param {String} type
+ */
+function createInputPseudo( type ) {
+       return function( elem ) {
+               var name = elem.nodeName.toLowerCase();
+               return name === "input" && elem.type === type;
+       };
+}
+
+/**
+ * Returns a function to use in pseudos for buttons
+ * @param {String} type
+ */
+function createButtonPseudo( type ) {
+       return function( elem ) {
+               var name = elem.nodeName.toLowerCase();
+               return ( name === "input" || name === "button" ) && elem.type === type;
+       };
+}
+
+/**
+ * Returns a function to use in pseudos for :enabled/:disabled
+ * @param {Boolean} disabled true for :disabled; false for :enabled
+ */
+function createDisabledPseudo( disabled ) {
+
+       // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
+       return function( elem ) {
+
+               // Only certain elements can match :enabled or :disabled
+               // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
+               // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
+               if ( "form" in elem ) {
+
+                       // Check for inherited disabledness on relevant non-disabled elements:
+                       // * listed form-associated elements in a disabled fieldset
+                       //   https://html.spec.whatwg.org/multipage/forms.html#category-listed
+                       //   https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
+                       // * option elements in a disabled optgroup
+                       //   https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
+                       // All such elements have a "form" property.
+                       if ( elem.parentNode && elem.disabled === false ) {
+
+                               // Option elements defer to a parent optgroup if present
+                               if ( "label" in elem ) {
+                                       if ( "label" in elem.parentNode ) {
+                                               return elem.parentNode.disabled === disabled;
+                                       } else {
+                                               return elem.disabled === disabled;
+                                       }
+                               }
+
+                               // Support: IE 6 - 11
+                               // Use the isDisabled shortcut property to check for disabled fieldset ancestors
+                               return elem.isDisabled === disabled ||
+
+                                       // Where there is no isDisabled, check manually
+                                       /* jshint -W018 */
+                                       elem.isDisabled !== !disabled &&
+                                       inDisabledFieldset( elem ) === disabled;
+                       }
+
+                       return elem.disabled === disabled;
+
+               // Try to winnow out elements that can't be disabled before trusting the disabled property.
+               // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
+               // even exist on them, let alone have a boolean value.
+               } else if ( "label" in elem ) {
+                       return elem.disabled === disabled;
+               }
+
+               // Remaining elements are neither :enabled nor :disabled
+               return false;
+       };
+}
+
+/**
+ * Returns a function to use in pseudos for positionals
+ * @param {Function} fn
+ */
+function createPositionalPseudo( fn ) {
+       return markFunction( function( argument ) {
+               argument = +argument;
+               return markFunction( function( seed, matches ) {
+                       var j,
+                               matchIndexes = fn( [], seed.length, argument ),
+                               i = matchIndexes.length;
+
+                       // Match elements found at the specified indexes
+                       while ( i-- ) {
+                               if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
+                                       seed[ j ] = !( matches[ j ] = seed[ j ] );
+                               }
+                       }
+               } );
+       } );
+}
+
+/**
+ * Checks a node for validity as a Sizzle context
+ * @param {Element|Object=} context
+ * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
+ */
+function testContext( context ) {
+       return context && typeof context.getElementsByTagName !== "undefined" && context;
+}
+
+// Expose support vars for convenience
+support = Sizzle.support = {};
+
+/**
+ * Detects XML nodes
+ * @param {Element|Object} elem An element or a document
+ * @returns {Boolean} True iff elem is a non-HTML XML node
+ */
+isXML = Sizzle.isXML = function( elem ) {
+       var namespace = elem.namespaceURI,
+               docElem = ( elem.ownerDocument || elem ).documentElement;
+
+       // Support: IE <=8
+       // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
+       // https://bugs.jquery.com/ticket/4833
+       return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
+};
+
+/**
+ * Sets document-related variables once based on the current document
+ * @param {Element|Object} [doc] An element or document object to use to set the document
+ * @returns {Object} Returns the current document
+ */
+setDocument = Sizzle.setDocument = function( node ) {
+       var hasCompare, subWindow,
+               doc = node ? node.ownerDocument || node : preferredDoc;
+
+       // Return early if doc is invalid or already selected
+       // Support: IE 11+, Edge 17 - 18+
+       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+       // two documents; shallow comparisons work.
+       // eslint-disable-next-line eqeqeq
+       if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
+               return document;
+       }
+
+       // Update global variables
+       document = doc;
+       docElem = document.documentElement;
+       documentIsHTML = !isXML( document );
+
+       // Support: IE 9 - 11+, Edge 12 - 18+
+       // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
+       // Support: IE 11+, Edge 17 - 18+
+       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+       // two documents; shallow comparisons work.
+       // eslint-disable-next-line eqeqeq
+       if ( preferredDoc != document &&
+               ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
+
+               // Support: IE 11, Edge
+               if ( subWindow.addEventListener ) {
+                       subWindow.addEventListener( "unload", unloadHandler, false );
+
+               // Support: IE 9 - 10 only
+               } else if ( subWindow.attachEvent ) {
+                       subWindow.attachEvent( "onunload", unloadHandler );
+               }
+       }
+
+       // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
+       // Safari 4 - 5 only, Opera <=11.6 - 12.x only
+       // IE/Edge & older browsers don't support the :scope pseudo-class.
+       // Support: Safari 6.0 only
+       // Safari 6.0 supports :scope but it's an alias of :root there.
+       support.scope = assert( function( el ) {
+               docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
+               return typeof el.querySelectorAll !== "undefined" &&
+                       !el.querySelectorAll( ":scope fieldset div" ).length;
+       } );
+
+       /* Attributes
+       ---------------------------------------------------------------------- */
+
+       // Support: IE<8
+       // Verify that getAttribute really returns attributes and not properties
+       // (excepting IE8 booleans)
+       support.attributes = assert( function( el ) {
+               el.className = "i";
+               return !el.getAttribute( "className" );
+       } );
+
+       /* getElement(s)By*
+       ---------------------------------------------------------------------- */
+
+       // Check if getElementsByTagName("*") returns only elements
+       support.getElementsByTagName = assert( function( el ) {
+               el.appendChild( document.createComment( "" ) );
+               return !el.getElementsByTagName( "*" ).length;
+       } );
+
+       // Support: IE<9
+       support.getElementsByClassName = rnative.test( document.getElementsByClassName );
+
+       // Support: IE<10
+       // Check if getElementById returns elements by name
+       // The broken getElementById methods don't pick up programmatically-set names,
+       // so use a roundabout getElementsByName test
+       support.getById = assert( function( el ) {
+               docElem.appendChild( el ).id = expando;
+               return !document.getElementsByName || !document.getElementsByName( expando ).length;
+       } );
+
+       // ID filter and find
+       if ( support.getById ) {
+               Expr.filter[ "ID" ] = function( id ) {
+                       var attrId = id.replace( runescape, funescape );
+                       return function( elem ) {
+                               return elem.getAttribute( "id" ) === attrId;
+                       };
+               };
+               Expr.find[ "ID" ] = function( id, context ) {
+                       if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
+                               var elem = context.getElementById( id );
+                               return elem ? [ elem ] : [];
+                       }
+               };
+       } else {
+               Expr.filter[ "ID" ] =  function( id ) {
+                       var attrId = id.replace( runescape, funescape );
+                       return function( elem ) {
+                               var node = typeof elem.getAttributeNode !== "undefined" &&
+                                       elem.getAttributeNode( "id" );
+                               return node && node.value === attrId;
+                       };
+               };
+
+               // Support: IE 6 - 7 only
+               // getElementById is not reliable as a find shortcut
+               Expr.find[ "ID" ] = function( id, context ) {
+                       if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
+                               var node, i, elems,
+                                       elem = context.getElementById( id );
+
+                               if ( elem ) {
+
+                                       // Verify the id attribute
+                                       node = elem.getAttributeNode( "id" );
+                                       if ( node && node.value === id ) {
+                                               return [ elem ];
+                                       }
+
+                                       // Fall back on getElementsByName
+                                       elems = context.getElementsByName( id );
+                                       i = 0;
+                                       while ( ( elem = elems[ i++ ] ) ) {
+                                               node = elem.getAttributeNode( "id" );
+                                               if ( node && node.value === id ) {
+                                                       return [ elem ];
+                                               }
+                                       }
+                               }
+
+                               return [];
+                       }
+               };
+       }
+
+       // Tag
+       Expr.find[ "TAG" ] = support.getElementsByTagName ?
+               function( tag, context ) {
+                       if ( typeof context.getElementsByTagName !== "undefined" ) {
+                               return context.getElementsByTagName( tag );
+
+                       // DocumentFragment nodes don't have gEBTN
+                       } else if ( support.qsa ) {
+                               return context.querySelectorAll( tag );
+                       }
+               } :
+
+               function( tag, context ) {
+                       var elem,
+                               tmp = [],
+                               i = 0,
+
+                               // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
+                               results = context.getElementsByTagName( tag );
+
+                       // Filter out possible comments
+                       if ( tag === "*" ) {
+                               while ( ( elem = results[ i++ ] ) ) {
+                                       if ( elem.nodeType === 1 ) {
+                                               tmp.push( elem );
+                                       }
+                               }
+
+                               return tmp;
+                       }
+                       return results;
+               };
+
+       // Class
+       Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
+               if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
+                       return context.getElementsByClassName( className );
+               }
+       };
+
+       /* QSA/matchesSelector
+       ---------------------------------------------------------------------- */
+
+       // QSA and matchesSelector support
+
+       // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+       rbuggyMatches = [];
+
+       // qSa(:focus) reports false when true (Chrome 21)
+       // We allow this because of a bug in IE8/9 that throws an error
+       // whenever `document.activeElement` is accessed on an iframe
+       // So, we allow :focus to pass through QSA all the time to avoid the IE error
+       // See https://bugs.jquery.com/ticket/13378
+       rbuggyQSA = [];
+
+       if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
+
+               // Build QSA regex
+               // Regex strategy adopted from Diego Perini
+               assert( function( el ) {
+
+                       var input;
+
+                       // Select is set to empty string on purpose
+                       // This is to test IE's treatment of not explicitly
+                       // setting a boolean content attribute,
+                       // since its presence should be enough
+                       // https://bugs.jquery.com/ticket/12359
+                       docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
+                               "<select id='" + expando + "-\r\\' msallowcapture=''>" +
+                               "<option selected=''></option></select>";
+
+                       // Support: IE8, Opera 11-12.16
+                       // Nothing should be selected when empty strings follow ^= or $= or *=
+                       // The test attribute must be unknown in Opera but "safe" for WinRT
+                       // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
+                       if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
+                               rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
+                       }
+
+                       // Support: IE8
+                       // Boolean attributes and "value" are not treated correctly
+                       if ( !el.querySelectorAll( "[selected]" ).length ) {
+                               rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
+                       }
+
+                       // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
+                       if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
+                               rbuggyQSA.push( "~=" );
+                       }
+
+                       // Support: IE 11+, Edge 15 - 18+
+                       // IE 11/Edge don't find elements on a `[name='']` query in some cases.
+                       // Adding a temporary attribute to the document before the selection works
+                       // around the issue.
+                       // Interestingly, IE 10 & older don't seem to have the issue.
+                       input = document.createElement( "input" );
+                       input.setAttribute( "name", "" );
+                       el.appendChild( input );
+                       if ( !el.querySelectorAll( "[name='']" ).length ) {
+                               rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
+                                       whitespace + "*(?:''|\"\")" );
+                       }
+
+                       // Webkit/Opera - :checked should return selected option elements
+                       // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+                       // IE8 throws error here and will not see later tests
+                       if ( !el.querySelectorAll( ":checked" ).length ) {
+                               rbuggyQSA.push( ":checked" );
+                       }
+
+                       // Support: Safari 8+, iOS 8+
+                       // https://bugs.webkit.org/show_bug.cgi?id=136851
+                       // In-page `selector#id sibling-combinator selector` fails
+                       if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
+                               rbuggyQSA.push( ".#.+[+~]" );
+                       }
+
+                       // Support: Firefox <=3.6 - 5 only
+                       // Old Firefox doesn't throw on a badly-escaped identifier.
+                       el.querySelectorAll( "\\\f" );
+                       rbuggyQSA.push( "[\\r\\n\\f]" );
+               } );
+
+               assert( function( el ) {
+                       el.innerHTML = "<a href='' disabled='disabled'></a>" +
+                               "<select disabled='disabled'><option/></select>";
+
+                       // Support: Windows 8 Native Apps
+                       // The type and name attributes are restricted during .innerHTML assignment
+                       var input = document.createElement( "input" );
+                       input.setAttribute( "type", "hidden" );
+                       el.appendChild( input ).setAttribute( "name", "D" );
+
+                       // Support: IE8
+                       // Enforce case-sensitivity of name attribute
+                       if ( el.querySelectorAll( "[name=d]" ).length ) {
+                               rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
+                       }
+
+                       // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+                       // IE8 throws error here and will not see later tests
+                       if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
+                               rbuggyQSA.push( ":enabled", ":disabled" );
+                       }
+
+                       // Support: IE9-11+
+                       // IE's :disabled selector does not pick up the children of disabled fieldsets
+                       docElem.appendChild( el ).disabled = true;
+                       if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
+                               rbuggyQSA.push( ":enabled", ":disabled" );
+                       }
+
+                       // Support: Opera 10 - 11 only
+                       // Opera 10-11 does not throw on post-comma invalid pseudos
+                       el.querySelectorAll( "*,:x" );
+                       rbuggyQSA.push( ",.*:" );
+               } );
+       }
+
+       if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
+               docElem.webkitMatchesSelector ||
+               docElem.mozMatchesSelector ||
+               docElem.oMatchesSelector ||
+               docElem.msMatchesSelector ) ) ) ) {
+
+               assert( function( el ) {
+
+                       // Check to see if it's possible to do matchesSelector
+                       // on a disconnected node (IE 9)
+                       support.disconnectedMatch = matches.call( el, "*" );
+
+                       // This should fail with an exception
+                       // Gecko does not error, returns false instead
+                       matches.call( el, "[s!='']:x" );
+                       rbuggyMatches.push( "!=", pseudos );
+               } );
+       }
+
+       rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
+       rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
+
+       /* Contains
+       ---------------------------------------------------------------------- */
+       hasCompare = rnative.test( docElem.compareDocumentPosition );
+
+       // Element contains another
+       // Purposefully self-exclusive
+       // As in, an element does not contain itself
+       contains = hasCompare || rnative.test( docElem.contains ) ?
+               function( a, b ) {
+                       var adown = a.nodeType === 9 ? a.documentElement : a,
+                               bup = b && b.parentNode;
+                       return a === bup || !!( bup && bup.nodeType === 1 && (
+                               adown.contains ?
+                                       adown.contains( bup ) :
+                                       a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
+                       ) );
+               } :
+               function( a, b ) {
+                       if ( b ) {
+                               while ( ( b = b.parentNode ) ) {
+                                       if ( b === a ) {
+                                               return true;
+                                       }
+                               }
+                       }
+                       return false;
+               };
+
+       /* Sorting
+       ---------------------------------------------------------------------- */
+
+       // Document order sorting
+       sortOrder = hasCompare ?
+       function( a, b ) {
+
+               // Flag for duplicate removal
+               if ( a === b ) {
+                       hasDuplicate = true;
+                       return 0;
+               }
+
+               // Sort on method existence if only one input has compareDocumentPosition
+               var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
+               if ( compare ) {
+                       return compare;
+               }
+
+               // Calculate position if both inputs belong to the same document
+               // Support: IE 11+, Edge 17 - 18+
+               // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+               // two documents; shallow comparisons work.
+               // eslint-disable-next-line eqeqeq
+               compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
+                       a.compareDocumentPosition( b ) :
+
+                       // Otherwise we know they are disconnected
+                       1;
+
+               // Disconnected nodes
+               if ( compare & 1 ||
+                       ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
+
+                       // Choose the first element that is related to our preferred document
+                       // Support: IE 11+, Edge 17 - 18+
+                       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+                       // two documents; shallow comparisons work.
+                       // eslint-disable-next-line eqeqeq
+                       if ( a == document || a.ownerDocument == preferredDoc &&
+                               contains( preferredDoc, a ) ) {
+                               return -1;
+                       }
+
+                       // Support: IE 11+, Edge 17 - 18+
+                       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+                       // two documents; shallow comparisons work.
+                       // eslint-disable-next-line eqeqeq
+                       if ( b == document || b.ownerDocument == preferredDoc &&
+                               contains( preferredDoc, b ) ) {
+                               return 1;
+                       }
+
+                       // Maintain original order
+                       return sortInput ?
+                               ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
+                               0;
+               }
+
+               return compare & 4 ? -1 : 1;
+       } :
+       function( a, b ) {
+
+               // Exit early if the nodes are identical
+               if ( a === b ) {
+                       hasDuplicate = true;
+                       return 0;
+               }
+
+               var cur,
+                       i = 0,
+                       aup = a.parentNode,
+                       bup = b.parentNode,
+                       ap = [ a ],
+                       bp = [ b ];
+
+               // Parentless nodes are either documents or disconnected
+               if ( !aup || !bup ) {
+
+                       // Support: IE 11+, Edge 17 - 18+
+                       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+                       // two documents; shallow comparisons work.
+                       /* eslint-disable eqeqeq */
+                       return a == document ? -1 :
+                               b == document ? 1 :
+                               /* eslint-enable eqeqeq */
+                               aup ? -1 :
+                               bup ? 1 :
+                               sortInput ?
+                               ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
+                               0;
+
+               // If the nodes are siblings, we can do a quick check
+               } else if ( aup === bup ) {
+                       return siblingCheck( a, b );
+               }
+
+               // Otherwise we need full lists of their ancestors for comparison
+               cur = a;
+               while ( ( cur = cur.parentNode ) ) {
+                       ap.unshift( cur );
+               }
+               cur = b;
+               while ( ( cur = cur.parentNode ) ) {
+                       bp.unshift( cur );
+               }
+
+               // Walk down the tree looking for a discrepancy
+               while ( ap[ i ] === bp[ i ] ) {
+                       i++;
+               }
+
+               return i ?
+
+                       // Do a sibling check if the nodes have a common ancestor
+                       siblingCheck( ap[ i ], bp[ i ] ) :
+
+                       // Otherwise nodes in our document sort first
+                       // Support: IE 11+, Edge 17 - 18+
+                       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+                       // two documents; shallow comparisons work.
+                       /* eslint-disable eqeqeq */
+                       ap[ i ] == preferredDoc ? -1 :
+                       bp[ i ] == preferredDoc ? 1 :
+                       /* eslint-enable eqeqeq */
+                       0;
+       };
+
+       return document;
+};
+
+Sizzle.matches = function( expr, elements ) {
+       return Sizzle( expr, null, null, elements );
+};
+
+Sizzle.matchesSelector = function( elem, expr ) {
+       setDocument( elem );
+
+       if ( support.matchesSelector && documentIsHTML &&
+               !nonnativeSelectorCache[ expr + " " ] &&
+               ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
+               ( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {
+
+               try {
+                       var ret = matches.call( elem, expr );
+
+                       // IE 9's matchesSelector returns false on disconnected nodes
+                       if ( ret || support.disconnectedMatch ||
+
+                               // As well, disconnected nodes are said to be in a document
+                               // fragment in IE 9
+                               elem.document && elem.document.nodeType !== 11 ) {
+                               return ret;
+                       }
+               } catch ( e ) {
+                       nonnativeSelectorCache( expr, true );
+               }
+       }
+
+       return Sizzle( expr, document, null, [ elem ] ).length > 0;
+};
+
+Sizzle.contains = function( context, elem ) {
+
+       // Set document vars if needed
+       // Support: IE 11+, Edge 17 - 18+
+       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+       // two documents; shallow comparisons work.
+       // eslint-disable-next-line eqeqeq
+       if ( ( context.ownerDocument || context ) != document ) {
+               setDocument( context );
+       }
+       return contains( context, elem );
+};
+
+Sizzle.attr = function( elem, name ) {
+
+       // Set document vars if needed
+       // Support: IE 11+, Edge 17 - 18+
+       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+       // two documents; shallow comparisons work.
+       // eslint-disable-next-line eqeqeq
+       if ( ( elem.ownerDocument || elem ) != document ) {
+               setDocument( elem );
+       }
+
+       var fn = Expr.attrHandle[ name.toLowerCase() ],
+
+               // Don't get fooled by Object.prototype properties (jQuery #13807)
+               val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
+                       fn( elem, name, !documentIsHTML ) :
+                       undefined;
+
+       return val !== undefined ?
+               val :
+               support.attributes || !documentIsHTML ?
+                       elem.getAttribute( name ) :
+                       ( val = elem.getAttributeNode( name ) ) && val.specified ?
+                               val.value :
+                               null;
+};
+
+Sizzle.escape = function( sel ) {
+       return ( sel + "" ).replace( rcssescape, fcssescape );
+};
+
+Sizzle.error = function( msg ) {
+       throw new Error( "Syntax error, unrecognized expression: " + msg );
+};
+
+/**
+ * Document sorting and removing duplicates
+ * @param {ArrayLike} results
+ */
+Sizzle.uniqueSort = function( results ) {
+       var elem,
+               duplicates = [],
+               j = 0,
+               i = 0;
+
+       // Unless we *know* we can detect duplicates, assume their presence
+       hasDuplicate = !support.detectDuplicates;
+       sortInput = !support.sortStable && results.slice( 0 );
+       results.sort( sortOrder );
+
+       if ( hasDuplicate ) {
+               while ( ( elem = results[ i++ ] ) ) {
+                       if ( elem === results[ i ] ) {
+                               j = duplicates.push( i );
+                       }
+               }
+               while ( j-- ) {
+                       results.splice( duplicates[ j ], 1 );
+               }
+       }
+
+       // Clear input after sorting to release objects
+       // See https://github.com/jquery/sizzle/pull/225
+       sortInput = null;
+
+       return results;
+};
+
+/**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+getText = Sizzle.getText = function( elem ) {
+       var node,
+               ret = "",
+               i = 0,
+               nodeType = elem.nodeType;
+
+       if ( !nodeType ) {
+
+               // If no nodeType, this is expected to be an array
+               while ( ( node = elem[ i++ ] ) ) {
+
+                       // Do not traverse comment nodes
+                       ret += getText( node );
+               }
+       } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+
+               // Use textContent for elements
+               // innerText usage removed for consistency of new lines (jQuery #11153)
+               if ( typeof elem.textContent === "string" ) {
+                       return elem.textContent;
+               } else {
+
+                       // Traverse its children
+                       for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+                               ret += getText( elem );
+                       }
+               }
+       } else if ( nodeType === 3 || nodeType === 4 ) {
+               return elem.nodeValue;
+       }
+
+       // Do not include comment or processing instruction nodes
+
+       return ret;
+};
+
+Expr = Sizzle.selectors = {
+
+       // Can be adjusted by the user
+       cacheLength: 50,
+
+       createPseudo: markFunction,
+
+       match: matchExpr,
+
+       attrHandle: {},
+
+       find: {},
+
+       relative: {
+               ">": { dir: "parentNode", first: true },
+               " ": { dir: "parentNode" },
+               "+": { dir: "previousSibling", first: true },
+               "~": { dir: "previousSibling" }
+       },
+
+       preFilter: {
+               "ATTR": function( match ) {
+                       match[ 1 ] = match[ 1 ].replace( runescape, funescape );
+
+                       // Move the given value to match[3] whether quoted or unquoted
+                       match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
+                               match[ 5 ] || "" ).replace( runescape, funescape );
+
+                       if ( match[ 2 ] === "~=" ) {
+                               match[ 3 ] = " " + match[ 3 ] + " ";
+                       }
+
+                       return match.slice( 0, 4 );
+               },
+
+               "CHILD": function( match ) {
+
+                       /* matches from matchExpr["CHILD"]
+                               1 type (only|nth|...)
+                               2 what (child|of-type)
+                               3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+                               4 xn-component of xn+y argument ([+-]?\d*n|)
+                               5 sign of xn-component
+                               6 x of xn-component
+                               7 sign of y-component
+                               8 y of y-component
+                       */
+                       match[ 1 ] = match[ 1 ].toLowerCase();
+
+                       if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
+
+                               // nth-* requires argument
+                               if ( !match[ 3 ] ) {
+                                       Sizzle.error( match[ 0 ] );
+                               }
+
+                               // numeric x and y parameters for Expr.filter.CHILD
+                               // remember that false/true cast respectively to 0/1
+                               match[ 4 ] = +( match[ 4 ] ?
+                                       match[ 5 ] + ( match[ 6 ] || 1 ) :
+                                       2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
+                               match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
+
+                               // other types prohibit arguments
+                       } else if ( match[ 3 ] ) {
+                               Sizzle.error( match[ 0 ] );
+                       }
+
+                       return match;
+               },
+
+               "PSEUDO": function( match ) {
+                       var excess,
+                               unquoted = !match[ 6 ] && match[ 2 ];
+
+                       if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
+                               return null;
+                       }
+
+                       // Accept quoted arguments as-is
+                       if ( match[ 3 ] ) {
+                               match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
+
+                       // Strip excess characters from unquoted arguments
+                       } else if ( unquoted && rpseudo.test( unquoted ) &&
+
+                               // Get excess from tokenize (recursively)
+                               ( excess = tokenize( unquoted, true ) ) &&
+
+                               // advance to the next closing parenthesis
+                               ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
+
+                               // excess is a negative index
+                               match[ 0 ] = match[ 0 ].slice( 0, excess );
+                               match[ 2 ] = unquoted.slice( 0, excess );
+                       }
+
+                       // Return only captures needed by the pseudo filter method (type and argument)
+                       return match.slice( 0, 3 );
+               }
+       },
+
+       filter: {
+
+               "TAG": function( nodeNameSelector ) {
+                       var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
+                       return nodeNameSelector === "*" ?
+                               function() {
+                                       return true;
+                               } :
+                               function( elem ) {
+                                       return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+                               };
+               },
+
+               "CLASS": function( className ) {
+                       var pattern = classCache[ className + " " ];
+
+                       return pattern ||
+                               ( pattern = new RegExp( "(^|" + whitespace +
+                                       ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
+                                               className, function( elem ) {
+                                                       return pattern.test(
+                                                               typeof elem.className === "string" && elem.className ||
+                                                               typeof elem.getAttribute !== "undefined" &&
+                                                                       elem.getAttribute( "class" ) ||
+                                                               ""
+                                                       );
+                               } );
+               },
+
+               "ATTR": function( name, operator, check ) {
+                       return function( elem ) {
+                               var result = Sizzle.attr( elem, name );
+
+                               if ( result == null ) {
+                                       return operator === "!=";
+                               }
+                               if ( !operator ) {
+                                       return true;
+                               }
+
+                               result += "";
+
+                               /* eslint-disable max-len */
+
+                               return operator === "=" ? result === check :
+                                       operator === "!=" ? result !== check :
+                                       operator === "^=" ? check && result.indexOf( check ) === 0 :
+                                       operator === "*=" ? check && result.indexOf( check ) > -1 :
+                                       operator === "$=" ? check && result.slice( -check.length ) === check :
+                                       operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
+                                       operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
+                                       false;
+                               /* eslint-enable max-len */
+
+                       };
+               },
+
+               "CHILD": function( type, what, _argument, first, last ) {
+                       var simple = type.slice( 0, 3 ) !== "nth",
+                               forward = type.slice( -4 ) !== "last",
+                               ofType = what === "of-type";
+
+                       return first === 1 && last === 0 ?
+
+                               // Shortcut for :nth-*(n)
+                               function( elem ) {
+                                       return !!elem.parentNode;
+                               } :
+
+                               function( elem, _context, xml ) {
+                                       var cache, uniqueCache, outerCache, node, nodeIndex, start,
+                                               dir = simple !== forward ? "nextSibling" : "previousSibling",
+                                               parent = elem.parentNode,
+                                               name = ofType && elem.nodeName.toLowerCase(),
+                                               useCache = !xml && !ofType,
+                                               diff = false;
+
+                                       if ( parent ) {
+
+                                               // :(first|last|only)-(child|of-type)
+                                               if ( simple ) {
+                                                       while ( dir ) {
+                                                               node = elem;
+                                                               while ( ( node = node[ dir ] ) ) {
+                                                                       if ( ofType ?
+                                                                               node.nodeName.toLowerCase() === name :
+                                                                               node.nodeType === 1 ) {
+
+                                                                               return false;
+                                                                       }
+                                                               }
+
+                                                               // Reverse direction for :only-* (if we haven't yet done so)
+                                                               start = dir = type === "only" && !start && "nextSibling";
+                                                       }
+                                                       return true;
+                                               }
+
+                                               start = [ forward ? parent.firstChild : parent.lastChild ];
+
+                                               // non-xml :nth-child(...) stores cache data on `parent`
+                                               if ( forward && useCache ) {
+
+                                                       // Seek `elem` from a previously-cached index
+
+                                                       // ...in a gzip-friendly way
+                                                       node = parent;
+                                                       outerCache = node[ expando ] || ( node[ expando ] = {} );
+
+                                                       // Support: IE <9 only
+                                                       // Defend against cloned attroperties (jQuery gh-1709)
+                                                       uniqueCache = outerCache[ node.uniqueID ] ||
+                                                               ( outerCache[ node.uniqueID ] = {} );
+
+                                                       cache = uniqueCache[ type ] || [];
+                                                       nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
+                                                       diff = nodeIndex && cache[ 2 ];
+                                                       node = nodeIndex && parent.childNodes[ nodeIndex ];
+
+                                                       while ( ( node = ++nodeIndex && node && node[ dir ] ||
+
+                                                               // Fallback to seeking `elem` from the start
+                                                               ( diff = nodeIndex = 0 ) || start.pop() ) ) {
+
+                                                               // When found, cache indexes on `parent` and break
+                                                               if ( node.nodeType === 1 && ++diff && node === elem ) {
+                                                                       uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
+                                                                       break;
+                                                               }
+                                                       }
+
+                                               } else {
+
+                                                       // Use previously-cached element index if available
+                                                       if ( useCache ) {
+
+                                                               // ...in a gzip-friendly way
+                                                               node = elem;
+                                                               outerCache = node[ expando ] || ( node[ expando ] = {} );
+
+                                                               // Support: IE <9 only
+                                                               // Defend against cloned attroperties (jQuery gh-1709)
+                                                               uniqueCache = outerCache[ node.uniqueID ] ||
+                                                                       ( outerCache[ node.uniqueID ] = {} );
+
+                                                               cache = uniqueCache[ type ] || [];
+                                                               nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
+                                                               diff = nodeIndex;
+                                                       }
+
+                                                       // xml :nth-child(...)
+                                                       // or :nth-last-child(...) or :nth(-last)?-of-type(...)
+                                                       if ( diff === false ) {
+
+                                                               // Use the same loop as above to seek `elem` from the start
+                                                               while ( ( node = ++nodeIndex && node && node[ dir ] ||
+                                                                       ( diff = nodeIndex = 0 ) || start.pop() ) ) {
+
+                                                                       if ( ( ofType ?
+                                                                               node.nodeName.toLowerCase() === name :
+                                                                               node.nodeType === 1 ) &&
+                                                                               ++diff ) {
+
+                                                                               // Cache the index of each encountered element
+                                                                               if ( useCache ) {
+                                                                                       outerCache = node[ expando ] ||
+                                                                                               ( node[ expando ] = {} );
+
+                                                                                       // Support: IE <9 only
+                                                                                       // Defend against cloned attroperties (jQuery gh-1709)
+                                                                                       uniqueCache = outerCache[ node.uniqueID ] ||
+                                                                                               ( outerCache[ node.uniqueID ] = {} );
+
+                                                                                       uniqueCache[ type ] = [ dirruns, diff ];
+                                                                               }
+
+                                                                               if ( node === elem ) {
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+
+                                               // Incorporate the offset, then check against cycle size
+                                               diff -= last;
+                                               return diff === first || ( diff % first === 0 && diff / first >= 0 );
+                                       }
+                               };
+               },
+
+               "PSEUDO": function( pseudo, argument ) {
+
+                       // pseudo-class names are case-insensitive
+                       // http://www.w3.org/TR/selectors/#pseudo-classes
+                       // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+                       // Remember that setFilters inherits from pseudos
+                       var args,
+                               fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+                                       Sizzle.error( "unsupported pseudo: " + pseudo );
+
+                       // The user may use createPseudo to indicate that
+                       // arguments are needed to create the filter function
+                       // just as Sizzle does
+                       if ( fn[ expando ] ) {
+                               return fn( argument );
+                       }
+
+                       // But maintain support for old signatures
+                       if ( fn.length > 1 ) {
+                               args = [ pseudo, pseudo, "", argument ];
+                               return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+                                       markFunction( function( seed, matches ) {
+                                               var idx,
+                                                       matched = fn( seed, argument ),
+                                                       i = matched.length;
+                                               while ( i-- ) {
+                                                       idx = indexOf( seed, matched[ i ] );
+                                                       seed[ idx ] = !( matches[ idx ] = matched[ i ] );
+                                               }
+                                       } ) :
+                                       function( elem ) {
+                                               return fn( elem, 0, args );
+                                       };
+                       }
+
+                       return fn;
+               }
+       },
+
+       pseudos: {
+
+               // Potentially complex pseudos
+               "not": markFunction( function( selector ) {
+
+                       // Trim the selector passed to compile
+                       // to avoid treating leading and trailing
+                       // spaces as combinators
+                       var input = [],
+                               results = [],
+                               matcher = compile( selector.replace( rtrim, "$1" ) );
+
+                       return matcher[ expando ] ?
+                               markFunction( function( seed, matches, _context, xml ) {
+                                       var elem,
+                                               unmatched = matcher( seed, null, xml, [] ),
+                                               i = seed.length;
+
+                                       // Match elements unmatched by `matcher`
+                                       while ( i-- ) {
+                                               if ( ( elem = unmatched[ i ] ) ) {
+                                                       seed[ i ] = !( matches[ i ] = elem );
+                                               }
+                                       }
+                               } ) :
+                               function( elem, _context, xml ) {
+                                       input[ 0 ] = elem;
+                                       matcher( input, null, xml, results );
+
+                                       // Don't keep the element (issue #299)
+                                       input[ 0 ] = null;
+                                       return !results.pop();
+                               };
+               } ),
+
+               "has": markFunction( function( selector ) {
+                       return function( elem ) {
+                               return Sizzle( selector, elem ).length > 0;
+                       };
+               } ),
+
+               "contains": markFunction( function( text ) {
+                       text = text.replace( runescape, funescape );
+                       return function( elem ) {
+                               return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
+                       };
+               } ),
+
+               // "Whether an element is represented by a :lang() selector
+               // is based solely on the element's language value
+               // being equal to the identifier C,
+               // or beginning with the identifier C immediately followed by "-".
+               // The matching of C against the element's language value is performed case-insensitively.
+               // The identifier C does not have to be a valid language name."
+               // http://www.w3.org/TR/selectors/#lang-pseudo
+               "lang": markFunction( function( lang ) {
+
+                       // lang value must be a valid identifier
+                       if ( !ridentifier.test( lang || "" ) ) {
+                               Sizzle.error( "unsupported lang: " + lang );
+                       }
+                       lang = lang.replace( runescape, funescape ).toLowerCase();
+                       return function( elem ) {
+                               var elemLang;
+                               do {
+                                       if ( ( elemLang = documentIsHTML ?
+                                               elem.lang :
+                                               elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
+
+                                               elemLang = elemLang.toLowerCase();
+                                               return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
+                                       }
+                               } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
+                               return false;
+                       };
+               } ),
+
+               // Miscellaneous
+               "target": function( elem ) {
+                       var hash = window.location && window.location.hash;
+                       return hash && hash.slice( 1 ) === elem.id;
+               },
+
+               "root": function( elem ) {
+                       return elem === docElem;
+               },
+
+               "focus": function( elem ) {
+                       return elem === document.activeElement &&
+                               ( !document.hasFocus || document.hasFocus() ) &&
+                               !!( elem.type || elem.href || ~elem.tabIndex );
+               },
+
+               // Boolean properties
+               "enabled": createDisabledPseudo( false ),
+               "disabled": createDisabledPseudo( true ),
+
+               "checked": function( elem ) {
+
+                       // In CSS3, :checked should return both checked and selected elements
+                       // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+                       var nodeName = elem.nodeName.toLowerCase();
+                       return ( nodeName === "input" && !!elem.checked ) ||
+                               ( nodeName === "option" && !!elem.selected );
+               },
+
+               "selected": function( elem ) {
+
+                       // Accessing this property makes selected-by-default
+                       // options in Safari work properly
+                       if ( elem.parentNode ) {
+                               // eslint-disable-next-line no-unused-expressions
+                               elem.parentNode.selectedIndex;
+                       }
+
+                       return elem.selected === true;
+               },
+
+               // Contents
+               "empty": function( elem ) {
+
+                       // http://www.w3.org/TR/selectors/#empty-pseudo
+                       // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
+                       //   but not by others (comment: 8; processing instruction: 7; etc.)
+                       // nodeType < 6 works because attributes (2) do not appear as children
+                       for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+                               if ( elem.nodeType < 6 ) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               },
+
+               "parent": function( elem ) {
+                       return !Expr.pseudos[ "empty" ]( elem );
+               },
+
+               // Element/input types
+               "header": function( elem ) {
+                       return rheader.test( elem.nodeName );
+               },
+
+               "input": function( elem ) {
+                       return rinputs.test( elem.nodeName );
+               },
+
+               "button": function( elem ) {
+                       var name = elem.nodeName.toLowerCase();
+                       return name === "input" && elem.type === "button" || name === "button";
+               },
+
+               "text": function( elem ) {
+                       var attr;
+                       return elem.nodeName.toLowerCase() === "input" &&
+                               elem.type === "text" &&
+
+                               // Support: IE<8
+                               // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
+                               ( ( attr = elem.getAttribute( "type" ) ) == null ||
+                                       attr.toLowerCase() === "text" );
+               },
+
+               // Position-in-collection
+               "first": createPositionalPseudo( function() {
+                       return [ 0 ];
+               } ),
+
+               "last": createPositionalPseudo( function( _matchIndexes, length ) {
+                       return [ length - 1 ];
+               } ),
+
+               "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
+                       return [ argument < 0 ? argument + length : argument ];
+               } ),
+
+               "even": createPositionalPseudo( function( matchIndexes, length ) {
+                       var i = 0;
+                       for ( ; i < length; i += 2 ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               } ),
+
+               "odd": createPositionalPseudo( function( matchIndexes, length ) {
+                       var i = 1;
+                       for ( ; i < length; i += 2 ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               } ),
+
+               "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
+                       var i = argument < 0 ?
+                               argument + length :
+                               argument > length ?
+                                       length :
+                                       argument;
+                       for ( ; --i >= 0; ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               } ),
+
+               "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
+                       var i = argument < 0 ? argument + length : argument;
+                       for ( ; ++i < length; ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               } )
+       }
+};
+
+Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
+
+// Add button/input type pseudos
+for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
+       Expr.pseudos[ i ] = createInputPseudo( i );
+}
+for ( i in { submit: true, reset: true } ) {
+       Expr.pseudos[ i ] = createButtonPseudo( i );
+}
+
+// Easy API for creating new setFilters
+function setFilters() {}
+setFilters.prototype = Expr.filters = Expr.pseudos;
+Expr.setFilters = new setFilters();
+
+tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
+       var matched, match, tokens, type,
+               soFar, groups, preFilters,
+               cached = tokenCache[ selector + " " ];
+
+       if ( cached ) {
+               return parseOnly ? 0 : cached.slice( 0 );
+       }
+
+       soFar = selector;
+       groups = [];
+       preFilters = Expr.preFilter;
+
+       while ( soFar ) {
+
+               // Comma and first run
+               if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
+                       if ( match ) {
+
+                               // Don't consume trailing commas as valid
+                               soFar = soFar.slice( match[ 0 ].length ) || soFar;
+                       }
+                       groups.push( ( tokens = [] ) );
+               }
+
+               matched = false;
+
+               // Combinators
+               if ( ( match = rcombinators.exec( soFar ) ) ) {
+                       matched = match.shift();
+                       tokens.push( {
+                               value: matched,
+
+                               // Cast descendant combinators to space
+                               type: match[ 0 ].replace( rtrim, " " )
+                       } );
+                       soFar = soFar.slice( matched.length );
+               }
+
+               // Filters
+               for ( type in Expr.filter ) {
+                       if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
+                               ( match = preFilters[ type ]( match ) ) ) ) {
+                               matched = match.shift();
+                               tokens.push( {
+                                       value: matched,
+                                       type: type,
+                                       matches: match
+                               } );
+                               soFar = soFar.slice( matched.length );
+                       }
+               }
+
+               if ( !matched ) {
+                       break;
+               }
+       }
+
+       // Return the length of the invalid excess
+       // if we're just parsing
+       // Otherwise, throw an error or return tokens
+       return parseOnly ?
+               soFar.length :
+               soFar ?
+                       Sizzle.error( selector ) :
+
+                       // Cache the tokens
+                       tokenCache( selector, groups ).slice( 0 );
+};
+
+function toSelector( tokens ) {
+       var i = 0,
+               len = tokens.length,
+               selector = "";
+       for ( ; i < len; i++ ) {
+               selector += tokens[ i ].value;
+       }
+       return selector;
+}
+
+function addCombinator( matcher, combinator, base ) {
+       var dir = combinator.dir,
+               skip = combinator.next,
+               key = skip || dir,
+               checkNonElements = base && key === "parentNode",
+               doneName = done++;
+
+       return combinator.first ?
+
+               // Check against closest ancestor/preceding element
+               function( elem, context, xml ) {
+                       while ( ( elem = elem[ dir ] ) ) {
+                               if ( elem.nodeType === 1 || checkNonElements ) {
+                                       return matcher( elem, context, xml );
+                               }
+                       }
+                       return false;
+               } :
+
+               // Check against all ancestor/preceding elements
+               function( elem, context, xml ) {
+                       var oldCache, uniqueCache, outerCache,
+                               newCache = [ dirruns, doneName ];
+
+                       // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
+                       if ( xml ) {
+                               while ( ( elem = elem[ dir ] ) ) {
+                                       if ( elem.nodeType === 1 || checkNonElements ) {
+                                               if ( matcher( elem, context, xml ) ) {
+                                                       return true;
+                                               }
+                                       }
+                               }
+                       } else {
+                               while ( ( elem = elem[ dir ] ) ) {
+                                       if ( elem.nodeType === 1 || checkNonElements ) {
+                                               outerCache = elem[ expando ] || ( elem[ expando ] = {} );
+
+                                               // Support: IE <9 only
+                                               // Defend against cloned attroperties (jQuery gh-1709)
+                                               uniqueCache = outerCache[ elem.uniqueID ] ||
+                                                       ( outerCache[ elem.uniqueID ] = {} );
+
+                                               if ( skip && skip === elem.nodeName.toLowerCase() ) {
+                                                       elem = elem[ dir ] || elem;
+                                               } else if ( ( oldCache = uniqueCache[ key ] ) &&
+                                                       oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
+
+                                                       // Assign to newCache so results back-propagate to previous elements
+                                                       return ( newCache[ 2 ] = oldCache[ 2 ] );
+                                               } else {
+
+                                                       // Reuse newcache so results back-propagate to previous elements
+                                                       uniqueCache[ key ] = newCache;
+
+                                                       // A match means we're done; a fail means we have to keep checking
+                                                       if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
+                                                               return true;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       return false;
+               };
+}
+
+function elementMatcher( matchers ) {
+       return matchers.length > 1 ?
+               function( elem, context, xml ) {
+                       var i = matchers.length;
+                       while ( i-- ) {
+                               if ( !matchers[ i ]( elem, context, xml ) ) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               } :
+               matchers[ 0 ];
+}
+
+function multipleContexts( selector, contexts, results ) {
+       var i = 0,
+               len = contexts.length;
+       for ( ; i < len; i++ ) {
+               Sizzle( selector, contexts[ i ], results );
+       }
+       return results;
+}
+
+function condense( unmatched, map, filter, context, xml ) {
+       var elem,
+               newUnmatched = [],
+               i = 0,
+               len = unmatched.length,
+               mapped = map != null;
+
+       for ( ; i < len; i++ ) {
+               if ( ( elem = unmatched[ i ] ) ) {
+                       if ( !filter || filter( elem, context, xml ) ) {
+                               newUnmatched.push( elem );
+                               if ( mapped ) {
+                                       map.push( i );
+                               }
+                       }
+               }
+       }
+
+       return newUnmatched;
+}
+
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+       if ( postFilter && !postFilter[ expando ] ) {
+               postFilter = setMatcher( postFilter );
+       }
+       if ( postFinder && !postFinder[ expando ] ) {
+               postFinder = setMatcher( postFinder, postSelector );
+       }
+       return markFunction( function( seed, results, context, xml ) {
+               var temp, i, elem,
+                       preMap = [],
+                       postMap = [],
+                       preexisting = results.length,
+
+                       // Get initial elements from seed or context
+                       elems = seed || multipleContexts(
+                               selector || "*",
+                               context.nodeType ? [ context ] : context,
+                               []
+                       ),
+
+                       // Prefilter to get matcher input, preserving a map for seed-results synchronization
+                       matcherIn = preFilter && ( seed || !selector ) ?
+                               condense( elems, preMap, preFilter, context, xml ) :
+                               elems,
+
+                       matcherOut = matcher ?
+
+                               // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+                               postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+                                       // ...intermediate processing is necessary
+                                       [] :
+
+                                       // ...otherwise use results directly
+                                       results :
+                               matcherIn;
+
+               // Find primary matches
+               if ( matcher ) {
+                       matcher( matcherIn, matcherOut, context, xml );
+               }
+
+               // Apply postFilter
+               if ( postFilter ) {
+                       temp = condense( matcherOut, postMap );
+                       postFilter( temp, [], context, xml );
+
+                       // Un-match failing elements by moving them back to matcherIn
+                       i = temp.length;
+                       while ( i-- ) {
+                               if ( ( elem = temp[ i ] ) ) {
+                                       matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
+                               }
+                       }
+               }
+
+               if ( seed ) {
+                       if ( postFinder || preFilter ) {
+                               if ( postFinder ) {
+
+                                       // Get the final matcherOut by condensing this intermediate into postFinder contexts
+                                       temp = [];
+                                       i = matcherOut.length;
+                                       while ( i-- ) {
+                                               if ( ( elem = matcherOut[ i ] ) ) {
+
+                                                       // Restore matcherIn since elem is not yet a final match
+                                                       temp.push( ( matcherIn[ i ] = elem ) );
+                                               }
+                                       }
+                                       postFinder( null, ( matcherOut = [] ), temp, xml );
+                               }
+
+                               // Move matched elements from seed to results to keep them synchronized
+                               i = matcherOut.length;
+                               while ( i-- ) {
+                                       if ( ( elem = matcherOut[ i ] ) &&
+                                               ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
+
+                                               seed[ temp ] = !( results[ temp ] = elem );
+                                       }
+                               }
+                       }
+
+               // Add elements to results, through postFinder if defined
+               } else {
+                       matcherOut = condense(
+                               matcherOut === results ?
+                                       matcherOut.splice( preexisting, matcherOut.length ) :
+                                       matcherOut
+                       );
+                       if ( postFinder ) {
+                               postFinder( null, results, matcherOut, xml );
+                       } else {
+                               push.apply( results, matcherOut );
+                       }
+               }
+       } );
+}
+
+function matcherFromTokens( tokens ) {
+       var checkContext, matcher, j,
+               len = tokens.length,
+               leadingRelative = Expr.relative[ tokens[ 0 ].type ],
+               implicitRelative = leadingRelative || Expr.relative[ " " ],
+               i = leadingRelative ? 1 : 0,
+
+               // The foundational matcher ensures that elements are reachable from top-level context(s)
+               matchContext = addCombinator( function( elem ) {
+                       return elem === checkContext;
+               }, implicitRelative, true ),
+               matchAnyContext = addCombinator( function( elem ) {
+                       return indexOf( checkContext, elem ) > -1;
+               }, implicitRelative, true ),
+               matchers = [ function( elem, context, xml ) {
+                       var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+                               ( checkContext = context ).nodeType ?
+                                       matchContext( elem, context, xml ) :
+                                       matchAnyContext( elem, context, xml ) );
+
+                       // Avoid hanging onto element (issue #299)
+                       checkContext = null;
+                       return ret;
+               } ];
+
+       for ( ; i < len; i++ ) {
+               if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
+                       matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
+               } else {
+                       matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
+
+                       // Return special upon seeing a positional matcher
+                       if ( matcher[ expando ] ) {
+
+                               // Find the next relative operator (if any) for proper handling
+                               j = ++i;
+                               for ( ; j < len; j++ ) {
+                                       if ( Expr.relative[ tokens[ j ].type ] ) {
+                                               break;
+                                       }
+                               }
+                               return setMatcher(
+                                       i > 1 && elementMatcher( matchers ),
+                                       i > 1 && toSelector(
+
+                                       // If the preceding token was a descendant combinator, insert an implicit any-element `*`
+                                       tokens
+                                               .slice( 0, i - 1 )
+                                               .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
+                                       ).replace( rtrim, "$1" ),
+                                       matcher,
+                                       i < j && matcherFromTokens( tokens.slice( i, j ) ),
+                                       j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
+                                       j < len && toSelector( tokens )
+                               );
+                       }
+                       matchers.push( matcher );
+               }
+       }
+
+       return elementMatcher( matchers );
+}
+
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+       var bySet = setMatchers.length > 0,
+               byElement = elementMatchers.length > 0,
+               superMatcher = function( seed, context, xml, results, outermost ) {
+                       var elem, j, matcher,
+                               matchedCount = 0,
+                               i = "0",
+                               unmatched = seed && [],
+                               setMatched = [],
+                               contextBackup = outermostContext,
+
+                               // We must always have either seed elements or outermost context
+                               elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
+
+                               // Use integer dirruns iff this is the outermost matcher
+                               dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
+                               len = elems.length;
+
+                       if ( outermost ) {
+
+                               // Support: IE 11+, Edge 17 - 18+
+                               // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+                               // two documents; shallow comparisons work.
+                               // eslint-disable-next-line eqeqeq
+                               outermostContext = context == document || context || outermost;
+                       }
+
+                       // Add elements passing elementMatchers directly to results
+                       // Support: IE<9, Safari
+                       // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
+                       for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
+                               if ( byElement && elem ) {
+                                       j = 0;
+
+                                       // Support: IE 11+, Edge 17 - 18+
+                                       // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
+                                       // two documents; shallow comparisons work.
+                                       // eslint-disable-next-line eqeqeq
+                                       if ( !context && elem.ownerDocument != document ) {
+                                               setDocument( elem );
+                                               xml = !documentIsHTML;
+                                       }
+                                       while ( ( matcher = elementMatchers[ j++ ] ) ) {
+                                               if ( matcher( elem, context || document, xml ) ) {
+                                                       results.push( elem );
+                                                       break;
+                                               }
+                                       }
+                                       if ( outermost ) {
+                                               dirruns = dirrunsUnique;
+                                       }
+                               }
+
+                               // Track unmatched elements for set filters
+                               if ( bySet ) {
+
+                                       // They will have gone through all possible matchers
+                                       if ( ( elem = !matcher && elem ) ) {
+                                               matchedCount--;
+                                       }
+
+                                       // Lengthen the array for every element, matched or not
+                                       if ( seed ) {
+                                               unmatched.push( elem );
+                                       }
+                               }
+                       }
+
+                       // `i` is now the count of elements visited above, and adding it to `matchedCount`
+                       // makes the latter nonnegative.
+                       matchedCount += i;
+
+                       // Apply set filters to unmatched elements
+                       // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
+                       // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
+                       // no element matchers and no seed.
+                       // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
+                       // case, which will result in a "00" `matchedCount` that differs from `i` but is also
+                       // numerically zero.
+                       if ( bySet && i !== matchedCount ) {
+                               j = 0;
+                               while ( ( matcher = setMatchers[ j++ ] ) ) {
+                                       matcher( unmatched, setMatched, context, xml );
+                               }
+
+                               if ( seed ) {
+
+                                       // Reintegrate element matches to eliminate the need for sorting
+                                       if ( matchedCount > 0 ) {
+                                               while ( i-- ) {
+                                                       if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
+                                                               setMatched[ i ] = pop.call( results );
+                                                       }
+                                               }
+                                       }
+
+                                       // Discard index placeholder values to get only actual matches
+                                       setMatched = condense( setMatched );
+                               }
+
+                               // Add matches to results
+                               push.apply( results, setMatched );
+
+                               // Seedless set matches succeeding multiple successful matchers stipulate sorting
+                               if ( outermost && !seed && setMatched.length > 0 &&
+                                       ( matchedCount + setMatchers.length ) > 1 ) {
+
+                                       Sizzle.uniqueSort( results );
+                               }
+                       }
+
+                       // Override manipulation of globals by nested matchers
+                       if ( outermost ) {
+                               dirruns = dirrunsUnique;
+                               outermostContext = contextBackup;
+                       }
+
+                       return unmatched;
+               };
+
+       return bySet ?
+               markFunction( superMatcher ) :
+               superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
+       var i,
+               setMatchers = [],
+               elementMatchers = [],
+               cached = compilerCache[ selector + " " ];
+
+       if ( !cached ) {
+
+               // Generate a function of recursive functions that can be used to check each element
+               if ( !match ) {
+                       match = tokenize( selector );
+               }
+               i = match.length;
+               while ( i-- ) {
+                       cached = matcherFromTokens( match[ i ] );
+                       if ( cached[ expando ] ) {
+                               setMatchers.push( cached );
+                       } else {
+                               elementMatchers.push( cached );
+                       }
+               }
+
+               // Cache the compiled function
+               cached = compilerCache(
+                       selector,
+                       matcherFromGroupMatchers( elementMatchers, setMatchers )
+               );
+
+               // Save selector and tokenization
+               cached.selector = selector;
+       }
+       return cached;
+};
+
+/**
+ * A low-level selection function that works with Sizzle's compiled
+ *  selector functions
+ * @param {String|Function} selector A selector or a pre-compiled
+ *  selector function built with Sizzle.compile
+ * @param {Element} context
+ * @param {Array} [results]
+ * @param {Array} [seed] A set of elements to match against
+ */
+select = Sizzle.select = function( selector, context, results, seed ) {
+       var i, tokens, token, type, find,
+               compiled = typeof selector === "function" && selector,
+               match = !seed && tokenize( ( selector = compiled.selector || selector ) );
+
+       results = results || [];
+
+       // Try to minimize operations if there is only one selector in the list and no seed
+       // (the latter of which guarantees us context)
+       if ( match.length === 1 ) {
+
+               // Reduce context if the leading compound selector is an ID
+               tokens = match[ 0 ] = match[ 0 ].slice( 0 );
+               if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
+                       context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
+
+                       context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
+                               .replace( runescape, funescape ), context ) || [] )[ 0 ];
+                       if ( !context ) {
+                               return results;
+
+                       // Precompiled matchers will still verify ancestry, so step up a level
+                       } else if ( compiled ) {
+                               context = context.parentNode;
+                       }
+
+                       selector = selector.slice( tokens.shift().value.length );
+               }
+
+               // Fetch a seed set for right-to-left matching
+               i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
+               while ( i-- ) {
+                       token = tokens[ i ];
+
+                       // Abort if we hit a combinator
+                       if ( Expr.relative[ ( type = token.type ) ] ) {
+                               break;
+                       }
+                       if ( ( find = Expr.find[ type ] ) ) {
+
+                               // Search, expanding context for leading sibling combinators
+                               if ( ( seed = find(
+                                       token.matches[ 0 ].replace( runescape, funescape ),
+                                       rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
+                                               context
+                               ) ) ) {
+
+                                       // If seed is empty or no tokens remain, we can return early
+                                       tokens.splice( i, 1 );
+                                       selector = seed.length && toSelector( tokens );
+                                       if ( !selector ) {
+                                               push.apply( results, seed );
+                                               return results;
+                                       }
+
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       // Compile and execute a filtering function if one is not provided
+       // Provide `match` to avoid retokenization if we modified the selector above
+       ( compiled || compile( selector, match ) )(
+               seed,
+               context,
+               !documentIsHTML,
+               results,
+               !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
+       );
+       return results;
+};
+
+// One-time assignments
+
+// Sort stability
+support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
+
+// Support: Chrome 14-35+
+// Always assume duplicates if they aren't passed to the comparison function
+support.detectDuplicates = !!hasDuplicate;
+
+// Initialize against the default document
+setDocument();
+
+// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
+// Detached nodes confoundingly follow *each other*
+support.sortDetached = assert( function( el ) {
+
+       // Should return 1, but returns 4 (following)
+       return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
+} );
+
+// Support: IE<8
+// Prevent attribute/property "interpolation"
+// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
+if ( !assert( function( el ) {
+       el.innerHTML = "<a href='#'></a>";
+       return el.firstChild.getAttribute( "href" ) === "#";
+} ) ) {
+       addHandle( "type|href|height|width", function( elem, name, isXML ) {
+               if ( !isXML ) {
+                       return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
+               }
+       } );
+}
+
+// Support: IE<9
+// Use defaultValue in place of getAttribute("value")
+if ( !support.attributes || !assert( function( el ) {
+       el.innerHTML = "<input/>";
+       el.firstChild.setAttribute( "value", "" );
+       return el.firstChild.getAttribute( "value" ) === "";
+} ) ) {
+       addHandle( "value", function( elem, _name, isXML ) {
+               if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
+                       return elem.defaultValue;
+               }
+       } );
+}
+
+// Support: IE<9
+// Use getAttributeNode to fetch booleans when getAttribute lies
+if ( !assert( function( el ) {
+       return el.getAttribute( "disabled" ) == null;
+} ) ) {
+       addHandle( booleans, function( elem, name, isXML ) {
+               var val;
+               if ( !isXML ) {
+                       return elem[ name ] === true ? name.toLowerCase() :
+                               ( val = elem.getAttributeNode( name ) ) && val.specified ?
+                                       val.value :
+                                       null;
+               }
+       } );
+}
+
+return Sizzle;
+
+} )( window );
+
+
+
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+
+// Deprecated
+jQuery.expr[ ":" ] = jQuery.expr.pseudos;
+jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+jQuery.escapeSelector = Sizzle.escape;
+
+
+
+
+var dir = function( elem, dir, until ) {
+       var matched = [],
+               truncate = until !== undefined;
+
+       while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
+               if ( elem.nodeType === 1 ) {
+                       if ( truncate && jQuery( elem ).is( until ) ) {
+                               break;
+                       }
+                       matched.push( elem );
+               }
+       }
+       return matched;
+};
+
+
+var siblings = function( n, elem ) {
+       var matched = [];
+
+       for ( ; n; n = n.nextSibling ) {
+               if ( n.nodeType === 1 && n !== elem ) {
+                       matched.push( n );
+               }
+       }
+
+       return matched;
+};
+
+
+var rneedsContext = jQuery.expr.match.needsContext;
+
+
+
+function nodeName( elem, name ) {
+
+  return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+
+};
+var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
+
+
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, not ) {
+       if ( isFunction( qualifier ) ) {
+               return jQuery.grep( elements, function( elem, i ) {
+                       return !!qualifier.call( elem, i, elem ) !== not;
+               } );
+       }
+
+       // Single element
+       if ( qualifier.nodeType ) {
+               return jQuery.grep( elements, function( elem ) {
+                       return ( elem === qualifier ) !== not;
+               } );
+       }
+
+       // Arraylike of elements (jQuery, arguments, Array)
+       if ( typeof qualifier !== "string" ) {
+               return jQuery.grep( elements, function( elem ) {
+                       return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
+               } );
+       }
+
+       // Filtered directly for both simple and complex selectors
+       return jQuery.filter( qualifier, elements, not );
+}
+
+jQuery.filter = function( expr, elems, not ) {
+       var elem = elems[ 0 ];
+
+       if ( not ) {
+               expr = ":not(" + expr + ")";
+       }
+
+       if ( elems.length === 1 && elem.nodeType === 1 ) {
+               return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
+       }
+
+       return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
+               return elem.nodeType === 1;
+       } ) );
+};
+
+jQuery.fn.extend( {
+       find: function( selector ) {
+               var i, ret,
+                       len = this.length,
+                       self = this;
+
+               if ( typeof selector !== "string" ) {
+                       return this.pushStack( jQuery( selector ).filter( function() {
+                               for ( i = 0; i < len; i++ ) {
+                                       if ( jQuery.contains( self[ i ], this ) ) {
+                                               return true;
+                                       }
+                               }
+                       } ) );
+               }
+
+               ret = this.pushStack( [] );
+
+               for ( i = 0; i < len; i++ ) {
+                       jQuery.find( selector, self[ i ], ret );
+               }
+
+               return len > 1 ? jQuery.uniqueSort( ret ) : ret;
+       },
+       filter: function( selector ) {
+               return this.pushStack( winnow( this, selector || [], false ) );
+       },
+       not: function( selector ) {
+               return this.pushStack( winnow( this, selector || [], true ) );
+       },
+       is: function( selector ) {
+               return !!winnow(
+                       this,
+
+                       // If this is a positional/relative selector, check membership in the returned set
+                       // so $("p:first").is("p:last") won't return true for a doc with two "p".
+                       typeof selector === "string" && rneedsContext.test( selector ) ?
+                               jQuery( selector ) :
+                               selector || [],
+                       false
+               ).length;
+       }
+} );
+
+
+// Initialize a jQuery object
+
+
+// A central reference to the root jQuery(document)
+var rootjQuery,
+
+       // A simple way to check for HTML strings
+       // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
+       // Strict HTML recognition (#11290: must start with <)
+       // Shortcut simple #id case for speed
+       rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
+
+       init = jQuery.fn.init = function( selector, context, root ) {
+               var match, elem;
+
+               // HANDLE: $(""), $(null), $(undefined), $(false)
+               if ( !selector ) {
+                       return this;
+               }
+
+               // Method init() accepts an alternate rootjQuery
+               // so migrate can support jQuery.sub (gh-2101)
+               root = root || rootjQuery;
+
+               // Handle HTML strings
+               if ( typeof selector === "string" ) {
+                       if ( selector[ 0 ] === "<" &&
+                               selector[ selector.length - 1 ] === ">" &&
+                               selector.length >= 3 ) {
+
+                               // Assume that strings that start and end with <> are HTML and skip the regex check
+                               match = [ null, selector, null ];
+
+                       } else {
+                               match = rquickExpr.exec( selector );
+                       }
+
+                       // Match html or make sure no context is specified for #id
+                       if ( match && ( match[ 1 ] || !context ) ) {
+
+                               // HANDLE: $(html) -> $(array)
+                               if ( match[ 1 ] ) {
+                                       context = context instanceof jQuery ? context[ 0 ] : context;
+
+                                       // Option to run scripts is true for back-compat
+                                       // Intentionally let the error be thrown if parseHTML is not present
+                                       jQuery.merge( this, jQuery.parseHTML(
+                                               match[ 1 ],
+                                               context && context.nodeType ? context.ownerDocument || context : document,
+                                               true
+                                       ) );
+
+                                       // HANDLE: $(html, props)
+                                       if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
+                                               for ( match in context ) {
+
+                                                       // Properties of context are called as methods if possible
+                                                       if ( isFunction( this[ match ] ) ) {
+                                                               this[ match ]( context[ match ] );
+
+                                                       // ...and otherwise set as attributes
+                                                       } else {
+                                                               this.attr( match, context[ match ] );
+                                                       }
+                                               }
+                                       }
+
+                                       return this;
+
+                               // HANDLE: $(#id)
+                               } else {
+                                       elem = document.getElementById( match[ 2 ] );
+
+                                       if ( elem ) {
+
+                                               // Inject the element directly into the jQuery object
+                                               this[ 0 ] = elem;
+                                               this.length = 1;
+                                       }
+                                       return this;
+                               }
+
+                       // HANDLE: $(expr, $(...))
+                       } else if ( !context || context.jquery ) {
+                               return ( context || root ).find( selector );
+
+                       // HANDLE: $(expr, context)
+                       // (which is just equivalent to: $(context).find(expr)
+                       } else {
+                               return this.constructor( context ).find( selector );
+                       }
+
+               // HANDLE: $(DOMElement)
+               } else if ( selector.nodeType ) {
+                       this[ 0 ] = selector;
+                       this.length = 1;
+                       return this;
+
+               // HANDLE: $(function)
+               // Shortcut for document ready
+               } else if ( isFunction( selector ) ) {
+                       return root.ready !== undefined ?
+                               root.ready( selector ) :
+
+                               // Execute immediately if ready is not present
+                               selector( jQuery );
+               }
+
+               return jQuery.makeArray( selector, this );
+       };
+
+// Give the init function the jQuery prototype for later instantiation
+init.prototype = jQuery.fn;
+
+// Initialize central reference
+rootjQuery = jQuery( document );
+
+
+var rparentsprev = /^(?:parents|prev(?:Until|All))/,
+
+       // Methods guaranteed to produce a unique set when starting from a unique set
+       guaranteedUnique = {
+               children: true,
+               contents: true,
+               next: true,
+               prev: true
+       };
+
+jQuery.fn.extend( {
+       has: function( target ) {
+               var targets = jQuery( target, this ),
+                       l = targets.length;
+
+               return this.filter( function() {
+                       var i = 0;
+                       for ( ; i < l; i++ ) {
+                               if ( jQuery.contains( this, targets[ i ] ) ) {
+                                       return true;
+                               }
+                       }
+               } );
+       },
+
+       closest: function( selectors, context ) {
+               var cur,
+                       i = 0,
+                       l = this.length,
+                       matched = [],
+                       targets = typeof selectors !== "string" && jQuery( selectors );
+
+               // Positional selectors never match, since there's no _selection_ context
+               if ( !rneedsContext.test( selectors ) ) {
+                       for ( ; i < l; i++ ) {
+                               for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
+
+                                       // Always skip document fragments
+                                       if ( cur.nodeType < 11 && ( targets ?
+                                               targets.index( cur ) > -1 :
+
+                                               // Don't pass non-elements to Sizzle
+                                               cur.nodeType === 1 &&
+                                                       jQuery.find.matchesSelector( cur, selectors ) ) ) {
+
+                                               matched.push( cur );
+                                               break;
+                                       }
+                               }
+                       }
+               }
+
+               return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
+       },
+
+       // Determine the position of an element within the set
+       index: function( elem ) {
+
+               // No argument, return index in parent
+               if ( !elem ) {
+                       return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
+               }
+
+               // Index in selector
+               if ( typeof elem === "string" ) {
+                       return indexOf.call( jQuery( elem ), this[ 0 ] );
+               }
+
+               // Locate the position of the desired element
+               return indexOf.call( this,
+
+                       // If it receives a jQuery object, the first element is used
+                       elem.jquery ? elem[ 0 ] : elem
+               );
+       },
+
+       add: function( selector, context ) {
+               return this.pushStack(
+                       jQuery.uniqueSort(
+                               jQuery.merge( this.get(), jQuery( selector, context ) )
+                       )
+               );
+       },
+
+       addBack: function( selector ) {
+               return this.add( selector == null ?
+                       this.prevObject : this.prevObject.filter( selector )
+               );
+       }
+} );
+
+function sibling( cur, dir ) {
+       while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
+       return cur;
+}
+
+jQuery.each( {
+       parent: function( elem ) {
+               var parent = elem.parentNode;
+               return parent && parent.nodeType !== 11 ? parent : null;
+       },
+       parents: function( elem ) {
+               return dir( elem, "parentNode" );
+       },
+       parentsUntil: function( elem, _i, until ) {
+               return dir( elem, "parentNode", until );
+       },
+       next: function( elem ) {
+               return sibling( elem, "nextSibling" );
+       },
+       prev: function( elem ) {
+               return sibling( elem, "previousSibling" );
+       },
+       nextAll: function( elem ) {
+               return dir( elem, "nextSibling" );
+       },
+       prevAll: function( elem ) {
+               return dir( elem, "previousSibling" );
+       },
+       nextUntil: function( elem, _i, until ) {
+               return dir( elem, "nextSibling", until );
+       },
+       prevUntil: function( elem, _i, until ) {
+               return dir( elem, "previousSibling", until );
+       },
+       siblings: function( elem ) {
+               return siblings( ( elem.parentNode || {} ).firstChild, elem );
+       },
+       children: function( elem ) {
+               return siblings( elem.firstChild );
+       },
+       contents: function( elem ) {
+               if ( elem.contentDocument != null &&
+
+                       // Support: IE 11+
+                       // <object> elements with no `data` attribute has an object
+                       // `contentDocument` with a `null` prototype.
+                       getProto( elem.contentDocument ) ) {
+
+                       return elem.contentDocument;
+               }
+
+               // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
+               // Treat the template element as a regular one in browsers that
+               // don't support it.
+               if ( nodeName( elem, "template" ) ) {
+                       elem = elem.content || elem;
+               }
+
+               return jQuery.merge( [], elem.childNodes );
+       }
+}, function( name, fn ) {
+       jQuery.fn[ name ] = function( until, selector ) {
+               var matched = jQuery.map( this, fn, until );
+
+               if ( name.slice( -5 ) !== "Until" ) {
+                       selector = until;
+               }
+
+               if ( selector && typeof selector === "string" ) {
+                       matched = jQuery.filter( selector, matched );
+               }
+
+               if ( this.length > 1 ) {
+
+                       // Remove duplicates
+                       if ( !guaranteedUnique[ name ] ) {
+                               jQuery.uniqueSort( matched );
+                       }
+
+                       // Reverse order for parents* and prev-derivatives
+                       if ( rparentsprev.test( name ) ) {
+                               matched.reverse();
+                       }
+               }
+
+               return this.pushStack( matched );
+       };
+} );
+var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
+
+
+
+// Convert String-formatted options into Object-formatted ones
+function createOptions( options ) {
+       var object = {};
+       jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
+               object[ flag ] = true;
+       } );
+       return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ *     options: an optional list of space-separated options that will change how
+ *                     the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ *     once:                   will ensure the callback list can only be fired once (like a Deferred)
+ *
+ *     memory:                 will keep track of previous values and will call any callback added
+ *                                     after the list has been fired right away with the latest "memorized"
+ *                                     values (like a Deferred)
+ *
+ *     unique:                 will ensure a callback can only be added once (no duplicate in the list)
+ *
+ *     stopOnFalse:    interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( options ) {
+
+       // Convert options from String-formatted to Object-formatted if needed
+       // (we check in cache first)
+       options = typeof options === "string" ?
+               createOptions( options ) :
+               jQuery.extend( {}, options );
+
+       var // Flag to know if list is currently firing
+               firing,
+
+               // Last fire value for non-forgettable lists
+               memory,
+
+               // Flag to know if list was already fired
+               fired,
+
+               // Flag to prevent firing
+               locked,
+
+               // Actual callback list
+               list = [],
+
+               // Queue of execution data for repeatable lists
+               queue = [],
+
+               // Index of currently firing callback (modified by add/remove as needed)
+               firingIndex = -1,
+
+               // Fire callbacks
+               fire = function() {
+
+                       // Enforce single-firing
+                       locked = locked || options.once;
+
+                       // Execute callbacks for all pending executions,
+                       // respecting firingIndex overrides and runtime changes
+                       fired = firing = true;
+                       for ( ; queue.length; firingIndex = -1 ) {
+                               memory = queue.shift();
+                               while ( ++firingIndex < list.length ) {
+
+                                       // Run callback and check for early termination
+                                       if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
+                                               options.stopOnFalse ) {
+
+                                               // Jump to end and forget the data so .add doesn't re-fire
+                                               firingIndex = list.length;
+                                               memory = false;
+                                       }
+                               }
+                       }
+
+                       // Forget the data if we're done with it
+                       if ( !options.memory ) {
+                               memory = false;
+                       }
+
+                       firing = false;
+
+                       // Clean up if we're done firing for good
+                       if ( locked ) {
+
+                               // Keep an empty list if we have data for future add calls
+                               if ( memory ) {
+                                       list = [];
+
+                               // Otherwise, this object is spent
+                               } else {
+                                       list = "";
+                               }
+                       }
+               },
+
+               // Actual Callbacks object
+               self = {
+
+                       // Add a callback or a collection of callbacks to the list
+                       add: function() {
+                               if ( list ) {
+
+                                       // If we have memory from a past run, we should fire after adding
+                                       if ( memory && !firing ) {
+                                               firingIndex = list.length - 1;
+                                               queue.push( memory );
+                                       }
+
+                                       ( function add( args ) {
+                                               jQuery.each( args, function( _, arg ) {
+                                                       if ( isFunction( arg ) ) {
+                                                               if ( !options.unique || !self.has( arg ) ) {
+                                                                       list.push( arg );
+                                                               }
+                                                       } else if ( arg && arg.length && toType( arg ) !== "string" ) {
+
+                                                               // Inspect recursively
+                                                               add( arg );
+                                                       }
+                                               } );
+                                       } )( arguments );
+
+                                       if ( memory && !firing ) {
+                                               fire();
+                                       }
+                               }
+                               return this;
+                       },
+
+                       // Remove a callback from the list
+                       remove: function() {
+                               jQuery.each( arguments, function( _, arg ) {
+                                       var index;
+                                       while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
+                                               list.splice( index, 1 );
+
+                                               // Handle firing indexes
+                                               if ( index <= firingIndex ) {
+                                                       firingIndex--;
+                                               }
+                                       }
+                               } );
+                               return this;
+                       },
+
+                       // Check if a given callback is in the list.
+                       // If no argument is given, return whether or not list has callbacks attached.
+                       has: function( fn ) {
+                               return fn ?
+                                       jQuery.inArray( fn, list ) > -1 :
+                                       list.length > 0;
+                       },
+
+                       // Remove all callbacks from the list
+                       empty: function() {
+                               if ( list ) {
+                                       list = [];
+                               }
+                               return this;
+                       },
+
+                       // Disable .fire and .add
+                       // Abort any current/pending executions
+                       // Clear all callbacks and values
+                       disable: function() {
+                               locked = queue = [];
+                               list = memory = "";
+                               return this;
+                       },
+                       disabled: function() {
+                               return !list;
+                       },
+
+                       // Disable .fire
+                       // Also disable .add unless we have memory (since it would have no effect)
+                       // Abort any pending executions
+                       lock: function() {
+                               locked = queue = [];
+                               if ( !memory && !firing ) {
+                                       list = memory = "";
+                               }
+                               return this;
+                       },
+                       locked: function() {
+                               return !!locked;
+                       },
+
+                       // Call all callbacks with the given context and arguments
+                       fireWith: function( context, args ) {
+                               if ( !locked ) {
+                                       args = args || [];
+                                       args = [ context, args.slice ? args.slice() : args ];
+                                       queue.push( args );
+                                       if ( !firing ) {
+                                               fire();
+                                       }
+                               }
+                               return this;
+                       },
+
+                       // Call all the callbacks with the given arguments
+                       fire: function() {
+                               self.fireWith( this, arguments );
+                               return this;
+                       },
+
+                       // To know if the callbacks have already been called at least once
+                       fired: function() {
+                               return !!fired;
+                       }
+               };
+
+       return self;
+};
+
+
+function Identity( v ) {
+       return v;
+}
+function Thrower( ex ) {
+       throw ex;
+}
+
+function adoptValue( value, resolve, reject, noValue ) {
+       var method;
+
+       try {
+
+               // Check for promise aspect first to privilege synchronous behavior
+               if ( value && isFunction( ( method = value.promise ) ) ) {
+                       method.call( value ).done( resolve ).fail( reject );
+
+               // Other thenables
+               } else if ( value && isFunction( ( method = value.then ) ) ) {
+                       method.call( value, resolve, reject );
+
+               // Other non-thenables
+               } else {
+
+                       // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
+                       // * false: [ value ].slice( 0 ) => resolve( value )
+                       // * true: [ value ].slice( 1 ) => resolve()
+                       resolve.apply( undefined, [ value ].slice( noValue ) );
+               }
+
+       // For Promises/A+, convert exceptions into rejections
+       // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
+       // Deferred#then to conditionally suppress rejection.
+       } catch ( value ) {
+
+               // Support: Android 4.0 only
+               // Strict mode functions invoked without .call/.apply get global-object context
+               reject.apply( undefined, [ value ] );
+       }
+}
+
+jQuery.extend( {
+
+       Deferred: function( func ) {
+               var tuples = [
+
+                               // action, add listener, callbacks,
+                               // ... .then handlers, argument index, [final state]
+                               [ "notify", "progress", jQuery.Callbacks( "memory" ),
+                                       jQuery.Callbacks( "memory" ), 2 ],
+                               [ "resolve", "done", jQuery.Callbacks( "once memory" ),
+                                       jQuery.Callbacks( "once memory" ), 0, "resolved" ],
+                               [ "reject", "fail", jQuery.Callbacks( "once memory" ),
+                                       jQuery.Callbacks( "once memory" ), 1, "rejected" ]
+                       ],
+                       state = "pending",
+                       promise = {
+                               state: function() {
+                                       return state;
+                               },
+                               always: function() {
+                                       deferred.done( arguments ).fail( arguments );
+                                       return this;
+                               },
+                               "catch": function( fn ) {
+                                       return promise.then( null, fn );
+                               },
+
+                               // Keep pipe for back-compat
+                               pipe: function( /* fnDone, fnFail, fnProgress */ ) {
+                                       var fns = arguments;
+
+                                       return jQuery.Deferred( function( newDefer ) {
+                                               jQuery.each( tuples, function( _i, tuple ) {
+
+                                                       // Map tuples (progress, done, fail) to arguments (done, fail, progress)
+                                                       var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
+
+                                                       // deferred.progress(function() { bind to newDefer or newDefer.notify })
+                                                       // deferred.done(function() { bind to newDefer or newDefer.resolve })
+                                                       // deferred.fail(function() { bind to newDefer or newDefer.reject })
+                                                       deferred[ tuple[ 1 ] ]( function() {
+                                                               var returned = fn && fn.apply( this, arguments );
+                                                               if ( returned && isFunction( returned.promise ) ) {
+                                                                       returned.promise()
+                                                                               .progress( newDefer.notify )
+                                                                               .done( newDefer.resolve )
+                                                                               .fail( newDefer.reject );
+                                                               } else {
+                                                                       newDefer[ tuple[ 0 ] + "With" ](
+                                                                               this,
+                                                                               fn ? [ returned ] : arguments
+                                                                       );
+                                                               }
+                                                       } );
+                                               } );
+                                               fns = null;
+                                       } ).promise();
+                               },
+                               then: function( onFulfilled, onRejected, onProgress ) {
+                                       var maxDepth = 0;
+                                       function resolve( depth, deferred, handler, special ) {
+                                               return function() {
+                                                       var that = this,
+                                                               args = arguments,
+                                                               mightThrow = function() {
+                                                                       var returned, then;
+
+                                                                       // Support: Promises/A+ section 2.3.3.3.3
+                                                                       // https://promisesaplus.com/#point-59
+                                                                       // Ignore double-resolution attempts
+                                                                       if ( depth < maxDepth ) {
+                                                                               return;
+                                                                       }
+
+                                                                       returned = handler.apply( that, args );
+
+                                                                       // Support: Promises/A+ section 2.3.1
+                                                                       // https://promisesaplus.com/#point-48
+                                                                       if ( returned === deferred.promise() ) {
+                                                                               throw new TypeError( "Thenable self-resolution" );
+                                                                       }
+
+                                                                       // Support: Promises/A+ sections 2.3.3.1, 3.5
+                                                                       // https://promisesaplus.com/#point-54
+                                                                       // https://promisesaplus.com/#point-75
+                                                                       // Retrieve `then` only once
+                                                                       then = returned &&
+
+                                                                               // Support: Promises/A+ section 2.3.4
+                                                                               // https://promisesaplus.com/#point-64
+                                                                               // Only check objects and functions for thenability
+                                                                               ( typeof returned === "object" ||
+                                                                                       typeof returned === "function" ) &&
+                                                                               returned.then;
+
+                                                                       // Handle a returned thenable
+                                                                       if ( isFunction( then ) ) {
+
+                                                                               // Special processors (notify) just wait for resolution
+                                                                               if ( special ) {
+                                                                                       then.call(
+                                                                                               returned,
+                                                                                               resolve( maxDepth, deferred, Identity, special ),
+                                                                                               resolve( maxDepth, deferred, Thrower, special )
+                                                                                       );
+
+                                                                               // Normal processors (resolve) also hook into progress
+                                                                               } else {
+
+                                                                                       // ...and disregard older resolution values
+                                                                                       maxDepth++;
+
+                                                                                       then.call(
+                                                                                               returned,
+                                                                                               resolve( maxDepth, deferred, Identity, special ),
+                                                                                               resolve( maxDepth, deferred, Thrower, special ),
+                                                                                               resolve( maxDepth, deferred, Identity,
+                                                                                                       deferred.notifyWith )
+                                                                                       );
+                                                                               }
+
+                                                                       // Handle all other returned values
+                                                                       } else {
+
+                                                                               // Only substitute handlers pass on context
+                                                                               // and multiple values (non-spec behavior)
+                                                                               if ( handler !== Identity ) {
+                                                                                       that = undefined;
+                                                                                       args = [ returned ];
+                                                                               }
+
+                                                                               // Process the value(s)
+                                                                               // Default process is resolve
+                                                                               ( special || deferred.resolveWith )( that, args );
+                                                                       }
+                                                               },
+
+                                                               // Only normal processors (resolve) catch and reject exceptions
+                                                               process = special ?
+                                                                       mightThrow :
+                                                                       function() {
+                                                                               try {
+                                                                                       mightThrow();
+                                                                               } catch ( e ) {
+
+                                                                                       if ( jQuery.Deferred.exceptionHook ) {
+                                                                                               jQuery.Deferred.exceptionHook( e,
+                                                                                                       process.stackTrace );
+                                                                                       }
+
+                                                                                       // Support: Promises/A+ section 2.3.3.3.4.1
+                                                                                       // https://promisesaplus.com/#point-61
+                                                                                       // Ignore post-resolution exceptions
+                                                                                       if ( depth + 1 >= maxDepth ) {
+
+                                                                                               // Only substitute handlers pass on context
+                                                                                               // and multiple values (non-spec behavior)
+                                                                                               if ( handler !== Thrower ) {
+                                                                                                       that = undefined;
+                                                                                                       args = [ e ];
+                                                                                               }
+
+                                                                                               deferred.rejectWith( that, args );
+                                                                                       }
+                                                                               }
+                                                                       };
+
+                                                       // Support: Promises/A+ section 2.3.3.3.1
+                                                       // https://promisesaplus.com/#point-57
+                                                       // Re-resolve promises immediately to dodge false rejection from
+                                                       // subsequent errors
+                                                       if ( depth ) {
+                                                               process();
+                                                       } else {
+
+                                                               // Call an optional hook to record the stack, in case of exception
+                                                               // since it's otherwise lost when execution goes async
+                                                               if ( jQuery.Deferred.getStackHook ) {
+                                                                       process.stackTrace = jQuery.Deferred.getStackHook();
+                                                               }
+                                                               window.setTimeout( process );
+                                                       }
+                                               };
+                                       }
+
+                                       return jQuery.Deferred( function( newDefer ) {
+
+                                               // progress_handlers.add( ... )
+                                               tuples[ 0 ][ 3 ].add(
+                                                       resolve(
+                                                               0,
+                                                               newDefer,
+                                                               isFunction( onProgress ) ?
+                                                                       onProgress :
+                                                                       Identity,
+                                                               newDefer.notifyWith
+                                                       )
+                                               );
+
+                                               // fulfilled_handlers.add( ... )
+                                               tuples[ 1 ][ 3 ].add(
+                                                       resolve(
+                                                               0,
+                                                               newDefer,
+                                                               isFunction( onFulfilled ) ?
+                                                                       onFulfilled :
+                                                                       Identity
+                                                       )
+                                               );
+
+                                               // rejected_handlers.add( ... )
+                                               tuples[ 2 ][ 3 ].add(
+                                                       resolve(
+                                                               0,
+                                                               newDefer,
+                                                               isFunction( onRejected ) ?
+                                                                       onRejected :
+                                                                       Thrower
+                                                       )
+                                               );
+                                       } ).promise();
+                               },
+
+                               // Get a promise for this deferred
+                               // If obj is provided, the promise aspect is added to the object
+                               promise: function( obj ) {
+                                       return obj != null ? jQuery.extend( obj, promise ) : promise;
+                               }
+                       },
+                       deferred = {};
+
+               // Add list-specific methods
+               jQuery.each( tuples, function( i, tuple ) {
+                       var list = tuple[ 2 ],
+                               stateString = tuple[ 5 ];
+
+                       // promise.progress = list.add
+                       // promise.done = list.add
+                       // promise.fail = list.add
+                       promise[ tuple[ 1 ] ] = list.add;
+
+                       // Handle state
+                       if ( stateString ) {
+                               list.add(
+                                       function() {
+
+                                               // state = "resolved" (i.e., fulfilled)
+                                               // state = "rejected"
+                                               state = stateString;
+                                       },
+
+                                       // rejected_callbacks.disable
+                                       // fulfilled_callbacks.disable
+                                       tuples[ 3 - i ][ 2 ].disable,
+
+                                       // rejected_handlers.disable
+                                       // fulfilled_handlers.disable
+                                       tuples[ 3 - i ][ 3 ].disable,
+
+                                       // progress_callbacks.lock
+                                       tuples[ 0 ][ 2 ].lock,
+
+                                       // progress_handlers.lock
+                                       tuples[ 0 ][ 3 ].lock
+                               );
+                       }
+
+                       // progress_handlers.fire
+                       // fulfilled_handlers.fire
+                       // rejected_handlers.fire
+                       list.add( tuple[ 3 ].fire );
+
+                       // deferred.notify = function() { deferred.notifyWith(...) }
+                       // deferred.resolve = function() { deferred.resolveWith(...) }
+                       // deferred.reject = function() { deferred.rejectWith(...) }
+                       deferred[ tuple[ 0 ] ] = function() {
+                               deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
+                               return this;
+                       };
+
+                       // deferred.notifyWith = list.fireWith
+                       // deferred.resolveWith = list.fireWith
+                       // deferred.rejectWith = list.fireWith
+                       deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
+               } );
+
+               // Make the deferred a promise
+               promise.promise( deferred );
+
+               // Call given func if any
+               if ( func ) {
+                       func.call( deferred, deferred );
+               }
+
+               // All done!
+               return deferred;
+       },
+
+       // Deferred helper
+       when: function( singleValue ) {
+               var
+
+                       // count of uncompleted subordinates
+                       remaining = arguments.length,
+
+                       // count of unprocessed arguments
+                       i = remaining,
+
+                       // subordinate fulfillment data
+                       resolveContexts = Array( i ),
+                       resolveValues = slice.call( arguments ),
+
+                       // the master Deferred
+                       master = jQuery.Deferred(),
+
+                       // subordinate callback factory
+                       updateFunc = function( i ) {
+                               return function( value ) {
+                                       resolveContexts[ i ] = this;
+                                       resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
+                                       if ( !( --remaining ) ) {
+                                               master.resolveWith( resolveContexts, resolveValues );
+                                       }
+                               };
+                       };
+
+               // Single- and empty arguments are adopted like Promise.resolve
+               if ( remaining <= 1 ) {
+                       adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
+                               !remaining );
+
+                       // Use .then() to unwrap secondary thenables (cf. gh-3000)
+                       if ( master.state() === "pending" ||
+                               isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
+
+                               return master.then();
+                       }
+               }
+
+               // Multiple arguments are aggregated like Promise.all array elements
+               while ( i-- ) {
+                       adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
+               }
+
+               return master.promise();
+       }
+} );
+
+
+// These usually indicate a programmer mistake during development,
+// warn about them ASAP rather than swallowing them by default.
+var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
+
+jQuery.Deferred.exceptionHook = function( error, stack ) {
+
+       // Support: IE 8 - 9 only
+       // Console exists when dev tools are open, which can happen at any time
+       if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
+               window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
+       }
+};
+
+
+
+
+jQuery.readyException = function( error ) {
+       window.setTimeout( function() {
+               throw error;
+       } );
+};
+
+
+
+
+// The deferred used on DOM ready
+var readyList = jQuery.Deferred();
+
+jQuery.fn.ready = function( fn ) {
+
+       readyList
+               .then( fn )
+
+               // Wrap jQuery.readyException in a function so that the lookup
+               // happens at the time of error handling instead of callback
+               // registration.
+               .catch( function( error ) {
+                       jQuery.readyException( error );
+               } );
+
+       return this;
+};
+
+jQuery.extend( {
+
+       // Is the DOM ready to be used? Set to true once it occurs.
+       isReady: false,
+
+       // A counter to track how many items to wait for before
+       // the ready event fires. See #6781
+       readyWait: 1,
+
+       // Handle when the DOM is ready
+       ready: function( wait ) {
+
+               // Abort if there are pending holds or we're already ready
+               if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+                       return;
+               }
+
+               // Remember that the DOM is ready
+               jQuery.isReady = true;
+
+               // If a normal DOM Ready event fired, decrement, and wait if need be
+               if ( wait !== true && --jQuery.readyWait > 0 ) {
+                       return;
+               }
+
+               // If there are functions bound, to execute
+               readyList.resolveWith( document, [ jQuery ] );
+       }
+} );
+
+jQuery.ready.then = readyList.then;
+
+// The ready event handler and self cleanup method
+function completed() {
+       document.removeEventListener( "DOMContentLoaded", completed );
+       window.removeEventListener( "load", completed );
+       jQuery.ready();
+}
+
+// Catch cases where $(document).ready() is called
+// after the browser event has already occurred.
+// Support: IE <=9 - 10 only
+// Older IE sometimes signals "interactive" too soon
+if ( document.readyState === "complete" ||
+       ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
+
+       // Handle it asynchronously to allow scripts the opportunity to delay ready
+       window.setTimeout( jQuery.ready );
+
+} else {
+
+       // Use the handy event callback
+       document.addEventListener( "DOMContentLoaded", completed );
+
+       // A fallback to window.onload, that will always work
+       window.addEventListener( "load", completed );
+}
+
+
+
+
+// Multifunctional method to get and set values of a collection
+// The value/s can optionally be executed if it's a function
+var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
+       var i = 0,
+               len = elems.length,
+               bulk = key == null;
+
+       // Sets many values
+       if ( toType( key ) === "object" ) {
+               chainable = true;
+               for ( i in key ) {
+                       access( elems, fn, i, key[ i ], true, emptyGet, raw );
+               }
+
+       // Sets one value
+       } else if ( value !== undefined ) {
+               chainable = true;
+
+               if ( !isFunction( value ) ) {
+                       raw = true;
+               }
+
+               if ( bulk ) {
+
+                       // Bulk operations run against the entire set
+                       if ( raw ) {
+                               fn.call( elems, value );
+                               fn = null;
+
+                       // ...except when executing function values
+                       } else {
+                               bulk = fn;
+                               fn = function( elem, _key, value ) {
+                                       return bulk.call( jQuery( elem ), value );
+                               };
+                       }
+               }
+
+               if ( fn ) {
+                       for ( ; i < len; i++ ) {
+                               fn(
+                                       elems[ i ], key, raw ?
+                                       value :
+                                       value.call( elems[ i ], i, fn( elems[ i ], key ) )
+                               );
+                       }
+               }
+       }
+
+       if ( chainable ) {
+               return elems;
+       }
+
+       // Gets
+       if ( bulk ) {
+               return fn.call( elems );
+       }
+
+       return len ? fn( elems[ 0 ], key ) : emptyGet;
+};
+
+
+// Matches dashed string for camelizing
+var rmsPrefix = /^-ms-/,
+       rdashAlpha = /-([a-z])/g;
+
+// Used by camelCase as callback to replace()
+function fcamelCase( _all, letter ) {
+       return letter.toUpperCase();
+}
+
+// Convert dashed to camelCase; used by the css and data modules
+// Support: IE <=9 - 11, Edge 12 - 15
+// Microsoft forgot to hump their vendor prefix (#9572)
+function camelCase( string ) {
+       return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+}
+var acceptData = function( owner ) {
+
+       // Accepts only:
+       //  - Node
+       //    - Node.ELEMENT_NODE
+       //    - Node.DOCUMENT_NODE
+       //  - Object
+       //    - Any
+       return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
+};
+
+
+
+
+function Data() {
+       this.expando = jQuery.expando + Data.uid++;
+}
+
+Data.uid = 1;
+
+Data.prototype = {
+
+       cache: function( owner ) {
+
+               // Check if the owner object already has a cache
+               var value = owner[ this.expando ];
+
+               // If not, create one
+               if ( !value ) {
+                       value = {};
+
+                       // We can accept data for non-element nodes in modern browsers,
+                       // but we should not, see #8335.
+                       // Always return an empty object.
+                       if ( acceptData( owner ) ) {
+
+                               // If it is a node unlikely to be stringify-ed or looped over
+                               // use plain assignment
+                               if ( owner.nodeType ) {
+                                       owner[ this.expando ] = value;
+
+                               // Otherwise secure it in a non-enumerable property
+                               // configurable must be true to allow the property to be
+                               // deleted when data is removed
+                               } else {
+                                       Object.defineProperty( owner, this.expando, {
+                                               value: value,
+                                               configurable: true
+                                       } );
+                               }
+                       }
+               }
+
+               return value;
+       },
+       set: function( owner, data, value ) {
+               var prop,
+                       cache = this.cache( owner );
+
+               // Handle: [ owner, key, value ] args
+               // Always use camelCase key (gh-2257)
+               if ( typeof data === "string" ) {
+                       cache[ camelCase( data ) ] = value;
+
+               // Handle: [ owner, { properties } ] args
+               } else {
+
+                       // Copy the properties one-by-one to the cache object
+                       for ( prop in data ) {
+                               cache[ camelCase( prop ) ] = data[ prop ];
+                       }
+               }
+               return cache;
+       },
+       get: function( owner, key ) {
+               return key === undefined ?
+                       this.cache( owner ) :
+
+                       // Always use camelCase key (gh-2257)
+                       owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
+       },
+       access: function( owner, key, value ) {
+
+               // In cases where either:
+               //
+               //   1. No key was specified
+               //   2. A string key was specified, but no value provided
+               //
+               // Take the "read" path and allow the get method to determine
+               // which value to return, respectively either:
+               //
+               //   1. The entire cache object
+               //   2. The data stored at the key
+               //
+               if ( key === undefined ||
+                               ( ( key && typeof key === "string" ) && value === undefined ) ) {
+
+                       return this.get( owner, key );
+               }
+
+               // When the key is not a string, or both a key and value
+               // are specified, set or extend (existing objects) with either:
+               //
+               //   1. An object of properties
+               //   2. A key and value
+               //
+               this.set( owner, key, value );
+
+               // Since the "set" path can have two possible entry points
+               // return the expected data based on which path was taken[*]
+               return value !== undefined ? value : key;
+       },
+       remove: function( owner, key ) {
+               var i,
+                       cache = owner[ this.expando ];
+
+               if ( cache === undefined ) {
+                       return;
+               }
+
+               if ( key !== undefined ) {
+
+                       // Support array or space separated string of keys
+                       if ( Array.isArray( key ) ) {
+
+                               // If key is an array of keys...
+                               // We always set camelCase keys, so remove that.
+                               key = key.map( camelCase );
+                       } else {
+                               key = camelCase( key );
+
+                               // If a key with the spaces exists, use it.
+                               // Otherwise, create an array by matching non-whitespace
+                               key = key in cache ?
+                                       [ key ] :
+                                       ( key.match( rnothtmlwhite ) || [] );
+                       }
+
+                       i = key.length;
+
+                       while ( i-- ) {
+                               delete cache[ key[ i ] ];
+                       }
+               }
+
+               // Remove the expando if there's no more data
+               if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
+
+                       // Support: Chrome <=35 - 45
+                       // Webkit & Blink performance suffers when deleting properties
+                       // from DOM nodes, so set to undefined instead
+                       // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
+                       if ( owner.nodeType ) {
+                               owner[ this.expando ] = undefined;
+                       } else {
+                               delete owner[ this.expando ];
+                       }
+               }
+       },
+       hasData: function( owner ) {
+               var cache = owner[ this.expando ];
+               return cache !== undefined && !jQuery.isEmptyObject( cache );
+       }
+};
+var dataPriv = new Data();
+
+var dataUser = new Data();
+
+
+
+//     Implementation Summary
+//
+//     1. Enforce API surface and semantic compatibility with 1.9.x branch
+//     2. Improve the module's maintainability by reducing the storage
+//             paths to a single mechanism.
+//     3. Use the same single mechanism to support "private" and "user" data.
+//     4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
+//     5. Avoid exposing implementation details on user objects (eg. expando properties)
+//     6. Provide a clear path for implementation upgrade to WeakMap in 2014
+
+var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
+       rmultiDash = /[A-Z]/g;
+
+function getData( data ) {
+       if ( data === "true" ) {
+               return true;
+       }
+
+       if ( data === "false" ) {
+               return false;
+       }
+
+       if ( data === "null" ) {
+               return null;
+       }
+
+       // Only convert to a number if it doesn't change the string
+       if ( data === +data + "" ) {
+               return +data;
+       }
+
+       if ( rbrace.test( data ) ) {
+               return JSON.parse( data );
+       }
+
+       return data;
+}
+
+function dataAttr( elem, key, data ) {
+       var name;
+
+       // If nothing was found internally, try to fetch any
+       // data from the HTML5 data-* attribute
+       if ( data === undefined && elem.nodeType === 1 ) {
+               name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
+               data = elem.getAttribute( name );
+
+               if ( typeof data === "string" ) {
+                       try {
+                               data = getData( data );
+                       } catch ( e ) {}
+
+                       // Make sure we set the data so it isn't changed later
+                       dataUser.set( elem, key, data );
+               } else {
+                       data = undefined;
+               }
+       }
+       return data;
+}
+
+jQuery.extend( {
+       hasData: function( elem ) {
+               return dataUser.hasData( elem ) || dataPriv.hasData( elem );
+       },
+
+       data: function( elem, name, data ) {
+               return dataUser.access( elem, name, data );
+       },
+
+       removeData: function( elem, name ) {
+               dataUser.remove( elem, name );
+       },
+
+       // TODO: Now that all calls to _data and _removeData have been replaced
+       // with direct calls to dataPriv methods, these can be deprecated.
+       _data: function( elem, name, data ) {
+               return dataPriv.access( elem, name, data );
+       },
+
+       _removeData: function( elem, name ) {
+               dataPriv.remove( elem, name );
+       }
+} );
+
+jQuery.fn.extend( {
+       data: function( key, value ) {
+               var i, name, data,
+                       elem = this[ 0 ],
+                       attrs = elem && elem.attributes;
+
+               // Gets all values
+               if ( key === undefined ) {
+                       if ( this.length ) {
+                               data = dataUser.get( elem );
+
+                               if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
+                                       i = attrs.length;
+                                       while ( i-- ) {
+
+                                               // Support: IE 11 only
+                                               // The attrs elements can be null (#14894)
+                                               if ( attrs[ i ] ) {
+                                                       name = attrs[ i ].name;
+                                                       if ( name.indexOf( "data-" ) === 0 ) {
+                                                               name = camelCase( name.slice( 5 ) );
+                                                               dataAttr( elem, name, data[ name ] );
+                                                       }
+                                               }
+                                       }
+                                       dataPriv.set( elem, "hasDataAttrs", true );
+                               }
+                       }
+
+                       return data;
+               }
+
+               // Sets multiple values
+               if ( typeof key === "object" ) {
+                       return this.each( function() {
+                               dataUser.set( this, key );
+                       } );
+               }
+
+               return access( this, function( value ) {
+                       var data;
+
+                       // The calling jQuery object (element matches) is not empty
+                       // (and therefore has an element appears at this[ 0 ]) and the
+                       // `value` parameter was not undefined. An empty jQuery object
+                       // will result in `undefined` for elem = this[ 0 ] which will
+                       // throw an exception if an attempt to read a data cache is made.
+                       if ( elem && value === undefined ) {
+
+                               // Attempt to get data from the cache
+                               // The key will always be camelCased in Data
+                               data = dataUser.get( elem, key );
+                               if ( data !== undefined ) {
+                                       return data;
+                               }
+
+                               // Attempt to "discover" the data in
+                               // HTML5 custom data-* attrs
+                               data = dataAttr( elem, key );
+                               if ( data !== undefined ) {
+                                       return data;
+                               }
+
+                               // We tried really hard, but the data doesn't exist.
+                               return;
+                       }
+
+                       // Set the data...
+                       this.each( function() {
+
+                               // We always store the camelCased key
+                               dataUser.set( this, key, value );
+                       } );
+               }, null, value, arguments.length > 1, null, true );
+       },
+
+       removeData: function( key ) {
+               return this.each( function() {
+                       dataUser.remove( this, key );
+               } );
+       }
+} );
+
+
+jQuery.extend( {
+       queue: function( elem, type, data ) {
+               var queue;
+
+               if ( elem ) {
+                       type = ( type || "fx" ) + "queue";
+                       queue = dataPriv.get( elem, type );
+
+                       // Speed up dequeue by getting out quickly if this is just a lookup
+                       if ( data ) {
+                               if ( !queue || Array.isArray( data ) ) {
+                                       queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
+                               } else {
+                                       queue.push( data );
+                               }
+                       }
+                       return queue || [];
+               }
+       },
+
+       dequeue: function( elem, type ) {
+               type = type || "fx";
+
+               var queue = jQuery.queue( elem, type ),
+                       startLength = queue.length,
+                       fn = queue.shift(),
+                       hooks = jQuery._queueHooks( elem, type ),
+                       next = function() {
+                               jQuery.dequeue( elem, type );
+                       };
+
+               // If the fx queue is dequeued, always remove the progress sentinel
+               if ( fn === "inprogress" ) {
+                       fn = queue.shift();
+                       startLength--;
+               }
+
+               if ( fn ) {
+
+                       // Add a progress sentinel to prevent the fx queue from being
+                       // automatically dequeued
+                       if ( type === "fx" ) {
+                               queue.unshift( "inprogress" );
+                       }
+
+                       // Clear up the last queue stop function
+                       delete hooks.stop;
+                       fn.call( elem, next, hooks );
+               }
+
+               if ( !startLength && hooks ) {
+                       hooks.empty.fire();
+               }
+       },
+
+       // Not public - generate a queueHooks object, or return the current one
+       _queueHooks: function( elem, type ) {
+               var key = type + "queueHooks";
+               return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
+                       empty: jQuery.Callbacks( "once memory" ).add( function() {
+                               dataPriv.remove( elem, [ type + "queue", key ] );
+                       } )
+               } );
+       }
+} );
+
+jQuery.fn.extend( {
+       queue: function( type, data ) {
+               var setter = 2;
+
+               if ( typeof type !== "string" ) {
+                       data = type;
+                       type = "fx";
+                       setter--;
+               }
+
+               if ( arguments.length < setter ) {
+                       return jQuery.queue( this[ 0 ], type );
+               }
+
+               return data === undefined ?
+                       this :
+                       this.each( function() {
+                               var queue = jQuery.queue( this, type, data );
+
+                               // Ensure a hooks for this queue
+                               jQuery._queueHooks( this, type );
+
+                               if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
+                                       jQuery.dequeue( this, type );
+                               }
+                       } );
+       },
+       dequeue: function( type ) {
+               return this.each( function() {
+                       jQuery.dequeue( this, type );
+               } );
+       },
+       clearQueue: function( type ) {
+               return this.queue( type || "fx", [] );
+       },
+
+       // Get a promise resolved when queues of a certain type
+       // are emptied (fx is the type by default)
+       promise: function( type, obj ) {
+               var tmp,
+                       count = 1,
+                       defer = jQuery.Deferred(),
+                       elements = this,
+                       i = this.length,
+                       resolve = function() {
+                               if ( !( --count ) ) {
+                                       defer.resolveWith( elements, [ elements ] );
+                               }
+                       };
+
+               if ( typeof type !== "string" ) {
+                       obj = type;
+                       type = undefined;
+               }
+               type = type || "fx";
+
+               while ( i-- ) {
+                       tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
+                       if ( tmp && tmp.empty ) {
+                               count++;
+                               tmp.empty.add( resolve );
+                       }
+               }
+               resolve();
+               return defer.promise( obj );
+       }
+} );
+var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
+
+var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
+
+
+var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
+
+var documentElement = document.documentElement;
+
+
+
+       var isAttached = function( elem ) {
+                       return jQuery.contains( elem.ownerDocument, elem );
+               },
+               composed = { composed: true };
+
+       // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
+       // Check attachment across shadow DOM boundaries when possible (gh-3504)
+       // Support: iOS 10.0-10.2 only
+       // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
+       // leading to errors. We need to check for `getRootNode`.
+       if ( documentElement.getRootNode ) {
+               isAttached = function( elem ) {
+                       return jQuery.contains( elem.ownerDocument, elem ) ||
+                               elem.getRootNode( composed ) === elem.ownerDocument;
+               };
+       }
+var isHiddenWithinTree = function( elem, el ) {
+
+               // isHiddenWithinTree might be called from jQuery#filter function;
+               // in that case, element will be second argument
+               elem = el || elem;
+
+               // Inline style trumps all
+               return elem.style.display === "none" ||
+                       elem.style.display === "" &&
+
+                       // Otherwise, check computed style
+                       // Support: Firefox <=43 - 45
+                       // Disconnected elements can have computed display: none, so first confirm that elem is
+                       // in the document.
+                       isAttached( elem ) &&
+
+                       jQuery.css( elem, "display" ) === "none";
+       };
+
+
+
+function adjustCSS( elem, prop, valueParts, tween ) {
+       var adjusted, scale,
+               maxIterations = 20,
+               currentValue = tween ?
+                       function() {
+                               return tween.cur();
+                       } :
+                       function() {
+                               return jQuery.css( elem, prop, "" );
+                       },
+               initial = currentValue(),
+               unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
+
+               // Starting value computation is required for potential unit mismatches
+               initialInUnit = elem.nodeType &&
+                       ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
+                       rcssNum.exec( jQuery.css( elem, prop ) );
+
+       if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
+
+               // Support: Firefox <=54
+               // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
+               initial = initial / 2;
+
+               // Trust units reported by jQuery.css
+               unit = unit || initialInUnit[ 3 ];
+
+               // Iteratively approximate from a nonzero starting point
+               initialInUnit = +initial || 1;
+
+               while ( maxIterations-- ) {
+
+                       // Evaluate and update our best guess (doubling guesses that zero out).
+                       // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
+                       jQuery.style( elem, prop, initialInUnit + unit );
+                       if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
+                               maxIterations = 0;
+                       }
+                       initialInUnit = initialInUnit / scale;
+
+               }
+
+               initialInUnit = initialInUnit * 2;
+               jQuery.style( elem, prop, initialInUnit + unit );
+
+               // Make sure we update the tween properties later on
+               valueParts = valueParts || [];
+       }
+
+       if ( valueParts ) {
+               initialInUnit = +initialInUnit || +initial || 0;
+
+               // Apply relative offset (+=/-=) if specified
+               adjusted = valueParts[ 1 ] ?
+                       initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+                       +valueParts[ 2 ];
+               if ( tween ) {
+                       tween.unit = unit;
+                       tween.start = initialInUnit;
+                       tween.end = adjusted;
+               }
+       }
+       return adjusted;
+}
+
+
+var defaultDisplayMap = {};
+
+function getDefaultDisplay( elem ) {
+       var temp,
+               doc = elem.ownerDocument,
+               nodeName = elem.nodeName,
+               display = defaultDisplayMap[ nodeName ];
+
+       if ( display ) {
+               return display;
+       }
+
+       temp = doc.body.appendChild( doc.createElement( nodeName ) );
+       display = jQuery.css( temp, "display" );
+
+       temp.parentNode.removeChild( temp );
+
+       if ( display === "none" ) {
+               display = "block";
+       }
+       defaultDisplayMap[ nodeName ] = display;
+
+       return display;
+}
+
+function showHide( elements, show ) {
+       var display, elem,
+               values = [],
+               index = 0,
+               length = elements.length;
+
+       // Determine new display value for elements that need to change
+       for ( ; index < length; index++ ) {
+               elem = elements[ index ];
+               if ( !elem.style ) {
+                       continue;
+               }
+
+               display = elem.style.display;
+               if ( show ) {
+
+                       // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
+                       // check is required in this first loop unless we have a nonempty display value (either
+                       // inline or about-to-be-restored)
+                       if ( display === "none" ) {
+                               values[ index ] = dataPriv.get( elem, "display" ) || null;
+                               if ( !values[ index ] ) {
+                                       elem.style.display = "";
+                               }
+                       }
+                       if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
+                               values[ index ] = getDefaultDisplay( elem );
+                       }
+               } else {
+                       if ( display !== "none" ) {
+                               values[ index ] = "none";
+
+                               // Remember what we're overwriting
+                               dataPriv.set( elem, "display", display );
+                       }
+               }
+       }
+
+       // Set the display of the elements in a second loop to avoid constant reflow
+       for ( index = 0; index < length; index++ ) {
+               if ( values[ index ] != null ) {
+                       elements[ index ].style.display = values[ index ];
+               }
+       }
+
+       return elements;
+}
+
+jQuery.fn.extend( {
+       show: function() {
+               return showHide( this, true );
+       },
+       hide: function() {
+               return showHide( this );
+       },
+       toggle: function( state ) {
+               if ( typeof state === "boolean" ) {
+                       return state ? this.show() : this.hide();
+               }
+
+               return this.each( function() {
+                       if ( isHiddenWithinTree( this ) ) {
+                               jQuery( this ).show();
+                       } else {
+                               jQuery( this ).hide();
+                       }
+               } );
+       }
+} );
+var rcheckableType = ( /^(?:checkbox|radio)$/i );
+
+var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
+
+var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
+
+
+
+( function() {
+       var fragment = document.createDocumentFragment(),
+               div = fragment.appendChild( document.createElement( "div" ) ),
+               input = document.createElement( "input" );
+
+       // Support: Android 4.0 - 4.3 only
+       // Check state lost if the name is set (#11217)
+       // Support: Windows Web Apps (WWA)
+       // `name` and `type` must use .setAttribute for WWA (#14901)
+       input.setAttribute( "type", "radio" );
+       input.setAttribute( "checked", "checked" );
+       input.setAttribute( "name", "t" );
+
+       div.appendChild( input );
+
+       // Support: Android <=4.1 only
+       // Older WebKit doesn't clone checked state correctly in fragments
+       support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+       // Support: IE <=11 only
+       // Make sure textarea (and checkbox) defaultValue is properly cloned
+       div.innerHTML = "<textarea>x</textarea>";
+       support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
+
+       // Support: IE <=9 only
+       // IE <=9 replaces <option> tags with their contents when inserted outside of
+       // the select element.
+       div.innerHTML = "<option></option>";
+       support.option = !!div.lastChild;
+} )();
+
+
+// We have to close these tags to support XHTML (#13200)
+var wrapMap = {
+
+       // XHTML parsers do not magically insert elements in the
+       // same way that tag soup parsers do. So we cannot shorten
+       // this by omitting <tbody> or other required elements.
+       thead: [ 1, "<table>", "</table>" ],
+       col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
+       tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+       td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+
+       _default: [ 0, "", "" ]
+};
+
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// Support: IE <=9 only
+if ( !support.option ) {
+       wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
+}
+
+
+function getAll( context, tag ) {
+
+       // Support: IE <=9 - 11 only
+       // Use typeof to avoid zero-argument method invocation on host objects (#15151)
+       var ret;
+
+       if ( typeof context.getElementsByTagName !== "undefined" ) {
+               ret = context.getElementsByTagName( tag || "*" );
+
+       } else if ( typeof context.querySelectorAll !== "undefined" ) {
+               ret = context.querySelectorAll( tag || "*" );
+
+       } else {
+               ret = [];
+       }
+
+       if ( tag === undefined || tag && nodeName( context, tag ) ) {
+               return jQuery.merge( [ context ], ret );
+       }
+
+       return ret;
+}
+
+
+// Mark scripts as having already been evaluated
+function setGlobalEval( elems, refElements ) {
+       var i = 0,
+               l = elems.length;
+
+       for ( ; i < l; i++ ) {
+               dataPriv.set(
+                       elems[ i ],
+                       "globalEval",
+                       !refElements || dataPriv.get( refElements[ i ], "globalEval" )
+               );
+       }
+}
+
+
+var rhtml = /<|&#?\w+;/;
+
+function buildFragment( elems, context, scripts, selection, ignored ) {
+       var elem, tmp, tag, wrap, attached, j,
+               fragment = context.createDocumentFragment(),
+               nodes = [],
+               i = 0,
+               l = elems.length;
+
+       for ( ; i < l; i++ ) {
+               elem = elems[ i ];
+
+               if ( elem || elem === 0 ) {
+
+                       // Add nodes directly
+                       if ( toType( elem ) === "object" ) {
+
+                               // Support: Android <=4.0 only, PhantomJS 1 only
+                               // push.apply(_, arraylike) throws on ancient WebKit
+                               jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
+
+                       // Convert non-html into a text node
+                       } else if ( !rhtml.test( elem ) ) {
+                               nodes.push( context.createTextNode( elem ) );
+
+                       // Convert html into DOM nodes
+                       } else {
+                               tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
+
+                               // Deserialize a standard representation
+                               tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
+                               wrap = wrapMap[ tag ] || wrapMap._default;
+                               tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
+
+                               // Descend through wrappers to the right content
+                               j = wrap[ 0 ];
+                               while ( j-- ) {
+                                       tmp = tmp.lastChild;
+                               }
+
+                               // Support: Android <=4.0 only, PhantomJS 1 only
+                               // push.apply(_, arraylike) throws on ancient WebKit
+                               jQuery.merge( nodes, tmp.childNodes );
+
+                               // Remember the top-level container
+                               tmp = fragment.firstChild;
+
+                               // Ensure the created nodes are orphaned (#12392)
+                               tmp.textContent = "";
+                       }
+               }
+       }
+
+       // Remove wrapper from fragment
+       fragment.textContent = "";
+
+       i = 0;
+       while ( ( elem = nodes[ i++ ] ) ) {
+
+               // Skip elements already in the context collection (trac-4087)
+               if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
+                       if ( ignored ) {
+                               ignored.push( elem );
+                       }
+                       continue;
+               }
+
+               attached = isAttached( elem );
+
+               // Append to fragment
+               tmp = getAll( fragment.appendChild( elem ), "script" );
+
+               // Preserve script evaluation history
+               if ( attached ) {
+                       setGlobalEval( tmp );
+               }
+
+               // Capture executables
+               if ( scripts ) {
+                       j = 0;
+                       while ( ( elem = tmp[ j++ ] ) ) {
+                               if ( rscriptType.test( elem.type || "" ) ) {
+                                       scripts.push( elem );
+                               }
+                       }
+               }
+       }
+
+       return fragment;
+}
+
+
+var
+       rkeyEvent = /^key/,
+       rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
+       rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
+
+function returnTrue() {
+       return true;
+}
+
+function returnFalse() {
+       return false;
+}
+
+// Support: IE <=9 - 11+
+// focus() and blur() are asynchronous, except when they are no-op.
+// So expect focus to be synchronous when the element is already active,
+// and blur to be synchronous when the element is not already active.
+// (focus and blur are always synchronous in other supported browsers,
+// this just defines when we can count on it).
+function expectSync( elem, type ) {
+       return ( elem === safeActiveElement() ) === ( type === "focus" );
+}
+
+// Support: IE <=9 only
+// Accessing document.activeElement can throw unexpectedly
+// https://bugs.jquery.com/ticket/13393
+function safeActiveElement() {
+       try {
+               return document.activeElement;
+       } catch ( err ) { }
+}
+
+function on( elem, types, selector, data, fn, one ) {
+       var origFn, type;
+
+       // Types can be a map of types/handlers
+       if ( typeof types === "object" ) {
+
+               // ( types-Object, selector, data )
+               if ( typeof selector !== "string" ) {
+
+                       // ( types-Object, data )
+                       data = data || selector;
+                       selector = undefined;
+               }
+               for ( type in types ) {
+                       on( elem, type, selector, data, types[ type ], one );
+               }
+               return elem;
+       }
+
+       if ( data == null && fn == null ) {
+
+               // ( types, fn )
+               fn = selector;
+               data = selector = undefined;
+       } else if ( fn == null ) {
+               if ( typeof selector === "string" ) {
+
+                       // ( types, selector, fn )
+                       fn = data;
+                       data = undefined;
+               } else {
+
+                       // ( types, data, fn )
+                       fn = data;
+                       data = selector;
+                       selector = undefined;
+               }
+       }
+       if ( fn === false ) {
+               fn = returnFalse;
+       } else if ( !fn ) {
+               return elem;
+       }
+
+       if ( one === 1 ) {
+               origFn = fn;
+               fn = function( event ) {
+
+                       // Can use an empty set, since event contains the info
+                       jQuery().off( event );
+                       return origFn.apply( this, arguments );
+               };
+
+               // Use same guid so caller can remove using origFn
+               fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+       }
+       return elem.each( function() {
+               jQuery.event.add( this, types, fn, data, selector );
+       } );
+}
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+       global: {},
+
+       add: function( elem, types, handler, data, selector ) {
+
+               var handleObjIn, eventHandle, tmp,
+                       events, t, handleObj,
+                       special, handlers, type, namespaces, origType,
+                       elemData = dataPriv.get( elem );
+
+               // Only attach events to objects that accept data
+               if ( !acceptData( elem ) ) {
+                       return;
+               }
+
+               // Caller can pass in an object of custom data in lieu of the handler
+               if ( handler.handler ) {
+                       handleObjIn = handler;
+                       handler = handleObjIn.handler;
+                       selector = handleObjIn.selector;
+               }
+
+               // Ensure that invalid selectors throw exceptions at attach time
+               // Evaluate against documentElement in case elem is a non-element node (e.g., document)
+               if ( selector ) {
+                       jQuery.find.matchesSelector( documentElement, selector );
+               }
+
+               // Make sure that the handler has a unique ID, used to find/remove it later
+               if ( !handler.guid ) {
+                       handler.guid = jQuery.guid++;
+               }
+
+               // Init the element's event structure and main handler, if this is the first
+               if ( !( events = elemData.events ) ) {
+                       events = elemData.events = Object.create( null );
+               }
+               if ( !( eventHandle = elemData.handle ) ) {
+                       eventHandle = elemData.handle = function( e ) {
+
+                               // Discard the second event of a jQuery.event.trigger() and
+                               // when an event is called after a page has unloaded
+                               return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
+                                       jQuery.event.dispatch.apply( elem, arguments ) : undefined;
+                       };
+               }
+
+               // Handle multiple events separated by a space
+               types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
+               t = types.length;
+               while ( t-- ) {
+                       tmp = rtypenamespace.exec( types[ t ] ) || [];
+                       type = origType = tmp[ 1 ];
+                       namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
+
+                       // There *must* be a type, no attaching namespace-only handlers
+                       if ( !type ) {
+                               continue;
+                       }
+
+                       // If event changes its type, use the special event handlers for the changed type
+                       special = jQuery.event.special[ type ] || {};
+
+                       // If selector defined, determine special event api type, otherwise given type
+                       type = ( selector ? special.delegateType : special.bindType ) || type;
+
+                       // Update special based on newly reset type
+                       special = jQuery.event.special[ type ] || {};
+
+                       // handleObj is passed to all event handlers
+                       handleObj = jQuery.extend( {
+                               type: type,
+                               origType: origType,
+                               data: data,
+                               handler: handler,
+                               guid: handler.guid,
+                               selector: selector,
+                               needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
+                               namespace: namespaces.join( "." )
+                       }, handleObjIn );
+
+                       // Init the event handler queue if we're the first
+                       if ( !( handlers = events[ type ] ) ) {
+                               handlers = events[ type ] = [];
+                               handlers.delegateCount = 0;
+
+                               // Only use addEventListener if the special events handler returns false
+                               if ( !special.setup ||
+                                       special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+
+                                       if ( elem.addEventListener ) {
+                                               elem.addEventListener( type, eventHandle );
+                                       }
+                               }
+                       }
+
+                       if ( special.add ) {
+                               special.add.call( elem, handleObj );
+
+                               if ( !handleObj.handler.guid ) {
+                                       handleObj.handler.guid = handler.guid;
+                               }
+                       }
+
+                       // Add to the element's handler list, delegates in front
+                       if ( selector ) {
+                               handlers.splice( handlers.delegateCount++, 0, handleObj );
+                       } else {
+                               handlers.push( handleObj );
+                       }
+
+                       // Keep track of which events have ever been used, for event optimization
+                       jQuery.event.global[ type ] = true;
+               }
+
+       },
+
+       // Detach an event or set of events from an element
+       remove: function( elem, types, handler, selector, mappedTypes ) {
+
+               var j, origCount, tmp,
+                       events, t, handleObj,
+                       special, handlers, type, namespaces, origType,
+                       elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
+
+               if ( !elemData || !( events = elemData.events ) ) {
+                       return;
+               }
+
+               // Once for each type.namespace in types; type may be omitted
+               types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
+               t = types.length;
+               while ( t-- ) {
+                       tmp = rtypenamespace.exec( types[ t ] ) || [];
+                       type = origType = tmp[ 1 ];
+                       namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
+
+                       // Unbind all events (on this namespace, if provided) for the element
+                       if ( !type ) {
+                               for ( type in events ) {
+                                       jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
+                               }
+                               continue;
+                       }
+
+                       special = jQuery.event.special[ type ] || {};
+                       type = ( selector ? special.delegateType : special.bindType ) || type;
+                       handlers = events[ type ] || [];
+                       tmp = tmp[ 2 ] &&
+                               new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
+
+                       // Remove matching events
+                       origCount = j = handlers.length;
+                       while ( j-- ) {
+                               handleObj = handlers[ j ];
+
+                               if ( ( mappedTypes || origType === handleObj.origType ) &&
+                                       ( !handler || handler.guid === handleObj.guid ) &&
+                                       ( !tmp || tmp.test( handleObj.namespace ) ) &&
+                                       ( !selector || selector === handleObj.selector ||
+                                               selector === "**" && handleObj.selector ) ) {
+                                       handlers.splice( j, 1 );
+
+                                       if ( handleObj.selector ) {
+                                               handlers.delegateCount--;
+                                       }
+                                       if ( special.remove ) {
+                                               special.remove.call( elem, handleObj );
+                                       }
+                               }
+                       }
+
+                       // Remove generic event handler if we removed something and no more handlers exist
+                       // (avoids potential for endless recursion during removal of special event handlers)
+                       if ( origCount && !handlers.length ) {
+                               if ( !special.teardown ||
+                                       special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
+
+                                       jQuery.removeEvent( elem, type, elemData.handle );
+                               }
+
+                               delete events[ type ];
+                       }
+               }
+
+               // Remove data and the expando if it's no longer used
+               if ( jQuery.isEmptyObject( events ) ) {
+                       dataPriv.remove( elem, "handle events" );
+               }
+       },
+
+       dispatch: function( nativeEvent ) {
+
+               var i, j, ret, matched, handleObj, handlerQueue,
+                       args = new Array( arguments.length ),
+
+                       // Make a writable jQuery.Event from the native event object
+                       event = jQuery.event.fix( nativeEvent ),
+
+                       handlers = (
+                                       dataPriv.get( this, "events" ) || Object.create( null )
+                               )[ event.type ] || [],
+                       special = jQuery.event.special[ event.type ] || {};
+
+               // Use the fix-ed jQuery.Event rather than the (read-only) native event
+               args[ 0 ] = event;
+
+               for ( i = 1; i < arguments.length; i++ ) {
+                       args[ i ] = arguments[ i ];
+               }
+
+               event.delegateTarget = this;
+
+               // Call the preDispatch hook for the mapped type, and let it bail if desired
+               if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+                       return;
+               }
+
+               // Determine handlers
+               handlerQueue = jQuery.event.handlers.call( this, event, handlers );
+
+               // Run delegates first; they may want to stop propagation beneath us
+               i = 0;
+               while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
+                       event.currentTarget = matched.elem;
+
+                       j = 0;
+                       while ( ( handleObj = matched.handlers[ j++ ] ) &&
+                               !event.isImmediatePropagationStopped() ) {
+
+                               // If the event is namespaced, then each handler is only invoked if it is
+                               // specially universal or its namespaces are a superset of the event's.
+                               if ( !event.rnamespace || handleObj.namespace === false ||
+                                       event.rnamespace.test( handleObj.namespace ) ) {
+
+                                       event.handleObj = handleObj;
+                                       event.data = handleObj.data;
+
+                                       ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
+                                               handleObj.handler ).apply( matched.elem, args );
+
+                                       if ( ret !== undefined ) {
+                                               if ( ( event.result = ret ) === false ) {
+                                                       event.preventDefault();
+                                                       event.stopPropagation();
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               // Call the postDispatch hook for the mapped type
+               if ( special.postDispatch ) {
+                       special.postDispatch.call( this, event );
+               }
+
+               return event.result;
+       },
+
+       handlers: function( event, handlers ) {
+               var i, handleObj, sel, matchedHandlers, matchedSelectors,
+                       handlerQueue = [],
+                       delegateCount = handlers.delegateCount,
+                       cur = event.target;
+
+               // Find delegate handlers
+               if ( delegateCount &&
+
+                       // Support: IE <=9
+                       // Black-hole SVG <use> instance trees (trac-13180)
+                       cur.nodeType &&
+
+                       // Support: Firefox <=42
+                       // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
+                       // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
+                       // Support: IE 11 only
+                       // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
+                       !( event.type === "click" && event.button >= 1 ) ) {
+
+                       for ( ; cur !== this; cur = cur.parentNode || this ) {
+
+                               // Don't check non-elements (#13208)
+                               // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
+                               if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
+                                       matchedHandlers = [];
+                                       matchedSelectors = {};
+                                       for ( i = 0; i < delegateCount; i++ ) {
+                                               handleObj = handlers[ i ];
+
+                                               // Don't conflict with Object.prototype properties (#13203)
+                                               sel = handleObj.selector + " ";
+
+                                               if ( matchedSelectors[ sel ] === undefined ) {
+                                                       matchedSelectors[ sel ] = handleObj.needsContext ?
+                                                               jQuery( sel, this ).index( cur ) > -1 :
+                                                               jQuery.find( sel, this, null, [ cur ] ).length;
+                                               }
+                                               if ( matchedSelectors[ sel ] ) {
+                                                       matchedHandlers.push( handleObj );
+                                               }
+                                       }
+                                       if ( matchedHandlers.length ) {
+                                               handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
+                                       }
+                               }
+                       }
+               }
+
+               // Add the remaining (directly-bound) handlers
+               cur = this;
+               if ( delegateCount < handlers.length ) {
+                       handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
+               }
+
+               return handlerQueue;
+       },
+
+       addProp: function( name, hook ) {
+               Object.defineProperty( jQuery.Event.prototype, name, {
+                       enumerable: true,
+                       configurable: true,
+
+                       get: isFunction( hook ) ?
+                               function() {
+                                       if ( this.originalEvent ) {
+                                                       return hook( this.originalEvent );
+                                       }
+                               } :
+                               function() {
+                                       if ( this.originalEvent ) {
+                                                       return this.originalEvent[ name ];
+                                       }
+                               },
+
+                       set: function( value ) {
+                               Object.defineProperty( this, name, {
+                                       enumerable: true,
+                                       configurable: true,
+                                       writable: true,
+                                       value: value
+                               } );
+                       }
+               } );
+       },
+
+       fix: function( originalEvent ) {
+               return originalEvent[ jQuery.expando ] ?
+                       originalEvent :
+                       new jQuery.Event( originalEvent );
+       },
+
+       special: {
+               load: {
+
+                       // Prevent triggered image.load events from bubbling to window.load
+                       noBubble: true
+               },
+               click: {
+
+                       // Utilize native event to ensure correct state for checkable inputs
+                       setup: function( data ) {
+
+                               // For mutual compressibility with _default, replace `this` access with a local var.
+                               // `|| data` is dead code meant only to preserve the variable through minification.
+                               var el = this || data;
+
+                               // Claim the first handler
+                               if ( rcheckableType.test( el.type ) &&
+                                       el.click && nodeName( el, "input" ) ) {
+
+                                       // dataPriv.set( el, "click", ... )
+                                       leverageNative( el, "click", returnTrue );
+                               }
+
+                               // Return false to allow normal processing in the caller
+                               return false;
+                       },
+                       trigger: function( data ) {
+
+                               // For mutual compressibility with _default, replace `this` access with a local var.
+                               // `|| data` is dead code meant only to preserve the variable through minification.
+                               var el = this || data;
+
+                               // Force setup before triggering a click
+                               if ( rcheckableType.test( el.type ) &&
+                                       el.click && nodeName( el, "input" ) ) {
+
+                                       leverageNative( el, "click" );
+                               }
+
+                               // Return non-false to allow normal event-path propagation
+                               return true;
+                       },
+
+                       // For cross-browser consistency, suppress native .click() on links
+                       // Also prevent it if we're currently inside a leveraged native-event stack
+                       _default: function( event ) {
+                               var target = event.target;
+                               return rcheckableType.test( target.type ) &&
+                                       target.click && nodeName( target, "input" ) &&
+                                       dataPriv.get( target, "click" ) ||
+                                       nodeName( target, "a" );
+                       }
+               },
+
+               beforeunload: {
+                       postDispatch: function( event ) {
+
+                               // Support: Firefox 20+
+                               // Firefox doesn't alert if the returnValue field is not set.
+                               if ( event.result !== undefined && event.originalEvent ) {
+                                       event.originalEvent.returnValue = event.result;
+                               }
+                       }
+               }
+       }
+};
+
+// Ensure the presence of an event listener that handles manually-triggered
+// synthetic events by interrupting progress until reinvoked in response to
+// *native* events that it fires directly, ensuring that state changes have
+// already occurred before other listeners are invoked.
+function leverageNative( el, type, expectSync ) {
+
+       // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
+       if ( !expectSync ) {
+               if ( dataPriv.get( el, type ) === undefined ) {
+                       jQuery.event.add( el, type, returnTrue );
+               }
+               return;
+       }
+
+       // Register the controller as a special universal handler for all event namespaces
+       dataPriv.set( el, type, false );
+       jQuery.event.add( el, type, {
+               namespace: false,
+               handler: function( event ) {
+                       var notAsync, result,
+                               saved = dataPriv.get( this, type );
+
+                       if ( ( event.isTrigger & 1 ) && this[ type ] ) {
+
+                               // Interrupt processing of the outer synthetic .trigger()ed event
+                               // Saved data should be false in such cases, but might be a leftover capture object
+                               // from an async native handler (gh-4350)
+                               if ( !saved.length ) {
+
+                                       // Store arguments for use when handling the inner native event
+                                       // There will always be at least one argument (an event object), so this array
+                                       // will not be confused with a leftover capture object.
+                                       saved = slice.call( arguments );
+                                       dataPriv.set( this, type, saved );
+
+                                       // Trigger the native event and capture its result
+                                       // Support: IE <=9 - 11+
+                                       // focus() and blur() are asynchronous
+                                       notAsync = expectSync( this, type );
+                                       this[ type ]();
+                                       result = dataPriv.get( this, type );
+                                       if ( saved !== result || notAsync ) {
+                                               dataPriv.set( this, type, false );
+                                       } else {
+                                               result = {};
+                                       }
+                                       if ( saved !== result ) {
+
+                                               // Cancel the outer synthetic event
+                                               event.stopImmediatePropagation();
+                                               event.preventDefault();
+                                               return result.value;
+                                       }
+
+                               // If this is an inner synthetic event for an event with a bubbling surrogate
+                               // (focus or blur), assume that the surrogate already propagated from triggering the
+                               // native event and prevent that from happening again here.
+                               // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
+                               // bubbling surrogate propagates *after* the non-bubbling base), but that seems
+                               // less bad than duplication.
+                               } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
+                                       event.stopPropagation();
+                               }
+
+                       // If this is a native event triggered above, everything is now in order
+                       // Fire an inner synthetic event with the original arguments
+                       } else if ( saved.length ) {
+
+                               // ...and capture the result
+                               dataPriv.set( this, type, {
+                                       value: jQuery.event.trigger(
+
+                                               // Support: IE <=9 - 11+
+                                               // Extend with the prototype to reset the above stopImmediatePropagation()
+                                               jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
+                                               saved.slice( 1 ),
+                                               this
+                                       )
+                               } );
+
+                               // Abort handling of the native event
+                               event.stopImmediatePropagation();
+                       }
+               }
+       } );
+}
+
+jQuery.removeEvent = function( elem, type, handle ) {
+
+       // This "if" is needed for plain objects
+       if ( elem.removeEventListener ) {
+               elem.removeEventListener( type, handle );
+       }
+};
+
+jQuery.Event = function( src, props ) {
+
+       // Allow instantiation without the 'new' keyword
+       if ( !( this instanceof jQuery.Event ) ) {
+               return new jQuery.Event( src, props );
+       }
+
+       // Event object
+       if ( src && src.type ) {
+               this.originalEvent = src;
+               this.type = src.type;
+
+               // Events bubbling up the document may have been marked as prevented
+               // by a handler lower down the tree; reflect the correct value.
+               this.isDefaultPrevented = src.defaultPrevented ||
+                               src.defaultPrevented === undefined &&
+
+                               // Support: Android <=2.3 only
+                               src.returnValue === false ?
+                       returnTrue :
+                       returnFalse;
+
+               // Create target properties
+               // Support: Safari <=6 - 7 only
+               // Target should not be a text node (#504, #13143)
+               this.target = ( src.target && src.target.nodeType === 3 ) ?
+                       src.target.parentNode :
+                       src.target;
+
+               this.currentTarget = src.currentTarget;
+               this.relatedTarget = src.relatedTarget;
+
+       // Event type
+       } else {
+               this.type = src;
+       }
+
+       // Put explicitly provided properties onto the event object
+       if ( props ) {
+               jQuery.extend( this, props );
+       }
+
+       // Create a timestamp if incoming event doesn't have one
+       this.timeStamp = src && src.timeStamp || Date.now();
+
+       // Mark it as fixed
+       this[ jQuery.expando ] = true;
+};
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+       constructor: jQuery.Event,
+       isDefaultPrevented: returnFalse,
+       isPropagationStopped: returnFalse,
+       isImmediatePropagationStopped: returnFalse,
+       isSimulated: false,
+
+       preventDefault: function() {
+               var e = this.originalEvent;
+
+               this.isDefaultPrevented = returnTrue;
+
+               if ( e && !this.isSimulated ) {
+                       e.preventDefault();
+               }
+       },
+       stopPropagation: function() {
+               var e = this.originalEvent;
+
+               this.isPropagationStopped = returnTrue;
+
+               if ( e && !this.isSimulated ) {
+                       e.stopPropagation();
+               }
+       },
+       stopImmediatePropagation: function() {
+               var e = this.originalEvent;
+
+               this.isImmediatePropagationStopped = returnTrue;
+
+               if ( e && !this.isSimulated ) {
+                       e.stopImmediatePropagation();
+               }
+
+               this.stopPropagation();
+       }
+};
+
+// Includes all common event props including KeyEvent and MouseEvent specific props
+jQuery.each( {
+       altKey: true,
+       bubbles: true,
+       cancelable: true,
+       changedTouches: true,
+       ctrlKey: true,
+       detail: true,
+       eventPhase: true,
+       metaKey: true,
+       pageX: true,
+       pageY: true,
+       shiftKey: true,
+       view: true,
+       "char": true,
+       code: true,
+       charCode: true,
+       key: true,
+       keyCode: true,
+       button: true,
+       buttons: true,
+       clientX: true,
+       clientY: true,
+       offsetX: true,
+       offsetY: true,
+       pointerId: true,
+       pointerType: true,
+       screenX: true,
+       screenY: true,
+       targetTouches: true,
+       toElement: true,
+       touches: true,
+
+       which: function( event ) {
+               var button = event.button;
+
+               // Add which for key events
+               if ( event.which == null && rkeyEvent.test( event.type ) ) {
+                       return event.charCode != null ? event.charCode : event.keyCode;
+               }
+
+               // Add which for click: 1 === left; 2 === middle; 3 === right
+               if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
+                       if ( button & 1 ) {
+                               return 1;
+                       }
+
+                       if ( button & 2 ) {
+                               return 3;
+                       }
+
+                       if ( button & 4 ) {
+                               return 2;
+                       }
+
+                       return 0;
+               }
+
+               return event.which;
+       }
+}, jQuery.event.addProp );
+
+jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
+       jQuery.event.special[ type ] = {
+
+               // Utilize native event if possible so blur/focus sequence is correct
+               setup: function() {
+
+                       // Claim the first handler
+                       // dataPriv.set( this, "focus", ... )
+                       // dataPriv.set( this, "blur", ... )
+                       leverageNative( this, type, expectSync );
+
+                       // Return false to allow normal processing in the caller
+                       return false;
+               },
+               trigger: function() {
+
+                       // Force setup before trigger
+                       leverageNative( this, type );
+
+                       // Return non-false to allow normal event-path propagation
+                       return true;
+               },
+
+               delegateType: delegateType
+       };
+} );
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+// so that event delegation works in jQuery.
+// Do the same for pointerenter/pointerleave and pointerover/pointerout
+//
+// Support: Safari 7 only
+// Safari sends mouseenter too often; see:
+// https://bugs.chromium.org/p/chromium/issues/detail?id=470258
+// for the description of the bug (it existed in older Chrome versions as well).
+jQuery.each( {
+       mouseenter: "mouseover",
+       mouseleave: "mouseout",
+       pointerenter: "pointerover",
+       pointerleave: "pointerout"
+}, function( orig, fix ) {
+       jQuery.event.special[ orig ] = {
+               delegateType: fix,
+               bindType: fix,
+
+               handle: function( event ) {
+                       var ret,
+                               target = this,
+                               related = event.relatedTarget,
+                               handleObj = event.handleObj;
+
+                       // For mouseenter/leave call the handler if related is outside the target.
+                       // NB: No relatedTarget if the mouse left/entered the browser window
+                       if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
+                               event.type = handleObj.origType;
+                               ret = handleObj.handler.apply( this, arguments );
+                               event.type = fix;
+                       }
+                       return ret;
+               }
+       };
+} );
+
+jQuery.fn.extend( {
+
+       on: function( types, selector, data, fn ) {
+               return on( this, types, selector, data, fn );
+       },
+       one: function( types, selector, data, fn ) {
+               return on( this, types, selector, data, fn, 1 );
+       },
+       off: function( types, selector, fn ) {
+               var handleObj, type;
+               if ( types && types.preventDefault && types.handleObj ) {
+
+                       // ( event )  dispatched jQuery.Event
+                       handleObj = types.handleObj;
+                       jQuery( types.delegateTarget ).off(
+                               handleObj.namespace ?
+                                       handleObj.origType + "." + handleObj.namespace :
+                                       handleObj.origType,
+                               handleObj.selector,
+                               handleObj.handler
+                       );
+                       return this;
+               }
+               if ( typeof types === "object" ) {
+
+                       // ( types-object [, selector] )
+                       for ( type in types ) {
+                               this.off( type, selector, types[ type ] );
+                       }
+                       return this;
+               }
+               if ( selector === false || typeof selector === "function" ) {
+
+                       // ( types [, fn] )
+                       fn = selector;
+                       selector = undefined;
+               }
+               if ( fn === false ) {
+                       fn = returnFalse;
+               }
+               return this.each( function() {
+                       jQuery.event.remove( this, types, fn, selector );
+               } );
+       }
+} );
+
+
+var
+
+       // Support: IE <=10 - 11, Edge 12 - 13 only
+       // In IE/Edge using regex groups here causes severe slowdowns.
+       // See https://connect.microsoft.com/IE/feedback/details/1736512/
+       rnoInnerhtml = /<script|<style|<link/i,
+
+       // checked="checked" or checked
+       rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
+       rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
+
+// Prefer a tbody over its parent table for containing new rows
+function manipulationTarget( elem, content ) {
+       if ( nodeName( elem, "table" ) &&
+               nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
+
+               return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
+       }
+
+       return elem;
+}
+
+// Replace/restore the type attribute of script elements for safe DOM manipulation
+function disableScript( elem ) {
+       elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
+       return elem;
+}
+function restoreScript( elem ) {
+       if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
+               elem.type = elem.type.slice( 5 );
+       } else {
+               elem.removeAttribute( "type" );
+       }
+
+       return elem;
+}
+
+function cloneCopyEvent( src, dest ) {
+       var i, l, type, pdataOld, udataOld, udataCur, events;
+
+       if ( dest.nodeType !== 1 ) {
+               return;
+       }
+
+       // 1. Copy private data: events, handlers, etc.
+       if ( dataPriv.hasData( src ) ) {
+               pdataOld = dataPriv.get( src );
+               events = pdataOld.events;
+
+               if ( events ) {
+                       dataPriv.remove( dest, "handle events" );
+
+                       for ( type in events ) {
+                               for ( i = 0, l = events[ type ].length; i < l; i++ ) {
+                                       jQuery.event.add( dest, type, events[ type ][ i ] );
+                               }
+                       }
+               }
+       }
+
+       // 2. Copy user data
+       if ( dataUser.hasData( src ) ) {
+               udataOld = dataUser.access( src );
+               udataCur = jQuery.extend( {}, udataOld );
+
+               dataUser.set( dest, udataCur );
+       }
+}
+
+// Fix IE bugs, see support tests
+function fixInput( src, dest ) {
+       var nodeName = dest.nodeName.toLowerCase();
+
+       // Fails to persist the checked state of a cloned checkbox or radio button.
+       if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
+               dest.checked = src.checked;
+
+       // Fails to return the selected option to the default selected state when cloning options
+       } else if ( nodeName === "input" || nodeName === "textarea" ) {
+               dest.defaultValue = src.defaultValue;
+       }
+}
+
+function domManip( collection, args, callback, ignored ) {
+
+       // Flatten any nested arrays
+       args = flat( args );
+
+       var fragment, first, scripts, hasScripts, node, doc,
+               i = 0,
+               l = collection.length,
+               iNoClone = l - 1,
+               value = args[ 0 ],
+               valueIsFunction = isFunction( value );
+
+       // We can't cloneNode fragments that contain checked, in WebKit
+       if ( valueIsFunction ||
+                       ( l > 1 && typeof value === "string" &&
+                               !support.checkClone && rchecked.test( value ) ) ) {
+               return collection.each( function( index ) {
+                       var self = collection.eq( index );
+                       if ( valueIsFunction ) {
+                               args[ 0 ] = value.call( this, index, self.html() );
+                       }
+                       domManip( self, args, callback, ignored );
+               } );
+       }
+
+       if ( l ) {
+               fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
+               first = fragment.firstChild;
+
+               if ( fragment.childNodes.length === 1 ) {
+                       fragment = first;
+               }
+
+               // Require either new content or an interest in ignored elements to invoke the callback
+               if ( first || ignored ) {
+                       scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
+                       hasScripts = scripts.length;
+
+                       // Use the original fragment for the last item
+                       // instead of the first because it can end up
+                       // being emptied incorrectly in certain situations (#8070).
+                       for ( ; i < l; i++ ) {
+                               node = fragment;
+
+                               if ( i !== iNoClone ) {
+                                       node = jQuery.clone( node, true, true );
+
+                                       // Keep references to cloned scripts for later restoration
+                                       if ( hasScripts ) {
+
+                                               // Support: Android <=4.0 only, PhantomJS 1 only
+                                               // push.apply(_, arraylike) throws on ancient WebKit
+                                               jQuery.merge( scripts, getAll( node, "script" ) );
+                                       }
+                               }
+
+                               callback.call( collection[ i ], node, i );
+                       }
+
+                       if ( hasScripts ) {
+                               doc = scripts[ scripts.length - 1 ].ownerDocument;
+
+                               // Reenable scripts
+                               jQuery.map( scripts, restoreScript );
+
+                               // Evaluate executable scripts on first document insertion
+                               for ( i = 0; i < hasScripts; i++ ) {
+                                       node = scripts[ i ];
+                                       if ( rscriptType.test( node.type || "" ) &&
+                                               !dataPriv.access( node, "globalEval" ) &&
+                                               jQuery.contains( doc, node ) ) {
+
+                                               if ( node.src && ( node.type || "" ).toLowerCase()  !== "module" ) {
+
+                                                       // Optional AJAX dependency, but won't run scripts if not present
+                                                       if ( jQuery._evalUrl && !node.noModule ) {
+                                                               jQuery._evalUrl( node.src, {
+                                                                       nonce: node.nonce || node.getAttribute( "nonce" )
+                                                               }, doc );
+                                                       }
+                                               } else {
+                                                       DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       return collection;
+}
+
+function remove( elem, selector, keepData ) {
+       var node,
+               nodes = selector ? jQuery.filter( selector, elem ) : elem,
+               i = 0;
+
+       for ( ; ( node = nodes[ i ] ) != null; i++ ) {
+               if ( !keepData && node.nodeType === 1 ) {
+                       jQuery.cleanData( getAll( node ) );
+               }
+
+               if ( node.parentNode ) {
+                       if ( keepData && isAttached( node ) ) {
+                               setGlobalEval( getAll( node, "script" ) );
+                       }
+                       node.parentNode.removeChild( node );
+               }
+       }
+
+       return elem;
+}
+
+jQuery.extend( {
+       htmlPrefilter: function( html ) {
+               return html;
+       },
+
+       clone: function( elem, dataAndEvents, deepDataAndEvents ) {
+               var i, l, srcElements, destElements,
+                       clone = elem.cloneNode( true ),
+                       inPage = isAttached( elem );
+
+               // Fix IE cloning issues
+               if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
+                               !jQuery.isXMLDoc( elem ) ) {
+
+                       // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
+                       destElements = getAll( clone );
+                       srcElements = getAll( elem );
+
+                       for ( i = 0, l = srcElements.length; i < l; i++ ) {
+                               fixInput( srcElements[ i ], destElements[ i ] );
+                       }
+               }
+
+               // Copy the events from the original to the clone
+               if ( dataAndEvents ) {
+                       if ( deepDataAndEvents ) {
+                               srcElements = srcElements || getAll( elem );
+                               destElements = destElements || getAll( clone );
+
+                               for ( i = 0, l = srcElements.length; i < l; i++ ) {
+                                       cloneCopyEvent( srcElements[ i ], destElements[ i ] );
+                               }
+                       } else {
+                               cloneCopyEvent( elem, clone );
+                       }
+               }
+
+               // Preserve script evaluation history
+               destElements = getAll( clone, "script" );
+               if ( destElements.length > 0 ) {
+                       setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
+               }
+
+               // Return the cloned set
+               return clone;
+       },
+
+       cleanData: function( elems ) {
+               var data, elem, type,
+                       special = jQuery.event.special,
+                       i = 0;
+
+               for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
+                       if ( acceptData( elem ) ) {
+                               if ( ( data = elem[ dataPriv.expando ] ) ) {
+                                       if ( data.events ) {
+                                               for ( type in data.events ) {
+                                                       if ( special[ type ] ) {
+                                                               jQuery.event.remove( elem, type );
+
+                                                       // This is a shortcut to avoid jQuery.event.remove's overhead
+                                                       } else {
+                                                               jQuery.removeEvent( elem, type, data.handle );
+                                                       }
+                                               }
+                                       }
+
+                                       // Support: Chrome <=35 - 45+
+                                       // Assign undefined instead of using delete, see Data#remove
+                                       elem[ dataPriv.expando ] = undefined;
+                               }
+                               if ( elem[ dataUser.expando ] ) {
+
+                                       // Support: Chrome <=35 - 45+
+                                       // Assign undefined instead of using delete, see Data#remove
+                                       elem[ dataUser.expando ] = undefined;
+                               }
+                       }
+               }
+       }
+} );
+
+jQuery.fn.extend( {
+       detach: function( selector ) {
+               return remove( this, selector, true );
+       },
+
+       remove: function( selector ) {
+               return remove( this, selector );
+       },
+
+       text: function( value ) {
+               return access( this, function( value ) {
+                       return value === undefined ?
+                               jQuery.text( this ) :
+                               this.empty().each( function() {
+                                       if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+                                               this.textContent = value;
+                                       }
+                               } );
+               }, null, value, arguments.length );
+       },
+
+       append: function() {
+               return domManip( this, arguments, function( elem ) {
+                       if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+                               var target = manipulationTarget( this, elem );
+                               target.appendChild( elem );
+                       }
+               } );
+       },
+
+       prepend: function() {
+               return domManip( this, arguments, function( elem ) {
+                       if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+                               var target = manipulationTarget( this, elem );
+                               target.insertBefore( elem, target.firstChild );
+                       }
+               } );
+       },
+
+       before: function() {
+               return domManip( this, arguments, function( elem ) {
+                       if ( this.parentNode ) {
+                               this.parentNode.insertBefore( elem, this );
+                       }
+               } );
+       },
+
+       after: function() {
+               return domManip( this, arguments, function( elem ) {
+                       if ( this.parentNode ) {
+                               this.parentNode.insertBefore( elem, this.nextSibling );
+                       }
+               } );
+       },
+
+       empty: function() {
+               var elem,
+                       i = 0;
+
+               for ( ; ( elem = this[ i ] ) != null; i++ ) {
+                       if ( elem.nodeType === 1 ) {
+
+                               // Prevent memory leaks
+                               jQuery.cleanData( getAll( elem, false ) );
+
+                               // Remove any remaining nodes
+                               elem.textContent = "";
+                       }
+               }
+
+               return this;
+       },
+
+       clone: function( dataAndEvents, deepDataAndEvents ) {
+               dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+               deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+               return this.map( function() {
+                       return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
+               } );
+       },
+
+       html: function( value ) {
+               return access( this, function( value ) {
+                       var elem = this[ 0 ] || {},
+                               i = 0,
+                               l = this.length;
+
+                       if ( value === undefined && elem.nodeType === 1 ) {
+                               return elem.innerHTML;
+                       }
+
+                       // See if we can take a shortcut and just use innerHTML
+                       if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+                               !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
+
+                               value = jQuery.htmlPrefilter( value );
+
+                               try {
+                                       for ( ; i < l; i++ ) {
+                                               elem = this[ i ] || {};
+
+                                               // Remove element nodes and prevent memory leaks
+                                               if ( elem.nodeType === 1 ) {
+                                                       jQuery.cleanData( getAll( elem, false ) );
+                                                       elem.innerHTML = value;
+                                               }
+                                       }
+
+                                       elem = 0;
+
+                               // If using innerHTML throws an exception, use the fallback method
+                               } catch ( e ) {}
+                       }
+
+                       if ( elem ) {
+                               this.empty().append( value );
+                       }
+               }, null, value, arguments.length );
+       },
+
+       replaceWith: function() {
+               var ignored = [];
+
+               // Make the changes, replacing each non-ignored context element with the new content
+               return domManip( this, arguments, function( elem ) {
+                       var parent = this.parentNode;
+
+                       if ( jQuery.inArray( this, ignored ) < 0 ) {
+                               jQuery.cleanData( getAll( this ) );
+                               if ( parent ) {
+                                       parent.replaceChild( elem, this );
+                               }
+                       }
+
+               // Force callback invocation
+               }, ignored );
+       }
+} );
+
+jQuery.each( {
+       appendTo: "append",
+       prependTo: "prepend",
+       insertBefore: "before",
+       insertAfter: "after",
+       replaceAll: "replaceWith"
+}, function( name, original ) {
+       jQuery.fn[ name ] = function( selector ) {
+               var elems,
+                       ret = [],
+                       insert = jQuery( selector ),
+                       last = insert.length - 1,
+                       i = 0;
+
+               for ( ; i <= last; i++ ) {
+                       elems = i === last ? this : this.clone( true );
+                       jQuery( insert[ i ] )[ original ]( elems );
+
+                       // Support: Android <=4.0 only, PhantomJS 1 only
+                       // .get() because push.apply(_, arraylike) throws on ancient WebKit
+                       push.apply( ret, elems.get() );
+               }
+
+               return this.pushStack( ret );
+       };
+} );
+var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
+
+var getStyles = function( elem ) {
+
+               // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
+               // IE throws on elements created in popups
+               // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
+               var view = elem.ownerDocument.defaultView;
+
+               if ( !view || !view.opener ) {
+                       view = window;
+               }
+
+               return view.getComputedStyle( elem );
+       };
+
+var swap = function( elem, options, callback ) {
+       var ret, name,
+               old = {};
+
+       // Remember the old values, and insert the new ones
+       for ( name in options ) {
+               old[ name ] = elem.style[ name ];
+               elem.style[ name ] = options[ name ];
+       }
+
+       ret = callback.call( elem );
+
+       // Revert the old values
+       for ( name in options ) {
+               elem.style[ name ] = old[ name ];
+       }
+
+       return ret;
+};
+
+
+var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
+
+
+
+( function() {
+
+       // Executing both pixelPosition & boxSizingReliable tests require only one layout
+       // so they're executed at the same time to save the second computation.
+       function computeStyleTests() {
+
+               // This is a singleton, we need to execute it only once
+               if ( !div ) {
+                       return;
+               }
+
+               container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
+                       "margin-top:1px;padding:0;border:0";
+               div.style.cssText =
+                       "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
+                       "margin:auto;border:1px;padding:1px;" +
+                       "width:60%;top:1%";
+               documentElement.appendChild( container ).appendChild( div );
+
+               var divStyle = window.getComputedStyle( div );
+               pixelPositionVal = divStyle.top !== "1%";
+
+               // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
+               reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
+
+               // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
+               // Some styles come back with percentage values, even though they shouldn't
+               div.style.right = "60%";
+               pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
+
+               // Support: IE 9 - 11 only
+               // Detect misreporting of content dimensions for box-sizing:border-box elements
+               boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
+
+               // Support: IE 9 only
+               // Detect overflow:scroll screwiness (gh-3699)
+               // Support: Chrome <=64
+               // Don't get tricked when zoom affects offsetWidth (gh-4029)
+               div.style.position = "absolute";
+               scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
+
+               documentElement.removeChild( container );
+
+               // Nullify the div so it wouldn't be stored in the memory and
+               // it will also be a sign that checks already performed
+               div = null;
+       }
+
+       function roundPixelMeasures( measure ) {
+               return Math.round( parseFloat( measure ) );
+       }
+
+       var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
+               reliableTrDimensionsVal, reliableMarginLeftVal,
+               container = document.createElement( "div" ),
+               div = document.createElement( "div" );
+
+       // Finish early in limited (non-browser) environments
+       if ( !div.style ) {
+               return;
+       }
+
+       // Support: IE <=9 - 11 only
+       // Style of cloned element affects source element cloned (#8908)
+       div.style.backgroundClip = "content-box";
+       div.cloneNode( true ).style.backgroundClip = "";
+       support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
+       jQuery.extend( support, {
+               boxSizingReliable: function() {
+                       computeStyleTests();
+                       return boxSizingReliableVal;
+               },
+               pixelBoxStyles: function() {
+                       computeStyleTests();
+                       return pixelBoxStylesVal;
+               },
+               pixelPosition: function() {
+                       computeStyleTests();
+                       return pixelPositionVal;
+               },
+               reliableMarginLeft: function() {
+                       computeStyleTests();
+                       return reliableMarginLeftVal;
+               },
+               scrollboxSize: function() {
+                       computeStyleTests();
+                       return scrollboxSizeVal;
+               },
+
+               // Support: IE 9 - 11+, Edge 15 - 18+
+               // IE/Edge misreport `getComputedStyle` of table rows with width/height
+               // set in CSS while `offset*` properties report correct values.
+               // Behavior in IE 9 is more subtle than in newer versions & it passes
+               // some versions of this test; make sure not to make it pass there!
+               reliableTrDimensions: function() {
+                       var table, tr, trChild, trStyle;
+                       if ( reliableTrDimensionsVal == null ) {
+                               table = document.createElement( "table" );
+                               tr = document.createElement( "tr" );
+                               trChild = document.createElement( "div" );
+
+                               table.style.cssText = "position:absolute;left:-11111px";
+                               tr.style.height = "1px";
+                               trChild.style.height = "9px";
+
+                               documentElement
+                                       .appendChild( table )
+                                       .appendChild( tr )
+                                       .appendChild( trChild );
+
+                               trStyle = window.getComputedStyle( tr );
+                               reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
+
+                               documentElement.removeChild( table );
+                       }
+                       return reliableTrDimensionsVal;
+               }
+       } );
+} )();
+
+
+function curCSS( elem, name, computed ) {
+       var width, minWidth, maxWidth, ret,
+
+               // Support: Firefox 51+
+               // Retrieving style before computed somehow
+               // fixes an issue with getting wrong values
+               // on detached elements
+               style = elem.style;
+
+       computed = computed || getStyles( elem );
+
+       // getPropertyValue is needed for:
+       //   .css('filter') (IE 9 only, #12537)
+       //   .css('--customProperty) (#3144)
+       if ( computed ) {
+               ret = computed.getPropertyValue( name ) || computed[ name ];
+
+               if ( ret === "" && !isAttached( elem ) ) {
+                       ret = jQuery.style( elem, name );
+               }
+
+               // A tribute to the "awesome hack by Dean Edwards"
+               // Android Browser returns percentage for some values,
+               // but width seems to be reliably pixels.
+               // This is against the CSSOM draft spec:
+               // https://drafts.csswg.org/cssom/#resolved-values
+               if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
+
+                       // Remember the original values
+                       width = style.width;
+                       minWidth = style.minWidth;
+                       maxWidth = style.maxWidth;
+
+                       // Put in the new values to get a computed value out
+                       style.minWidth = style.maxWidth = style.width = ret;
+                       ret = computed.width;
+
+                       // Revert the changed values
+                       style.width = width;
+                       style.minWidth = minWidth;
+                       style.maxWidth = maxWidth;
+               }
+       }
+
+       return ret !== undefined ?
+
+               // Support: IE <=9 - 11 only
+               // IE returns zIndex value as an integer.
+               ret + "" :
+               ret;
+}
+
+
+function addGetHookIf( conditionFn, hookFn ) {
+
+       // Define the hook, we'll check on the first run if it's really needed.
+       return {
+               get: function() {
+                       if ( conditionFn() ) {
+
+                               // Hook not needed (or it's not possible to use it due
+                               // to missing dependency), remove it.
+                               delete this.get;
+                               return;
+                       }
+
+                       // Hook needed; redefine it so that the support test is not executed again.
+                       return ( this.get = hookFn ).apply( this, arguments );
+               }
+       };
+}
+
+
+var cssPrefixes = [ "Webkit", "Moz", "ms" ],
+       emptyStyle = document.createElement( "div" ).style,
+       vendorProps = {};
+
+// Return a vendor-prefixed property or undefined
+function vendorPropName( name ) {
+
+       // Check for vendor prefixed names
+       var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
+               i = cssPrefixes.length;
+
+       while ( i-- ) {
+               name = cssPrefixes[ i ] + capName;
+               if ( name in emptyStyle ) {
+                       return name;
+               }
+       }
+}
+
+// Return a potentially-mapped jQuery.cssProps or vendor prefixed property
+function finalPropName( name ) {
+       var final = jQuery.cssProps[ name ] || vendorProps[ name ];
+
+       if ( final ) {
+               return final;
+       }
+       if ( name in emptyStyle ) {
+               return name;
+       }
+       return vendorProps[ name ] = vendorPropName( name ) || name;
+}
+
+
+var
+
+       // Swappable if display is none or starts with table
+       // except "table", "table-cell", or "table-caption"
+       // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
+       rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+       rcustomProp = /^--/,
+       cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+       cssNormalTransform = {
+               letterSpacing: "0",
+               fontWeight: "400"
+       };
+
+function setPositiveNumber( _elem, value, subtract ) {
+
+       // Any relative (+/-) values have already been
+       // normalized at this point
+       var matches = rcssNum.exec( value );
+       return matches ?
+
+               // Guard against undefined "subtract", e.g., when used as in cssHooks
+               Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
+               value;
+}
+
+function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
+       var i = dimension === "width" ? 1 : 0,
+               extra = 0,
+               delta = 0;
+
+       // Adjustment may not be necessary
+       if ( box === ( isBorderBox ? "border" : "content" ) ) {
+               return 0;
+       }
+
+       for ( ; i < 4; i += 2 ) {
+
+               // Both box models exclude margin
+               if ( box === "margin" ) {
+                       delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
+               }
+
+               // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
+               if ( !isBorderBox ) {
+
+                       // Add padding
+                       delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+
+                       // For "border" or "margin", add border
+                       if ( box !== "padding" ) {
+                               delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+
+                       // But still keep track of it otherwise
+                       } else {
+                               extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+                       }
+
+               // If we get here with a border-box (content + padding + border), we're seeking "content" or
+               // "padding" or "margin"
+               } else {
+
+                       // For "content", subtract padding
+                       if ( box === "content" ) {
+                               delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+                       }
+
+                       // For "content" or "padding", subtract border
+                       if ( box !== "margin" ) {
+                               delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+                       }
+               }
+       }
+
+       // Account for positive content-box scroll gutter when requested by providing computedVal
+       if ( !isBorderBox && computedVal >= 0 ) {
+
+               // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
+               // Assuming integer scroll gutter, subtract the rest and round down
+               delta += Math.max( 0, Math.ceil(
+                       elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
+                       computedVal -
+                       delta -
+                       extra -
+                       0.5
+
+               // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
+               // Use an explicit zero to avoid NaN (gh-3964)
+               ) ) || 0;
+       }
+
+       return delta;
+}
+
+function getWidthOrHeight( elem, dimension, extra ) {
+
+       // Start with computed style
+       var styles = getStyles( elem ),
+
+               // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
+               // Fake content-box until we know it's needed to know the true value.
+               boxSizingNeeded = !support.boxSizingReliable() || extra,
+               isBorderBox = boxSizingNeeded &&
+                       jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
+               valueIsBorderBox = isBorderBox,
+
+               val = curCSS( elem, dimension, styles ),
+               offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
+
+       // Support: Firefox <=54
+       // Return a confounding non-pixel value or feign ignorance, as appropriate.
+       if ( rnumnonpx.test( val ) ) {
+               if ( !extra ) {
+                       return val;
+               }
+               val = "auto";
+       }
+
+
+       // Support: IE 9 - 11 only
+       // Use offsetWidth/offsetHeight for when box sizing is unreliable.
+       // In those cases, the computed value can be trusted to be border-box.
+       if ( ( !support.boxSizingReliable() && isBorderBox ||
+
+               // Support: IE 10 - 11+, Edge 15 - 18+
+               // IE/Edge misreport `getComputedStyle` of table rows with width/height
+               // set in CSS while `offset*` properties report correct values.
+               // Interestingly, in some cases IE 9 doesn't suffer from this issue.
+               !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
+
+               // Fall back to offsetWidth/offsetHeight when value is "auto"
+               // This happens for inline elements with no explicit setting (gh-3571)
+               val === "auto" ||
+
+               // Support: Android <=4.1 - 4.3 only
+               // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
+               !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
+
+               // Make sure the element is visible & connected
+               elem.getClientRects().length ) {
+
+               isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
+
+               // Where available, offsetWidth/offsetHeight approximate border box dimensions.
+               // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
+               // retrieved value as a content box dimension.
+               valueIsBorderBox = offsetProp in elem;
+               if ( valueIsBorderBox ) {
+                       val = elem[ offsetProp ];
+               }
+       }
+
+       // Normalize "" and auto
+       val = parseFloat( val ) || 0;
+
+       // Adjust for the element's box model
+       return ( val +
+               boxModelAdjustment(
+                       elem,
+                       dimension,
+                       extra || ( isBorderBox ? "border" : "content" ),
+                       valueIsBorderBox,
+                       styles,
+
+                       // Provide the current computed size to request scroll gutter calculation (gh-3589)
+                       val
+               )
+       ) + "px";
+}
+
+jQuery.extend( {
+
+       // Add in style property hooks for overriding the default
+       // behavior of getting and setting a style property
+       cssHooks: {
+               opacity: {
+                       get: function( elem, computed ) {
+                               if ( computed ) {
+
+                                       // We should always get a number back from opacity
+                                       var ret = curCSS( elem, "opacity" );
+                                       return ret === "" ? "1" : ret;
+                               }
+                       }
+               }
+       },
+
+       // Don't automatically add "px" to these possibly-unitless properties
+       cssNumber: {
+               "animationIterationCount": true,
+               "columnCount": true,
+               "fillOpacity": true,
+               "flexGrow": true,
+               "flexShrink": true,
+               "fontWeight": true,
+               "gridArea": true,
+               "gridColumn": true,
+               "gridColumnEnd": true,
+               "gridColumnStart": true,
+               "gridRow": true,
+               "gridRowEnd": true,
+               "gridRowStart": true,
+               "lineHeight": true,
+               "opacity": true,
+               "order": true,
+               "orphans": true,
+               "widows": true,
+               "zIndex": true,
+               "zoom": true
+       },
+
+       // Add in properties whose names you wish to fix before
+       // setting or getting the value
+       cssProps: {},
+
+       // Get and set the style property on a DOM Node
+       style: function( elem, name, value, extra ) {
+
+               // Don't set styles on text and comment nodes
+               if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
+                       return;
+               }
+
+               // Make sure that we're working with the right name
+               var ret, type, hooks,
+                       origName = camelCase( name ),
+                       isCustomProp = rcustomProp.test( name ),
+                       style = elem.style;
+
+               // Make sure that we're working with the right name. We don't
+               // want to query the value if it is a CSS custom property
+               // since they are user-defined.
+               if ( !isCustomProp ) {
+                       name = finalPropName( origName );
+               }
+
+               // Gets hook for the prefixed version, then unprefixed version
+               hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+               // Check if we're setting a value
+               if ( value !== undefined ) {
+                       type = typeof value;
+
+                       // Convert "+=" or "-=" to relative numbers (#7345)
+                       if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
+                               value = adjustCSS( elem, name, ret );
+
+                               // Fixes bug #9237
+                               type = "number";
+                       }
+
+                       // Make sure that null and NaN values aren't set (#7116)
+                       if ( value == null || value !== value ) {
+                               return;
+                       }
+
+                       // If a number was passed in, add the unit (except for certain CSS properties)
+                       // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
+                       // "px" to a few hardcoded values.
+                       if ( type === "number" && !isCustomProp ) {
+                               value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
+                       }
+
+                       // background-* props affect original clone's values
+                       if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
+                               style[ name ] = "inherit";
+                       }
+
+                       // If a hook was provided, use that value, otherwise just set the specified value
+                       if ( !hooks || !( "set" in hooks ) ||
+                               ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
+
+                               if ( isCustomProp ) {
+                                       style.setProperty( name, value );
+                               } else {
+                                       style[ name ] = value;
+                               }
+                       }
+
+               } else {
+
+                       // If a hook was provided get the non-computed value from there
+                       if ( hooks && "get" in hooks &&
+                               ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
+
+                               return ret;
+                       }
+
+                       // Otherwise just get the value from the style object
+                       return style[ name ];
+               }
+       },
+
+       css: function( elem, name, extra, styles ) {
+               var val, num, hooks,
+                       origName = camelCase( name ),
+                       isCustomProp = rcustomProp.test( name );
+
+               // Make sure that we're working with the right name. We don't
+               // want to modify the value if it is a CSS custom property
+               // since they are user-defined.
+               if ( !isCustomProp ) {
+                       name = finalPropName( origName );
+               }
+
+               // Try prefixed name followed by the unprefixed name
+               hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+               // If a hook was provided get the computed value from there
+               if ( hooks && "get" in hooks ) {
+                       val = hooks.get( elem, true, extra );
+               }
+
+               // Otherwise, if a way to get the computed value exists, use that
+               if ( val === undefined ) {
+                       val = curCSS( elem, name, styles );
+               }
+
+               // Convert "normal" to computed value
+               if ( val === "normal" && name in cssNormalTransform ) {
+                       val = cssNormalTransform[ name ];
+               }
+
+               // Make numeric if forced or a qualifier was provided and val looks numeric
+               if ( extra === "" || extra ) {
+                       num = parseFloat( val );
+                       return extra === true || isFinite( num ) ? num || 0 : val;
+               }
+
+               return val;
+       }
+} );
+
+jQuery.each( [ "height", "width" ], function( _i, dimension ) {
+       jQuery.cssHooks[ dimension ] = {
+               get: function( elem, computed, extra ) {
+                       if ( computed ) {
+
+                               // Certain elements can have dimension info if we invisibly show them
+                               // but it must have a current display style that would benefit
+                               return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
+
+                                       // Support: Safari 8+
+                                       // Table columns in Safari have non-zero offsetWidth & zero
+                                       // getBoundingClientRect().width unless display is changed.
+                                       // Support: IE <=11 only
+                                       // Running getBoundingClientRect on a disconnected node
+                                       // in IE throws an error.
+                                       ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
+                                               swap( elem, cssShow, function() {
+                                                       return getWidthOrHeight( elem, dimension, extra );
+                                               } ) :
+                                               getWidthOrHeight( elem, dimension, extra );
+                       }
+               },
+
+               set: function( elem, value, extra ) {
+                       var matches,
+                               styles = getStyles( elem ),
+
+                               // Only read styles.position if the test has a chance to fail
+                               // to avoid forcing a reflow.
+                               scrollboxSizeBuggy = !support.scrollboxSize() &&
+                                       styles.position === "absolute",
+
+                               // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
+                               boxSizingNeeded = scrollboxSizeBuggy || extra,
+                               isBorderBox = boxSizingNeeded &&
+                                       jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
+                               subtract = extra ?
+                                       boxModelAdjustment(
+                                               elem,
+                                               dimension,
+                                               extra,
+                                               isBorderBox,
+                                               styles
+                                       ) :
+                                       0;
+
+                       // Account for unreliable border-box dimensions by comparing offset* to computed and
+                       // faking a content-box to get border and padding (gh-3699)
+                       if ( isBorderBox && scrollboxSizeBuggy ) {
+                               subtract -= Math.ceil(
+                                       elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
+                                       parseFloat( styles[ dimension ] ) -
+                                       boxModelAdjustment( elem, dimension, "border", false, styles ) -
+                                       0.5
+                               );
+                       }
+
+                       // Convert to pixels if value adjustment is needed
+                       if ( subtract && ( matches = rcssNum.exec( value ) ) &&
+                               ( matches[ 3 ] || "px" ) !== "px" ) {
+
+                               elem.style[ dimension ] = value;
+                               value = jQuery.css( elem, dimension );
+                       }
+
+                       return setPositiveNumber( elem, value, subtract );
+               }
+       };
+} );
+
+jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
+       function( elem, computed ) {
+               if ( computed ) {
+                       return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
+                               elem.getBoundingClientRect().left -
+                                       swap( elem, { marginLeft: 0 }, function() {
+                                               return elem.getBoundingClientRect().left;
+                                       } )
+                               ) + "px";
+               }
+       }
+);
+
+// These hooks are used by animate to expand properties
+jQuery.each( {
+       margin: "",
+       padding: "",
+       border: "Width"
+}, function( prefix, suffix ) {
+       jQuery.cssHooks[ prefix + suffix ] = {
+               expand: function( value ) {
+                       var i = 0,
+                               expanded = {},
+
+                               // Assumes a single number if not a string
+                               parts = typeof value === "string" ? value.split( " " ) : [ value ];
+
+                       for ( ; i < 4; i++ ) {
+                               expanded[ prefix + cssExpand[ i ] + suffix ] =
+                                       parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+                       }
+
+                       return expanded;
+               }
+       };
+
+       if ( prefix !== "margin" ) {
+               jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+       }
+} );
+
+jQuery.fn.extend( {
+       css: function( name, value ) {
+               return access( this, function( elem, name, value ) {
+                       var styles, len,
+                               map = {},
+                               i = 0;
+
+                       if ( Array.isArray( name ) ) {
+                               styles = getStyles( elem );
+                               len = name.length;
+
+                               for ( ; i < len; i++ ) {
+                                       map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
+                               }
+
+                               return map;
+                       }
+
+                       return value !== undefined ?
+                               jQuery.style( elem, name, value ) :
+                               jQuery.css( elem, name );
+               }, name, value, arguments.length > 1 );
+       }
+} );
+
+
+function Tween( elem, options, prop, end, easing ) {
+       return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+       constructor: Tween,
+       init: function( elem, options, prop, end, easing, unit ) {
+               this.elem = elem;
+               this.prop = prop;
+               this.easing = easing || jQuery.easing._default;
+               this.options = options;
+               this.start = this.now = this.cur();
+               this.end = end;
+               this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+       },
+       cur: function() {
+               var hooks = Tween.propHooks[ this.prop ];
+
+               return hooks && hooks.get ?
+                       hooks.get( this ) :
+                       Tween.propHooks._default.get( this );
+       },
+       run: function( percent ) {
+               var eased,
+                       hooks = Tween.propHooks[ this.prop ];
+
+               if ( this.options.duration ) {
+                       this.pos = eased = jQuery.easing[ this.easing ](
+                               percent, this.options.duration * percent, 0, 1, this.options.duration
+                       );
+               } else {
+                       this.pos = eased = percent;
+               }
+               this.now = ( this.end - this.start ) * eased + this.start;
+
+               if ( this.options.step ) {
+                       this.options.step.call( this.elem, this.now, this );
+               }
+
+               if ( hooks && hooks.set ) {
+                       hooks.set( this );
+               } else {
+                       Tween.propHooks._default.set( this );
+               }
+               return this;
+       }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+       _default: {
+               get: function( tween ) {
+                       var result;
+
+                       // Use a property on the element directly when it is not a DOM element,
+                       // or when there is no matching style property that exists.
+                       if ( tween.elem.nodeType !== 1 ||
+                               tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
+                               return tween.elem[ tween.prop ];
+                       }
+
+                       // Passing an empty string as a 3rd parameter to .css will automatically
+                       // attempt a parseFloat and fallback to a string if the parse fails.
+                       // Simple values such as "10px" are parsed to Float;
+                       // complex values such as "rotate(1rad)" are returned as-is.
+                       result = jQuery.css( tween.elem, tween.prop, "" );
+
+                       // Empty strings, null, undefined and "auto" are converted to 0.
+                       return !result || result === "auto" ? 0 : result;
+               },
+               set: function( tween ) {
+
+                       // Use step hook for back compat.
+                       // Use cssHook if its there.
+                       // Use .style if available and use plain properties where available.
+                       if ( jQuery.fx.step[ tween.prop ] ) {
+                               jQuery.fx.step[ tween.prop ]( tween );
+                       } else if ( tween.elem.nodeType === 1 && (
+                                       jQuery.cssHooks[ tween.prop ] ||
+                                       tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
+                               jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+                       } else {
+                               tween.elem[ tween.prop ] = tween.now;
+                       }
+               }
+       }
+};
+
+// Support: IE <=9 only
+// Panic based approach to setting things on disconnected nodes
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+       set: function( tween ) {
+               if ( tween.elem.nodeType && tween.elem.parentNode ) {
+                       tween.elem[ tween.prop ] = tween.now;
+               }
+       }
+};
+
+jQuery.easing = {
+       linear: function( p ) {
+               return p;
+       },
+       swing: function( p ) {
+               return 0.5 - Math.cos( p * Math.PI ) / 2;
+       },
+       _default: "swing"
+};
+
+jQuery.fx = Tween.prototype.init;
+
+// Back compat <1.8 extension point
+jQuery.fx.step = {};
+
+
+
+
+var
+       fxNow, inProgress,
+       rfxtypes = /^(?:toggle|show|hide)$/,
+       rrun = /queueHooks$/;
+
+function schedule() {
+       if ( inProgress ) {
+               if ( document.hidden === false && window.requestAnimationFrame ) {
+                       window.requestAnimationFrame( schedule );
+               } else {
+                       window.setTimeout( schedule, jQuery.fx.interval );
+               }
+
+               jQuery.fx.tick();
+       }
+}
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+       window.setTimeout( function() {
+               fxNow = undefined;
+       } );
+       return ( fxNow = Date.now() );
+}
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+       var which,
+               i = 0,
+               attrs = { height: type };
+
+       // If we include width, step value is 1 to do all cssExpand values,
+       // otherwise step value is 2 to skip over Left and Right
+       includeWidth = includeWidth ? 1 : 0;
+       for ( ; i < 4; i += 2 - includeWidth ) {
+               which = cssExpand[ i ];
+               attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+       }
+
+       if ( includeWidth ) {
+               attrs.opacity = attrs.width = type;
+       }
+
+       return attrs;
+}
+
+function createTween( value, prop, animation ) {
+       var tween,
+               collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
+               index = 0,
+               length = collection.length;
+       for ( ; index < length; index++ ) {
+               if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
+
+                       // We're done with this property
+                       return tween;
+               }
+       }
+}
+
+function defaultPrefilter( elem, props, opts ) {
+       var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
+               isBox = "width" in props || "height" in props,
+               anim = this,
+               orig = {},
+               style = elem.style,
+               hidden = elem.nodeType && isHiddenWithinTree( elem ),
+               dataShow = dataPriv.get( elem, "fxshow" );
+
+       // Queue-skipping animations hijack the fx hooks
+       if ( !opts.queue ) {
+               hooks = jQuery._queueHooks( elem, "fx" );
+               if ( hooks.unqueued == null ) {
+                       hooks.unqueued = 0;
+                       oldfire = hooks.empty.fire;
+                       hooks.empty.fire = function() {
+                               if ( !hooks.unqueued ) {
+                                       oldfire();
+                               }
+                       };
+               }
+               hooks.unqueued++;
+
+               anim.always( function() {
+
+                       // Ensure the complete handler is called before this completes
+                       anim.always( function() {
+                               hooks.unqueued--;
+                               if ( !jQuery.queue( elem, "fx" ).length ) {
+                                       hooks.empty.fire();
+                               }
+                       } );
+               } );
+       }
+
+       // Detect show/hide animations
+       for ( prop in props ) {
+               value = props[ prop ];
+               if ( rfxtypes.test( value ) ) {
+                       delete props[ prop ];
+                       toggle = toggle || value === "toggle";
+                       if ( value === ( hidden ? "hide" : "show" ) ) {
+
+                               // Pretend to be hidden if this is a "show" and
+                               // there is still data from a stopped show/hide
+                               if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
+                                       hidden = true;
+
+                               // Ignore all other no-op show/hide data
+                               } else {
+                                       continue;
+                               }
+                       }
+                       orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
+               }
+       }
+
+       // Bail out if this is a no-op like .hide().hide()
+       propTween = !jQuery.isEmptyObject( props );
+       if ( !propTween && jQuery.isEmptyObject( orig ) ) {
+               return;
+       }
+
+       // Restrict "overflow" and "display" styles during box animations
+       if ( isBox && elem.nodeType === 1 ) {
+
+               // Support: IE <=9 - 11, Edge 12 - 15
+               // Record all 3 overflow attributes because IE does not infer the shorthand
+               // from identically-valued overflowX and overflowY and Edge just mirrors
+               // the overflowX value there.
+               opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+               // Identify a display type, preferring old show/hide data over the CSS cascade
+               restoreDisplay = dataShow && dataShow.display;
+               if ( restoreDisplay == null ) {
+                       restoreDisplay = dataPriv.get( elem, "display" );
+               }
+               display = jQuery.css( elem, "display" );
+               if ( display === "none" ) {
+                       if ( restoreDisplay ) {
+                               display = restoreDisplay;
+                       } else {
+
+                               // Get nonempty value(s) by temporarily forcing visibility
+                               showHide( [ elem ], true );
+                               restoreDisplay = elem.style.display || restoreDisplay;
+                               display = jQuery.css( elem, "display" );
+                               showHide( [ elem ] );
+                       }
+               }
+
+               // Animate inline elements as inline-block
+               if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
+                       if ( jQuery.css( elem, "float" ) === "none" ) {
+
+                               // Restore the original display value at the end of pure show/hide animations
+                               if ( !propTween ) {
+                                       anim.done( function() {
+                                               style.display = restoreDisplay;
+                                       } );
+                                       if ( restoreDisplay == null ) {
+                                               display = style.display;
+                                               restoreDisplay = display === "none" ? "" : display;
+                                       }
+                               }
+                               style.display = "inline-block";
+                       }
+               }
+       }
+
+       if ( opts.overflow ) {
+               style.overflow = "hidden";
+               anim.always( function() {
+                       style.overflow = opts.overflow[ 0 ];
+                       style.overflowX = opts.overflow[ 1 ];
+                       style.overflowY = opts.overflow[ 2 ];
+               } );
+       }
+
+       // Implement show/hide animations
+       propTween = false;
+       for ( prop in orig ) {
+
+               // General show/hide setup for this element animation
+               if ( !propTween ) {
+                       if ( dataShow ) {
+                               if ( "hidden" in dataShow ) {
+                                       hidden = dataShow.hidden;
+                               }
+                       } else {
+                               dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
+                       }
+
+                       // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
+                       if ( toggle ) {
+                               dataShow.hidden = !hidden;
+                       }
+
+                       // Show elements before animating them
+                       if ( hidden ) {
+                               showHide( [ elem ], true );
+                       }
+
+                       /* eslint-disable no-loop-func */
+
+                       anim.done( function() {
+
+                       /* eslint-enable no-loop-func */
+
+                               // The final step of a "hide" animation is actually hiding the element
+                               if ( !hidden ) {
+                                       showHide( [ elem ] );
+                               }
+                               dataPriv.remove( elem, "fxshow" );
+                               for ( prop in orig ) {
+                                       jQuery.style( elem, prop, orig[ prop ] );
+                               }
+                       } );
+               }
+
+               // Per-property setup
+               propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
+               if ( !( prop in dataShow ) ) {
+                       dataShow[ prop ] = propTween.start;
+                       if ( hidden ) {
+                               propTween.end = propTween.start;
+                               propTween.start = 0;
+                       }
+               }
+       }
+}
+
+function propFilter( props, specialEasing ) {
+       var index, name, easing, value, hooks;
+
+       // camelCase, specialEasing and expand cssHook pass
+       for ( index in props ) {
+               name = camelCase( index );
+               easing = specialEasing[ name ];
+               value = props[ index ];
+               if ( Array.isArray( value ) ) {
+                       easing = value[ 1 ];
+                       value = props[ index ] = value[ 0 ];
+               }
+
+               if ( index !== name ) {
+                       props[ name ] = value;
+                       delete props[ index ];
+               }
+
+               hooks = jQuery.cssHooks[ name ];
+               if ( hooks && "expand" in hooks ) {
+                       value = hooks.expand( value );
+                       delete props[ name ];
+
+                       // Not quite $.extend, this won't overwrite existing keys.
+                       // Reusing 'index' because we have the correct "name"
+                       for ( index in value ) {
+                               if ( !( index in props ) ) {
+                                       props[ index ] = value[ index ];
+                                       specialEasing[ index ] = easing;
+                               }
+                       }
+               } else {
+                       specialEasing[ name ] = easing;
+               }
+       }
+}
+
+function Animation( elem, properties, options ) {
+       var result,
+               stopped,
+               index = 0,
+               length = Animation.prefilters.length,
+               deferred = jQuery.Deferred().always( function() {
+
+                       // Don't match elem in the :animated selector
+                       delete tick.elem;
+               } ),
+               tick = function() {
+                       if ( stopped ) {
+                               return false;
+                       }
+                       var currentTime = fxNow || createFxNow(),
+                               remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+
+                               // Support: Android 2.3 only
+                               // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
+                               temp = remaining / animation.duration || 0,
+                               percent = 1 - temp,
+                               index = 0,
+                               length = animation.tweens.length;
+
+                       for ( ; index < length; index++ ) {
+                               animation.tweens[ index ].run( percent );
+                       }
+
+                       deferred.notifyWith( elem, [ animation, percent, remaining ] );
+
+                       // If there's more to do, yield
+                       if ( percent < 1 && length ) {
+                               return remaining;
+                       }
+
+                       // If this was an empty animation, synthesize a final progress notification
+                       if ( !length ) {
+                               deferred.notifyWith( elem, [ animation, 1, 0 ] );
+                       }
+
+                       // Resolve the animation and report its conclusion
+                       deferred.resolveWith( elem, [ animation ] );
+                       return false;
+               },
+               animation = deferred.promise( {
+                       elem: elem,
+                       props: jQuery.extend( {}, properties ),
+                       opts: jQuery.extend( true, {
+                               specialEasing: {},
+                               easing: jQuery.easing._default
+                       }, options ),
+                       originalProperties: properties,
+                       originalOptions: options,
+                       startTime: fxNow || createFxNow(),
+                       duration: options.duration,
+                       tweens: [],
+                       createTween: function( prop, end ) {
+                               var tween = jQuery.Tween( elem, animation.opts, prop, end,
+                                               animation.opts.specialEasing[ prop ] || animation.opts.easing );
+                               animation.tweens.push( tween );
+                               return tween;
+                       },
+                       stop: function( gotoEnd ) {
+                               var index = 0,
+
+                                       // If we are going to the end, we want to run all the tweens
+                                       // otherwise we skip this part
+                                       length = gotoEnd ? animation.tweens.length : 0;
+                               if ( stopped ) {
+                                       return this;
+                               }
+                               stopped = true;
+                               for ( ; index < length; index++ ) {
+                                       animation.tweens[ index ].run( 1 );
+                               }
+
+                               // Resolve when we played the last frame; otherwise, reject
+                               if ( gotoEnd ) {
+                                       deferred.notifyWith( elem, [ animation, 1, 0 ] );
+                                       deferred.resolveWith( elem, [ animation, gotoEnd ] );
+                               } else {
+                                       deferred.rejectWith( elem, [ animation, gotoEnd ] );
+                               }
+                               return this;
+                       }
+               } ),
+               props = animation.props;
+
+       propFilter( props, animation.opts.specialEasing );
+
+       for ( ; index < length; index++ ) {
+               result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
+               if ( result ) {
+                       if ( isFunction( result.stop ) ) {
+                               jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
+                                       result.stop.bind( result );
+                       }
+                       return result;
+               }
+       }
+
+       jQuery.map( props, createTween, animation );
+
+       if ( isFunction( animation.opts.start ) ) {
+               animation.opts.start.call( elem, animation );
+       }
+
+       // Attach callbacks from options
+       animation
+               .progress( animation.opts.progress )
+               .done( animation.opts.done, animation.opts.complete )
+               .fail( animation.opts.fail )
+               .always( animation.opts.always );
+
+       jQuery.fx.timer(
+               jQuery.extend( tick, {
+                       elem: elem,
+                       anim: animation,
+                       queue: animation.opts.queue
+               } )
+       );
+
+       return animation;
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+
+       tweeners: {
+               "*": [ function( prop, value ) {
+                       var tween = this.createTween( prop, value );
+                       adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
+                       return tween;
+               } ]
+       },
+
+       tweener: function( props, callback ) {
+               if ( isFunction( props ) ) {
+                       callback = props;
+                       props = [ "*" ];
+               } else {
+                       props = props.match( rnothtmlwhite );
+               }
+
+               var prop,
+                       index = 0,
+                       length = props.length;
+
+               for ( ; index < length; index++ ) {
+                       prop = props[ index ];
+                       Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
+                       Animation.tweeners[ prop ].unshift( callback );
+               }
+       },
+
+       prefilters: [ defaultPrefilter ],
+
+       prefilter: function( callback, prepend ) {
+               if ( prepend ) {
+                       Animation.prefilters.unshift( callback );
+               } else {
+                       Animation.prefilters.push( callback );
+               }
+       }
+} );
+
+jQuery.speed = function( speed, easing, fn ) {
+       var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
+               complete: fn || !fn && easing ||
+                       isFunction( speed ) && speed,
+               duration: speed,
+               easing: fn && easing || easing && !isFunction( easing ) && easing
+       };
+
+       // Go to the end state if fx are off
+       if ( jQuery.fx.off ) {
+               opt.duration = 0;
+
+       } else {
+               if ( typeof opt.duration !== "number" ) {
+                       if ( opt.duration in jQuery.fx.speeds ) {
+                               opt.duration = jQuery.fx.speeds[ opt.duration ];
+
+                       } else {
+                               opt.duration = jQuery.fx.speeds._default;
+                       }
+               }
+       }
+
+       // Normalize opt.queue - true/undefined/null -> "fx"
+       if ( opt.queue == null || opt.queue === true ) {
+               opt.queue = "fx";
+       }
+
+       // Queueing
+       opt.old = opt.complete;
+
+       opt.complete = function() {
+               if ( isFunction( opt.old ) ) {
+                       opt.old.call( this );
+               }
+
+               if ( opt.queue ) {
+                       jQuery.dequeue( this, opt.queue );
+               }
+       };
+
+       return opt;
+};
+
+jQuery.fn.extend( {
+       fadeTo: function( speed, to, easing, callback ) {
+
+               // Show any hidden elements after setting opacity to 0
+               return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
+
+                       // Animate to the value specified
+                       .end().animate( { opacity: to }, speed, easing, callback );
+       },
+       animate: function( prop, speed, easing, callback ) {
+               var empty = jQuery.isEmptyObject( prop ),
+                       optall = jQuery.speed( speed, easing, callback ),
+                       doAnimation = function() {
+
+                               // Operate on a copy of prop so per-property easing won't be lost
+                               var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+
+                               // Empty animations, or finishing resolves immediately
+                               if ( empty || dataPriv.get( this, "finish" ) ) {
+                                       anim.stop( true );
+                               }
+                       };
+                       doAnimation.finish = doAnimation;
+
+               return empty || optall.queue === false ?
+                       this.each( doAnimation ) :
+                       this.queue( optall.queue, doAnimation );
+       },
+       stop: function( type, clearQueue, gotoEnd ) {
+               var stopQueue = function( hooks ) {
+                       var stop = hooks.stop;
+                       delete hooks.stop;
+                       stop( gotoEnd );
+               };
+
+               if ( typeof type !== "string" ) {
+                       gotoEnd = clearQueue;
+                       clearQueue = type;
+                       type = undefined;
+               }
+               if ( clearQueue ) {
+                       this.queue( type || "fx", [] );
+               }
+
+               return this.each( function() {
+                       var dequeue = true,
+                               index = type != null && type + "queueHooks",
+                               timers = jQuery.timers,
+                               data = dataPriv.get( this );
+
+                       if ( index ) {
+                               if ( data[ index ] && data[ index ].stop ) {
+                                       stopQueue( data[ index ] );
+                               }
+                       } else {
+                               for ( index in data ) {
+                                       if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+                                               stopQueue( data[ index ] );
+                                       }
+                               }
+                       }
+
+                       for ( index = timers.length; index--; ) {
+                               if ( timers[ index ].elem === this &&
+                                       ( type == null || timers[ index ].queue === type ) ) {
+
+                                       timers[ index ].anim.stop( gotoEnd );
+                                       dequeue = false;
+                                       timers.splice( index, 1 );
+                               }
+                       }
+
+                       // Start the next in the queue if the last step wasn't forced.
+                       // Timers currently will call their complete callbacks, which
+                       // will dequeue but only if they were gotoEnd.
+                       if ( dequeue || !gotoEnd ) {
+                               jQuery.dequeue( this, type );
+                       }
+               } );
+       },
+       finish: function( type ) {
+               if ( type !== false ) {
+                       type = type || "fx";
+               }
+               return this.each( function() {
+                       var index,
+                               data = dataPriv.get( this ),
+                               queue = data[ type + "queue" ],
+                               hooks = data[ type + "queueHooks" ],
+                               timers = jQuery.timers,
+                               length = queue ? queue.length : 0;
+
+                       // Enable finishing flag on private data
+                       data.finish = true;
+
+                       // Empty the queue first
+                       jQuery.queue( this, type, [] );
+
+                       if ( hooks && hooks.stop ) {
+                               hooks.stop.call( this, true );
+                       }
+
+                       // Look for any active animations, and finish them
+                       for ( index = timers.length; index--; ) {
+                               if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
+                                       timers[ index ].anim.stop( true );
+                                       timers.splice( index, 1 );
+                               }
+                       }
+
+                       // Look for any animations in the old queue and finish them
+                       for ( index = 0; index < length; index++ ) {
+                               if ( queue[ index ] && queue[ index ].finish ) {
+                                       queue[ index ].finish.call( this );
+                               }
+                       }
+
+                       // Turn off finishing flag
+                       delete data.finish;
+               } );
+       }
+} );
+
+jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
+       var cssFn = jQuery.fn[ name ];
+       jQuery.fn[ name ] = function( speed, easing, callback ) {
+               return speed == null || typeof speed === "boolean" ?
+                       cssFn.apply( this, arguments ) :
+                       this.animate( genFx( name, true ), speed, easing, callback );
+       };
+} );
+
+// Generate shortcuts for custom animations
+jQuery.each( {
+       slideDown: genFx( "show" ),
+       slideUp: genFx( "hide" ),
+       slideToggle: genFx( "toggle" ),
+       fadeIn: { opacity: "show" },
+       fadeOut: { opacity: "hide" },
+       fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+       jQuery.fn[ name ] = function( speed, easing, callback ) {
+               return this.animate( props, speed, easing, callback );
+       };
+} );
+
+jQuery.timers = [];
+jQuery.fx.tick = function() {
+       var timer,
+               i = 0,
+               timers = jQuery.timers;
+
+       fxNow = Date.now();
+
+       for ( ; i < timers.length; i++ ) {
+               timer = timers[ i ];
+
+               // Run the timer and safely remove it when done (allowing for external removal)
+               if ( !timer() && timers[ i ] === timer ) {
+                       timers.splice( i--, 1 );
+               }
+       }
+
+       if ( !timers.length ) {
+               jQuery.fx.stop();
+       }
+       fxNow = undefined;
+};
+
+jQuery.fx.timer = function( timer ) {
+       jQuery.timers.push( timer );
+       jQuery.fx.start();
+};
+
+jQuery.fx.interval = 13;
+jQuery.fx.start = function() {
+       if ( inProgress ) {
+               return;
+       }
+
+       inProgress = true;
+       schedule();
+};
+
+jQuery.fx.stop = function() {
+       inProgress = null;
+};
+
+jQuery.fx.speeds = {
+       slow: 600,
+       fast: 200,
+
+       // Default speed
+       _default: 400
+};
+
+
+// Based off of the plugin by Clint Helfers, with permission.
+// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
+jQuery.fn.delay = function( time, type ) {
+       time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+       type = type || "fx";
+
+       return this.queue( type, function( next, hooks ) {
+               var timeout = window.setTimeout( next, time );
+               hooks.stop = function() {
+                       window.clearTimeout( timeout );
+               };
+       } );
+};
+
+
+( function() {
+       var input = document.createElement( "input" ),
+               select = document.createElement( "select" ),
+               opt = select.appendChild( document.createElement( "option" ) );
+
+       input.type = "checkbox";
+
+       // Support: Android <=4.3 only
+       // Default value for a checkbox should be "on"
+       support.checkOn = input.value !== "";
+
+       // Support: IE <=11 only
+       // Must access selectedIndex to make default options select
+       support.optSelected = opt.selected;
+
+       // Support: IE <=11 only
+       // An input loses its value after becoming a radio
+       input = document.createElement( "input" );
+       input.value = "t";
+       input.type = "radio";
+       support.radioValue = input.value === "t";
+} )();
+
+
+var boolHook,
+       attrHandle = jQuery.expr.attrHandle;
+
+jQuery.fn.extend( {
+       attr: function( name, value ) {
+               return access( this, jQuery.attr, name, value, arguments.length > 1 );
+       },
+
+       removeAttr: function( name ) {
+               return this.each( function() {
+                       jQuery.removeAttr( this, name );
+               } );
+       }
+} );
+
+jQuery.extend( {
+       attr: function( elem, name, value ) {
+               var ret, hooks,
+                       nType = elem.nodeType;
+
+               // Don't get/set attributes on text, comment and attribute nodes
+               if ( nType === 3 || nType === 8 || nType === 2 ) {
+                       return;
+               }
+
+               // Fallback to prop when attributes are not supported
+               if ( typeof elem.getAttribute === "undefined" ) {
+                       return jQuery.prop( elem, name, value );
+               }
+
+               // Attribute hooks are determined by the lowercase version
+               // Grab necessary hook if one is defined
+               if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+                       hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
+                               ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
+               }
+
+               if ( value !== undefined ) {
+                       if ( value === null ) {
+                               jQuery.removeAttr( elem, name );
+                               return;
+                       }
+
+                       if ( hooks && "set" in hooks &&
+                               ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
+                               return ret;
+                       }
+
+                       elem.setAttribute( name, value + "" );
+                       return value;
+               }
+
+               if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
+                       return ret;
+               }
+
+               ret = jQuery.find.attr( elem, name );
+
+               // Non-existent attributes return null, we normalize to undefined
+               return ret == null ? undefined : ret;
+       },
+
+       attrHooks: {
+               type: {
+                       set: function( elem, value ) {
+                               if ( !support.radioValue && value === "radio" &&
+                                       nodeName( elem, "input" ) ) {
+                                       var val = elem.value;
+                                       elem.setAttribute( "type", value );
+                                       if ( val ) {
+                                               elem.value = val;
+                                       }
+                                       return value;
+                               }
+                       }
+               }
+       },
+
+       removeAttr: function( elem, value ) {
+               var name,
+                       i = 0,
+
+                       // Attribute names can contain non-HTML whitespace characters
+                       // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
+                       attrNames = value && value.match( rnothtmlwhite );
+
+               if ( attrNames && elem.nodeType === 1 ) {
+                       while ( ( name = attrNames[ i++ ] ) ) {
+                               elem.removeAttribute( name );
+                       }
+               }
+       }
+} );
+
+// Hooks for boolean attributes
+boolHook = {
+       set: function( elem, value, name ) {
+               if ( value === false ) {
+
+                       // Remove boolean attributes when set to false
+                       jQuery.removeAttr( elem, name );
+               } else {
+                       elem.setAttribute( name, name );
+               }
+               return name;
+       }
+};
+
+jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
+       var getter = attrHandle[ name ] || jQuery.find.attr;
+
+       attrHandle[ name ] = function( elem, name, isXML ) {
+               var ret, handle,
+                       lowercaseName = name.toLowerCase();
+
+               if ( !isXML ) {
+
+                       // Avoid an infinite loop by temporarily removing this function from the getter
+                       handle = attrHandle[ lowercaseName ];
+                       attrHandle[ lowercaseName ] = ret;
+                       ret = getter( elem, name, isXML ) != null ?
+                               lowercaseName :
+                               null;
+                       attrHandle[ lowercaseName ] = handle;
+               }
+               return ret;
+       };
+} );
+
+
+
+
+var rfocusable = /^(?:input|select|textarea|button)$/i,
+       rclickable = /^(?:a|area)$/i;
+
+jQuery.fn.extend( {
+       prop: function( name, value ) {
+               return access( this, jQuery.prop, name, value, arguments.length > 1 );
+       },
+
+       removeProp: function( name ) {
+               return this.each( function() {
+                       delete this[ jQuery.propFix[ name ] || name ];
+               } );
+       }
+} );
+
+jQuery.extend( {
+       prop: function( elem, name, value ) {
+               var ret, hooks,
+                       nType = elem.nodeType;
+
+               // Don't get/set properties on text, comment and attribute nodes
+               if ( nType === 3 || nType === 8 || nType === 2 ) {
+                       return;
+               }
+
+               if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+
+                       // Fix name and attach hooks
+                       name = jQuery.propFix[ name ] || name;
+                       hooks = jQuery.propHooks[ name ];
+               }
+
+               if ( value !== undefined ) {
+                       if ( hooks && "set" in hooks &&
+                               ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
+                               return ret;
+                       }
+
+                       return ( elem[ name ] = value );
+               }
+
+               if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
+                       return ret;
+               }
+
+               return elem[ name ];
+       },
+
+       propHooks: {
+               tabIndex: {
+                       get: function( elem ) {
+
+                               // Support: IE <=9 - 11 only
+                               // elem.tabIndex doesn't always return the
+                               // correct value when it hasn't been explicitly set
+                               // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+                               // Use proper attribute retrieval(#12072)
+                               var tabindex = jQuery.find.attr( elem, "tabindex" );
+
+                               if ( tabindex ) {
+                                       return parseInt( tabindex, 10 );
+                               }
+
+                               if (
+                                       rfocusable.test( elem.nodeName ) ||
+                                       rclickable.test( elem.nodeName ) &&
+                                       elem.href
+                               ) {
+                                       return 0;
+                               }
+
+                               return -1;
+                       }
+               }
+       },
+
+       propFix: {
+               "for": "htmlFor",
+               "class": "className"
+       }
+} );
+
+// Support: IE <=11 only
+// Accessing the selectedIndex property
+// forces the browser to respect setting selected
+// on the option
+// The getter ensures a default option is selected
+// when in an optgroup
+// eslint rule "no-unused-expressions" is disabled for this code
+// since it considers such accessions noop
+if ( !support.optSelected ) {
+       jQuery.propHooks.selected = {
+               get: function( elem ) {
+
+                       /* eslint no-unused-expressions: "off" */
+
+                       var parent = elem.parentNode;
+                       if ( parent && parent.parentNode ) {
+                               parent.parentNode.selectedIndex;
+                       }
+                       return null;
+               },
+               set: function( elem ) {
+
+                       /* eslint no-unused-expressions: "off" */
+
+                       var parent = elem.parentNode;
+                       if ( parent ) {
+                               parent.selectedIndex;
+
+                               if ( parent.parentNode ) {
+                                       parent.parentNode.selectedIndex;
+                               }
+                       }
+               }
+       };
+}
+
+jQuery.each( [
+       "tabIndex",
+       "readOnly",
+       "maxLength",
+       "cellSpacing",
+       "cellPadding",
+       "rowSpan",
+       "colSpan",
+       "useMap",
+       "frameBorder",
+       "contentEditable"
+], function() {
+       jQuery.propFix[ this.toLowerCase() ] = this;
+} );
+
+
+
+
+       // Strip and collapse whitespace according to HTML spec
+       // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
+       function stripAndCollapse( value ) {
+               var tokens = value.match( rnothtmlwhite ) || [];
+               return tokens.join( " " );
+       }
+
+
+function getClass( elem ) {
+       return elem.getAttribute && elem.getAttribute( "class" ) || "";
+}
+
+function classesToArray( value ) {
+       if ( Array.isArray( value ) ) {
+               return value;
+       }
+       if ( typeof value === "string" ) {
+               return value.match( rnothtmlwhite ) || [];
+       }
+       return [];
+}
+
+jQuery.fn.extend( {
+       addClass: function( value ) {
+               var classes, elem, cur, curValue, clazz, j, finalValue,
+                       i = 0;
+
+               if ( isFunction( value ) ) {
+                       return this.each( function( j ) {
+                               jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
+                       } );
+               }
+
+               classes = classesToArray( value );
+
+               if ( classes.length ) {
+                       while ( ( elem = this[ i++ ] ) ) {
+                               curValue = getClass( elem );
+                               cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
+
+                               if ( cur ) {
+                                       j = 0;
+                                       while ( ( clazz = classes[ j++ ] ) ) {
+                                               if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
+                                                       cur += clazz + " ";
+                                               }
+                                       }
+
+                                       // Only assign if different to avoid unneeded rendering.
+                                       finalValue = stripAndCollapse( cur );
+                                       if ( curValue !== finalValue ) {
+                                               elem.setAttribute( "class", finalValue );
+                                       }
+                               }
+                       }
+               }
+
+               return this;
+       },
+
+       removeClass: function( value ) {
+               var classes, elem, cur, curValue, clazz, j, finalValue,
+                       i = 0;
+
+               if ( isFunction( value ) ) {
+                       return this.each( function( j ) {
+                               jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
+                       } );
+               }
+
+               if ( !arguments.length ) {
+                       return this.attr( "class", "" );
+               }
+
+               classes = classesToArray( value );
+
+               if ( classes.length ) {
+                       while ( ( elem = this[ i++ ] ) ) {
+                               curValue = getClass( elem );
+
+                               // This expression is here for better compressibility (see addClass)
+                               cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
+
+                               if ( cur ) {
+                                       j = 0;
+                                       while ( ( clazz = classes[ j++ ] ) ) {
+
+                                               // Remove *all* instances
+                                               while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
+                                                       cur = cur.replace( " " + clazz + " ", " " );
+                                               }
+                                       }
+
+                                       // Only assign if different to avoid unneeded rendering.
+                                       finalValue = stripAndCollapse( cur );
+                                       if ( curValue !== finalValue ) {
+                                               elem.setAttribute( "class", finalValue );
+                                       }
+                               }
+                       }
+               }
+
+               return this;
+       },
+
+       toggleClass: function( value, stateVal ) {
+               var type = typeof value,
+                       isValidValue = type === "string" || Array.isArray( value );
+
+               if ( typeof stateVal === "boolean" && isValidValue ) {
+                       return stateVal ? this.addClass( value ) : this.removeClass( value );
+               }
+
+               if ( isFunction( value ) ) {
+                       return this.each( function( i ) {
+                               jQuery( this ).toggleClass(
+                                       value.call( this, i, getClass( this ), stateVal ),
+                                       stateVal
+                               );
+                       } );
+               }
+
+               return this.each( function() {
+                       var className, i, self, classNames;
+
+                       if ( isValidValue ) {
+
+                               // Toggle individual class names
+                               i = 0;
+                               self = jQuery( this );
+                               classNames = classesToArray( value );
+
+                               while ( ( className = classNames[ i++ ] ) ) {
+
+                                       // Check each className given, space separated list
+                                       if ( self.hasClass( className ) ) {
+                                               self.removeClass( className );
+                                       } else {
+                                               self.addClass( className );
+                                       }
+                               }
+
+                       // Toggle whole class name
+                       } else if ( value === undefined || type === "boolean" ) {
+                               className = getClass( this );
+                               if ( className ) {
+
+                                       // Store className if set
+                                       dataPriv.set( this, "__className__", className );
+                               }
+
+                               // If the element has a class name or if we're passed `false`,
+                               // then remove the whole classname (if there was one, the above saved it).
+                               // Otherwise bring back whatever was previously saved (if anything),
+                               // falling back to the empty string if nothing was stored.
+                               if ( this.setAttribute ) {
+                                       this.setAttribute( "class",
+                                               className || value === false ?
+                                               "" :
+                                               dataPriv.get( this, "__className__" ) || ""
+                                       );
+                               }
+                       }
+               } );
+       },
+
+       hasClass: function( selector ) {
+               var className, elem,
+                       i = 0;
+
+               className = " " + selector + " ";
+               while ( ( elem = this[ i++ ] ) ) {
+                       if ( elem.nodeType === 1 &&
+                               ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
+                                       return true;
+                       }
+               }
+
+               return false;
+       }
+} );
+
+
+
+
+var rreturn = /\r/g;
+
+jQuery.fn.extend( {
+       val: function( value ) {
+               var hooks, ret, valueIsFunction,
+                       elem = this[ 0 ];
+
+               if ( !arguments.length ) {
+                       if ( elem ) {
+                               hooks = jQuery.valHooks[ elem.type ] ||
+                                       jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+                               if ( hooks &&
+                                       "get" in hooks &&
+                                       ( ret = hooks.get( elem, "value" ) ) !== undefined
+                               ) {
+                                       return ret;
+                               }
+
+                               ret = elem.value;
+
+                               // Handle most common string cases
+                               if ( typeof ret === "string" ) {
+                                       return ret.replace( rreturn, "" );
+                               }
+
+                               // Handle cases where value is null/undef or number
+                               return ret == null ? "" : ret;
+                       }
+
+                       return;
+               }
+
+               valueIsFunction = isFunction( value );
+
+               return this.each( function( i ) {
+                       var val;
+
+                       if ( this.nodeType !== 1 ) {
+                               return;
+                       }
+
+                       if ( valueIsFunction ) {
+                               val = value.call( this, i, jQuery( this ).val() );
+                       } else {
+                               val = value;
+                       }
+
+                       // Treat null/undefined as ""; convert numbers to string
+                       if ( val == null ) {
+                               val = "";
+
+                       } else if ( typeof val === "number" ) {
+                               val += "";
+
+                       } else if ( Array.isArray( val ) ) {
+                               val = jQuery.map( val, function( value ) {
+                                       return value == null ? "" : value + "";
+                               } );
+                       }
+
+                       hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+                       // If set returns undefined, fall back to normal setting
+                       if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
+                               this.value = val;
+                       }
+               } );
+       }
+} );
+
+jQuery.extend( {
+       valHooks: {
+               option: {
+                       get: function( elem ) {
+
+                               var val = jQuery.find.attr( elem, "value" );
+                               return val != null ?
+                                       val :
+
+                                       // Support: IE <=10 - 11 only
+                                       // option.text throws exceptions (#14686, #14858)
+                                       // Strip and collapse whitespace
+                                       // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
+                                       stripAndCollapse( jQuery.text( elem ) );
+                       }
+               },
+               select: {
+                       get: function( elem ) {
+                               var value, option, i,
+                                       options = elem.options,
+                                       index = elem.selectedIndex,
+                                       one = elem.type === "select-one",
+                                       values = one ? null : [],
+                                       max = one ? index + 1 : options.length;
+
+                               if ( index < 0 ) {
+                                       i = max;
+
+                               } else {
+                                       i = one ? index : 0;
+                               }
+
+                               // Loop through all the selected options
+                               for ( ; i < max; i++ ) {
+                                       option = options[ i ];
+
+                                       // Support: IE <=9 only
+                                       // IE8-9 doesn't update selected after form reset (#2551)
+                                       if ( ( option.selected || i === index ) &&
+
+                                                       // Don't return options that are disabled or in a disabled optgroup
+                                                       !option.disabled &&
+                                                       ( !option.parentNode.disabled ||
+                                                               !nodeName( option.parentNode, "optgroup" ) ) ) {
+
+                                               // Get the specific value for the option
+                                               value = jQuery( option ).val();
+
+                                               // We don't need an array for one selects
+                                               if ( one ) {
+                                                       return value;
+                                               }
+
+                                               // Multi-Selects return an array
+                                               values.push( value );
+                                       }
+                               }
+
+                               return values;
+                       },
+
+                       set: function( elem, value ) {
+                               var optionSet, option,
+                                       options = elem.options,
+                                       values = jQuery.makeArray( value ),
+                                       i = options.length;
+
+                               while ( i-- ) {
+                                       option = options[ i ];
+
+                                       /* eslint-disable no-cond-assign */
+
+                                       if ( option.selected =
+                                               jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
+                                       ) {
+                                               optionSet = true;
+                                       }
+
+                                       /* eslint-enable no-cond-assign */
+                               }
+
+                               // Force browsers to behave consistently when non-matching value is set
+                               if ( !optionSet ) {
+                                       elem.selectedIndex = -1;
+                               }
+                               return values;
+                       }
+               }
+       }
+} );
+
+// Radios and checkboxes getter/setter
+jQuery.each( [ "radio", "checkbox" ], function() {
+       jQuery.valHooks[ this ] = {
+               set: function( elem, value ) {
+                       if ( Array.isArray( value ) ) {
+                               return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
+                       }
+               }
+       };
+       if ( !support.checkOn ) {
+               jQuery.valHooks[ this ].get = function( elem ) {
+                       return elem.getAttribute( "value" ) === null ? "on" : elem.value;
+               };
+       }
+} );
+
+
+
+
+// Return jQuery for attributes-only inclusion
+
+
+support.focusin = "onfocusin" in window;
+
+
+var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+       stopPropagationCallback = function( e ) {
+               e.stopPropagation();
+       };
+
+jQuery.extend( jQuery.event, {
+
+       trigger: function( event, data, elem, onlyHandlers ) {
+
+               var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
+                       eventPath = [ elem || document ],
+                       type = hasOwn.call( event, "type" ) ? event.type : event,
+                       namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
+
+               cur = lastElement = tmp = elem = elem || document;
+
+               // Don't do events on text and comment nodes
+               if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+                       return;
+               }
+
+               // focus/blur morphs to focusin/out; ensure we're not firing them right now
+               if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
+                       return;
+               }
+
+               if ( type.indexOf( "." ) > -1 ) {
+
+                       // Namespaced trigger; create a regexp to match event type in handle()
+                       namespaces = type.split( "." );
+                       type = namespaces.shift();
+                       namespaces.sort();
+               }
+               ontype = type.indexOf( ":" ) < 0 && "on" + type;
+
+               // Caller can pass in a jQuery.Event object, Object, or just an event type string
+               event = event[ jQuery.expando ] ?
+                       event :
+                       new jQuery.Event( type, typeof event === "object" && event );
+
+               // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
+               event.isTrigger = onlyHandlers ? 2 : 3;
+               event.namespace = namespaces.join( "." );
+               event.rnamespace = event.namespace ?
+                       new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
+                       null;
+
+               // Clean up the event in case it is being reused
+               event.result = undefined;
+               if ( !event.target ) {
+                       event.target = elem;
+               }
+
+               // Clone any incoming data and prepend the event, creating the handler arg list
+               data = data == null ?
+                       [ event ] :
+                       jQuery.makeArray( data, [ event ] );
+
+               // Allow special events to draw outside the lines
+               special = jQuery.event.special[ type ] || {};
+               if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
+                       return;
+               }
+
+               // Determine event propagation path in advance, per W3C events spec (#9951)
+               // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+               if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
+
+                       bubbleType = special.delegateType || type;
+                       if ( !rfocusMorph.test( bubbleType + type ) ) {
+                               cur = cur.parentNode;
+                       }
+                       for ( ; cur; cur = cur.parentNode ) {
+                               eventPath.push( cur );
+                               tmp = cur;
+                       }
+
+                       // Only add window if we got to document (e.g., not plain obj or detached DOM)
+                       if ( tmp === ( elem.ownerDocument || document ) ) {
+                               eventPath.push( tmp.defaultView || tmp.parentWindow || window );
+                       }
+               }
+
+               // Fire handlers on the event path
+               i = 0;
+               while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
+                       lastElement = cur;
+                       event.type = i > 1 ?
+                               bubbleType :
+                               special.bindType || type;
+
+                       // jQuery handler
+                       handle = (
+                                       dataPriv.get( cur, "events" ) || Object.create( null )
+                               )[ event.type ] &&
+                               dataPriv.get( cur, "handle" );
+                       if ( handle ) {
+                               handle.apply( cur, data );
+                       }
+
+                       // Native handler
+                       handle = ontype && cur[ ontype ];
+                       if ( handle && handle.apply && acceptData( cur ) ) {
+                               event.result = handle.apply( cur, data );
+                               if ( event.result === false ) {
+                                       event.preventDefault();
+                               }
+                       }
+               }
+               event.type = type;
+
+               // If nobody prevented the default action, do it now
+               if ( !onlyHandlers && !event.isDefaultPrevented() ) {
+
+                       if ( ( !special._default ||
+                               special._default.apply( eventPath.pop(), data ) === false ) &&
+                               acceptData( elem ) ) {
+
+                               // Call a native DOM method on the target with the same name as the event.
+                               // Don't do default actions on window, that's where global variables be (#6170)
+                               if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
+
+                                       // Don't re-trigger an onFOO event when we call its FOO() method
+                                       tmp = elem[ ontype ];
+
+                                       if ( tmp ) {
+                                               elem[ ontype ] = null;
+                                       }
+
+                                       // Prevent re-triggering of the same event, since we already bubbled it above
+                                       jQuery.event.triggered = type;
+
+                                       if ( event.isPropagationStopped() ) {
+                                               lastElement.addEventListener( type, stopPropagationCallback );
+                                       }
+
+                                       elem[ type ]();
+
+                                       if ( event.isPropagationStopped() ) {
+                                               lastElement.removeEventListener( type, stopPropagationCallback );
+                                       }
+
+                                       jQuery.event.triggered = undefined;
+
+                                       if ( tmp ) {
+                                               elem[ ontype ] = tmp;
+                                       }
+                               }
+                       }
+               }
+
+               return event.result;
+       },
+
+       // Piggyback on a donor event to simulate a different one
+       // Used only for `focus(in | out)` events
+       simulate: function( type, elem, event ) {
+               var e = jQuery.extend(
+                       new jQuery.Event(),
+                       event,
+                       {
+                               type: type,
+                               isSimulated: true
+                       }
+               );
+
+               jQuery.event.trigger( e, null, elem );
+       }
+
+} );
+
+jQuery.fn.extend( {
+
+       trigger: function( type, data ) {
+               return this.each( function() {
+                       jQuery.event.trigger( type, data, this );
+               } );
+       },
+       triggerHandler: function( type, data ) {
+               var elem = this[ 0 ];
+               if ( elem ) {
+                       return jQuery.event.trigger( type, data, elem, true );
+               }
+       }
+} );
+
+
+// Support: Firefox <=44
+// Firefox doesn't have focus(in | out) events
+// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
+//
+// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
+// focus(in | out) events fire after focus & blur events,
+// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
+// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
+if ( !support.focusin ) {
+       jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+               // Attach a single capturing handler on the document while someone wants focusin/focusout
+               var handler = function( event ) {
+                       jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
+               };
+
+               jQuery.event.special[ fix ] = {
+                       setup: function() {
+
+                               // Handle: regular nodes (via `this.ownerDocument`), window
+                               // (via `this.document`) & document (via `this`).
+                               var doc = this.ownerDocument || this.document || this,
+                                       attaches = dataPriv.access( doc, fix );
+
+                               if ( !attaches ) {
+                                       doc.addEventListener( orig, handler, true );
+                               }
+                               dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
+                       },
+                       teardown: function() {
+                               var doc = this.ownerDocument || this.document || this,
+                                       attaches = dataPriv.access( doc, fix ) - 1;
+
+                               if ( !attaches ) {
+                                       doc.removeEventListener( orig, handler, true );
+                                       dataPriv.remove( doc, fix );
+
+                               } else {
+                                       dataPriv.access( doc, fix, attaches );
+                               }
+                       }
+               };
+       } );
+}
+var location = window.location;
+
+var nonce = { guid: Date.now() };
+
+var rquery = ( /\?/ );
+
+
+
+// Cross-browser xml parsing
+jQuery.parseXML = function( data ) {
+       var xml;
+       if ( !data || typeof data !== "string" ) {
+               return null;
+       }
+
+       // Support: IE 9 - 11 only
+       // IE throws on parseFromString with invalid input.
+       try {
+               xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
+       } catch ( e ) {
+               xml = undefined;
+       }
+
+       if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
+               jQuery.error( "Invalid XML: " + data );
+       }
+       return xml;
+};
+
+
+var
+       rbracket = /\[\]$/,
+       rCRLF = /\r?\n/g,
+       rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
+       rsubmittable = /^(?:input|select|textarea|keygen)/i;
+
+function buildParams( prefix, obj, traditional, add ) {
+       var name;
+
+       if ( Array.isArray( obj ) ) {
+
+               // Serialize array item.
+               jQuery.each( obj, function( i, v ) {
+                       if ( traditional || rbracket.test( prefix ) ) {
+
+                               // Treat each array item as a scalar.
+                               add( prefix, v );
+
+                       } else {
+
+                               // Item is non-scalar (array or object), encode its numeric index.
+                               buildParams(
+                                       prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
+                                       v,
+                                       traditional,
+                                       add
+                               );
+                       }
+               } );
+
+       } else if ( !traditional && toType( obj ) === "object" ) {
+
+               // Serialize object item.
+               for ( name in obj ) {
+                       buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+               }
+
+       } else {
+
+               // Serialize scalar item.
+               add( prefix, obj );
+       }
+}
+
+// Serialize an array of form elements or a set of
+// key/values into a query string
+jQuery.param = function( a, traditional ) {
+       var prefix,
+               s = [],
+               add = function( key, valueOrFunction ) {
+
+                       // If value is a function, invoke it and use its return value
+                       var value = isFunction( valueOrFunction ) ?
+                               valueOrFunction() :
+                               valueOrFunction;
+
+                       s[ s.length ] = encodeURIComponent( key ) + "=" +
+                               encodeURIComponent( value == null ? "" : value );
+               };
+
+       if ( a == null ) {
+               return "";
+       }
+
+       // If an array was passed in, assume that it is an array of form elements.
+       if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+
+               // Serialize the form elements
+               jQuery.each( a, function() {
+                       add( this.name, this.value );
+               } );
+
+       } else {
+
+               // If traditional, encode the "old" way (the way 1.3.2 or older
+               // did it), otherwise encode params recursively.
+               for ( prefix in a ) {
+                       buildParams( prefix, a[ prefix ], traditional, add );
+               }
+       }
+
+       // Return the resulting serialization
+       return s.join( "&" );
+};
+
+jQuery.fn.extend( {
+       serialize: function() {
+               return jQuery.param( this.serializeArray() );
+       },
+       serializeArray: function() {
+               return this.map( function() {
+
+                       // Can add propHook for "elements" to filter or add form elements
+                       var elements = jQuery.prop( this, "elements" );
+                       return elements ? jQuery.makeArray( elements ) : this;
+               } )
+               .filter( function() {
+                       var type = this.type;
+
+                       // Use .is( ":disabled" ) so that fieldset[disabled] works
+                       return this.name && !jQuery( this ).is( ":disabled" ) &&
+                               rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
+                               ( this.checked || !rcheckableType.test( type ) );
+               } )
+               .map( function( _i, elem ) {
+                       var val = jQuery( this ).val();
+
+                       if ( val == null ) {
+                               return null;
+                       }
+
+                       if ( Array.isArray( val ) ) {
+                               return jQuery.map( val, function( val ) {
+                                       return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+                               } );
+                       }
+
+                       return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+               } ).get();
+       }
+} );
+
+
+var
+       r20 = /%20/g,
+       rhash = /#.*$/,
+       rantiCache = /([?&])_=[^&]*/,
+       rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
+
+       // #7653, #8125, #8152: local protocol detection
+       rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
+       rnoContent = /^(?:GET|HEAD)$/,
+       rprotocol = /^\/\//,
+
+       /* Prefilters
+        * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+        * 2) These are called:
+        *    - BEFORE asking for a transport
+        *    - AFTER param serialization (s.data is a string if s.processData is true)
+        * 3) key is the dataType
+        * 4) the catchall symbol "*" can be used
+        * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+        */
+       prefilters = {},
+
+       /* Transports bindings
+        * 1) key is the dataType
+        * 2) the catchall symbol "*" can be used
+        * 3) selection will start with transport dataType and THEN go to "*" if needed
+        */
+       transports = {},
+
+       // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+       allTypes = "*/".concat( "*" ),
+
+       // Anchor tag for parsing the document origin
+       originAnchor = document.createElement( "a" );
+       originAnchor.href = location.href;
+
+// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
+function addToPrefiltersOrTransports( structure ) {
+
+       // dataTypeExpression is optional and defaults to "*"
+       return function( dataTypeExpression, func ) {
+
+               if ( typeof dataTypeExpression !== "string" ) {
+                       func = dataTypeExpression;
+                       dataTypeExpression = "*";
+               }
+
+               var dataType,
+                       i = 0,
+                       dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
+
+               if ( isFunction( func ) ) {
+
+                       // For each dataType in the dataTypeExpression
+                       while ( ( dataType = dataTypes[ i++ ] ) ) {
+
+                               // Prepend if requested
+                               if ( dataType[ 0 ] === "+" ) {
+                                       dataType = dataType.slice( 1 ) || "*";
+                                       ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
+
+                               // Otherwise append
+                               } else {
+                                       ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
+                               }
+                       }
+               }
+       };
+}
+
+// Base inspection function for prefilters and transports
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
+
+       var inspected = {},
+               seekingTransport = ( structure === transports );
+
+       function inspect( dataType ) {
+               var selected;
+               inspected[ dataType ] = true;
+               jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
+                       var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
+                       if ( typeof dataTypeOrTransport === "string" &&
+                               !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
+
+                               options.dataTypes.unshift( dataTypeOrTransport );
+                               inspect( dataTypeOrTransport );
+                               return false;
+                       } else if ( seekingTransport ) {
+                               return !( selected = dataTypeOrTransport );
+                       }
+               } );
+               return selected;
+       }
+
+       return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
+}
+
+// A special extend for ajax options
+// that takes "flat" options (not to be deep extended)
+// Fixes #9887
+function ajaxExtend( target, src ) {
+       var key, deep,
+               flatOptions = jQuery.ajaxSettings.flatOptions || {};
+
+       for ( key in src ) {
+               if ( src[ key ] !== undefined ) {
+                       ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
+               }
+       }
+       if ( deep ) {
+               jQuery.extend( true, target, deep );
+       }
+
+       return target;
+}
+
+/* Handles responses to an ajax request:
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+
+       var ct, type, finalDataType, firstDataType,
+               contents = s.contents,
+               dataTypes = s.dataTypes;
+
+       // Remove auto dataType and get content-type in the process
+       while ( dataTypes[ 0 ] === "*" ) {
+               dataTypes.shift();
+               if ( ct === undefined ) {
+                       ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
+               }
+       }
+
+       // Check if we're dealing with a known content-type
+       if ( ct ) {
+               for ( type in contents ) {
+                       if ( contents[ type ] && contents[ type ].test( ct ) ) {
+                               dataTypes.unshift( type );
+                               break;
+                       }
+               }
+       }
+
+       // Check to see if we have a response for the expected dataType
+       if ( dataTypes[ 0 ] in responses ) {
+               finalDataType = dataTypes[ 0 ];
+       } else {
+
+               // Try convertible dataTypes
+               for ( type in responses ) {
+                       if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
+                               finalDataType = type;
+                               break;
+                       }
+                       if ( !firstDataType ) {
+                               firstDataType = type;
+                       }
+               }
+
+               // Or just use first one
+               finalDataType = finalDataType || firstDataType;
+       }
+
+       // If we found a dataType
+       // We add the dataType to the list if needed
+       // and return the corresponding response
+       if ( finalDataType ) {
+               if ( finalDataType !== dataTypes[ 0 ] ) {
+                       dataTypes.unshift( finalDataType );
+               }
+               return responses[ finalDataType ];
+       }
+}
+
+/* Chain conversions given the request and the original response
+ * Also sets the responseXXX fields on the jqXHR instance
+ */
+function ajaxConvert( s, response, jqXHR, isSuccess ) {
+       var conv2, current, conv, tmp, prev,
+               converters = {},
+
+               // Work with a copy of dataTypes in case we need to modify it for conversion
+               dataTypes = s.dataTypes.slice();
+
+       // Create converters map with lowercased keys
+       if ( dataTypes[ 1 ] ) {
+               for ( conv in s.converters ) {
+                       converters[ conv.toLowerCase() ] = s.converters[ conv ];
+               }
+       }
+
+       current = dataTypes.shift();
+
+       // Convert to each sequential dataType
+       while ( current ) {
+
+               if ( s.responseFields[ current ] ) {
+                       jqXHR[ s.responseFields[ current ] ] = response;
+               }
+
+               // Apply the dataFilter if provided
+               if ( !prev && isSuccess && s.dataFilter ) {
+                       response = s.dataFilter( response, s.dataType );
+               }
+
+               prev = current;
+               current = dataTypes.shift();
+
+               if ( current ) {
+
+                       // There's only work to do if current dataType is non-auto
+                       if ( current === "*" ) {
+
+                               current = prev;
+
+                       // Convert response if prev dataType is non-auto and differs from current
+                       } else if ( prev !== "*" && prev !== current ) {
+
+                               // Seek a direct converter
+                               conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+                               // If none found, seek a pair
+                               if ( !conv ) {
+                                       for ( conv2 in converters ) {
+
+                                               // If conv2 outputs current
+                                               tmp = conv2.split( " " );
+                                               if ( tmp[ 1 ] === current ) {
+
+                                                       // If prev can be converted to accepted input
+                                                       conv = converters[ prev + " " + tmp[ 0 ] ] ||
+                                                               converters[ "* " + tmp[ 0 ] ];
+                                                       if ( conv ) {
+
+                                                               // Condense equivalence converters
+                                                               if ( conv === true ) {
+                                                                       conv = converters[ conv2 ];
+
+                                                               // Otherwise, insert the intermediate dataType
+                                                               } else if ( converters[ conv2 ] !== true ) {
+                                                                       current = tmp[ 0 ];
+                                                                       dataTypes.unshift( tmp[ 1 ] );
+                                                               }
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               // Apply converter (if not an equivalence)
+                               if ( conv !== true ) {
+
+                                       // Unless errors are allowed to bubble, catch and return them
+                                       if ( conv && s.throws ) {
+                                               response = conv( response );
+                                       } else {
+                                               try {
+                                                       response = conv( response );
+                                               } catch ( e ) {
+                                                       return {
+                                                               state: "parsererror",
+                                                               error: conv ? e : "No conversion from " + prev + " to " + current
+                                                       };
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       return { state: "success", data: response };
+}
+
+jQuery.extend( {
+
+       // Counter for holding the number of active queries
+       active: 0,
+
+       // Last-Modified header cache for next request
+       lastModified: {},
+       etag: {},
+
+       ajaxSettings: {
+               url: location.href,
+               type: "GET",
+               isLocal: rlocalProtocol.test( location.protocol ),
+               global: true,
+               processData: true,
+               async: true,
+               contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+
+               /*
+               timeout: 0,
+               data: null,
+               dataType: null,
+               username: null,
+               password: null,
+               cache: null,
+               throws: false,
+               traditional: false,
+               headers: {},
+               */
+
+               accepts: {
+                       "*": allTypes,
+                       text: "text/plain",
+                       html: "text/html",
+                       xml: "application/xml, text/xml",
+                       json: "application/json, text/javascript"
+               },
+
+               contents: {
+                       xml: /\bxml\b/,
+                       html: /\bhtml/,
+                       json: /\bjson\b/
+               },
+
+               responseFields: {
+                       xml: "responseXML",
+                       text: "responseText",
+                       json: "responseJSON"
+               },
+
+               // Data converters
+               // Keys separate source (or catchall "*") and destination types with a single space
+               converters: {
+
+                       // Convert anything to text
+                       "* text": String,
+
+                       // Text to html (true = no transformation)
+                       "text html": true,
+
+                       // Evaluate text as a json expression
+                       "text json": JSON.parse,
+
+                       // Parse text as xml
+                       "text xml": jQuery.parseXML
+               },
+
+               // For options that shouldn't be deep extended:
+               // you can add your own custom options here if
+               // and when you create one that shouldn't be
+               // deep extended (see ajaxExtend)
+               flatOptions: {
+                       url: true,
+                       context: true
+               }
+       },
+
+       // Creates a full fledged settings object into target
+       // with both ajaxSettings and settings fields.
+       // If target is omitted, writes into ajaxSettings.
+       ajaxSetup: function( target, settings ) {
+               return settings ?
+
+                       // Building a settings object
+                       ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
+
+                       // Extending ajaxSettings
+                       ajaxExtend( jQuery.ajaxSettings, target );
+       },
+
+       ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+       ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+       // Main method
+       ajax: function( url, options ) {
+
+               // If url is an object, simulate pre-1.5 signature
+               if ( typeof url === "object" ) {
+                       options = url;
+                       url = undefined;
+               }
+
+               // Force options to be an object
+               options = options || {};
+
+               var transport,
+
+                       // URL without anti-cache param
+                       cacheURL,
+
+                       // Response headers
+                       responseHeadersString,
+                       responseHeaders,
+
+                       // timeout handle
+                       timeoutTimer,
+
+                       // Url cleanup var
+                       urlAnchor,
+
+                       // Request state (becomes false upon send and true upon completion)
+                       completed,
+
+                       // To know if global events are to be dispatched
+                       fireGlobals,
+
+                       // Loop variable
+                       i,
+
+                       // uncached part of the url
+                       uncached,
+
+                       // Create the final options object
+                       s = jQuery.ajaxSetup( {}, options ),
+
+                       // Callbacks context
+                       callbackContext = s.context || s,
+
+                       // Context for global events is callbackContext if it is a DOM node or jQuery collection
+                       globalEventContext = s.context &&
+                               ( callbackContext.nodeType || callbackContext.jquery ) ?
+                                       jQuery( callbackContext ) :
+                                       jQuery.event,
+
+                       // Deferreds
+                       deferred = jQuery.Deferred(),
+                       completeDeferred = jQuery.Callbacks( "once memory" ),
+
+                       // Status-dependent callbacks
+                       statusCode = s.statusCode || {},
+
+                       // Headers (they are sent all at once)
+                       requestHeaders = {},
+                       requestHeadersNames = {},
+
+                       // Default abort message
+                       strAbort = "canceled",
+
+                       // Fake xhr
+                       jqXHR = {
+                               readyState: 0,
+
+                               // Builds headers hashtable if needed
+                               getResponseHeader: function( key ) {
+                                       var match;
+                                       if ( completed ) {
+                                               if ( !responseHeaders ) {
+                                                       responseHeaders = {};
+                                                       while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
+                                                               responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
+                                                                       ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
+                                                                               .concat( match[ 2 ] );
+                                                       }
+                                               }
+                                               match = responseHeaders[ key.toLowerCase() + " " ];
+                                       }
+                                       return match == null ? null : match.join( ", " );
+                               },
+
+                               // Raw string
+                               getAllResponseHeaders: function() {
+                                       return completed ? responseHeadersString : null;
+                               },
+
+                               // Caches the header
+                               setRequestHeader: function( name, value ) {
+                                       if ( completed == null ) {
+                                               name = requestHeadersNames[ name.toLowerCase() ] =
+                                                       requestHeadersNames[ name.toLowerCase() ] || name;
+                                               requestHeaders[ name ] = value;
+                                       }
+                                       return this;
+                               },
+
+                               // Overrides response content-type header
+                               overrideMimeType: function( type ) {
+                                       if ( completed == null ) {
+                                               s.mimeType = type;
+                                       }
+                                       return this;
+                               },
+
+                               // Status-dependent callbacks
+                               statusCode: function( map ) {
+                                       var code;
+                                       if ( map ) {
+                                               if ( completed ) {
+
+                                                       // Execute the appropriate callbacks
+                                                       jqXHR.always( map[ jqXHR.status ] );
+                                               } else {
+
+                                                       // Lazy-add the new callbacks in a way that preserves old ones
+                                                       for ( code in map ) {
+                                                               statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
+                                                       }
+                                               }
+                                       }
+                                       return this;
+                               },
+
+                               // Cancel the request
+                               abort: function( statusText ) {
+                                       var finalText = statusText || strAbort;
+                                       if ( transport ) {
+                                               transport.abort( finalText );
+                                       }
+                                       done( 0, finalText );
+                                       return this;
+                               }
+                       };
+
+               // Attach deferreds
+               deferred.promise( jqXHR );
+
+               // Add protocol if not provided (prefilters might expect it)
+               // Handle falsy url in the settings object (#10093: consistency with old signature)
+               // We also use the url parameter if available
+               s.url = ( ( url || s.url || location.href ) + "" )
+                       .replace( rprotocol, location.protocol + "//" );
+
+               // Alias method option to type as per ticket #12004
+               s.type = options.method || options.type || s.method || s.type;
+
+               // Extract dataTypes list
+               s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
+
+               // A cross-domain request is in order when the origin doesn't match the current origin.
+               if ( s.crossDomain == null ) {
+                       urlAnchor = document.createElement( "a" );
+
+                       // Support: IE <=8 - 11, Edge 12 - 15
+                       // IE throws exception on accessing the href property if url is malformed,
+                       // e.g. http://example.com:80x/
+                       try {
+                               urlAnchor.href = s.url;
+
+                               // Support: IE <=8 - 11 only
+                               // Anchor's host property isn't correctly set when s.url is relative
+                               urlAnchor.href = urlAnchor.href;
+                               s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
+                                       urlAnchor.protocol + "//" + urlAnchor.host;
+                       } catch ( e ) {
+
+                               // If there is an error parsing the URL, assume it is crossDomain,
+                               // it can be rejected by the transport if it is invalid
+                               s.crossDomain = true;
+                       }
+               }
+
+               // Convert data if not already a string
+               if ( s.data && s.processData && typeof s.data !== "string" ) {
+                       s.data = jQuery.param( s.data, s.traditional );
+               }
+
+               // Apply prefilters
+               inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+               // If request was aborted inside a prefilter, stop there
+               if ( completed ) {
+                       return jqXHR;
+               }
+
+               // We can fire global events as of now if asked to
+               // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
+               fireGlobals = jQuery.event && s.global;
+
+               // Watch for a new set of requests
+               if ( fireGlobals && jQuery.active++ === 0 ) {
+                       jQuery.event.trigger( "ajaxStart" );
+               }
+
+               // Uppercase the type
+               s.type = s.type.toUpperCase();
+
+               // Determine if request has content
+               s.hasContent = !rnoContent.test( s.type );
+
+               // Save the URL in case we're toying with the If-Modified-Since
+               // and/or If-None-Match header later on
+               // Remove hash to simplify url manipulation
+               cacheURL = s.url.replace( rhash, "" );
+
+               // More options handling for requests with no content
+               if ( !s.hasContent ) {
+
+                       // Remember the hash so we can put it back
+                       uncached = s.url.slice( cacheURL.length );
+
+                       // If data is available and should be processed, append data to url
+                       if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
+                               cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
+
+                               // #9682: remove data so that it's not used in an eventual retry
+                               delete s.data;
+                       }
+
+                       // Add or update anti-cache param if needed
+                       if ( s.cache === false ) {
+                               cacheURL = cacheURL.replace( rantiCache, "$1" );
+                               uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
+                                       uncached;
+                       }
+
+                       // Put hash and anti-cache on the URL that will be requested (gh-1732)
+                       s.url = cacheURL + uncached;
+
+               // Change '%20' to '+' if this is encoded form body content (gh-2658)
+               } else if ( s.data && s.processData &&
+                       ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
+                       s.data = s.data.replace( r20, "+" );
+               }
+
+               // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+               if ( s.ifModified ) {
+                       if ( jQuery.lastModified[ cacheURL ] ) {
+                               jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
+                       }
+                       if ( jQuery.etag[ cacheURL ] ) {
+                               jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
+                       }
+               }
+
+               // Set the correct header, if data is being sent
+               if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+                       jqXHR.setRequestHeader( "Content-Type", s.contentType );
+               }
+
+               // Set the Accepts header for the server, depending on the dataType
+               jqXHR.setRequestHeader(
+                       "Accept",
+                       s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
+                               s.accepts[ s.dataTypes[ 0 ] ] +
+                                       ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+                               s.accepts[ "*" ]
+               );
+
+               // Check for headers option
+               for ( i in s.headers ) {
+                       jqXHR.setRequestHeader( i, s.headers[ i ] );
+               }
+
+               // Allow custom headers/mimetypes and early abort
+               if ( s.beforeSend &&
+                       ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
+
+                       // Abort if not done already and return
+                       return jqXHR.abort();
+               }
+
+               // Aborting is no longer a cancellation
+               strAbort = "abort";
+
+               // Install callbacks on deferreds
+               completeDeferred.add( s.complete );
+               jqXHR.done( s.success );
+               jqXHR.fail( s.error );
+
+               // Get transport
+               transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+               // If no transport, we auto-abort
+               if ( !transport ) {
+                       done( -1, "No Transport" );
+               } else {
+                       jqXHR.readyState = 1;
+
+                       // Send global event
+                       if ( fireGlobals ) {
+                               globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+                       }
+
+                       // If request was aborted inside ajaxSend, stop there
+                       if ( completed ) {
+                               return jqXHR;
+                       }
+
+                       // Timeout
+                       if ( s.async && s.timeout > 0 ) {
+                               timeoutTimer = window.setTimeout( function() {
+                                       jqXHR.abort( "timeout" );
+                               }, s.timeout );
+                       }
+
+                       try {
+                               completed = false;
+                               transport.send( requestHeaders, done );
+                       } catch ( e ) {
+
+                               // Rethrow post-completion exceptions
+                               if ( completed ) {
+                                       throw e;
+                               }
+
+                               // Propagate others as results
+                               done( -1, e );
+                       }
+               }
+
+               // Callback for when everything is done
+               function done( status, nativeStatusText, responses, headers ) {
+                       var isSuccess, success, error, response, modified,
+                               statusText = nativeStatusText;
+
+                       // Ignore repeat invocations
+                       if ( completed ) {
+                               return;
+                       }
+
+                       completed = true;
+
+                       // Clear timeout if it exists
+                       if ( timeoutTimer ) {
+                               window.clearTimeout( timeoutTimer );
+                       }
+
+                       // Dereference transport for early garbage collection
+                       // (no matter how long the jqXHR object will be used)
+                       transport = undefined;
+
+                       // Cache response headers
+                       responseHeadersString = headers || "";
+
+                       // Set readyState
+                       jqXHR.readyState = status > 0 ? 4 : 0;
+
+                       // Determine if successful
+                       isSuccess = status >= 200 && status < 300 || status === 304;
+
+                       // Get response data
+                       if ( responses ) {
+                               response = ajaxHandleResponses( s, jqXHR, responses );
+                       }
+
+                       // Use a noop converter for missing script
+                       if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) {
+                               s.converters[ "text script" ] = function() {};
+                       }
+
+                       // Convert no matter what (that way responseXXX fields are always set)
+                       response = ajaxConvert( s, response, jqXHR, isSuccess );
+
+                       // If successful, handle type chaining
+                       if ( isSuccess ) {
+
+                               // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+                               if ( s.ifModified ) {
+                                       modified = jqXHR.getResponseHeader( "Last-Modified" );
+                                       if ( modified ) {
+                                               jQuery.lastModified[ cacheURL ] = modified;
+                                       }
+                                       modified = jqXHR.getResponseHeader( "etag" );
+                                       if ( modified ) {
+                                               jQuery.etag[ cacheURL ] = modified;
+                                       }
+                               }
+
+                               // if no content
+                               if ( status === 204 || s.type === "HEAD" ) {
+                                       statusText = "nocontent";
+
+                               // if not modified
+                               } else if ( status === 304 ) {
+                                       statusText = "notmodified";
+
+                               // If we have data, let's convert it
+                               } else {
+                                       statusText = response.state;
+                                       success = response.data;
+                                       error = response.error;
+                                       isSuccess = !error;
+                               }
+                       } else {
+
+                               // Extract error from statusText and normalize for non-aborts
+                               error = statusText;
+                               if ( status || !statusText ) {
+                                       statusText = "error";
+                                       if ( status < 0 ) {
+                                               status = 0;
+                                       }
+                               }
+                       }
+
+                       // Set data for the fake xhr object
+                       jqXHR.status = status;
+                       jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+                       // Success/Error
+                       if ( isSuccess ) {
+                               deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+                       } else {
+                               deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+                       }
+
+                       // Status-dependent callbacks
+                       jqXHR.statusCode( statusCode );
+                       statusCode = undefined;
+
+                       if ( fireGlobals ) {
+                               globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
+                                       [ jqXHR, s, isSuccess ? success : error ] );
+                       }
+
+                       // Complete
+                       completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+                       if ( fireGlobals ) {
+                               globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+
+                               // Handle the global AJAX counter
+                               if ( !( --jQuery.active ) ) {
+                                       jQuery.event.trigger( "ajaxStop" );
+                               }
+                       }
+               }
+
+               return jqXHR;
+       },
+
+       getJSON: function( url, data, callback ) {
+               return jQuery.get( url, data, callback, "json" );
+       },
+
+       getScript: function( url, callback ) {
+               return jQuery.get( url, undefined, callback, "script" );
+       }
+} );
+
+jQuery.each( [ "get", "post" ], function( _i, method ) {
+       jQuery[ method ] = function( url, data, callback, type ) {
+
+               // Shift arguments if data argument was omitted
+               if ( isFunction( data ) ) {
+                       type = type || callback;
+                       callback = data;
+                       data = undefined;
+               }
+
+               // The url can be an options object (which then must have .url)
+               return jQuery.ajax( jQuery.extend( {
+                       url: url,
+                       type: method,
+                       dataType: type,
+                       data: data,
+                       success: callback
+               }, jQuery.isPlainObject( url ) && url ) );
+       };
+} );
+
+jQuery.ajaxPrefilter( function( s ) {
+       var i;
+       for ( i in s.headers ) {
+               if ( i.toLowerCase() === "content-type" ) {
+                       s.contentType = s.headers[ i ] || "";
+               }
+       }
+} );
+
+
+jQuery._evalUrl = function( url, options, doc ) {
+       return jQuery.ajax( {
+               url: url,
+
+               // Make this explicit, since user can override this through ajaxSetup (#11264)
+               type: "GET",
+               dataType: "script",
+               cache: true,
+               async: false,
+               global: false,
+
+               // Only evaluate the response if it is successful (gh-4126)
+               // dataFilter is not invoked for failure responses, so using it instead
+               // of the default converter is kludgy but it works.
+               converters: {
+                       "text script": function() {}
+               },
+               dataFilter: function( response ) {
+                       jQuery.globalEval( response, options, doc );
+               }
+       } );
+};
+
+
+jQuery.fn.extend( {
+       wrapAll: function( html ) {
+               var wrap;
+
+               if ( this[ 0 ] ) {
+                       if ( isFunction( html ) ) {
+                               html = html.call( this[ 0 ] );
+                       }
+
+                       // The elements to wrap the target around
+                       wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
+
+                       if ( this[ 0 ].parentNode ) {
+                               wrap.insertBefore( this[ 0 ] );
+                       }
+
+                       wrap.map( function() {
+                               var elem = this;
+
+                               while ( elem.firstElementChild ) {
+                                       elem = elem.firstElementChild;
+                               }
+
+                               return elem;
+                       } ).append( this );
+               }
+
+               return this;
+       },
+
+       wrapInner: function( html ) {
+               if ( isFunction( html ) ) {
+                       return this.each( function( i ) {
+                               jQuery( this ).wrapInner( html.call( this, i ) );
+                       } );
+               }
+
+               return this.each( function() {
+                       var self = jQuery( this ),
+                               contents = self.contents();
+
+                       if ( contents.length ) {
+                               contents.wrapAll( html );
+
+                       } else {
+                               self.append( html );
+                       }
+               } );
+       },
+
+       wrap: function( html ) {
+               var htmlIsFunction = isFunction( html );
+
+               return this.each( function( i ) {
+                       jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
+               } );
+       },
+
+       unwrap: function( selector ) {
+               this.parent( selector ).not( "body" ).each( function() {
+                       jQuery( this ).replaceWith( this.childNodes );
+               } );
+               return this;
+       }
+} );
+
+
+jQuery.expr.pseudos.hidden = function( elem ) {
+       return !jQuery.expr.pseudos.visible( elem );
+};
+jQuery.expr.pseudos.visible = function( elem ) {
+       return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
+};
+
+
+
+
+jQuery.ajaxSettings.xhr = function() {
+       try {
+               return new window.XMLHttpRequest();
+       } catch ( e ) {}
+};
+
+var xhrSuccessStatus = {
+
+               // File protocol always yields status code 0, assume 200
+               0: 200,
+
+               // Support: IE <=9 only
+               // #1450: sometimes IE returns 1223 when it should be 204
+               1223: 204
+       },
+       xhrSupported = jQuery.ajaxSettings.xhr();
+
+support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
+support.ajax = xhrSupported = !!xhrSupported;
+
+jQuery.ajaxTransport( function( options ) {
+       var callback, errorCallback;
+
+       // Cross domain only allowed if supported through XMLHttpRequest
+       if ( support.cors || xhrSupported && !options.crossDomain ) {
+               return {
+                       send: function( headers, complete ) {
+                               var i,
+                                       xhr = options.xhr();
+
+                               xhr.open(
+                                       options.type,
+                                       options.url,
+                                       options.async,
+                                       options.username,
+                                       options.password
+                               );
+
+                               // Apply custom fields if provided
+                               if ( options.xhrFields ) {
+                                       for ( i in options.xhrFields ) {
+                                               xhr[ i ] = options.xhrFields[ i ];
+                                       }
+                               }
+
+                               // Override mime type if needed
+                               if ( options.mimeType && xhr.overrideMimeType ) {
+                                       xhr.overrideMimeType( options.mimeType );
+                               }
+
+                               // X-Requested-With header
+                               // For cross-domain requests, seeing as conditions for a preflight are
+                               // akin to a jigsaw puzzle, we simply never set it to be sure.
+                               // (it can always be set on a per-request basis or even using ajaxSetup)
+                               // For same-domain requests, won't change header if already provided.
+                               if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
+                                       headers[ "X-Requested-With" ] = "XMLHttpRequest";
+                               }
+
+                               // Set headers
+                               for ( i in headers ) {
+                                       xhr.setRequestHeader( i, headers[ i ] );
+                               }
+
+                               // Callback
+                               callback = function( type ) {
+                                       return function() {
+                                               if ( callback ) {
+                                                       callback = errorCallback = xhr.onload =
+                                                               xhr.onerror = xhr.onabort = xhr.ontimeout =
+                                                                       xhr.onreadystatechange = null;
+
+                                                       if ( type === "abort" ) {
+                                                               xhr.abort();
+                                                       } else if ( type === "error" ) {
+
+                                                               // Support: IE <=9 only
+                                                               // On a manual native abort, IE9 throws
+                                                               // errors on any property access that is not readyState
+                                                               if ( typeof xhr.status !== "number" ) {
+                                                                       complete( 0, "error" );
+                                                               } else {
+                                                                       complete(
+
+                                                                               // File: protocol always yields status 0; see #8605, #14207
+                                                                               xhr.status,
+                                                                               xhr.statusText
+                                                                       );
+                                                               }
+                                                       } else {
+                                                               complete(
+                                                                       xhrSuccessStatus[ xhr.status ] || xhr.status,
+                                                                       xhr.statusText,
+
+                                                                       // Support: IE <=9 only
+                                                                       // IE9 has no XHR2 but throws on binary (trac-11426)
+                                                                       // For XHR2 non-text, let the caller handle it (gh-2498)
+                                                                       ( xhr.responseType || "text" ) !== "text"  ||
+                                                                       typeof xhr.responseText !== "string" ?
+                                                                               { binary: xhr.response } :
+                                                                               { text: xhr.responseText },
+                                                                       xhr.getAllResponseHeaders()
+                                                               );
+                                                       }
+                                               }
+                                       };
+                               };
+
+                               // Listen to events
+                               xhr.onload = callback();
+                               errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
+
+                               // Support: IE 9 only
+                               // Use onreadystatechange to replace onabort
+                               // to handle uncaught aborts
+                               if ( xhr.onabort !== undefined ) {
+                                       xhr.onabort = errorCallback;
+                               } else {
+                                       xhr.onreadystatechange = function() {
+
+                                               // Check readyState before timeout as it changes
+                                               if ( xhr.readyState === 4 ) {
+
+                                                       // Allow onerror to be called first,
+                                                       // but that will not handle a native abort
+                                                       // Also, save errorCallback to a variable
+                                                       // as xhr.onerror cannot be accessed
+                                                       window.setTimeout( function() {
+                                                               if ( callback ) {
+                                                                       errorCallback();
+                                                               }
+                                                       } );
+                                               }
+                                       };
+                               }
+
+                               // Create the abort callback
+                               callback = callback( "abort" );
+
+                               try {
+
+                                       // Do send the request (this may raise an exception)
+                                       xhr.send( options.hasContent && options.data || null );
+                               } catch ( e ) {
+
+                                       // #14683: Only rethrow if this hasn't been notified as an error yet
+                                       if ( callback ) {
+                                               throw e;
+                                       }
+                               }
+                       },
+
+                       abort: function() {
+                               if ( callback ) {
+                                       callback();
+                               }
+                       }
+               };
+       }
+} );
+
+
+
+
+// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
+jQuery.ajaxPrefilter( function( s ) {
+       if ( s.crossDomain ) {
+               s.contents.script = false;
+       }
+} );
+
+// Install script dataType
+jQuery.ajaxSetup( {
+       accepts: {
+               script: "text/javascript, application/javascript, " +
+                       "application/ecmascript, application/x-ecmascript"
+       },
+       contents: {
+               script: /\b(?:java|ecma)script\b/
+       },
+       converters: {
+               "text script": function( text ) {
+                       jQuery.globalEval( text );
+                       return text;
+               }
+       }
+} );
+
+// Handle cache's special case and crossDomain
+jQuery.ajaxPrefilter( "script", function( s ) {
+       if ( s.cache === undefined ) {
+               s.cache = false;
+       }
+       if ( s.crossDomain ) {
+               s.type = "GET";
+       }
+} );
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function( s ) {
+
+       // This transport only deals with cross domain or forced-by-attrs requests
+       if ( s.crossDomain || s.scriptAttrs ) {
+               var script, callback;
+               return {
+                       send: function( _, complete ) {
+                               script = jQuery( "<script>" )
+                                       .attr( s.scriptAttrs || {} )
+                                       .prop( { charset: s.scriptCharset, src: s.url } )
+                                       .on( "load error", callback = function( evt ) {
+                                               script.remove();
+                                               callback = null;
+                                               if ( evt ) {
+                                                       complete( evt.type === "error" ? 404 : 200, evt.type );
+                                               }
+                                       } );
+
+                               // Use native DOM manipulation to avoid our domManip AJAX trickery
+                               document.head.appendChild( script[ 0 ] );
+                       },
+                       abort: function() {
+                               if ( callback ) {
+                                       callback();
+                               }
+                       }
+               };
+       }
+} );
+
+
+
+
+var oldCallbacks = [],
+       rjsonp = /(=)\?(?=&|$)|\?\?/;
+
+// Default jsonp settings
+jQuery.ajaxSetup( {
+       jsonp: "callback",
+       jsonpCallback: function() {
+               var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
+               this[ callback ] = true;
+               return callback;
+       }
+} );
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+       var callbackName, overwritten, responseContainer,
+               jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
+                       "url" :
+                       typeof s.data === "string" &&
+                               ( s.contentType || "" )
+                                       .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
+                               rjsonp.test( s.data ) && "data"
+               );
+
+       // Handle iff the expected data type is "jsonp" or we have a parameter to set
+       if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
+
+               // Get callback name, remembering preexisting value associated with it
+               callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
+                       s.jsonpCallback() :
+                       s.jsonpCallback;
+
+               // Insert callback into url or form data
+               if ( jsonProp ) {
+                       s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
+               } else if ( s.jsonp !== false ) {
+                       s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+               }
+
+               // Use data converter to retrieve json after script execution
+               s.converters[ "script json" ] = function() {
+                       if ( !responseContainer ) {
+                               jQuery.error( callbackName + " was not called" );
+                       }
+                       return responseContainer[ 0 ];
+               };
+
+               // Force json dataType
+               s.dataTypes[ 0 ] = "json";
+
+               // Install callback
+               overwritten = window[ callbackName ];
+               window[ callbackName ] = function() {
+                       responseContainer = arguments;
+               };
+
+               // Clean-up function (fires after converters)
+               jqXHR.always( function() {
+
+                       // If previous value didn't exist - remove it
+                       if ( overwritten === undefined ) {
+                               jQuery( window ).removeProp( callbackName );
+
+                       // Otherwise restore preexisting value
+                       } else {
+                               window[ callbackName ] = overwritten;
+                       }
+
+                       // Save back as free
+                       if ( s[ callbackName ] ) {
+
+                               // Make sure that re-using the options doesn't screw things around
+                               s.jsonpCallback = originalSettings.jsonpCallback;
+
+                               // Save the callback name for future use
+                               oldCallbacks.push( callbackName );
+                       }
+
+                       // Call if it was a function and we have a response
+                       if ( responseContainer && isFunction( overwritten ) ) {
+                               overwritten( responseContainer[ 0 ] );
+                       }
+
+                       responseContainer = overwritten = undefined;
+               } );
+
+               // Delegate to script
+               return "script";
+       }
+} );
+
+
+
+
+// Support: Safari 8 only
+// In Safari 8 documents created via document.implementation.createHTMLDocument
+// collapse sibling forms: the second one becomes a child of the first one.
+// Because of that, this security measure has to be disabled in Safari 8.
+// https://bugs.webkit.org/show_bug.cgi?id=137337
+support.createHTMLDocument = ( function() {
+       var body = document.implementation.createHTMLDocument( "" ).body;
+       body.innerHTML = "<form></form><form></form>";
+       return body.childNodes.length === 2;
+} )();
+
+
+// Argument "data" should be string of html
+// context (optional): If specified, the fragment will be created in this context,
+// defaults to document
+// keepScripts (optional): If true, will include scripts passed in the html string
+jQuery.parseHTML = function( data, context, keepScripts ) {
+       if ( typeof data !== "string" ) {
+               return [];
+       }
+       if ( typeof context === "boolean" ) {
+               keepScripts = context;
+               context = false;
+       }
+
+       var base, parsed, scripts;
+
+       if ( !context ) {
+
+               // Stop scripts or inline event handlers from being executed immediately
+               // by using document.implementation
+               if ( support.createHTMLDocument ) {
+                       context = document.implementation.createHTMLDocument( "" );
+
+                       // Set the base href for the created document
+                       // so any parsed elements with URLs
+                       // are based on the document's URL (gh-2965)
+                       base = context.createElement( "base" );
+                       base.href = document.location.href;
+                       context.head.appendChild( base );
+               } else {
+                       context = document;
+               }
+       }
+
+       parsed = rsingleTag.exec( data );
+       scripts = !keepScripts && [];
+
+       // Single tag
+       if ( parsed ) {
+               return [ context.createElement( parsed[ 1 ] ) ];
+       }
+
+       parsed = buildFragment( [ data ], context, scripts );
+
+       if ( scripts && scripts.length ) {
+               jQuery( scripts ).remove();
+       }
+
+       return jQuery.merge( [], parsed.childNodes );
+};
+
+
+/**
+ * Load a url into a page
+ */
+jQuery.fn.load = function( url, params, callback ) {
+       var selector, type, response,
+               self = this,
+               off = url.indexOf( " " );
+
+       if ( off > -1 ) {
+               selector = stripAndCollapse( url.slice( off ) );
+               url = url.slice( 0, off );
+       }
+
+       // If it's a function
+       if ( isFunction( params ) ) {
+
+               // We assume that it's the callback
+               callback = params;
+               params = undefined;
+
+       // Otherwise, build a param string
+       } else if ( params && typeof params === "object" ) {
+               type = "POST";
+       }
+
+       // If we have elements to modify, make the request
+       if ( self.length > 0 ) {
+               jQuery.ajax( {
+                       url: url,
+
+                       // If "type" variable is undefined, then "GET" method will be used.
+                       // Make value of this field explicit since
+                       // user can override it through ajaxSetup method
+                       type: type || "GET",
+                       dataType: "html",
+                       data: params
+               } ).done( function( responseText ) {
+
+                       // Save response for use in complete callback
+                       response = arguments;
+
+                       self.html( selector ?
+
+                               // If a selector was specified, locate the right elements in a dummy div
+                               // Exclude scripts to avoid IE 'Permission Denied' errors
+                               jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
+
+                               // Otherwise use the full result
+                               responseText );
+
+               // If the request succeeds, this function gets "data", "status", "jqXHR"
+               // but they are ignored because response was set above.
+               // If it fails, this function gets "jqXHR", "status", "error"
+               } ).always( callback && function( jqXHR, status ) {
+                       self.each( function() {
+                               callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
+                       } );
+               } );
+       }
+
+       return this;
+};
+
+
+
+
+jQuery.expr.pseudos.animated = function( elem ) {
+       return jQuery.grep( jQuery.timers, function( fn ) {
+               return elem === fn.elem;
+       } ).length;
+};
+
+
+
+
+jQuery.offset = {
+       setOffset: function( elem, options, i ) {
+               var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
+                       position = jQuery.css( elem, "position" ),
+                       curElem = jQuery( elem ),
+                       props = {};
+
+               // Set position first, in-case top/left are set even on static elem
+               if ( position === "static" ) {
+                       elem.style.position = "relative";
+               }
+
+               curOffset = curElem.offset();
+               curCSSTop = jQuery.css( elem, "top" );
+               curCSSLeft = jQuery.css( elem, "left" );
+               calculatePosition = ( position === "absolute" || position === "fixed" ) &&
+                       ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
+
+               // Need to be able to calculate position if either
+               // top or left is auto and position is either absolute or fixed
+               if ( calculatePosition ) {
+                       curPosition = curElem.position();
+                       curTop = curPosition.top;
+                       curLeft = curPosition.left;
+
+               } else {
+                       curTop = parseFloat( curCSSTop ) || 0;
+                       curLeft = parseFloat( curCSSLeft ) || 0;
+               }
+
+               if ( isFunction( options ) ) {
+
+                       // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
+                       options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
+               }
+
+               if ( options.top != null ) {
+                       props.top = ( options.top - curOffset.top ) + curTop;
+               }
+               if ( options.left != null ) {
+                       props.left = ( options.left - curOffset.left ) + curLeft;
+               }
+
+               if ( "using" in options ) {
+                       options.using.call( elem, props );
+
+               } else {
+                       if ( typeof props.top === "number" ) {
+                               props.top += "px";
+                       }
+                       if ( typeof props.left === "number" ) {
+                               props.left += "px";
+                       }
+                       curElem.css( props );
+               }
+       }
+};
+
+jQuery.fn.extend( {
+
+       // offset() relates an element's border box to the document origin
+       offset: function( options ) {
+
+               // Preserve chaining for setter
+               if ( arguments.length ) {
+                       return options === undefined ?
+                               this :
+                               this.each( function( i ) {
+                                       jQuery.offset.setOffset( this, options, i );
+                               } );
+               }
+
+               var rect, win,
+                       elem = this[ 0 ];
+
+               if ( !elem ) {
+                       return;
+               }
+
+               // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
+               // Support: IE <=11 only
+               // Running getBoundingClientRect on a
+               // disconnected node in IE throws an error
+               if ( !elem.getClientRects().length ) {
+                       return { top: 0, left: 0 };
+               }
+
+               // Get document-relative position by adding viewport scroll to viewport-relative gBCR
+               rect = elem.getBoundingClientRect();
+               win = elem.ownerDocument.defaultView;
+               return {
+                       top: rect.top + win.pageYOffset,
+                       left: rect.left + win.pageXOffset
+               };
+       },
+
+       // position() relates an element's margin box to its offset parent's padding box
+       // This corresponds to the behavior of CSS absolute positioning
+       position: function() {
+               if ( !this[ 0 ] ) {
+                       return;
+               }
+
+               var offsetParent, offset, doc,
+                       elem = this[ 0 ],
+                       parentOffset = { top: 0, left: 0 };
+
+               // position:fixed elements are offset from the viewport, which itself always has zero offset
+               if ( jQuery.css( elem, "position" ) === "fixed" ) {
+
+                       // Assume position:fixed implies availability of getBoundingClientRect
+                       offset = elem.getBoundingClientRect();
+
+               } else {
+                       offset = this.offset();
+
+                       // Account for the *real* offset parent, which can be the document or its root element
+                       // when a statically positioned element is identified
+                       doc = elem.ownerDocument;
+                       offsetParent = elem.offsetParent || doc.documentElement;
+                       while ( offsetParent &&
+                               ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
+                               jQuery.css( offsetParent, "position" ) === "static" ) {
+
+                               offsetParent = offsetParent.parentNode;
+                       }
+                       if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
+
+                               // Incorporate borders into its offset, since they are outside its content origin
+                               parentOffset = jQuery( offsetParent ).offset();
+                               parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
+                               parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
+                       }
+               }
+
+               // Subtract parent offsets and element margins
+               return {
+                       top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
+                       left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
+               };
+       },
+
+       // This method will return documentElement in the following cases:
+       // 1) For the element inside the iframe without offsetParent, this method will return
+       //    documentElement of the parent window
+       // 2) For the hidden or detached element
+       // 3) For body or html element, i.e. in case of the html node - it will return itself
+       //
+       // but those exceptions were never presented as a real life use-cases
+       // and might be considered as more preferable results.
+       //
+       // This logic, however, is not guaranteed and can change at any point in the future
+       offsetParent: function() {
+               return this.map( function() {
+                       var offsetParent = this.offsetParent;
+
+                       while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
+                               offsetParent = offsetParent.offsetParent;
+                       }
+
+                       return offsetParent || documentElement;
+               } );
+       }
+} );
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
+       var top = "pageYOffset" === prop;
+
+       jQuery.fn[ method ] = function( val ) {
+               return access( this, function( elem, method, val ) {
+
+                       // Coalesce documents and windows
+                       var win;
+                       if ( isWindow( elem ) ) {
+                               win = elem;
+                       } else if ( elem.nodeType === 9 ) {
+                               win = elem.defaultView;
+                       }
+
+                       if ( val === undefined ) {
+                               return win ? win[ prop ] : elem[ method ];
+                       }
+
+                       if ( win ) {
+                               win.scrollTo(
+                                       !top ? val : win.pageXOffset,
+                                       top ? val : win.pageYOffset
+                               );
+
+                       } else {
+                               elem[ method ] = val;
+                       }
+               }, method, val, arguments.length );
+       };
+} );
+
+// Support: Safari <=7 - 9.1, Chrome <=37 - 49
+// Add the top/left cssHooks using jQuery.fn.position
+// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
+// getComputedStyle returns percent when specified for top/left/bottom/right;
+// rather than make the css module depend on the offset module, just check for it here
+jQuery.each( [ "top", "left" ], function( _i, prop ) {
+       jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
+               function( elem, computed ) {
+                       if ( computed ) {
+                               computed = curCSS( elem, prop );
+
+                               // If curCSS returns percentage, fallback to offset
+                               return rnumnonpx.test( computed ) ?
+                                       jQuery( elem ).position()[ prop ] + "px" :
+                                       computed;
+                       }
+               }
+       );
+} );
+
+
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+       jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
+               function( defaultExtra, funcName ) {
+
+               // Margin is only for outerHeight, outerWidth
+               jQuery.fn[ funcName ] = function( margin, value ) {
+                       var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+                               extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+                       return access( this, function( elem, type, value ) {
+                               var doc;
+
+                               if ( isWindow( elem ) ) {
+
+                                       // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
+                                       return funcName.indexOf( "outer" ) === 0 ?
+                                               elem[ "inner" + name ] :
+                                               elem.document.documentElement[ "client" + name ];
+                               }
+
+                               // Get document width or height
+                               if ( elem.nodeType === 9 ) {
+                                       doc = elem.documentElement;
+
+                                       // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
+                                       // whichever is greatest
+                                       return Math.max(
+                                               elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+                                               elem.body[ "offset" + name ], doc[ "offset" + name ],
+                                               doc[ "client" + name ]
+                                       );
+                               }
+
+                               return value === undefined ?
+
+                                       // Get width or height on the element, requesting but not forcing parseFloat
+                                       jQuery.css( elem, type, extra ) :
+
+                                       // Set width or height on the element
+                                       jQuery.style( elem, type, value, extra );
+                       }, type, chainable ? margin : undefined, chainable );
+               };
+       } );
+} );
+
+
+jQuery.each( [
+       "ajaxStart",
+       "ajaxStop",
+       "ajaxComplete",
+       "ajaxError",
+       "ajaxSuccess",
+       "ajaxSend"
+], function( _i, type ) {
+       jQuery.fn[ type ] = function( fn ) {
+               return this.on( type, fn );
+       };
+} );
+
+
+
+
+jQuery.fn.extend( {
+
+       bind: function( types, data, fn ) {
+               return this.on( types, null, data, fn );
+       },
+       unbind: function( types, fn ) {
+               return this.off( types, null, fn );
+       },
+
+       delegate: function( selector, types, data, fn ) {
+               return this.on( types, selector, data, fn );
+       },
+       undelegate: function( selector, types, fn ) {
+
+               // ( namespace ) or ( selector, types [, fn] )
+               return arguments.length === 1 ?
+                       this.off( selector, "**" ) :
+                       this.off( types, selector || "**", fn );
+       },
+
+       hover: function( fnOver, fnOut ) {
+               return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+       }
+} );
+
+jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
+       "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+       "change select submit keydown keypress keyup contextmenu" ).split( " " ),
+       function( _i, name ) {
+
+               // Handle event binding
+               jQuery.fn[ name ] = function( data, fn ) {
+                       return arguments.length > 0 ?
+                               this.on( name, null, data, fn ) :
+                               this.trigger( name );
+               };
+       } );
+
+
+
+
+// Support: Android <=4.0 only
+// Make sure we trim BOM and NBSP
+var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
+
+// Bind a function to a context, optionally partially applying any
+// arguments.
+// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
+// However, it is not slated for removal any time soon
+jQuery.proxy = function( fn, context ) {
+       var tmp, args, proxy;
+
+       if ( typeof context === "string" ) {
+               tmp = fn[ context ];
+               context = fn;
+               fn = tmp;
+       }
+
+       // Quick check to determine if target is callable, in the spec
+       // this throws a TypeError, but we will just return undefined.
+       if ( !isFunction( fn ) ) {
+               return undefined;
+       }
+
+       // Simulated bind
+       args = slice.call( arguments, 2 );
+       proxy = function() {
+               return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
+       };
+
+       // Set the guid of unique handler to the same of original handler, so it can be removed
+       proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+       return proxy;
+};
+
+jQuery.holdReady = function( hold ) {
+       if ( hold ) {
+               jQuery.readyWait++;
+       } else {
+               jQuery.ready( true );
+       }
+};
+jQuery.isArray = Array.isArray;
+jQuery.parseJSON = JSON.parse;
+jQuery.nodeName = nodeName;
+jQuery.isFunction = isFunction;
+jQuery.isWindow = isWindow;
+jQuery.camelCase = camelCase;
+jQuery.type = toType;
+
+jQuery.now = Date.now;
+
+jQuery.isNumeric = function( obj ) {
+
+       // As of jQuery 3.0, isNumeric is limited to
+       // strings and numbers (primitives or objects)
+       // that can be coerced to finite numbers (gh-2662)
+       var type = jQuery.type( obj );
+       return ( type === "number" || type === "string" ) &&
+
+               // parseFloat NaNs numeric-cast false positives ("")
+               // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
+               // subtraction forces infinities to NaN
+               !isNaN( obj - parseFloat( obj ) );
+};
+
+jQuery.trim = function( text ) {
+       return text == null ?
+               "" :
+               ( text + "" ).replace( rtrim, "" );
+};
+
+
+
+// Register as a named AMD module, since jQuery can be concatenated with other
+// files that may use define, but not via a proper concatenation script that
+// understands anonymous AMD modules. A named AMD is safest and most robust
+// way to register. Lowercase jquery is used because AMD module names are
+// derived from file names, and jQuery is normally delivered in a lowercase
+// file name. Do this after creating the global so that if an AMD module wants
+// to call noConflict to hide this version of jQuery, it will work.
+
+// Note that for maximum portability, libraries that are not jQuery should
+// declare themselves as anonymous modules, and avoid setting a global if an
+// AMD loader is present. jQuery is a special case. For more information, see
+// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
+
+if ( typeof define === "function" && define.amd ) {
+       define( "jquery", [], function() {
+               return jQuery;
+       } );
+}
+
+
+
+
+var
+
+       // Map over jQuery in case of overwrite
+       _jQuery = window.jQuery,
+
+       // Map over the $ in case of overwrite
+       _$ = window.$;
+
+jQuery.noConflict = function( deep ) {
+       if ( window.$ === jQuery ) {
+               window.$ = _$;
+       }
+
+       if ( deep && window.jQuery === jQuery ) {
+               window.jQuery = _jQuery;
+       }
+
+       return jQuery;
+};
+
+// Expose jQuery and $ identifiers, even in AMD
+// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
+// and CommonJS for browser emulators (#13566)
+if ( typeof noGlobal === "undefined" ) {
+       window.jQuery = window.$ = jQuery;
+}
+
+
+
+
+return jQuery;
+} );
index 644d35e..b061403 100644 (file)
@@ -1,4 +1,2 @@
-/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */
-!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c<b?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:h,sort:c.sort,splice:c.splice},r.extend=r.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||r.isFunction(g)||(g={}),h===i&&(g=this,h--);h<i;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(r.isPlainObject(d)||(e=Array.isArray(d)))?(e?(e=!1,f=c&&Array.isArray(c)?c:[]):f=c&&r.isPlainObject(c)?c:{},g[b]=r.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},r.extend({expando:"jQuery"+(q+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===r.type(a)},isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=r.type(a);return("number"===b||"string"===b)&&!isNaN(a-parseFloat(a))},isPlainObject:function(a){var b,c;return!(!a||"[object Object]"!==k.call(a))&&(!(b=e(a))||(c=l.call(b,"constructor")&&b.constructor,"function"==typeof c&&m.call(c)===n))},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?j[k.call(a)]||"object":typeof a},globalEval:function(a){p(a)},camelCase:function(a){return a.replace(t,"ms-").replace(u,v)},each:function(a,b){var c,d=0;if(w(a)){for(c=a.length;d<c;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(s,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(w(Object(a))?r.merge(c,"string"==typeof a?[a]:a):h.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:i.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;d<c;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;f<g;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,f=0,h=[];if(w(a))for(d=a.length;f<d;f++)e=b(a[f],f,c),null!=e&&h.push(e);else for(f in a)e=b(a[f],f,c),null!=e&&h.push(e);return g.apply([],h)},guid:1,proxy:function(a,b){var c,d,e;if("string"==typeof b&&(c=a[b],b=a,a=c),r.isFunction(a))return d=f.call(arguments,2),e=function(){return a.apply(b||this,d.concat(f.call(arguments)))},e.guid=a.guid=a.guid||r.guid++,e},now:Date.now,support:o}),"function"==typeof Symbol&&(r.fn[Symbol.iterator]=c[Symbol.iterator]),r.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){j["[object "+b+"]"]=b.toLowerCase()});function w(a){var b=!!a&&"length"in a&&a.length,c=r.type(a);return"function"!==c&&!r.isWindow(a)&&("array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",M="\\["+K+"*("+L+")(?:"+K+"*([*^$|!~]?=)"+K+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+K+"*\\]",N=":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",O=new RegExp(K+"+","g"),P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\r\\' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c<b;c+=2)a.push(c);return a}),odd:pa(function(a,b){for(var c=1;c<b;c+=2)a.push(c);return a}),lt:pa(function(a,b,c){for(var d=c<0?c+b:c;--d>=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=ma(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=na(b);function ra(){}ra.prototype=d.filters=d.pseudos,d.setFilters=new ra,g=ga.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){c&&!(e=Q.exec(h))||(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?ga.error(a):z(a,i).slice(0)};function sa(a){for(var b=0,c=a.length,d="";b<c;b++)d+=a[b].value;return d}function ta(a,b,c){var d=b.dir,e=b.next,f=e||d,g=c&&"parentNode"===f,h=x++;return b.first?function(b,c,e){while(b=b[d])if(1===b.nodeType||g)return a(b,c,e);return!1}:function(b,c,i){var j,k,l,m=[w,h];if(i){while(b=b[d])if((1===b.nodeType||g)&&a(b,c,i))return!0}else while(b=b[d])if(1===b.nodeType||g)if(l=b[u]||(b[u]={}),k=l[b.uniqueID]||(l[b.uniqueID]={}),e&&e===b.nodeName.toLowerCase())b=b[d]||b;else{if((j=k[f])&&j[0]===w&&j[1]===h)return m[2]=j[2];if(k[f]=m,m[2]=a(b,c,i))return!0}return!1}}function ua(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d<e;d++)ga(a,b[d],c);return c}function wa(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;h<i;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function xa(a,b,c,d,e,f){return d&&!d[u]&&(d=xa(d)),e&&!e[u]&&(e=xa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||va(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:wa(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=wa(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i<f;i++)if(c=d.relative[a[i].type])m=[ta(ua(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;e<f;e++)if(d.relative[a[e].type])break;return xa(i>1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i<e&&ya(a.slice(i,e)),e<f&&ya(a=a.slice(e)),e<f&&sa(a))}m.push(c)}return ua(m)}function za(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext;function B(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()}var C=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,D=/^.[^:#\[\.,]*$/;function E(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):D.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b<d;b++)if(r.contains(e[b],this))return!0}));for(c=this.pushStack([]),b=0;b<d;b++)r.find(a,e[b],c);return d>1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(E(this,a||[],!1))},not:function(a){return this.pushStack(E(this,a||[],!0))},is:function(a){return!!E(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var F,G=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,H=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||F,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:G.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),C.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};H.prototype=r.fn,F=r(d);var I=/^(?:parents|prev(?:Until|All))/,J={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a<c;a++)if(r.contains(this,b[a]))return!0})},closest:function(a,b){var c,d=0,e=this.length,f=[],g="string"!=typeof a&&r(a);if(!A.test(a))for(;d<e;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function K(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return K(a,"nextSibling")},prev:function(a){return K(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return B(a,"iframe")?a.contentDocument:(B(a,"template")&&(a=a.content||a),r.merge([],a.childNodes))}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(J[a]||r.uniqueSort(e),I.test(a)&&e.reverse()),this.pushStack(e)}});var L=/[^\x20\t\r\n\f]+/g;function M(a){var b={};return r.each(a.match(L)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?M(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=e||a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h<f.length)f[h].apply(c[0],c[1])===!1&&a.stopOnFalse&&(h=f.length,c=!1)}a.memory||(c=!1),b=!1,e&&(f=c?[]:"")},j={add:function(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){r.each(b,function(b,c){r.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==r.type(c)&&d(c)})}(arguments),c&&!b&&i()),this},remove:function(){return r.each(arguments,function(a,b){var c;while((c=r.inArray(b,f,c))>-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function N(a){return a}function O(a){throw a}function P(a,b,c,d){var e;try{a&&r.isFunction(e=a.promise)?e.call(a).done(b).fail(c):a&&r.isFunction(e=a.then)?e.call(a,b,c):b.apply(void 0,[a].slice(d))}catch(a){c.apply(void 0,[a])}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b<f)){if(a=d.apply(h,i),a===c.promise())throw new TypeError("Thenable self-resolution");j=a&&("object"==typeof a||"function"==typeof a)&&a.then,r.isFunction(j)?e?j.call(a,g(f,c,N,e),g(f,c,O,e)):(f++,j.call(a,g(f,c,N,e),g(f,c,O,e),g(f,c,N,c.notifyWith))):(d!==N&&(h=void 0,i=[a]),(e||c.resolveWith)(h,i))}},k=e?j:function(){try{j()}catch(a){r.Deferred.exceptionHook&&r.Deferred.exceptionHook(a,k.stackTrace),b+1>=f&&(d!==O&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:N,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:N)),c[2][3].add(g(0,a,r.isFunction(d)?d:O))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(P(a,g.done(h(c)).resolve,g.reject,!b),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)P(e[c],h(c),g.reject);return g.promise()}});var Q=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&Q.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var R=r.Deferred();r.fn.ready=function(a){return R.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||R.resolveWith(d,[r]))}}),r.ready.then=R.then;function S(){d.removeEventListener("DOMContentLoaded",S),
-a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h<i;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},U=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function V(){this.expando=r.expando+V.uid++}V.uid=1,V.prototype={cache:function(a){var b=a[this.expando];return b||(b={},U(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[r.camelCase(b)]=c;else for(d in b)e[r.camelCase(d)]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][r.camelCase(b)]},access:function(a,b,c){return void 0===b||b&&"string"==typeof b&&void 0===c?this.get(a,b):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d=a[this.expando];if(void 0!==d){if(void 0!==b){Array.isArray(b)?b=b.map(r.camelCase):(b=r.camelCase(b),b=b in d?[b]:b.match(L)||[]),c=b.length;while(c--)delete d[b[c]]}(void 0===b||r.isEmptyObject(d))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!r.isEmptyObject(b)}};var W=new V,X=new V,Y=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Z=/[A-Z]/g;function $(a){return"true"===a||"false"!==a&&("null"===a?null:a===+a+""?+a:Y.test(a)?JSON.parse(a):a)}function _(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Z,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c=$(c)}catch(e){}X.set(a,b,c)}else c=void 0;return c}r.extend({hasData:function(a){return X.hasData(a)||W.hasData(a)},data:function(a,b,c){return X.access(a,b,c)},removeData:function(a,b){X.remove(a,b)},_data:function(a,b,c){return W.access(a,b,c)},_removeData:function(a,b){W.remove(a,b)}}),r.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=X.get(f),1===f.nodeType&&!W.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=r.camelCase(d.slice(5)),_(f,d,e[d])));W.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){X.set(this,a)}):T(this,function(b){var c;if(f&&void 0===b){if(c=X.get(f,a),void 0!==c)return c;if(c=_(f,a),void 0!==c)return c}else this.each(function(){X.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){X.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=W.get(a,b),c&&(!d||Array.isArray(c)?d=W.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return W.get(a,c)||W.access(a,c,{empty:r.Callbacks("once memory").add(function(){W.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?r.queue(this[0],a):void 0===b?this:this.each(function(){var c=r.queue(this,a,b);r._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&r.dequeue(this,a)})},dequeue:function(a){return this.each(function(){r.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=r.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=W.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var aa=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ba=new RegExp("^(?:([+-])=|)("+aa+")([a-z%]*)$","i"),ca=["Top","Right","Bottom","Left"],da=function(a,b){return a=b||a,"none"===a.style.display||""===a.style.display&&r.contains(a.ownerDocument,a)&&"none"===r.css(a,"display")},ea=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};function fa(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return r.css(a,b,"")},i=h(),j=c&&c[3]||(r.cssNumber[b]?"":"px"),k=(r.cssNumber[b]||"px"!==j&&+i)&&ba.exec(r.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,r.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var ga={};function ha(a){var b,c=a.ownerDocument,d=a.nodeName,e=ga[d];return e?e:(b=c.body.appendChild(c.createElement(d)),e=r.css(b,"display"),b.parentNode.removeChild(b),"none"===e&&(e="block"),ga[d]=e,e)}function ia(a,b){for(var c,d,e=[],f=0,g=a.length;f<g;f++)d=a[f],d.style&&(c=d.style.display,b?("none"===c&&(e[f]=W.get(d,"display")||null,e[f]||(d.style.display="")),""===d.style.display&&da(d)&&(e[f]=ha(d))):"none"!==c&&(e[f]="none",W.set(d,"display",c)));for(f=0;f<g;f++)null!=e[f]&&(a[f].style.display=e[f]);return a}r.fn.extend({show:function(){return ia(this,!0)},hide:function(){return ia(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){da(this)?r(this).show():r(this).hide()})}});var ja=/^(?:checkbox|radio)$/i,ka=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,la=/^$|\/(?:java|ecma)script/i,ma={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ma.optgroup=ma.option,ma.tbody=ma.tfoot=ma.colgroup=ma.caption=ma.thead,ma.th=ma.td;function na(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&B(a,b)?r.merge([a],c):c}function oa(a,b){for(var c=0,d=a.length;c<d;c++)W.set(a[c],"globalEval",!b||W.get(b[c],"globalEval"))}var pa=/<|&#?\w+;/;function qa(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],n=0,o=a.length;n<o;n++)if(f=a[n],f||0===f)if("object"===r.type(f))r.merge(m,f.nodeType?[f]:f);else if(pa.test(f)){g=g||l.appendChild(b.createElement("div")),h=(ka.exec(f)||["",""])[1].toLowerCase(),i=ma[h]||ma._default,g.innerHTML=i[1]+r.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;r.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",n=0;while(f=m[n++])if(d&&r.inArray(f,d)>-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=na(l.appendChild(f),"script"),j&&oa(g),c){k=0;while(f=g[k++])la.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var ra=d.documentElement,sa=/^key/,ta=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ua=/^([^.]*)(?:\.(.+)|)/;function va(){return!0}function wa(){return!1}function xa(){try{return d.activeElement}catch(a){}}function ya(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ya(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=wa;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(ra,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(L)||[""],j=b.length;while(j--)h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.hasData(a)&&W.get(a);if(q&&(i=q.events)){b=(b||"").match(L)||[""],j=b.length;while(j--)if(h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&W.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(W.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c<arguments.length;c++)i[c]=arguments[c];if(b.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,b)!==!1){h=r.event.handlers.call(this,b,j),c=0;while((f=h[c++])&&!b.isPropagationStopped()){b.currentTarget=f.elem,d=0;while((g=f.handlers[d++])&&!b.isImmediatePropagationStopped())b.rnamespace&&!b.rnamespace.test(g.namespace)||(b.handleObj=g,b.data=g.data,e=((r.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(b.result=e)===!1&&(b.preventDefault(),b.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,b),b.result}},handlers:function(a,b){var c,d,e,f,g,h=[],i=b.delegateCount,j=a.target;if(i&&j.nodeType&&!("click"===a.type&&a.button>=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c<i;c++)d=b[c],e=d.selector+" ",void 0===g[e]&&(g[e]=d.needsContext?r(e,this).index(j)>-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i<b.length&&h.push({elem:j,handlers:b.slice(i)}),h},addProp:function(a,b){Object.defineProperty(r.Event.prototype,a,{enumerable:!0,configurable:!0,get:r.isFunction(b)?function(){if(this.originalEvent)return b(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[a]},set:function(b){Object.defineProperty(this,a,{enumerable:!0,configurable:!0,writable:!0,value:b})}})},fix:function(a){return a[r.expando]?a:new r.Event(a)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==xa()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===xa()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&B(this,"input"))return this.click(),!1},_default:function(a){return B(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}}},r.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c)},r.Event=function(a,b){return this instanceof r.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?va:wa,this.target=a.target&&3===a.target.nodeType?a.target.parentNode:a.target,this.currentTarget=a.currentTarget,this.relatedTarget=a.relatedTarget):this.type=a,b&&r.extend(this,b),this.timeStamp=a&&a.timeStamp||r.now(),void(this[r.expando]=!0)):new r.Event(a,b)},r.Event.prototype={constructor:r.Event,isDefaultPrevented:wa,isPropagationStopped:wa,isImmediatePropagationStopped:wa,isSimulated:!1,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=va,a&&!this.isSimulated&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=va,a&&!this.isSimulated&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=va,a&&!this.isSimulated&&a.stopImmediatePropagation(),this.stopPropagation()}},r.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(a){var b=a.button;return null==a.which&&sa.test(a.type)?null!=a.charCode?a.charCode:a.keyCode:!a.which&&void 0!==b&&ta.test(a.type)?1&b?1:2&b?3:4&b?2:0:a.which}},r.event.addProp),r.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){r.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return e&&(e===d||r.contains(d,e))||(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),r.fn.extend({on:function(a,b,c,d){return ya(this,a,b,c,d)},one:function(a,b,c,d){return ya(this,a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,r(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return b!==!1&&"function"!=typeof b||(c=b,b=void 0),c===!1&&(c=wa),this.each(function(){r.event.remove(this,a,c,b)})}});var za=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Aa=/<script|<style|<link/i,Ba=/checked\s*(?:[^=]|=\s*.checked.)/i,Ca=/^true\/(.*)/,Da=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Ea(a,b){return B(a,"table")&&B(11!==b.nodeType?b:b.firstChild,"tr")?r(">tbody",a)[0]||a:a}function Fa(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Ga(a){var b=Ca.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ha(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(W.hasData(a)&&(f=W.access(a),g=W.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c<d;c++)r.event.add(b,e,j[e][c])}X.hasData(a)&&(h=X.access(a),i=r.extend({},h),X.set(b,i))}}function Ia(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ja.test(a.type)?b.checked=a.checked:"input"!==c&&"textarea"!==c||(b.defaultValue=a.defaultValue)}function Ja(a,b,c,d){b=g.apply([],b);var e,f,h,i,j,k,l=0,m=a.length,n=m-1,q=b[0],s=r.isFunction(q);if(s||m>1&&"string"==typeof q&&!o.checkClone&&Ba.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ja(f,b,c,d)});if(m&&(e=qa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(na(e,"script"),Fa),i=h.length;l<m;l++)j=e,l!==n&&(j=r.clone(j,!0,!0),i&&r.merge(h,na(j,"script"))),c.call(a[l],j,l);if(i)for(k=h[h.length-1].ownerDocument,r.map(h,Ga),l=0;l<i;l++)j=h[l],la.test(j.type||"")&&!W.access(j,"globalEval")&&r.contains(k,j)&&(j.src?r._evalUrl&&r._evalUrl(j.src):p(j.textContent.replace(Da,""),k))}return a}function Ka(a,b,c){for(var d,e=b?r.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||r.cleanData(na(d)),d.parentNode&&(c&&r.contains(d.ownerDocument,d)&&oa(na(d,"script")),d.parentNode.removeChild(d));return a}r.extend({htmlPrefilter:function(a){return a.replace(za,"<$1></$2>")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=na(h),f=na(a),d=0,e=f.length;d<e;d++)Ia(f[d],g[d]);if(b)if(c)for(f=f||na(a),g=g||na(h),d=0,e=f.length;d<e;d++)Ha(f[d],g[d]);else Ha(a,h);return g=na(h,"script"),g.length>0&&oa(g,!i&&na(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(U(c)){if(b=c[W.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[W.expando]=void 0}c[X.expando]&&(c[X.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ka(this,a,!0)},remove:function(a){return Ka(this,a)},text:function(a){return T(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.appendChild(a)}})},prepend:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(na(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return T(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!Aa.test(a)&&!ma[(ka.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c<d;c++)b=this[c]||{},1===b.nodeType&&(r.cleanData(na(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=[];return Ja(this,arguments,function(b){var c=this.parentNode;r.inArray(this,a)<0&&(r.cleanData(na(this)),c&&c.replaceChild(b,this))},a)}}),r.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){r.fn[a]=function(a){for(var c,d=[],e=r(a),f=e.length-1,g=0;g<=f;g++)c=g===f?this:this.clone(!0),r(e[g])[b](c),h.apply(d,c.get());return this.pushStack(d)}});var La=/^margin/,Ma=new RegExp("^("+aa+")(?!px)[a-z%]+$","i"),Na=function(b){var c=b.ownerDocument.defaultView;return c&&c.opener||(c=a),c.getComputedStyle(b)};!function(){function b(){if(i){i.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",i.innerHTML="",ra.appendChild(h);var b=a.getComputedStyle(i);c="1%"!==b.top,g="2px"===b.marginLeft,e="4px"===b.width,i.style.marginRight="50%",f="4px"===b.marginRight,ra.removeChild(h),i=null}}var c,e,f,g,h=d.createElement("div"),i=d.createElement("div");i.style&&(i.style.backgroundClip="content-box",i.cloneNode(!0).style.backgroundClip="",o.clearCloneStyle="content-box"===i.style.backgroundClip,h.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",h.appendChild(i),r.extend(o,{pixelPosition:function(){return b(),c},boxSizingReliable:function(){return b(),e},pixelMarginRight:function(){return b(),f},reliableMarginLeft:function(){return b(),g}}))}();function Oa(a,b,c){var d,e,f,g,h=a.style;return c=c||Na(a),c&&(g=c.getPropertyValue(b)||c[b],""!==g||r.contains(a.ownerDocument,a)||(g=r.style(a,b)),!o.pixelMarginRight()&&Ma.test(g)&&La.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function Pa(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}var Qa=/^(none|table(?!-c[ea]).+)/,Ra=/^--/,Sa={position:"absolute",visibility:"hidden",display:"block"},Ta={letterSpacing:"0",fontWeight:"400"},Ua=["Webkit","Moz","ms"],Va=d.createElement("div").style;function Wa(a){if(a in Va)return a;var b=a[0].toUpperCase()+a.slice(1),c=Ua.length;while(c--)if(a=Ua[c]+b,a in Va)return a}function Xa(a){var b=r.cssProps[a];return b||(b=r.cssProps[a]=Wa(a)||a),b}function Ya(a,b,c){var d=ba.exec(b);return d?Math.max(0,d[2]-(c||0))+(d[3]||"px"):b}function Za(a,b,c,d,e){var f,g=0;for(f=c===(d?"border":"content")?4:"width"===b?1:0;f<4;f+=2)"margin"===c&&(g+=r.css(a,c+ca[f],!0,e)),d?("content"===c&&(g-=r.css(a,"padding"+ca[f],!0,e)),"margin"!==c&&(g-=r.css(a,"border"+ca[f]+"Width",!0,e))):(g+=r.css(a,"padding"+ca[f],!0,e),"padding"!==c&&(g+=r.css(a,"border"+ca[f]+"Width",!0,e)));return g}function $a(a,b,c){var d,e=Na(a),f=Oa(a,b,e),g="border-box"===r.css(a,"boxSizing",!1,e);return Ma.test(f)?f:(d=g&&(o.boxSizingReliable()||f===a.style[b]),"auto"===f&&(f=a["offset"+b[0].toUpperCase()+b.slice(1)]),f=parseFloat(f)||0,f+Za(a,b,c||(g?"border":"content"),d,e)+"px")}r.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Oa(a,"opacity");return""===c?"1":c}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=r.camelCase(b),i=Ra.test(b),j=a.style;return i||(b=Xa(h)),g=r.cssHooks[b]||r.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:j[b]:(f=typeof c,"string"===f&&(e=ba.exec(c))&&e[1]&&(c=fa(a,b,e),f="number"),null!=c&&c===c&&("number"===f&&(c+=e&&e[3]||(r.cssNumber[h]?"":"px")),o.clearCloneStyle||""!==c||0!==b.indexOf("background")||(j[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i?j.setProperty(b,c):j[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=r.camelCase(b),i=Ra.test(b);return i||(b=Xa(h)),g=r.cssHooks[b]||r.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=Oa(a,b,d)),"normal"===e&&b in Ta&&(e=Ta[b]),""===c||c?(f=parseFloat(e),c===!0||isFinite(f)?f||0:e):e}}),r.each(["height","width"],function(a,b){r.cssHooks[b]={get:function(a,c,d){if(c)return!Qa.test(r.css(a,"display"))||a.getClientRects().length&&a.getBoundingClientRect().width?$a(a,b,d):ea(a,Sa,function(){return $a(a,b,d)})},set:function(a,c,d){var e,f=d&&Na(a),g=d&&Za(a,b,d,"border-box"===r.css(a,"boxSizing",!1,f),f);return g&&(e=ba.exec(c))&&"px"!==(e[3]||"px")&&(a.style[b]=c,c=r.css(a,b)),Ya(a,c,g)}}}),r.cssHooks.marginLeft=Pa(o.reliableMarginLeft,function(a,b){if(b)return(parseFloat(Oa(a,"marginLeft"))||a.getBoundingClientRect().left-ea(a,{marginLeft:0},function(){return a.getBoundingClientRect().left}))+"px"}),r.each({margin:"",padding:"",border:"Width"},function(a,b){r.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+ca[d]+b]=f[d]||f[d-2]||f[0];return e}},La.test(a)||(r.cssHooks[a+b].set=Ya)}),r.fn.extend({css:function(a,b){return T(this,function(a,b,c){var d,e,f={},g=0;if(Array.isArray(b)){for(d=Na(a),e=b.length;g<e;g++)f[b[g]]=r.css(a,b[g],!1,d);return f}return void 0!==c?r.style(a,b,c):r.css(a,b)},a,b,arguments.length>1)}});function _a(a,b,c,d,e){return new _a.prototype.init(a,b,c,d,e)}r.Tween=_a,_a.prototype={constructor:_a,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=_a.propHooks[this.prop];return a&&a.get?a.get(this):_a.propHooks._default.get(this)},run:function(a){var b,c=_a.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):_a.propHooks._default.set(this),this}},_a.prototype.init.prototype=_a.prototype,_a.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},_a.propHooks.scrollTop=_a.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=_a.prototype.init,r.fx.step={};var ab,bb,cb=/^(?:toggle|show|hide)$/,db=/queueHooks$/;function eb(){bb&&(d.hidden===!1&&a.requestAnimationFrame?a.requestAnimationFrame(eb):a.setTimeout(eb,r.fx.interval),r.fx.tick())}function fb(){return a.setTimeout(function(){ab=void 0}),ab=r.now()}function gb(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ca[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function hb(a,b,c){for(var d,e=(kb.tweeners[b]||[]).concat(kb.tweeners["*"]),f=0,g=e.length;f<g;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,k,l="width"in b||"height"in b,m=this,n={},o=a.style,p=a.nodeType&&da(a),q=W.get(a,"fxshow");c.queue||(g=r._queueHooks(a,"fx"),null==g.unqueued&&(g.unqueued=0,h=g.empty.fire,g.empty.fire=function(){g.unqueued||h()}),g.unqueued++,m.always(function(){m.always(function(){g.unqueued--,r.queue(a,"fx").length||g.empty.fire()})}));for(d in b)if(e=b[d],cb.test(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}n[d]=q&&q[d]||r.style(a,d)}if(i=!r.isEmptyObject(b),i||!r.isEmptyObject(n)){l&&1===a.nodeType&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=q&&q.display,null==j&&(j=W.get(a,"display")),k=r.css(a,"display"),"none"===k&&(j?k=j:(ia([a],!0),j=a.style.display||j,k=r.css(a,"display"),ia([a]))),("inline"===k||"inline-block"===k&&null!=j)&&"none"===r.css(a,"float")&&(i||(m.done(function(){o.display=j}),null==j&&(k=o.display,j="none"===k?"":k)),o.display="inline-block")),c.overflow&&(o.overflow="hidden",m.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]})),i=!1;for(d in n)i||(q?"hidden"in q&&(p=q.hidden):q=W.access(a,"fxshow",{display:j}),f&&(q.hidden=!p),p&&ia([a],!0),m.done(function(){p||ia([a]),W.remove(a,"fxshow");for(d in n)r.style(a,d,n[d])})),i=hb(p?q[d]:0,d,m),d in q||(q[d]=i.start,p&&(i.end=i.start,i.start=0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=r.camelCase(c),e=b[d],f=a[c],Array.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=r.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=kb.prefilters.length,h=r.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=ab||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;g<i;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),f<1&&i?c:(i||h.notifyWith(a,[j,1,0]),h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:r.extend({},b),opts:r.extend(!0,{specialEasing:{},easing:r.easing._default},c),originalProperties:b,originalOptions:c,startTime:ab||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=r.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;c<d;c++)j.tweens[c].run(1);return b?(h.notifyWith(a,[j,1,0]),h.resolveWith(a,[j,b])):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);f<g;f++)if(d=kb.prefilters[f].call(j,a,k,j.opts))return r.isFunction(d.stop)&&(r._queueHooks(j.elem,j.opts.queue).stop=r.proxy(d.stop,d)),d;return r.map(k,hb,j),r.isFunction(j.opts.start)&&j.opts.start.call(a,j),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always),r.fx.timer(r.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j}r.Animation=r.extend(kb,{tweeners:{"*":[function(a,b){var c=this.createTween(a,b);return fa(c.elem,a,ba.exec(b),c),c}]},tweener:function(a,b){r.isFunction(a)?(b=a,a=["*"]):a=a.match(L);for(var c,d=0,e=a.length;d<e;d++)c=a[d],kb.tweeners[c]=kb.tweeners[c]||[],kb.tweeners[c].unshift(b)},prefilters:[ib],prefilter:function(a,b){b?kb.prefilters.unshift(a):kb.prefilters.push(a)}}),r.speed=function(a,b,c){var d=a&&"object"==typeof a?r.extend({},a):{complete:c||!c&&b||r.isFunction(a)&&a,duration:a,easing:c&&b||b&&!r.isFunction(b)&&b};return r.fx.off?d.duration=0:"number"!=typeof d.duration&&(d.duration in r.fx.speeds?d.duration=r.fx.speeds[d.duration]:d.duration=r.fx.speeds._default),null!=d.queue&&d.queue!==!0||(d.queue="fx"),d.old=d.complete,d.complete=function(){r.isFunction(d.old)&&d.old.call(this),d.queue&&r.dequeue(this,d.queue)},d},r.fn.extend({fadeTo:function(a,b,c,d){return this.filter(da).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=r.isEmptyObject(a),f=r.speed(b,c,d),g=function(){var b=kb(this,r.extend({},a),f);(e||W.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=r.timers,g=W.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&db.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));!b&&c||r.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=W.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=r.timers,g=d?d.length:0;for(c.finish=!0,r.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;b<g;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),r.each(["toggle","show","hide"],function(a,b){var c=r.fn[b];r.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gb(b,!0),a,d,e)}}),r.each({slideDown:gb("show"),slideUp:gb("hide"),slideToggle:gb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){r.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),r.timers=[],r.fx.tick=function(){var a,b=0,c=r.timers;for(ab=r.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||r.fx.stop(),ab=void 0},r.fx.timer=function(a){r.timers.push(a),r.fx.start()},r.fx.interval=13,r.fx.start=function(){bb||(bb=!0,eb())},r.fx.stop=function(){bb=null},r.fx.speeds={slow:600,fast:200,_default:400},r.fn.delay=function(b,c){return b=r.fx?r.fx.speeds[b]||b:b,c=c||"fx",this.queue(c,function(c,d){var e=a.setTimeout(c,b);d.stop=function(){a.clearTimeout(e)}})},function(){var a=d.createElement("input"),b=d.createElement("select"),c=b.appendChild(d.createElement("option"));a.type="checkbox",o.checkOn=""!==a.value,o.optSelected=c.selected,a=d.createElement("input"),a.value="t",a.type="radio",o.radioValue="t"===a.value}();var lb,mb=r.expr.attrHandle;r.fn.extend({attr:function(a,b){return T(this,r.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?lb:void 0)),void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),
-null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=mb[g],mb[g]=e,e=null!=c(a,b,d)?g:null,mb[g]=f),e}});var nb=/^(?:input|select|textarea|button)$/i,ob=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return T(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):nb.test(a.nodeName)||ob.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function pb(a){var b=a.match(L)||[];return b.join(" ")}function qb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,qb(this)))});if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,qb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,qb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(L)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=qb(this),b&&W.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":W.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+pb(qb(c))+" ").indexOf(b)>-1)return!0;return!1}});var rb=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":Array.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(rb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:pb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d<i;d++)if(c=e[d],(c.selected||d===f)&&!c.disabled&&(!c.parentNode.disabled||!B(c.parentNode,"optgroup"))){if(b=r(c).val(),g)return b;h.push(b)}return h},set:function(a,b){var c,d,e=a.options,f=r.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=r.inArray(r.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(Array.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var sb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!sb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,sb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(W.get(h,"events")||{})[b.type]&&W.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&U(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!U(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=W.access(d,b);e||d.addEventListener(a,c,!0),W.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=W.access(d,b)-1;e?W.access(d,b,e):(d.removeEventListener(a,c,!0),W.remove(d,b))}}});var tb=a.location,ub=r.now(),vb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var wb=/\[\]$/,xb=/\r?\n/g,yb=/^(?:submit|button|image|reset|file)$/i,zb=/^(?:input|select|textarea|keygen)/i;function Ab(a,b,c,d){var e;if(Array.isArray(b))r.each(b,function(b,e){c||wb.test(a)?d(a,e):Ab(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)Ab(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(Array.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)Ab(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&zb.test(this.nodeName)&&!yb.test(a)&&(this.checked||!ja.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:Array.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(xb,"\r\n")}}):{name:b.name,value:c.replace(xb,"\r\n")}}).get()}});var Bb=/%20/g,Cb=/#.*$/,Db=/([?&])_=[^&]*/,Eb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Fb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Gb=/^(?:GET|HEAD)$/,Hb=/^\/\//,Ib={},Jb={},Kb="*/".concat("*"),Lb=d.createElement("a");Lb.href=tb.href;function Mb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(L)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Nb(a,b,c,d){var e={},f=a===Jb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Ob(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Pb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Qb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:tb.href,type:"GET",isLocal:Fb.test(tb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Kb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Ob(Ob(a,r.ajaxSettings),b):Ob(r.ajaxSettings,a)},ajaxPrefilter:Mb(Ib),ajaxTransport:Mb(Jb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Eb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||tb.href)+"").replace(Hb,tb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(L)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Lb.protocol+"//"+Lb.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Nb(Ib,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Gb.test(o.type),f=o.url.replace(Cb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(Bb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(vb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Db,"$1"),n=(vb.test(f)?"&":"?")+"_="+ub++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Kb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Nb(Jb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Pb(o,y,d)),v=Qb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Rb={0:200,1223:204},Sb=r.ajaxSettings.xhr();o.cors=!!Sb&&"withCredentials"in Sb,o.ajax=Sb=!!Sb,r.ajaxTransport(function(b){var c,d;if(o.cors||Sb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Rb[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("<script>").prop({charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&f("error"===a.type?404:200,a.type)}),d.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Tb=[],Ub=/(=)\?(?=&|$)|\?\?/;r.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Tb.pop()||r.expando+"_"+ub++;return this[a]=!0,a}}),r.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Ub.test(b.url)?"url":"string"==typeof b.data&&0===(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ub.test(b.data)&&"data");if(h||"jsonp"===b.dataTypes[0])return e=b.jsonpCallback=r.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Ub,"$1"+e):b.jsonp!==!1&&(b.url+=(vb.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||r.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){void 0===f?r(a).removeProp(e):a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Tb.push(e)),g&&r.isFunction(f)&&f(g[0]),g=f=void 0}),"script"}),o.createHTMLDocument=function(){var a=d.implementation.createHTMLDocument("").body;return a.innerHTML="<form></form><form></form>",2===a.childNodes.length}(),r.parseHTML=function(a,b,c){if("string"!=typeof a)return[];"boolean"==typeof b&&(c=b,b=!1);var e,f,g;return b||(o.createHTMLDocument?(b=d.implementation.createHTMLDocument(""),e=b.createElement("base"),e.href=d.location.href,b.head.appendChild(e)):b=d),f=C.exec(a),g=!c&&[],f?[b.createElement(f[1])]:(f=qa([a],b,g),g&&g.length&&r(g).remove(),r.merge([],f.childNodes))},r.fn.load=function(a,b,c){var d,e,f,g=this,h=a.indexOf(" ");return h>-1&&(d=pb(a.slice(h)),a=a.slice(0,h)),r.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&r.ajax({url:a,type:e||"GET",dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?r("<div>").append(r.parseHTML(a)).find(d):a)}).always(c&&function(a,b){g.each(function(){c.apply(this,f||[a.responseText,b,a])})}),this},r.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){r.fn[b]=function(a){return this.on(b,a)}}),r.expr.pseudos.animated=function(a){return r.grep(r.timers,function(b){return a===b.elem}).length},r.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=r.css(a,"position"),l=r(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=r.css(a,"top"),i=r.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),r.isFunction(b)&&(b=b.call(a,c,r.extend({},h))),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},r.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){r.offset.setOffset(this,a,b)});var b,c,d,e,f=this[0];if(f)return f.getClientRects().length?(d=f.getBoundingClientRect(),b=f.ownerDocument,c=b.documentElement,e=b.defaultView,{top:d.top+e.pageYOffset-c.clientTop,left:d.left+e.pageXOffset-c.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===r.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),B(a[0],"html")||(d=a.offset()),d={top:d.top+r.css(a[0],"borderTopWidth",!0),left:d.left+r.css(a[0],"borderLeftWidth",!0)}),{top:b.top-d.top-r.css(c,"marginTop",!0),left:b.left-d.left-r.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent;while(a&&"static"===r.css(a,"position"))a=a.offsetParent;return a||ra})}}),r.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c="pageYOffset"===b;r.fn[a]=function(d){return T(this,function(a,d,e){var f;return r.isWindow(a)?f=a:9===a.nodeType&&(f=a.defaultView),void 0===e?f?f[b]:a[d]:void(f?f.scrollTo(c?f.pageXOffset:e,c?e:f.pageYOffset):a[d]=e)},a,d,arguments.length)}}),r.each(["top","left"],function(a,b){r.cssHooks[b]=Pa(o.pixelPosition,function(a,c){if(c)return c=Oa(a,b),Ma.test(c)?r(a).position()[b]+"px":c})}),r.each({Height:"height",Width:"width"},function(a,b){r.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){r.fn[d]=function(e,f){var g=arguments.length&&(c||"boolean"!=typeof e),h=c||(e===!0||f===!0?"margin":"border");return T(this,function(b,c,e){var f;return r.isWindow(b)?0===d.indexOf("outer")?b["inner"+a]:b.document.documentElement["client"+a]:9===b.nodeType?(f=b.documentElement,Math.max(b.body["scroll"+a],f["scroll"+a],b.body["offset"+a],f["offset"+a],f["client"+a])):void 0===e?r.css(b,c,h):r.style(b,c,e,h)},b,g?e:void 0,g)}})}),r.fn.extend({bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}}),r.holdReady=function(a){a?r.readyWait++:r.ready(!0)},r.isArray=Array.isArray,r.parseJSON=JSON.parse,r.nodeName=B,"function"==typeof define&&define.amd&&define("jquery",[],function(){return r});var Vb=a.jQuery,Wb=a.$;return r.noConflict=function(b){return a.$===r&&(a.$=Wb),b&&a.jQuery===r&&(a.jQuery=Vb),r},b||(a.jQuery=a.$=r),r});
+/*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */
+!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.5.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),D=function(e,t){return e===t&&(l=!0),0},j={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="<a id='"+S+"'></a><select id='"+S+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0<se(t,C,null,[e]).length},se.contains=function(e,t){return(e.ownerDocument||e)!=C&&T(e),y(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!=C&&T(e);var n=b.attrHandle[t.toLowerCase()],r=n&&j.call(b.attrHandle,t.toLowerCase())?n(e,t,!E):void 0;return void 0!==r?r:d.attributes||!E?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},se.escape=function(e){return(e+"").replace(re,ie)},se.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},se.uniqueSort=function(e){var t,n=[],r=0,i=0;if(l=!d.detectDuplicates,u=!d.sortStable&&e.slice(0),e.sort(D),l){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)e.splice(n[r],1)}return u=null,e},o=se.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else while(t=e[r++])n+=o(t);return n},(b=se.selectors={cacheLength:50,createPseudo:le,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1<t.indexOf(i):"$="===r?i&&t.slice(-i.length)===i:"~="===r?-1<(" "+t.replace(B," ")+" ").indexOf(i):"|="===r&&(t===i||t.slice(0,i.length+1)===i+"-"))}},CHILD:function(h,e,t,g,v){var y="nth"!==h.slice(0,3),m="last"!==h.slice(-4),x="of-type"===e;return 1===g&&0===v?function(e){return!!e.parentNode}:function(e,t,n){var r,i,o,a,s,u,l=y!==m?"nextSibling":"previousSibling",c=e.parentNode,f=x&&e.nodeName.toLowerCase(),p=!n&&!x,d=!1;if(c){if(y){while(l){a=e;while(a=a[l])if(x?a.nodeName.toLowerCase()===f:1===a.nodeType)return!1;u=l="only"===h&&!u&&"nextSibling"}return!0}if(u=[m?c.firstChild:c.lastChild],m&&p){d=(s=(r=(i=(o=(a=c)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1])&&r[2],a=s&&c.childNodes[s];while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if(1===a.nodeType&&++d&&a===e){i[h]=[k,s,d];break}}else if(p&&(d=s=(r=(i=(o=(a=e)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1]),!1===d)while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if((x?a.nodeName.toLowerCase()===f:1===a.nodeType)&&++d&&(p&&((i=(o=a[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]=[k,d]),a===e))break;return(d-=v)===g||d%g==0&&0<=d/g}}},PSEUDO:function(e,o){var t,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||se.error("unsupported pseudo: "+e);return a[S]?a(o):1<a.length?(t=[e,e,"",o],b.setFilters.hasOwnProperty(e.toLowerCase())?le(function(e,t){var n,r=a(e,o),i=r.length;while(i--)e[n=P(e,r[i])]=!(t[n]=r[i])}):function(e){return a(e,0,t)}):a}},pseudos:{not:le(function(e){var r=[],i=[],s=f(e.replace($,"$1"));return s[S]?le(function(e,t,n,r){var i,o=s(e,null,r,[]),a=e.length;while(a--)(i=o[a])&&(e[a]=!(t[a]=i))}):function(e,t,n){return r[0]=e,s(r,null,n,i),r[0]=null,!i.pop()}}),has:le(function(t){return function(e){return 0<se(t,e).length}}),contains:le(function(t){return t=t.replace(te,ne),function(e){return-1<(e.textContent||o(e)).indexOf(t)}}),lang:le(function(n){return V.test(n||"")||se.error("unsupported lang: "+n),n=n.replace(te,ne).toLowerCase(),function(e){var t;do{if(t=E?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(t=t.toLowerCase())===n||0===t.indexOf(n+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=n.location&&n.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===a},focus:function(e){return e===C.activeElement&&(!C.hasFocus||C.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ge(!1),disabled:ge(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!b.pseudos.empty(e)},header:function(e){return J.test(e.nodeName)},input:function(e){return Q.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:ve(function(){return[0]}),last:ve(function(e,t){return[t-1]}),eq:ve(function(e,t,n){return[n<0?n+t:n]}),even:ve(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:ve(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:ve(function(e,t,n){for(var r=n<0?n+t:t<n?t:n;0<=--r;)e.push(r);return e}),gt:ve(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=b.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})b.pseudos[e]=de(e);for(e in{submit:!0,reset:!0})b.pseudos[e]=he(e);function me(){}function xe(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function be(s,e,t){var u=e.dir,l=e.next,c=l||u,f=t&&"parentNode"===c,p=r++;return e.first?function(e,t,n){while(e=e[u])if(1===e.nodeType||f)return s(e,t,n);return!1}:function(e,t,n){var r,i,o,a=[k,p];if(n){while(e=e[u])if((1===e.nodeType||f)&&s(e,t,n))return!0}else while(e=e[u])if(1===e.nodeType||f)if(i=(o=e[S]||(e[S]={}))[e.uniqueID]||(o[e.uniqueID]={}),l&&l===e.nodeName.toLowerCase())e=e[u]||e;else{if((r=i[c])&&r[0]===k&&r[1]===p)return a[2]=r[2];if((i[c]=a)[2]=s(e,t,n))return!0}return!1}}function we(i){return 1<i.length?function(e,t,n){var r=i.length;while(r--)if(!i[r](e,t,n))return!1;return!0}:i[0]}function Te(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function Ce(d,h,g,v,y,e){return v&&!v[S]&&(v=Ce(v)),y&&!y[S]&&(y=Ce(y,e)),le(function(e,t,n,r){var i,o,a,s=[],u=[],l=t.length,c=e||function(e,t,n){for(var r=0,i=t.length;r<i;r++)se(e,t[r],n);return n}(h||"*",n.nodeType?[n]:n,[]),f=!d||!e&&h?c:Te(c,s,d,n,r),p=g?y||(e?d:l||v)?[]:t:f;if(g&&g(f,p,n,r),v){i=Te(p,u),v(i,[],n,r),o=i.length;while(o--)(a=i[o])&&(p[u[o]]=!(f[u[o]]=a))}if(e){if(y||d){if(y){i=[],o=p.length;while(o--)(a=p[o])&&i.push(f[o]=a);y(null,p=[],i,r)}o=p.length;while(o--)(a=p[o])&&-1<(i=y?P(e,a):s[o])&&(e[i]=!(t[i]=a))}}else p=Te(p===t?p.splice(l,p.length):p),y?y(null,t,p,r):H.apply(t,p)})}function Ee(e){for(var i,t,n,r=e.length,o=b.relative[e[0].type],a=o||b.relative[" "],s=o?1:0,u=be(function(e){return e===i},a,!0),l=be(function(e){return-1<P(i,e)},a,!0),c=[function(e,t,n){var r=!o&&(n||t!==w)||((i=t).nodeType?u(e,t,n):l(e,t,n));return i=null,r}];s<r;s++)if(t=b.relative[e[s].type])c=[be(we(c),t)];else{if((t=b.filter[e[s].type].apply(null,e[s].matches))[S]){for(n=++s;n<r;n++)if(b.relative[e[n].type])break;return Ce(1<s&&we(c),1<s&&xe(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace($,"$1"),t,s<n&&Ee(e.slice(s,n)),n<r&&Ee(e=e.slice(n)),n<r&&xe(e))}c.push(t)}return we(c)}return me.prototype=b.filters=b.pseudos,b.setFilters=new me,h=se.tokenize=function(e,t){var n,r,i,o,a,s,u,l=x[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=b.preFilter;while(a){for(o in n&&!(r=_.exec(a))||(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=z.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace($," ")}),a=a.slice(n.length)),b.filter)!(r=G[o].exec(a))||u[o]&&!(r=u[o](r))||(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?se.error(e):x(e,s).slice(0)},f=se.compile=function(e,t){var n,v,y,m,x,r,i=[],o=[],a=A[e+" "];if(!a){t||(t=h(e)),n=t.length;while(n--)(a=Ee(t[n]))[S]?i.push(a):o.push(a);(a=A(e,(v=o,m=0<(y=i).length,x=0<v.length,r=function(e,t,n,r,i){var o,a,s,u=0,l="0",c=e&&[],f=[],p=w,d=e||x&&b.find.TAG("*",i),h=k+=null==p?1:Math.random()||.1,g=d.length;for(i&&(w=t==C||t||i);l!==g&&null!=(o=d[l]);l++){if(x&&o){a=0,t||o.ownerDocument==C||(T(o),n=!E);while(s=v[a++])if(s(o,t||C,n)){r.push(o);break}i&&(k=h)}m&&((o=!s&&o)&&u--,e&&c.push(o))}if(u+=l,m&&l!==u){a=0;while(s=y[a++])s(c,f,t,n);if(e){if(0<u)while(l--)c[l]||f[l]||(f[l]=q.call(r));f=Te(f)}H.apply(r,f),i&&!e&&0<f.length&&1<u+y.length&&se.uniqueSort(r)}return i&&(k=h,w=p),c},m?le(r):r))).selector=e}return a},g=se.select=function(e,t,n,r){var i,o,a,s,u,l="function"==typeof e&&e,c=!r&&h(e=l.selector||e);if(n=n||[],1===c.length){if(2<(o=c[0]=c[0].slice(0)).length&&"ID"===(a=o[0]).type&&9===t.nodeType&&E&&b.relative[o[1].type]){if(!(t=(b.find.ID(a.matches[0].replace(te,ne),t)||[])[0]))return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=G.needsContext.test(e)?0:o.length;while(i--){if(a=o[i],b.relative[s=a.type])break;if((u=b.find[s])&&(r=u(a.matches[0].replace(te,ne),ee.test(o[0].type)&&ye(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&xe(o)))return H.apply(n,r),n;break}}}return(l||f(e,c))(r,t,!E,n,!t||ee.test(e)&&ye(t.parentNode)||t),n},d.sortStable=S.split("").sort(D).join("")===S,d.detectDuplicates=!!l,T(),d.sortDetached=ce(function(e){return 1&e.compareDocumentPosition(C.createElement("fieldset"))}),ce(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||fe("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),d.attributes&&ce(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||fe("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ce(function(e){return null==e.getAttribute("disabled")})||fe(R,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),se}(C);S.find=d,S.expr=d.selectors,S.expr[":"]=S.expr.pseudos,S.uniqueSort=S.unique=d.uniqueSort,S.text=d.getText,S.isXMLDoc=d.isXML,S.contains=d.contains,S.escapeSelector=d.escape;var h=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&S(e).is(n))break;r.push(e)}return r},T=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},k=S.expr.match.needsContext;function A(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var N=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function D(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1<i.call(n,e)!==r}):S.filter(n,e,r)}S.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?S.find.matchesSelector(r,e)?[r]:[]:S.find.matches(e,S.grep(t,function(e){return 1===e.nodeType}))},S.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(S(e).filter(function(){for(t=0;t<r;t++)if(S.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)S.find(e,i[t],n);return 1<r?S.uniqueSort(n):n},filter:function(e){return this.pushStack(D(this,e||[],!1))},not:function(e){return this.pushStack(D(this,e||[],!0))},is:function(e){return!!D(this,"string"==typeof e&&k.test(e)?S(e):e||[],!1).length}});var j,q=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||j,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,j=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(S.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&S(e);if(!k.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?-1<a.index(n):1===n.nodeType&&S.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(1<o.length?S.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?i.call(S(e),this[0]):i.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(S.uniqueSort(S.merge(this.get(),S(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),S.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return h(e,"parentNode")},parentsUntil:function(e,t,n){return h(e,"parentNode",n)},next:function(e){return O(e,"nextSibling")},prev:function(e){return O(e,"previousSibling")},nextAll:function(e){return h(e,"nextSibling")},prevAll:function(e){return h(e,"previousSibling")},nextUntil:function(e,t,n){return h(e,"nextSibling",n)},prevUntil:function(e,t,n){return h(e,"previousSibling",n)},siblings:function(e){return T((e.parentNode||{}).firstChild,e)},children:function(e){return T(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(A(e,"template")&&(e=e.content||e),S.merge([],e.childNodes))}},function(r,i){S.fn[r]=function(e,t){var n=S.map(this,i,e);return"Until"!==r.slice(-5)&&(t=e),t&&"string"==typeof t&&(n=S.filter(t,n)),1<this.length&&(H[r]||S.uniqueSort(n),L.test(r)&&n.reverse()),this.pushStack(n)}});var P=/[^\x20\t\r\n\f]+/g;function R(e){return e}function M(e){throw e}function I(e,t,n,r){var i;try{e&&m(i=e.promise)?i.call(e).done(t).fail(n):e&&m(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}S.Callbacks=function(r){var e,n;r="string"==typeof r?(e=r,n={},S.each(e.match(P)||[],function(e,t){n[t]=!0}),n):S.extend({},r);var i,t,o,a,s=[],u=[],l=-1,c=function(){for(a=a||r.once,o=i=!0;u.length;l=-1){t=u.shift();while(++l<s.length)!1===s[l].apply(t[0],t[1])&&r.stopOnFalse&&(l=s.length,t=!1)}r.memory||(t=!1),i=!1,a&&(s=t?[]:"")},f={add:function(){return s&&(t&&!i&&(l=s.length-1,u.push(t)),function n(e){S.each(e,function(e,t){m(t)?r.unique&&f.has(t)||s.push(t):t&&t.length&&"string"!==w(t)&&n(t)})}(arguments),t&&!i&&c()),this},remove:function(){return S.each(arguments,function(e,t){var n;while(-1<(n=S.inArray(t,s,n)))s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?-1<S.inArray(e,s):0<s.length},empty:function(){return s&&(s=[]),this},disable:function(){return a=u=[],s=t="",this},disabled:function(){return!s},lock:function(){return a=u=[],t||i||(s=t=""),this},locked:function(){return!!a},fireWith:function(e,t){return a||(t=[e,(t=t||[]).slice?t.slice():t],u.push(t),i||c()),this},fire:function(){return f.fireWith(this,arguments),this},fired:function(){return!!o}};return f},S.extend({Deferred:function(e){var o=[["notify","progress",S.Callbacks("memory"),S.Callbacks("memory"),2],["resolve","done",S.Callbacks("once memory"),S.Callbacks("once memory"),0,"resolved"],["reject","fail",S.Callbacks("once memory"),S.Callbacks("once memory"),1,"rejected"]],i="pending",a={state:function(){return i},always:function(){return s.done(arguments).fail(arguments),this},"catch":function(e){return a.then(null,e)},pipe:function(){var i=arguments;return S.Deferred(function(r){S.each(o,function(e,t){var n=m(i[t[4]])&&i[t[4]];s[t[1]](function(){var e=n&&n.apply(this,arguments);e&&m(e.promise)?e.promise().progress(r.notify).done(r.resolve).fail(r.reject):r[t[0]+"With"](this,n?[e]:arguments)})}),i=null}).promise()},then:function(t,n,r){var u=0;function l(i,o,a,s){return function(){var n=this,r=arguments,e=function(){var e,t;if(!(i<u)){if((e=a.apply(n,r))===o.promise())throw new TypeError("Thenable self-resolution");t=e&&("object"==typeof e||"function"==typeof e)&&e.then,m(t)?s?t.call(e,l(u,o,R,s),l(u,o,M,s)):(u++,t.call(e,l(u,o,R,s),l(u,o,M,s),l(u,o,R,o.notifyWith))):(a!==R&&(n=void 0,r=[e]),(s||o.resolveWith)(n,r))}},t=s?e:function(){try{e()}catch(e){S.Deferred.exceptionHook&&S.Deferred.exceptionHook(e,t.stackTrace),u<=i+1&&(a!==M&&(n=void 0,r=[e]),o.rejectWith(n,r))}};i?t():(S.Deferred.getStackHook&&(t.stackTrace=S.Deferred.getStackHook()),C.setTimeout(t))}}return S.Deferred(function(e){o[0][3].add(l(0,e,m(r)?r:R,e.notifyWith)),o[1][3].add(l(0,e,m(t)?t:R)),o[2][3].add(l(0,e,m(n)?n:M))}).promise()},promise:function(e){return null!=e?S.extend(e,a):a}},s={};return S.each(o,function(e,t){var n=t[2],r=t[5];a[t[1]]=n.add,r&&n.add(function(){i=r},o[3-e][2].disable,o[3-e][3].disable,o[0][2].lock,o[0][3].lock),n.add(t[3].fire),s[t[0]]=function(){return s[t[0]+"With"](this===s?void 0:this,arguments),this},s[t[0]+"With"]=n.fireWith}),a.promise(s),e&&e.call(s,s),s},when:function(e){var n=arguments.length,t=n,r=Array(t),i=s.call(arguments),o=S.Deferred(),a=function(t){return function(e){r[t]=this,i[t]=1<arguments.length?s.call(arguments):e,--n||o.resolveWith(r,i)}};if(n<=1&&(I(e,o.done(a(t)).resolve,o.reject,!n),"pending"===o.state()||m(i[t]&&i[t].then)))return o.then();while(t--)I(i[t],a(t),o.reject);return o.promise()}});var W=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;S.Deferred.exceptionHook=function(e,t){C.console&&C.console.warn&&e&&W.test(e.name)&&C.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},S.readyException=function(e){C.setTimeout(function(){throw e})};var F=S.Deferred();function B(){E.removeEventListener("DOMContentLoaded",B),C.removeEventListener("load",B),S.ready()}S.fn.ready=function(e){return F.then(e)["catch"](function(e){S.readyException(e)}),this},S.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--S.readyWait:S.isReady)||(S.isReady=!0)!==e&&0<--S.readyWait||F.resolveWith(E,[S])}}),S.ready.then=F.then,"complete"===E.readyState||"loading"!==E.readyState&&!E.documentElement.doScroll?C.setTimeout(S.ready):(E.addEventListener("DOMContentLoaded",B),C.addEventListener("load",B));var $=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===w(n))for(s in i=!0,n)$(e,t,s,n[s],!0,o,a);else if(void 0!==r&&(i=!0,m(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(S(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},_=/^-ms-/,z=/-([a-z])/g;function U(e,t){return t.toUpperCase()}function X(e){return e.replace(_,"ms-").replace(z,U)}var V=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function G(){this.expando=S.expando+G.uid++}G.uid=1,G.prototype={cache:function(e){var t=e[this.expando];return t||(t={},V(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[X(t)]=n;else for(r in t)i[X(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][X(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(X):(t=X(t))in r?[t]:t.match(P)||[]).length;while(n--)delete r[t[n]]}(void 0===t||S.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!S.isEmptyObject(t)}};var Y=new G,Q=new G,J=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,K=/[A-Z]/g;function Z(e,t,n){var r,i;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(K,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n="true"===(i=n)||"false"!==i&&("null"===i?null:i===+i+""?+i:J.test(i)?JSON.parse(i):i)}catch(e){}Q.set(e,t,n)}else n=void 0;return n}S.extend({hasData:function(e){return Q.hasData(e)||Y.hasData(e)},data:function(e,t,n){return Q.access(e,t,n)},removeData:function(e,t){Q.remove(e,t)},_data:function(e,t,n){return Y.access(e,t,n)},_removeData:function(e,t){Y.remove(e,t)}}),S.fn.extend({data:function(n,e){var t,r,i,o=this[0],a=o&&o.attributes;if(void 0===n){if(this.length&&(i=Q.get(o),1===o.nodeType&&!Y.get(o,"hasDataAttrs"))){t=a.length;while(t--)a[t]&&0===(r=a[t].name).indexOf("data-")&&(r=X(r.slice(5)),Z(o,r,i[r]));Y.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof n?this.each(function(){Q.set(this,n)}):$(this,function(e){var t;if(o&&void 0===e)return void 0!==(t=Q.get(o,n))?t:void 0!==(t=Z(o,n))?t:void 0;this.each(function(){Q.set(this,n,e)})},null,e,1<arguments.length,null,!0)},removeData:function(e){return this.each(function(){Q.remove(this,e)})}}),S.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Y.get(e,t),n&&(!r||Array.isArray(n)?r=Y.access(e,t,S.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=S.queue(e,t),r=n.length,i=n.shift(),o=S._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){S.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Y.get(e,n)||Y.access(e,n,{empty:S.Callbacks("once memory").add(function(){Y.remove(e,[t+"queue",n])})})}}),S.fn.extend({queue:function(t,n){var e=2;return"string"!=typeof t&&(n=t,t="fx",e--),arguments.length<e?S.queue(this[0],t):void 0===n?this:this.each(function(){var e=S.queue(this,t,n);S._queueHooks(this,t),"fx"===t&&"inprogress"!==e[0]&&S.dequeue(this,t)})},dequeue:function(e){return this.each(function(){S.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=S.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=Y.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var ee=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,te=new RegExp("^(?:([+-])=|)("+ee+")([a-z%]*)$","i"),ne=["Top","Right","Bottom","Left"],re=E.documentElement,ie=function(e){return S.contains(e.ownerDocument,e)},oe={composed:!0};re.getRootNode&&(ie=function(e){return S.contains(e.ownerDocument,e)||e.getRootNode(oe)===e.ownerDocument});var ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&ie(e)&&"none"===S.css(e,"display")};function se(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return S.css(e,t,"")},u=s(),l=n&&n[3]||(S.cssNumber[t]?"":"px"),c=e.nodeType&&(S.cssNumber[t]||"px"!==l&&+u)&&te.exec(S.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)S.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,S.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var ue={};function le(e,t){for(var n,r,i,o,a,s,u,l=[],c=0,f=e.length;c<f;c++)(r=e[c]).style&&(n=r.style.display,t?("none"===n&&(l[c]=Y.get(r,"display")||null,l[c]||(r.style.display="")),""===r.style.display&&ae(r)&&(l[c]=(u=a=o=void 0,a=(i=r).ownerDocument,s=i.nodeName,(u=ue[s])||(o=a.body.appendChild(a.createElement(s)),u=S.css(o,"display"),o.parentNode.removeChild(o),"none"===u&&(u="block"),ue[s]=u)))):"none"!==n&&(l[c]="none",Y.set(r,"display",n)));for(c=0;c<f;c++)null!=l[c]&&(e[c].style.display=l[c]);return e}S.fn.extend({show:function(){return le(this,!0)},hide:function(){return le(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?S(this).show():S(this).hide()})}});var ce,fe,pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="<textarea>x</textarea>",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="<option></option>",y.option=!!ce.lastChild;var ge={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n<r;n++)Y.set(e[n],"globalEval",!t||Y.get(t[n],"globalEval"))}ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td,y.option||(ge.optgroup=ge.option=[1,"<select multiple='multiple'>","</select>"]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===w(o))S.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+S.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;S.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&-1<S.inArray(o,r))i&&i.push(o);else if(l=ie(o),a=ve(f.appendChild(o),"script"),l&&ye(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}var be=/^key/,we=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Te=/^([^.]*)(?:\.(.+)|)/;function Ce(){return!0}function Ee(){return!1}function Se(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function ke(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)ke(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Ee;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return S().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=S.guid++)),e.each(function(){S.event.add(this,t,i,r,n)})}function Ae(e,i,o){o?(Y.set(e,i,!1),S.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Y.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(S.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Y.set(this,i,r),t=o(this,i),this[i](),r!==(n=Y.get(this,i))||t?Y.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Y.set(this,i,{value:S.event.trigger(S.extend(r[0],S.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Y.get(e,i)&&S.event.add(e,i,Ce)}S.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Y.get(t);if(V(t)){n.handler&&(n=(o=n).handler,i=o.selector),i&&S.find.matchesSelector(re,i),n.guid||(n.guid=S.guid++),(u=v.events)||(u=v.events=Object.create(null)),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof S&&S.event.triggered!==e.type?S.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(P)||[""]).length;while(l--)d=g=(s=Te.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=S.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=S.event.special[d]||{},c=S.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&S.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),S.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Y.hasData(e)&&Y.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(P)||[""]).length;while(l--)if(d=g=(s=Te.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=S.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||S.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)S.event.remove(e,d+t[l],n,r,!0);S.isEmptyObject(u)&&Y.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=new Array(arguments.length),u=S.event.fix(e),l=(Y.get(this,"events")||Object.create(null))[u.type]||[],c=S.event.special[u.type]||{};for(s[0]=u,t=1;t<arguments.length;t++)s[t]=arguments[t];if(u.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,u)){a=S.event.handlers.call(this,u,l),t=0;while((i=a[t++])&&!u.isPropagationStopped()){u.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!u.isImmediatePropagationStopped())u.rnamespace&&!1!==o.namespace&&!u.rnamespace.test(o.namespace)||(u.handleObj=o,u.data=o.data,void 0!==(r=((S.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s))&&!1===(u.result=r)&&(u.preventDefault(),u.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,u),u.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&1<=e.button))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?-1<S(i,this).index(l):S.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(t,e){Object.defineProperty(S.Event.prototype,t,{enumerable:!0,configurable:!0,get:m(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[t]},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(e){return e[S.expando]?e:new S.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Ae(t,"click",Ce),!1},trigger:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Ae(t,"click"),!0},_default:function(e){var t=e.target;return pe.test(t.type)&&t.click&&A(t,"input")&&Y.get(t,"click")||A(t,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},S.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},S.Event=function(e,t){if(!(this instanceof S.Event))return new S.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?Ce:Ee,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&S.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[S.expando]=!0},S.Event.prototype={constructor:S.Event,isDefaultPrevented:Ee,isPropagationStopped:Ee,isImmediatePropagationStopped:Ee,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Ce,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Ce,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Ce,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},S.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&be.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&we.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},S.event.addProp),S.each({focus:"focusin",blur:"focusout"},function(e,t){S.event.special[e]={setup:function(){return Ae(this,e,Se),!1},trigger:function(){return Ae(this,e),!0},delegateType:t}}),S.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){S.event.special[e]={delegateType:i,bindType:i,handle:function(e){var t,n=e.relatedTarget,r=e.handleObj;return n&&(n===this||S.contains(this,n))||(e.type=r.origType,t=r.handler.apply(this,arguments),e.type=i),t}}}),S.fn.extend({on:function(e,t,n,r){return ke(this,e,t,n,r)},one:function(e,t,n,r){return ke(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,S(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=Ee),this.each(function(){S.event.remove(this,e,n,t)})}});var Ne=/<script|<style|<link/i,De=/checked\s*(?:[^=]|=\s*.checked.)/i,je=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function qe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function Le(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function He(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Oe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n<r;n++)S.event.add(t,i,s[i][n]);Q.hasData(e)&&(o=Q.access(e),a=S.extend({},o),Q.set(t,a))}}function Pe(n,r,i,o){r=g(r);var e,t,a,s,u,l,c=0,f=n.length,p=f-1,d=r[0],h=m(d);if(h||1<f&&"string"==typeof d&&!y.checkClone&&De.test(d))return n.each(function(e){var t=n.eq(e);h&&(r[0]=d.call(this,e,t.html())),Pe(t,r,i,o)});if(f&&(t=(e=xe(r,n[0].ownerDocument,!1,n,o)).firstChild,1===e.childNodes.length&&(e=t),t||o)){for(s=(a=S.map(ve(e,"script"),Le)).length;c<f;c++)u=e,c!==p&&(u=S.clone(u,!0,!0),s&&S.merge(a,ve(u,"script"))),i.call(n[c],u,c);if(s)for(l=a[a.length-1].ownerDocument,S.map(a,He),c=0;c<s;c++)u=a[c],he.test(u.type||"")&&!Y.access(u,"globalEval")&&S.contains(l,u)&&(u.src&&"module"!==(u.type||"").toLowerCase()?S._evalUrl&&!u.noModule&&S._evalUrl(u.src,{nonce:u.nonce||u.getAttribute("nonce")},l):b(u.textContent.replace(je,""),u,l))}return n}function Re(e,t,n){for(var r,i=t?S.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||S.cleanData(ve(r)),r.parentNode&&(n&&ie(r)&&ye(ve(r,"script")),r.parentNode.removeChild(r));return e}S.extend({htmlPrefilter:function(e){return e},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=ie(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||S.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r<i;r++)s=o[r],u=a[r],void 0,"input"===(l=u.nodeName.toLowerCase())&&pe.test(s.type)?u.checked=s.checked:"input"!==l&&"textarea"!==l||(u.defaultValue=s.defaultValue);if(t)if(n)for(o=o||ve(e),a=a||ve(c),r=0,i=o.length;r<i;r++)Oe(o[r],a[r]);else Oe(e,c);return 0<(a=ve(c,"script")).length&&ye(a,!f&&ve(e,"script")),c},cleanData:function(e){for(var t,n,r,i=S.event.special,o=0;void 0!==(n=e[o]);o++)if(V(n)){if(t=n[Y.expando]){if(t.events)for(r in t.events)i[r]?S.event.remove(n,r):S.removeEvent(n,r,t.handle);n[Y.expando]=void 0}n[Q.expando]&&(n[Q.expando]=void 0)}}}),S.fn.extend({detach:function(e){return Re(this,e,!0)},remove:function(e){return Re(this,e)},text:function(e){return $(this,function(e){return void 0===e?S.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Pe(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||qe(this,e).appendChild(e)})},prepend:function(){return Pe(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=qe(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Pe(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Pe(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(S.cleanData(ve(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return S.clone(this,e,t)})},html:function(e){return $(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ne.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=S.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(S.cleanData(ve(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var n=[];return Pe(this,arguments,function(e){var t=this.parentNode;S.inArray(this,n)<0&&(S.cleanData(ve(this)),t&&t.replaceChild(e,this))},n)}}),S.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,a){S.fn[e]=function(e){for(var t,n=[],r=S(e),i=r.length-1,o=0;o<=i;o++)t=o===i?this:this.clone(!0),S(r[o])[a](t),u.apply(n,t.get());return this.pushStack(n)}});var Me=new RegExp("^("+ee+")(?!px)[a-z%]+$","i"),Ie=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=C),t.getComputedStyle(e)},We=function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r},Fe=new RegExp(ne.join("|"),"i");function Be(e,t,n){var r,i,o,a,s=e.style;return(n=n||Ie(e))&&(""!==(a=n.getPropertyValue(t)||n[t])||ie(e)||(a=S.style(e,t)),!y.pixelBoxStyles()&&Me.test(a)&&Fe.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function $e(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function e(){if(l){u.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",re.appendChild(u).appendChild(l);var e=C.getComputedStyle(l);n="1%"!==e.top,s=12===t(e.marginLeft),l.style.right="60%",o=36===t(e.right),r=36===t(e.width),l.style.position="absolute",i=12===t(l.offsetWidth/3),re.removeChild(u),l=null}}function t(e){return Math.round(parseFloat(e))}var n,r,i,o,a,s,u=E.createElement("div"),l=E.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",y.clearCloneStyle="content-box"===l.style.backgroundClip,S.extend(y,{boxSizingReliable:function(){return e(),r},pixelBoxStyles:function(){return e(),o},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),s},scrollboxSize:function(){return e(),i},reliableTrDimensions:function(){var e,t,n,r;return null==a&&(e=E.createElement("table"),t=E.createElement("tr"),n=E.createElement("div"),e.style.cssText="position:absolute;left:-11111px",t.style.height="1px",n.style.height="9px",re.appendChild(e).appendChild(t).appendChild(n),r=C.getComputedStyle(t),a=3<parseInt(r.height),re.removeChild(e)),a}}))}();var _e=["Webkit","Moz","ms"],ze=E.createElement("div").style,Ue={};function Xe(e){var t=S.cssProps[e]||Ue[e];return t||(e in ze?e:Ue[e]=function(e){var t=e[0].toUpperCase()+e.slice(1),n=_e.length;while(n--)if((e=_e[n]+t)in ze)return e}(e)||e)}var Ve=/^(none|table(?!-c[ea]).+)/,Ge=/^--/,Ye={position:"absolute",visibility:"hidden",display:"block"},Qe={letterSpacing:"0",fontWeight:"400"};function Je(e,t,n){var r=te.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Ke(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=S.css(e,n+ne[a],!0,i)),r?("content"===n&&(u-=S.css(e,"padding"+ne[a],!0,i)),"margin"!==n&&(u-=S.css(e,"border"+ne[a]+"Width",!0,i))):(u+=S.css(e,"padding"+ne[a],!0,i),"padding"!==n?u+=S.css(e,"border"+ne[a]+"Width",!0,i):s+=S.css(e,"border"+ne[a]+"Width",!0,i));return!r&&0<=o&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u}function Ze(e,t,n){var r=Ie(e),i=(!y.boxSizingReliable()||n)&&"border-box"===S.css(e,"boxSizing",!1,r),o=i,a=Be(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(Me.test(a)){if(!n)return a;a="auto"}return(!y.boxSizingReliable()&&i||!y.reliableTrDimensions()&&A(e,"tr")||"auto"===a||!parseFloat(a)&&"inline"===S.css(e,"display",!1,r))&&e.getClientRects().length&&(i="border-box"===S.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+Ke(e,t,n||(i?"border":"content"),o,r,a)+"px"}function et(e,t,n,r,i){return new et.prototype.init(e,t,n,r,i)}S.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Be(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=X(t),u=Ge.test(t),l=e.style;if(u||(t=Xe(s)),a=S.cssHooks[t]||S.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"===(o=typeof n)&&(i=te.exec(n))&&i[1]&&(n=se(e,t,i),o="number"),null!=n&&n==n&&("number"!==o||u||(n+=i&&i[3]||(S.cssNumber[s]?"":"px")),y.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=X(t);return Ge.test(t)||(t=Xe(s)),(a=S.cssHooks[t]||S.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Be(e,t,r)),"normal"===i&&t in Qe&&(i=Qe[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),S.each(["height","width"],function(e,u){S.cssHooks[u]={get:function(e,t,n){if(t)return!Ve.test(S.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Ze(e,u,n):We(e,Ye,function(){return Ze(e,u,n)})},set:function(e,t,n){var r,i=Ie(e),o=!y.scrollboxSize()&&"absolute"===i.position,a=(o||n)&&"border-box"===S.css(e,"boxSizing",!1,i),s=n?Ke(e,u,n,a,i):0;return a&&o&&(s-=Math.ceil(e["offset"+u[0].toUpperCase()+u.slice(1)]-parseFloat(i[u])-Ke(e,u,"border",!1,i)-.5)),s&&(r=te.exec(t))&&"px"!==(r[3]||"px")&&(e.style[u]=t,t=S.css(e,u)),Je(0,t,s)}}}),S.cssHooks.marginLeft=$e(y.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Be(e,"marginLeft"))||e.getBoundingClientRect().left-We(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),S.each({margin:"",padding:"",border:"Width"},function(i,o){S.cssHooks[i+o]={expand:function(e){for(var t=0,n={},r="string"==typeof e?e.split(" "):[e];t<4;t++)n[i+ne[t]+o]=r[t]||r[t-2]||r[0];return n}},"margin"!==i&&(S.cssHooks[i+o].set=Je)}),S.fn.extend({css:function(e,t){return $(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=Ie(e),i=t.length;a<i;a++)o[t[a]]=S.css(e,t[a],!1,r);return o}return void 0!==n?S.style(e,t,n):S.css(e,t)},e,t,1<arguments.length)}}),((S.Tween=et).prototype={constructor:et,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||S.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(S.cssNumber[n]?"":"px")},cur:function(){var e=et.propHooks[this.prop];return e&&e.get?e.get(this):et.propHooks._default.get(this)},run:function(e){var t,n=et.propHooks[this.prop];return this.options.duration?this.pos=t=S.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):et.propHooks._default.set(this),this}}).init.prototype=et.prototype,(et.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=S.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){S.fx.step[e.prop]?S.fx.step[e.prop](e):1!==e.elem.nodeType||!S.cssHooks[e.prop]&&null==e.elem.style[Xe(e.prop)]?e.elem[e.prop]=e.now:S.style(e.elem,e.prop,e.now+e.unit)}}}).scrollTop=et.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},S.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},S.fx=et.prototype.init,S.fx.step={};var tt,nt,rt,it,ot=/^(?:toggle|show|hide)$/,at=/queueHooks$/;function st(){nt&&(!1===E.hidden&&C.requestAnimationFrame?C.requestAnimationFrame(st):C.setTimeout(st,S.fx.interval),S.fx.tick())}function ut(){return C.setTimeout(function(){tt=void 0}),tt=Date.now()}function lt(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=ne[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function ct(e,t,n){for(var r,i=(ft.tweeners[t]||[]).concat(ft.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function ft(o,e,t){var n,a,r=0,i=ft.prefilters.length,s=S.Deferred().always(function(){delete u.elem}),u=function(){if(a)return!1;for(var e=tt||ut(),t=Math.max(0,l.startTime+l.duration-e),n=1-(t/l.duration||0),r=0,i=l.tweens.length;r<i;r++)l.tweens[r].run(n);return s.notifyWith(o,[l,n,t]),n<1&&i?t:(i||s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l]),!1)},l=s.promise({elem:o,props:S.extend({},e),opts:S.extend(!0,{specialEasing:{},easing:S.easing._default},t),originalProperties:e,originalOptions:t,startTime:tt||ut(),duration:t.duration,tweens:[],createTween:function(e,t){var n=S.Tween(o,l.opts,e,t,l.opts.specialEasing[e]||l.opts.easing);return l.tweens.push(n),n},stop:function(e){var t=0,n=e?l.tweens.length:0;if(a)return this;for(a=!0;t<n;t++)l.tweens[t].run(1);return e?(s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l,e])):s.rejectWith(o,[l,e]),this}}),c=l.props;for(!function(e,t){var n,r,i,o,a;for(n in e)if(i=t[r=X(n)],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=S.cssHooks[r])&&"expand"in a)for(n in o=a.expand(o),delete e[r],o)n in e||(e[n]=o[n],t[n]=i);else t[r]=i}(c,l.opts.specialEasing);r<i;r++)if(n=ft.prefilters[r].call(l,o,c,l.opts))return m(n.stop)&&(S._queueHooks(l.elem,l.opts.queue).stop=n.stop.bind(n)),n;return S.map(c,ct,l),m(l.opts.start)&&l.opts.start.call(o,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),S.fx.timer(S.extend(u,{elem:o,anim:l,queue:l.opts.queue})),l}S.Animation=S.extend(ft,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return se(n.elem,e,te.exec(t),n),n}]},tweener:function(e,t){m(e)?(t=e,e=["*"]):e=e.match(P);for(var n,r=0,i=e.length;r<i;r++)n=e[r],ft.tweeners[n]=ft.tweeners[n]||[],ft.tweeners[n].unshift(t)},prefilters:[function(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),v=Y.get(e,"fxshow");for(r in n.queue||(null==(a=S._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,S.queue(e,"fx").length||a.empty.fire()})})),t)if(i=t[r],ot.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}d[r]=v&&v[r]||S.style(e,r)}if((u=!S.isEmptyObject(t))||!S.isEmptyObject(d))for(r in f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=v&&v.display)&&(l=Y.get(e,"display")),"none"===(c=S.css(e,"display"))&&(l?c=l:(le([e],!0),l=e.style.display||l,c=S.css(e,"display"),le([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===S.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1,d)u||(v?"hidden"in v&&(g=v.hidden):v=Y.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&le([e],!0),p.done(function(){for(r in g||le([e]),Y.remove(e,"fxshow"),d)S.style(e,r,d[r])})),u=ct(g?v[r]:0,r,p),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}],prefilter:function(e,t){t?ft.prefilters.unshift(e):ft.prefilters.push(e)}}),S.speed=function(e,t,n){var r=e&&"object"==typeof e?S.extend({},e):{complete:n||!n&&t||m(e)&&e,duration:e,easing:n&&t||t&&!m(t)&&t};return S.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in S.fx.speeds?r.duration=S.fx.speeds[r.duration]:r.duration=S.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){m(r.old)&&r.old.call(this),r.queue&&S.dequeue(this,r.queue)},r},S.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(t,e,n,r){var i=S.isEmptyObject(t),o=S.speed(e,n,r),a=function(){var e=ft(this,S.extend({},t),o);(i||Y.get(this,"finish"))&&e.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(i,e,o){var a=function(e){var t=e.stop;delete e.stop,t(o)};return"string"!=typeof i&&(o=e,e=i,i=void 0),e&&this.queue(i||"fx",[]),this.each(function(){var e=!0,t=null!=i&&i+"queueHooks",n=S.timers,r=Y.get(this);if(t)r[t]&&r[t].stop&&a(r[t]);else for(t in r)r[t]&&r[t].stop&&at.test(t)&&a(r[t]);for(t=n.length;t--;)n[t].elem!==this||null!=i&&n[t].queue!==i||(n[t].anim.stop(o),e=!1,n.splice(t,1));!e&&o||S.dequeue(this,i)})},finish:function(a){return!1!==a&&(a=a||"fx"),this.each(function(){var e,t=Y.get(this),n=t[a+"queue"],r=t[a+"queueHooks"],i=S.timers,o=n?n.length:0;for(t.finish=!0,S.queue(this,a,[]),r&&r.stop&&r.stop.call(this,!0),e=i.length;e--;)i[e].elem===this&&i[e].queue===a&&(i[e].anim.stop(!0),i.splice(e,1));for(e=0;e<o;e++)n[e]&&n[e].finish&&n[e].finish.call(this);delete t.finish})}}),S.each(["toggle","show","hide"],function(e,r){var i=S.fn[r];S.fn[r]=function(e,t,n){return null==e||"boolean"==typeof e?i.apply(this,arguments):this.animate(lt(r,!0),e,t,n)}}),S.each({slideDown:lt("show"),slideUp:lt("hide"),slideToggle:lt("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,r){S.fn[e]=function(e,t,n){return this.animate(r,e,t,n)}}),S.timers=[],S.fx.tick=function(){var e,t=0,n=S.timers;for(tt=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||S.fx.stop(),tt=void 0},S.fx.timer=function(e){S.timers.push(e),S.fx.start()},S.fx.interval=13,S.fx.start=function(){nt||(nt=!0,st())},S.fx.stop=function(){nt=null},S.fx.speeds={slow:600,fast:200,_default:400},S.fn.delay=function(r,e){return r=S.fx&&S.fx.speeds[r]||r,e=e||"fx",this.queue(e,function(e,t){var n=C.setTimeout(e,r);t.stop=function(){C.clearTimeout(n)}})},rt=E.createElement("input"),it=E.createElement("select").appendChild(E.createElement("option")),rt.type="checkbox",y.checkOn=""!==rt.value,y.optSelected=it.selected,(rt=E.createElement("input")).value="t",rt.type="radio",y.radioValue="t"===rt.value;var pt,dt=S.expr.attrHandle;S.fn.extend({attr:function(e,t){return $(this,S.attr,e,t,1<arguments.length)},removeAttr:function(e){return this.each(function(){S.removeAttr(this,e)})}}),S.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?S.prop(e,t,n):(1===o&&S.isXMLDoc(e)||(i=S.attrHooks[t.toLowerCase()]||(S.expr.match.bool.test(t)?pt:void 0)),void 0!==n?null===n?void S.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=S.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!y.radioValue&&"radio"===t&&A(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(P);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),pt={set:function(e,t,n){return!1===t?S.removeAttr(e,n):e.setAttribute(n,n),n}},S.each(S.expr.match.bool.source.match(/\w+/g),function(e,t){var a=dt[t]||S.find.attr;dt[t]=function(e,t,n){var r,i,o=t.toLowerCase();return n||(i=dt[o],dt[o]=r,r=null!=a(e,t,n)?o:null,dt[o]=i),r}});var ht=/^(?:input|select|textarea|button)$/i,gt=/^(?:a|area)$/i;function vt(e){return(e.match(P)||[]).join(" ")}function yt(e){return e.getAttribute&&e.getAttribute("class")||""}function mt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(P)||[]}S.fn.extend({prop:function(e,t){return $(this,S.prop,e,t,1<arguments.length)},removeProp:function(e){return this.each(function(){delete this[S.propFix[e]||e]})}}),S.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&S.isXMLDoc(e)||(t=S.propFix[t]||t,i=S.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=S.find.attr(e,"tabindex");return t?parseInt(t,10):ht.test(e.nodeName)||gt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),y.optSelected||(S.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),S.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){S.propFix[this.toLowerCase()]=this}),S.fn.extend({addClass:function(t){var e,n,r,i,o,a,s,u=0;if(m(t))return this.each(function(e){S(this).addClass(t.call(this,e,yt(this)))});if((e=mt(t)).length)while(n=this[u++])if(i=yt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=e[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(t){var e,n,r,i,o,a,s,u=0;if(m(t))return this.each(function(e){S(this).removeClass(t.call(this,e,yt(this)))});if(!arguments.length)return this.attr("class","");if((e=mt(t)).length)while(n=this[u++])if(i=yt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=e[a++])while(-1<r.indexOf(" "+o+" "))r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(i,t){var o=typeof i,a="string"===o||Array.isArray(i);return"boolean"==typeof t&&a?t?this.addClass(i):this.removeClass(i):m(i)?this.each(function(e){S(this).toggleClass(i.call(this,e,yt(this),t),t)}):this.each(function(){var e,t,n,r;if(a){t=0,n=S(this),r=mt(i);while(e=r[t++])n.hasClass(e)?n.removeClass(e):n.addClass(e)}else void 0!==i&&"boolean"!==o||((e=yt(this))&&Y.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===i?"":Y.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&-1<(" "+vt(yt(n))+" ").indexOf(t))return!0;return!1}});var xt=/\r/g;S.fn.extend({val:function(n){var r,e,i,t=this[0];return arguments.length?(i=m(n),this.each(function(e){var t;1===this.nodeType&&(null==(t=i?n.call(this,e,S(this).val()):n)?t="":"number"==typeof t?t+="":Array.isArray(t)&&(t=S.map(t,function(e){return null==e?"":e+""})),(r=S.valHooks[this.type]||S.valHooks[this.nodeName.toLowerCase()])&&"set"in r&&void 0!==r.set(this,t,"value")||(this.value=t))})):t?(r=S.valHooks[t.type]||S.valHooks[t.nodeName.toLowerCase()])&&"get"in r&&void 0!==(e=r.get(t,"value"))?e:"string"==typeof(e=t.value)?e.replace(xt,""):null==e?"":e:void 0}}),S.extend({valHooks:{option:{get:function(e){var t=S.find.attr(e,"value");return null!=t?t:vt(S.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!A(n.parentNode,"optgroup"))){if(t=S(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=S.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=-1<S.inArray(S.valHooks.option.get(r),o))&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),S.each(["radio","checkbox"],function(){S.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=-1<S.inArray(S(e).val(),t)}},y.checkOn||(S.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),y.focusin="onfocusin"in C;var bt=/^(?:focusinfocus|focusoutblur)$/,wt=function(e){e.stopPropagation()};S.extend(S.event,{trigger:function(e,t,n,r){var i,o,a,s,u,l,c,f,p=[n||E],d=v.call(e,"type")?e.type:e,h=v.call(e,"namespace")?e.namespace.split("."):[];if(o=f=a=n=n||E,3!==n.nodeType&&8!==n.nodeType&&!bt.test(d+S.event.triggered)&&(-1<d.indexOf(".")&&(d=(h=d.split(".")).shift(),h.sort()),u=d.indexOf(":")<0&&"on"+d,(e=e[S.expando]?e:new S.Event(d,"object"==typeof e&&e)).isTrigger=r?2:3,e.namespace=h.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:S.makeArray(t,[e]),c=S.event.special[d]||{},r||!c.trigger||!1!==c.trigger.apply(n,t))){if(!r&&!c.noBubble&&!x(n)){for(s=c.delegateType||d,bt.test(s+d)||(o=o.parentNode);o;o=o.parentNode)p.push(o),a=o;a===(n.ownerDocument||E)&&p.push(a.defaultView||a.parentWindow||C)}i=0;while((o=p[i++])&&!e.isPropagationStopped())f=o,e.type=1<i?s:c.bindType||d,(l=(Y.get(o,"events")||Object.create(null))[e.type]&&Y.get(o,"handle"))&&l.apply(o,t),(l=u&&o[u])&&l.apply&&V(o)&&(e.result=l.apply(o,t),!1===e.result&&e.preventDefault());return e.type=d,r||e.isDefaultPrevented()||c._default&&!1!==c._default.apply(p.pop(),t)||!V(n)||u&&m(n[d])&&!x(n)&&((a=n[u])&&(n[u]=null),S.event.triggered=d,e.isPropagationStopped()&&f.addEventListener(d,wt),n[d](),e.isPropagationStopped()&&f.removeEventListener(d,wt),S.event.triggered=void 0,a&&(n[u]=a)),e.result}},simulate:function(e,t,n){var r=S.extend(new S.Event,n,{type:e,isSimulated:!0});S.event.trigger(r,null,t)}}),S.fn.extend({trigger:function(e,t){return this.each(function(){S.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return S.event.trigger(e,t,n,!0)}}),y.focusin||S.each({focus:"focusin",blur:"focusout"},function(n,r){var i=function(e){S.event.simulate(r,e.target,S.event.fix(e))};S.event.special[r]={setup:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r);t||e.addEventListener(n,i,!0),Y.access(e,r,(t||0)+1)},teardown:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r)-1;t?Y.access(e,r,t):(e.removeEventListener(n,i,!0),Y.remove(e,r))}}});var Tt=C.location,Ct={guid:Date.now()},Et=/\?/;S.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new C.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||S.error("Invalid XML: "+e),t};var St=/\[\]$/,kt=/\r?\n/g,At=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;function Dt(n,e,r,i){var t;if(Array.isArray(e))S.each(e,function(e,t){r||St.test(n)?i(n,t):Dt(n+"["+("object"==typeof t&&null!=t?e:"")+"]",t,r,i)});else if(r||"object"!==w(e))i(n,e);else for(t in e)Dt(n+"["+t+"]",e[t],r,i)}S.param=function(e,t){var n,r=[],i=function(e,t){var n=m(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!S.isPlainObject(e))S.each(e,function(){i(this.name,this.value)});else for(n in e)Dt(n,e[n],t,i);return r.join("&")},S.fn.extend({serialize:function(){return S.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=S.prop(this,"elements");return e?S.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!S(this).is(":disabled")&&Nt.test(this.nodeName)&&!At.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=S(this).val();return null==n?null:Array.isArray(n)?S.map(n,function(e){return{name:t.name,value:e.replace(kt,"\r\n")}}):{name:t.name,value:n.replace(kt,"\r\n")}}).get()}});var jt=/%20/g,qt=/#.*$/,Lt=/([?&])_=[^&]*/,Ht=/^(.*?):[ \t]*([^\r\n]*)$/gm,Ot=/^(?:GET|HEAD)$/,Pt=/^\/\//,Rt={},Mt={},It="*/".concat("*"),Wt=E.createElement("a");function Ft(o){return function(e,t){"string"!=typeof e&&(t=e,e="*");var n,r=0,i=e.toLowerCase().match(P)||[];if(m(t))while(n=i[r++])"+"===n[0]?(n=n.slice(1)||"*",(o[n]=o[n]||[]).unshift(t)):(o[n]=o[n]||[]).push(t)}}function Bt(t,i,o,a){var s={},u=t===Mt;function l(e){var r;return s[e]=!0,S.each(t[e]||[],function(e,t){var n=t(i,o,a);return"string"!=typeof n||u||s[n]?u?!(r=n):void 0:(i.dataTypes.unshift(n),l(n),!1)}),r}return l(i.dataTypes[0])||!s["*"]&&l("*")}function $t(e,t){var n,r,i=S.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&S.extend(!0,e,r),e}Wt.href=Tt.href,S.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Tt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Tt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":It,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":S.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?$t($t(e,S.ajaxSettings),t):$t(S.ajaxSettings,e)},ajaxPrefilter:Ft(Rt),ajaxTransport:Ft(Mt),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var c,f,p,n,d,r,h,g,i,o,v=S.ajaxSetup({},t),y=v.context||v,m=v.context&&(y.nodeType||y.jquery)?S(y):S.event,x=S.Deferred(),b=S.Callbacks("once memory"),w=v.statusCode||{},a={},s={},u="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(h){if(!n){n={};while(t=Ht.exec(p))n[t[1].toLowerCase()+" "]=(n[t[1].toLowerCase()+" "]||[]).concat(t[2])}t=n[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return h?p:null},setRequestHeader:function(e,t){return null==h&&(e=s[e.toLowerCase()]=s[e.toLowerCase()]||e,a[e]=t),this},overrideMimeType:function(e){return null==h&&(v.mimeType=e),this},statusCode:function(e){var t;if(e)if(h)T.always(e[T.status]);else for(t in e)w[t]=[w[t],e[t]];return this},abort:function(e){var t=e||u;return c&&c.abort(t),l(0,t),this}};if(x.promise(T),v.url=((e||v.url||Tt.href)+"").replace(Pt,Tt.protocol+"//"),v.type=t.method||t.type||v.method||v.type,v.dataTypes=(v.dataType||"*").toLowerCase().match(P)||[""],null==v.crossDomain){r=E.createElement("a");try{r.href=v.url,r.href=r.href,v.crossDomain=Wt.protocol+"//"+Wt.host!=r.protocol+"//"+r.host}catch(e){v.crossDomain=!0}}if(v.data&&v.processData&&"string"!=typeof v.data&&(v.data=S.param(v.data,v.traditional)),Bt(Rt,v,t,T),h)return T;for(i in(g=S.event&&v.global)&&0==S.active++&&S.event.trigger("ajaxStart"),v.type=v.type.toUpperCase(),v.hasContent=!Ot.test(v.type),f=v.url.replace(qt,""),v.hasContent?v.data&&v.processData&&0===(v.contentType||"").indexOf("application/x-www-form-urlencoded")&&(v.data=v.data.replace(jt,"+")):(o=v.url.slice(f.length),v.data&&(v.processData||"string"==typeof v.data)&&(f+=(Et.test(f)?"&":"?")+v.data,delete v.data),!1===v.cache&&(f=f.replace(Lt,"$1"),o=(Et.test(f)?"&":"?")+"_="+Ct.guid+++o),v.url=f+o),v.ifModified&&(S.lastModified[f]&&T.setRequestHeader("If-Modified-Since",S.lastModified[f]),S.etag[f]&&T.setRequestHeader("If-None-Match",S.etag[f])),(v.data&&v.hasContent&&!1!==v.contentType||t.contentType)&&T.setRequestHeader("Content-Type",v.contentType),T.setRequestHeader("Accept",v.dataTypes[0]&&v.accepts[v.dataTypes[0]]?v.accepts[v.dataTypes[0]]+("*"!==v.dataTypes[0]?", "+It+"; q=0.01":""):v.accepts["*"]),v.headers)T.setRequestHeader(i,v.headers[i]);if(v.beforeSend&&(!1===v.beforeSend.call(y,T,v)||h))return T.abort();if(u="abort",b.add(v.complete),T.done(v.success),T.fail(v.error),c=Bt(Mt,v,t,T)){if(T.readyState=1,g&&m.trigger("ajaxSend",[T,v]),h)return T;v.async&&0<v.timeout&&(d=C.setTimeout(function(){T.abort("timeout")},v.timeout));try{h=!1,c.send(a,l)}catch(e){if(h)throw e;l(-1,e)}}else l(-1,"No Transport");function l(e,t,n,r){var i,o,a,s,u,l=t;h||(h=!0,d&&C.clearTimeout(d),c=void 0,p=r||"",T.readyState=0<e?4:0,i=200<=e&&e<300||304===e,n&&(s=function(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(v,T,n)),!i&&-1<S.inArray("script",v.dataTypes)&&(v.converters["text script"]=function(){}),s=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}(v,s,T,i),i?(v.ifModified&&((u=T.getResponseHeader("Last-Modified"))&&(S.lastModified[f]=u),(u=T.getResponseHeader("etag"))&&(S.etag[f]=u)),204===e||"HEAD"===v.type?l="nocontent":304===e?l="notmodified":(l=s.state,o=s.data,i=!(a=s.error))):(a=l,!e&&l||(l="error",e<0&&(e=0))),T.status=e,T.statusText=(t||l)+"",i?x.resolveWith(y,[o,l,T]):x.rejectWith(y,[T,l,a]),T.statusCode(w),w=void 0,g&&m.trigger(i?"ajaxSuccess":"ajaxError",[T,v,i?o:a]),b.fireWith(y,[T,l]),g&&(m.trigger("ajaxComplete",[T,v]),--S.active||S.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return S.get(e,t,n,"json")},getScript:function(e,t){return S.get(e,void 0,t,"script")}}),S.each(["get","post"],function(e,i){S[i]=function(e,t,n,r){return m(t)&&(r=r||n,n=t,t=void 0),S.ajax(S.extend({url:e,type:i,dataType:r,data:t,success:n},S.isPlainObject(e)&&e))}}),S.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),S._evalUrl=function(e,t,n){return S.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){S.globalEval(e,t,n)}})},S.fn.extend({wrapAll:function(e){var t;return this[0]&&(m(e)&&(e=e.call(this[0])),t=S(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(n){return m(n)?this.each(function(e){S(this).wrapInner(n.call(this,e))}):this.each(function(){var e=S(this),t=e.contents();t.length?t.wrapAll(n):e.append(n)})},wrap:function(t){var n=m(t);return this.each(function(e){S(this).wrapAll(n?t.call(this,e):t)})},unwrap:function(e){return this.parent(e).not("body").each(function(){S(this).replaceWith(this.childNodes)}),this}}),S.expr.pseudos.hidden=function(e){return!S.expr.pseudos.visible(e)},S.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},S.ajaxSettings.xhr=function(){try{return new C.XMLHttpRequest}catch(e){}};var _t={0:200,1223:204},zt=S.ajaxSettings.xhr();y.cors=!!zt&&"withCredentials"in zt,y.ajax=zt=!!zt,S.ajaxTransport(function(i){var o,a;if(y.cors||zt&&!i.crossDomain)return{send:function(e,t){var n,r=i.xhr();if(r.open(i.type,i.url,i.async,i.username,i.password),i.xhrFields)for(n in i.xhrFields)r[n]=i.xhrFields[n];for(n in i.mimeType&&r.overrideMimeType&&r.overrideMimeType(i.mimeType),i.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest"),e)r.setRequestHeader(n,e[n]);o=function(e){return function(){o&&(o=a=r.onload=r.onerror=r.onabort=r.ontimeout=r.onreadystatechange=null,"abort"===e?r.abort():"error"===e?"number"!=typeof r.status?t(0,"error"):t(r.status,r.statusText):t(_t[r.status]||r.status,r.statusText,"text"!==(r.responseType||"text")||"string"!=typeof r.responseText?{binary:r.response}:{text:r.responseText},r.getAllResponseHeaders()))}},r.onload=o(),a=r.onerror=r.ontimeout=o("error"),void 0!==r.onabort?r.onabort=a:r.onreadystatechange=function(){4===r.readyState&&C.setTimeout(function(){o&&a()})},o=o("abort");try{r.send(i.hasContent&&i.data||null)}catch(e){if(o)throw e}},abort:function(){o&&o()}}}),S.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),S.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return S.globalEval(e),e}}}),S.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),S.ajaxTransport("script",function(n){var r,i;if(n.crossDomain||n.scriptAttrs)return{send:function(e,t){r=S("<script>").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1<s&&(r=vt(e.slice(s)),e=e.slice(0,s)),m(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),0<a.length&&S.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?S("<div>").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):("number"==typeof f.top&&(f.top+="px"),"number"==typeof f.left&&(f.left+="px"),c.css(f))}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=$e(y.pixelPosition,function(e,t){if(t)return t=Be(e,n),Me.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0<arguments.length?this.on(n,null,e,t):this.trigger(n)}});var Gt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;S.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),m(e))return r=s.call(arguments,2),(i=function(){return e.apply(t||this,r.concat(s.call(arguments)))}).guid=e.guid=e.guid||S.guid++,i},S.holdReady=function(e){e?S.readyWait++:S.ready(!0)},S.isArray=Array.isArray,S.parseJSON=JSON.parse,S.nodeName=A,S.isFunction=m,S.isWindow=x,S.camelCase=X,S.type=w,S.now=Date.now,S.isNumeric=function(e){var t=S.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},S.trim=function(e){return null==e?"":(e+"").replace(Gt,"")},"function"==typeof define&&define.amd&&define("jquery",[],function(){return S});var Yt=C.jQuery,Qt=C.$;return S.noConflict=function(e){return C.$===S&&(C.$=Qt),e&&C.jQuery===S&&(C.jQuery=Yt),S},"undefined"==typeof e&&(C.jQuery=C.$=S),S});
diff --git a/docs/sphinx_docs/_build/html/_static/language_data.js b/docs/sphinx_docs/_build/html/_static/language_data.js
new file mode 100644 (file)
index 0000000..863704b
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+ * language_data.js
+ * ~~~~~~~~~~~~~~~~
+ *
+ * This script contains the language-specific data used by searchtools.js,
+ * namely the list of stopwords, stemmer, scorer and splitter.
+ *
+ * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :license: BSD, see LICENSE for details.
+ *
+ */
+
+var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
+
+
+/* Non-minified version is copied as a separate JS file, is available */
+
+/**
+ * Porter Stemmer
+ */
+var Stemmer = function() {
+
+  var step2list = {
+    ational: 'ate',
+    tional: 'tion',
+    enci: 'ence',
+    anci: 'ance',
+    izer: 'ize',
+    bli: 'ble',
+    alli: 'al',
+    entli: 'ent',
+    eli: 'e',
+    ousli: 'ous',
+    ization: 'ize',
+    ation: 'ate',
+    ator: 'ate',
+    alism: 'al',
+    iveness: 'ive',
+    fulness: 'ful',
+    ousness: 'ous',
+    aliti: 'al',
+    iviti: 'ive',
+    biliti: 'ble',
+    logi: 'log'
+  };
+
+  var step3list = {
+    icate: 'ic',
+    ative: '',
+    alize: 'al',
+    iciti: 'ic',
+    ical: 'ic',
+    ful: '',
+    ness: ''
+  };
+
+  var c = "[^aeiou]";          // consonant
+  var v = "[aeiouy]";          // vowel
+  var C = c + "[^aeiouy]*";    // consonant sequence
+  var V = v + "[aeiou]*";      // vowel sequence
+
+  var mgr0 = "^(" + C + ")?" + V + C;                      // [C]VC... is m>0
+  var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$";    // [C]VC[V] is m=1
+  var mgr1 = "^(" + C + ")?" + V + C + V + C;              // [C]VCVC... is m>1
+  var s_v   = "^(" + C + ")?" + v;                         // vowel in stem
+
+  this.stemWord = function (w) {
+    var stem;
+    var suffix;
+    var firstch;
+    var origword = w;
+
+    if (w.length < 3)
+      return w;
+
+    var re;
+    var re2;
+    var re3;
+    var re4;
+
+    firstch = w.substr(0,1);
+    if (firstch == "y")
+      w = firstch.toUpperCase() + w.substr(1);
+
+    // Step 1a
+    re = /^(.+?)(ss|i)es$/;
+    re2 = /^(.+?)([^s])s$/;
+
+    if (re.test(w))
+      w = w.replace(re,"$1$2");
+    else if (re2.test(w))
+      w = w.replace(re2,"$1$2");
+
+    // Step 1b
+    re = /^(.+?)eed$/;
+    re2 = /^(.+?)(ed|ing)$/;
+    if (re.test(w)) {
+      var fp = re.exec(w);
+      re = new RegExp(mgr0);
+      if (re.test(fp[1])) {
+        re = /.$/;
+        w = w.replace(re,"");
+      }
+    }
+    else if (re2.test(w)) {
+      var fp = re2.exec(w);
+      stem = fp[1];
+      re2 = new RegExp(s_v);
+      if (re2.test(stem)) {
+        w = stem;
+        re2 = /(at|bl|iz)$/;
+        re3 = new RegExp("([^aeiouylsz])\\1$");
+        re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+        if (re2.test(w))
+          w = w + "e";
+        else if (re3.test(w)) {
+          re = /.$/;
+          w = w.replace(re,"");
+        }
+        else if (re4.test(w))
+          w = w + "e";
+      }
+    }
+
+    // Step 1c
+    re = /^(.+?)y$/;
+    if (re.test(w)) {
+      var fp = re.exec(w);
+      stem = fp[1];
+      re = new RegExp(s_v);
+      if (re.test(stem))
+        w = stem + "i";
+    }
+
+    // Step 2
+    re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
+    if (re.test(w)) {
+      var fp = re.exec(w);
+      stem = fp[1];
+      suffix = fp[2];
+      re = new RegExp(mgr0);
+      if (re.test(stem))
+        w = stem + step2list[suffix];
+    }
+
+    // Step 3
+    re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
+    if (re.test(w)) {
+      var fp = re.exec(w);
+      stem = fp[1];
+      suffix = fp[2];
+      re = new RegExp(mgr0);
+      if (re.test(stem))
+        w = stem + step3list[suffix];
+    }
+
+    // Step 4
+    re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
+    re2 = /^(.+?)(s|t)(ion)$/;
+    if (re.test(w)) {
+      var fp = re.exec(w);
+      stem = fp[1];
+      re = new RegExp(mgr1);
+      if (re.test(stem))
+        w = stem;
+    }
+    else if (re2.test(w)) {
+      var fp = re2.exec(w);
+      stem = fp[1] + fp[2];
+      re2 = new RegExp(mgr1);
+      if (re2.test(stem))
+        w = stem;
+    }
+
+    // Step 5
+    re = /^(.+?)e$/;
+    if (re.test(w)) {
+      var fp = re.exec(w);
+      stem = fp[1];
+      re = new RegExp(mgr1);
+      re2 = new RegExp(meq1);
+      re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+      if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
+        w = stem;
+    }
+    re = /ll$/;
+    re2 = new RegExp(mgr1);
+    if (re.test(w) && re2.test(w)) {
+      re = /.$/;
+      w = w.replace(re,"");
+    }
+
+    // and turn initial Y back to y
+    if (firstch == "y")
+      w = firstch.toLowerCase() + w.substr(1);
+    return w;
+  }
+}
+
+
+
+
+var splitChars = (function() {
+    var result = {};
+    var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
+         1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
+         2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
+         2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
+         3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
+         3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
+         4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
+         8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
+         11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
+         43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
+    var i, j, start, end;
+    for (i = 0; i < singles.length; i++) {
+        result[singles[i]] = true;
+    }
+    var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
+         [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
+         [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
+         [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
+         [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
+         [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
+         [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
+         [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
+         [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
+         [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
+         [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
+         [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
+         [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
+         [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
+         [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
+         [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
+         [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
+         [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
+         [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
+         [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
+         [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
+         [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
+         [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
+         [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
+         [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
+         [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
+         [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
+         [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
+         [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
+         [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
+         [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
+         [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
+         [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
+         [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
+         [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
+         [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
+         [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
+         [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
+         [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
+         [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
+         [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
+         [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
+         [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
+         [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
+         [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
+         [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
+         [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
+         [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
+         [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
+    for (i = 0; i < ranges.length; i++) {
+        start = ranges[i][0];
+        end = ranges[i][1];
+        for (j = start; j <= end; j++) {
+            result[j] = true;
+        }
+    }
+    return result;
+})();
+
+function splitQuery(query) {
+    var result = [];
+    var start = -1;
+    for (var i = 0; i < query.length; i++) {
+        if (splitChars[query.charCodeAt(i)]) {
+            if (start !== -1) {
+                result.push(query.slice(start, i));
+                start = -1;
+            }
+        } else if (start === -1) {
+            start = i;
+        }
+    }
+    if (start !== -1) {
+        result.push(query.slice(start));
+    }
+    return result;
+}
+
+
index 20c4814..f346859 100644 (file)
@@ -1,5 +1,10 @@
+pre { line-height: 125%; margin: 0; }
+td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; }
+td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
 .highlight .hll { background-color: #ffffcc }
-.highlight  { background: #eeffcc; }
+.highlight { background: #eeffcc; }
 .highlight .c { color: #408090; font-style: italic } /* Comment */
 .highlight .err { border: 1px solid #FF0000 } /* Error */
 .highlight .k { color: #007020; font-weight: bold } /* Keyword */
index 41b8336..002e9c4 100644 (file)
 /*
- * searchtools.js_t
+ * searchtools.js
  * ~~~~~~~~~~~~~~~~
  *
  * Sphinx JavaScript utilities for the full-text search.
  *
- * :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
  * :license: BSD, see LICENSE for details.
  *
  */
 
-
-/* Non-minified version JS is _stemmer.js if file is provided */ 
-/**
- * Porter Stemmer
- */
-var Stemmer = function() {
-
-  var step2list = {
-    ational: 'ate',
-    tional: 'tion',
-    enci: 'ence',
-    anci: 'ance',
-    izer: 'ize',
-    bli: 'ble',
-    alli: 'al',
-    entli: 'ent',
-    eli: 'e',
-    ousli: 'ous',
-    ization: 'ize',
-    ation: 'ate',
-    ator: 'ate',
-    alism: 'al',
-    iveness: 'ive',
-    fulness: 'ful',
-    ousness: 'ous',
-    aliti: 'al',
-    iviti: 'ive',
-    biliti: 'ble',
-    logi: 'log'
-  };
-
-  var step3list = {
-    icate: 'ic',
-    ative: '',
-    alize: 'al',
-    iciti: 'ic',
-    ical: 'ic',
-    ful: '',
-    ness: ''
+if (!Scorer) {
+  /**
+   * Simple result scoring code.
+   */
+  var Scorer = {
+    // Implement the following function to further tweak the score for each result
+    // The function takes a result array [filename, title, anchor, descr, score]
+    // and returns the new score.
+    /*
+    score: function(result) {
+      return result[4];
+    },
+    */
+
+    // query matches the full name of an object
+    objNameMatch: 11,
+    // or matches in the last dotted part of the object name
+    objPartialMatch: 6,
+    // Additive scores depending on the priority of the object
+    objPrio: {0:  15,   // used to be importantResults
+              1:  5,   // used to be objectResults
+              2: -5},  // used to be unimportantResults
+    //  Used when the priority is not in the mapping.
+    objPrioDefault: 0,
+
+    // query found in title
+    title: 15,
+    partialTitle: 7,
+    // query found in terms
+    term: 5,
+    partialTerm: 2
   };
-
-  var c = "[^aeiou]";          // consonant
-  var v = "[aeiouy]";          // vowel
-  var C = c + "[^aeiouy]*";    // consonant sequence
-  var V = v + "[aeiou]*";      // vowel sequence
-
-  var mgr0 = "^(" + C + ")?" + V + C;                      // [C]VC... is m>0
-  var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$";    // [C]VC[V] is m=1
-  var mgr1 = "^(" + C + ")?" + V + C + V + C;              // [C]VCVC... is m>1
-  var s_v   = "^(" + C + ")?" + v;                         // vowel in stem
-
-  this.stemWord = function (w) {
-    var stem;
-    var suffix;
-    var firstch;
-    var origword = w;
-
-    if (w.length < 3)
-      return w;
-
-    var re;
-    var re2;
-    var re3;
-    var re4;
-
-    firstch = w.substr(0,1);
-    if (firstch == "y")
-      w = firstch.toUpperCase() + w.substr(1);
-
-    // Step 1a
-    re = /^(.+?)(ss|i)es$/;
-    re2 = /^(.+?)([^s])s$/;
-
-    if (re.test(w))
-      w = w.replace(re,"$1$2");
-    else if (re2.test(w))
-      w = w.replace(re2,"$1$2");
-
-    // Step 1b
-    re = /^(.+?)eed$/;
-    re2 = /^(.+?)(ed|ing)$/;
-    if (re.test(w)) {
-      var fp = re.exec(w);
-      re = new RegExp(mgr0);
-      if (re.test(fp[1])) {
-        re = /.$/;
-        w = w.replace(re,"");
-      }
-    }
-    else if (re2.test(w)) {
-      var fp = re2.exec(w);
-      stem = fp[1];
-      re2 = new RegExp(s_v);
-      if (re2.test(stem)) {
-        w = stem;
-        re2 = /(at|bl|iz)$/;
-        re3 = new RegExp("([^aeiouylsz])\\1$");
-        re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
-        if (re2.test(w))
-          w = w + "e";
-        else if (re3.test(w)) {
-          re = /.$/;
-          w = w.replace(re,"");
-        }
-        else if (re4.test(w))
-          w = w + "e";
-      }
-    }
-
-    // Step 1c
-    re = /^(.+?)y$/;
-    if (re.test(w)) {
-      var fp = re.exec(w);
-      stem = fp[1];
-      re = new RegExp(s_v);
-      if (re.test(stem))
-        w = stem + "i";
-    }
-
-    // Step 2
-    re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
-    if (re.test(w)) {
-      var fp = re.exec(w);
-      stem = fp[1];
-      suffix = fp[2];
-      re = new RegExp(mgr0);
-      if (re.test(stem))
-        w = stem + step2list[suffix];
-    }
-
-    // Step 3
-    re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
-    if (re.test(w)) {
-      var fp = re.exec(w);
-      stem = fp[1];
-      suffix = fp[2];
-      re = new RegExp(mgr0);
-      if (re.test(stem))
-        w = stem + step3list[suffix];
-    }
-
-    // Step 4
-    re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
-    re2 = /^(.+?)(s|t)(ion)$/;
-    if (re.test(w)) {
-      var fp = re.exec(w);
-      stem = fp[1];
-      re = new RegExp(mgr1);
-      if (re.test(stem))
-        w = stem;
-    }
-    else if (re2.test(w)) {
-      var fp = re2.exec(w);
-      stem = fp[1] + fp[2];
-      re2 = new RegExp(mgr1);
-      if (re2.test(stem))
-        w = stem;
-    }
-
-    // Step 5
-    re = /^(.+?)e$/;
-    if (re.test(w)) {
-      var fp = re.exec(w);
-      stem = fp[1];
-      re = new RegExp(mgr1);
-      re2 = new RegExp(meq1);
-      re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
-      if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
-        w = stem;
-    }
-    re = /ll$/;
-    re2 = new RegExp(mgr1);
-    if (re.test(w) && re2.test(w)) {
-      re = /.$/;
-      w = w.replace(re,"");
-    }
-
-    // and turn initial Y back to y
-    if (firstch == "y")
-      w = firstch.toLowerCase() + w.substr(1);
-    return w;
-  }
 }
 
-
-
-/**
- * Simple result scoring code.
- */
-var Scorer = {
-  // Implement the following function to further tweak the score for each result
-  // The function takes a result array [filename, title, anchor, descr, score]
-  // and returns the new score.
-  /*
-  score: function(result) {
-    return result[4];
-  },
-  */
-
-  // query matches the full name of an object
-  objNameMatch: 11,
-  // or matches in the last dotted part of the object name
-  objPartialMatch: 6,
-  // Additive scores depending on the priority of the object
-  objPrio: {0:  15,   // used to be importantResults
-            1:  5,   // used to be objectResults
-            2: -5},  // used to be unimportantResults
-  //  Used when the priority is not in the mapping.
-  objPrioDefault: 0,
-
-  // query found in title
-  title: 15,
-  // query found in terms
-  term: 5
-};
-
-
-
-
-
-var splitChars = (function() {
-    var result = {};
-    var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
-         1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
-         2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
-         2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
-         3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
-         3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
-         4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
-         8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
-         11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
-         43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
-    var i, j, start, end;
-    for (i = 0; i < singles.length; i++) {
-        result[singles[i]] = true;
-    }
-    var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
-         [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
-         [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
-         [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
-         [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
-         [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
-         [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
-         [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
-         [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
-         [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
-         [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
-         [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
-         [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
-         [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
-         [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
-         [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
-         [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
-         [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
-         [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
-         [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
-         [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
-         [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
-         [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
-         [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
-         [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
-         [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
-         [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
-         [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
-         [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
-         [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
-         [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
-         [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
-         [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
-         [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
-         [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
-         [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
-         [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
-         [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
-         [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
-         [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
-         [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
-         [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
-         [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
-         [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
-         [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
-         [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
-         [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
-         [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
-         [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
-    for (i = 0; i < ranges.length; i++) {
-        start = ranges[i][0];
-        end = ranges[i][1];
-        for (j = start; j <= end; j++) {
-            result[j] = true;
-        }
-    }
-    return result;
-})();
-
-function splitQuery(query) {
-    var result = [];
-    var start = -1;
-    for (var i = 0; i < query.length; i++) {
-        if (splitChars[query.charCodeAt(i)]) {
-            if (start !== -1) {
-                result.push(query.slice(start, i));
-                start = -1;
-            }
-        } else if (start === -1) {
-            start = i;
-        }
-    }
-    if (start !== -1) {
-        result.push(query.slice(start));
-    }
-    return result;
+if (!splitQuery) {
+  function splitQuery(query) {
+    return query.split(/\s+/);
+  }
 }
 
-
-
-
 /**
  * Search Module
  */
@@ -335,6 +58,19 @@ var Search = {
   _queued_query : null,
   _pulse_status : -1,
 
+  htmlToText : function(htmlString) {
+      var virtualDocument = document.implementation.createHTMLDocument('virtual');
+      var htmlElement = $(htmlString, virtualDocument);
+      htmlElement.find('.headerlink').remove();
+      docContent = htmlElement.find('[role=main]')[0];
+      if(docContent === undefined) {
+          console.warn("Content block not found. Sphinx search tries to obtain it " +
+                       "via '[role=main]'. Could you check your theme or template.");
+          return "";
+      }
+      return docContent.textContent || docContent.innerText;
+  },
+
   init : function() {
       var params = $.getQueryParameters();
       if (params.q) {
@@ -399,7 +135,7 @@ var Search = {
     this.out = $('#search-results');
     this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
     this.dots = $('<span></span>').appendTo(this.title);
-    this.status = $('<p style="display: none"></p>').appendTo(this.out);
+    this.status = $('<p class="search-summary">&nbsp;</p>').appendTo(this.out);
     this.output = $('<ul class="search"/>').appendTo(this.out);
 
     $('#search-progress').text(_('Preparing search...'));
@@ -417,7 +153,6 @@ var Search = {
    */
   query : function(query) {
     var i;
-    var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
 
     // stem the searchterms and add them to the correct list
     var stemmer = new Stemmer();
@@ -431,8 +166,7 @@ var Search = {
           objectterms.push(tmp[i].toLowerCase());
       }
 
-      if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) ||
-          tmp[i] === "") {
+      if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i] === "") {
         // skip this "word"
         continue;
       }
@@ -514,8 +248,10 @@ var Search = {
       // results left, load the summary and display it
       if (results.length) {
         var item = results.pop();
-        var listItem = $('<li style="display:none"></li>');
-        if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {
+        var listItem = $('<li></li>');
+        var requestUrl = "";
+        var linkUrl = "";
+        if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') {
           // dirhtml builder
           var dirname = item[0] + '/';
           if (dirname.match(/\/index\/$/)) {
@@ -523,44 +259,45 @@ var Search = {
           } else if (dirname == 'index/') {
             dirname = '';
           }
-          listItem.append($('<a/>').attr('href',
-            DOCUMENTATION_OPTIONS.URL_ROOT + dirname +
-            highlightstring + item[2]).html(item[1]));
+          requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + dirname;
+          linkUrl = requestUrl;
+
         } else {
           // normal html builders
-          listItem.append($('<a/>').attr('href',
-            item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
-            highlightstring + item[2]).html(item[1]));
+          requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX;
+          linkUrl = item[0] + DOCUMENTATION_OPTIONS.LINK_SUFFIX;
         }
+        listItem.append($('<a/>').attr('href',
+            linkUrl +
+            highlightstring + item[2]).html(item[1]));
         if (item[3]) {
           listItem.append($('<span> (' + item[3] + ')</span>'));
           Search.output.append(listItem);
-          listItem.slideDown(5, function() {
+          setTimeout(function() {
             displayNextItem();
-          });
+          }, 5);
         } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
-          var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX;
-          if (suffix === undefined) {
-            suffix = '.txt';
-          }
-          $.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix),
+          $.ajax({url: requestUrl,
                   dataType: "text",
                   complete: function(jqxhr, textstatus) {
                     var data = jqxhr.responseText;
                     if (data !== '' && data !== undefined) {
-                      listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
+                      var summary = Search.makeSearchSummary(data, searchterms, hlterms);
+                      if (summary) {
+                        listItem.append(summary);
+                      }
                     }
                     Search.output.append(listItem);
-                    listItem.slideDown(5, function() {
+                    setTimeout(function() {
                       displayNextItem();
-                    });
+                    }, 5);
                   }});
         } else {
           // no source available, just display title
           Search.output.append(listItem);
-          listItem.slideDown(5, function() {
+          setTimeout(function() {
             displayNextItem();
-          });
+          }, 5);
         }
       }
       // search finished, update title and status message
@@ -591,20 +328,22 @@ var Search = {
     var results = [];
 
     for (var prefix in objects) {
-      for (var name in objects[prefix]) {
+      for (var iMatch = 0; iMatch != objects[prefix].length; ++iMatch) {
+        var match = objects[prefix][iMatch];
+        var name = match[4];
         var fullname = (prefix ? prefix + '.' : '') + name;
-        if (fullname.toLowerCase().indexOf(object) > -1) {
+        var fullnameLower = fullname.toLowerCase()
+        if (fullnameLower.indexOf(object) > -1) {
           var score = 0;
-          var parts = fullname.split('.');
+          var parts = fullnameLower.split('.');
           // check for different match types: exact matches of full name or
           // "last name" (i.e. last dotted part)
-          if (fullname == object || parts[parts.length - 1] == object) {
+          if (fullnameLower == object || parts[parts.length - 1] == object) {
             score += Scorer.objNameMatch;
           // matches in last name
           } else if (parts[parts.length - 1].indexOf(object) > -1) {
             score += Scorer.objPartialMatch;
           }
-          var match = objects[prefix][name];
           var objname = objnames[match[1]][2];
           var title = titles[match[0]];
           // If more than one term searched for, we require other words to be
@@ -645,6 +384,13 @@ var Search = {
   },
 
   /**
+   * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+   */
+  escapeRegExp : function(string) {
+    return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
+  },
+
+  /**
    * search for full-text terms in the index
    */
   performTermsSearch : function(searchterms, excluded, terms, titleterms) {
@@ -665,6 +411,20 @@ var Search = {
         {files: terms[word], score: Scorer.term},
         {files: titleterms[word], score: Scorer.title}
       ];
+      // add support for partial matches
+      if (word.length > 2) {
+        var word_regex = this.escapeRegExp(word);
+        for (var w in terms) {
+          if (w.match(word_regex) && !terms[word]) {
+            _o.push({files: terms[w], score: Scorer.partialTerm})
+          }
+        }
+        for (var w in titleterms) {
+          if (w.match(word_regex) && !titleterms[word]) {
+              _o.push({files: titleterms[w], score: Scorer.partialTitle})
+          }
+        }
+      }
 
       // no match but word was a required one
       if ($u.every(_o, function(o){return o.files === undefined;})) {
@@ -684,7 +444,7 @@ var Search = {
         for (j = 0; j < _files.length; j++) {
           file = _files[j];
           if (!(file in scoreMap))
-            scoreMap[file] = {}
+            scoreMap[file] = {};
           scoreMap[file][word] = o.score;
         }
       });
@@ -692,7 +452,7 @@ var Search = {
       // create the mapping
       for (j = 0; j < files.length; j++) {
         file = files[j];
-        if (file in fileMap)
+        if (file in fileMap && fileMap[file].indexOf(word) === -1)
           fileMap[file].push(word);
         else
           fileMap[file] = [word];
@@ -704,8 +464,12 @@ var Search = {
       var valid = true;
 
       // check if all requirements are matched
-      if (fileMap[file].length != searchterms.length)
-          continue;
+      var filteredTermCount = // as search terms with length < 3 are discarded: ignore
+        searchterms.filter(function(term){return term.length > 2}).length
+      if (
+        fileMap[file].length != searchterms.length &&
+        fileMap[file].length != filteredTermCount
+      ) continue;
 
       // ensure that none of the excluded terms is in the search result
       for (i = 0; i < excluded.length; i++) {
@@ -736,7 +500,11 @@ var Search = {
    * words. the first one is used to find the occurrence, the
    * latter for highlighting it.
    */
-  makeSearchSummary : function(text, keywords, hlwords) {
+  makeSearchSummary : function(htmlText, keywords, hlwords) {
+    var text = Search.htmlToText(htmlText);
+    if (text == "") {
+      return null;
+    }
     var textLower = text.toLowerCase();
     var start = 0;
     $.each(keywords, function() {
@@ -748,7 +516,7 @@ var Search = {
     var excerpt = ((start > 0) ? '...' : '') +
       $.trim(text.substr(start, 240)) +
       ((start + 240 - text.length) ? '...' : '');
-    var rv = $('<div class="context"></div>').text(excerpt);
+    var rv = $('<p class="context"></p>').text(excerpt);
     $.each(hlwords, function() {
       rv = rv.highlightText(this, 'highlighted');
     });
@@ -758,4 +526,4 @@ var Search = {
 
 $(document).ready(function() {
   Search.init();
-});
\ No newline at end of file
+});
diff --git a/docs/sphinx_docs/_build/html/_static/underscore-1.13.1.js b/docs/sphinx_docs/_build/html/_static/underscore-1.13.1.js
new file mode 100644 (file)
index 0000000..ffd77af
--- /dev/null
@@ -0,0 +1,2042 @@
+(function (global, factory) {
+  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+  typeof define === 'function' && define.amd ? define('underscore', factory) :
+  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
+    var current = global._;
+    var exports = global._ = factory();
+    exports.noConflict = function () { global._ = current; return exports; };
+  }()));
+}(this, (function () {
+  //     Underscore.js 1.13.1
+  //     https://underscorejs.org
+  //     (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
+  //     Underscore may be freely distributed under the MIT license.
+
+  // Current version.
+  var VERSION = '1.13.1';
+
+  // Establish the root object, `window` (`self`) in the browser, `global`
+  // on the server, or `this` in some virtual machines. We use `self`
+  // instead of `window` for `WebWorker` support.
+  var root = typeof self == 'object' && self.self === self && self ||
+            typeof global == 'object' && global.global === global && global ||
+            Function('return this')() ||
+            {};
+
+  // Save bytes in the minified (but not gzipped) version:
+  var ArrayProto = Array.prototype, ObjProto = Object.prototype;
+  var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
+
+  // Create quick reference variables for speed access to core prototypes.
+  var push = ArrayProto.push,
+      slice = ArrayProto.slice,
+      toString = ObjProto.toString,
+      hasOwnProperty = ObjProto.hasOwnProperty;
+
+  // Modern feature detection.
+  var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined',
+      supportsDataView = typeof DataView !== 'undefined';
+
+  // All **ECMAScript 5+** native function implementations that we hope to use
+  // are declared here.
+  var nativeIsArray = Array.isArray,
+      nativeKeys = Object.keys,
+      nativeCreate = Object.create,
+      nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;
+
+  // Create references to these builtin functions because we override them.
+  var _isNaN = isNaN,
+      _isFinite = isFinite;
+
+  // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
+  var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
+  var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
+    'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
+
+  // The largest integer that can be represented exactly.
+  var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
+
+  // Some functions take a variable number of arguments, or a few expected
+  // arguments at the beginning and then a variable number of values to operate
+  // on. This helper accumulates all remaining arguments past the function’s
+  // argument length (or an explicit `startIndex`), into an array that becomes
+  // the last argument. Similar to ES6’s "rest parameter".
+  function restArguments(func, startIndex) {
+    startIndex = startIndex == null ? func.length - 1 : +startIndex;
+    return function() {
+      var length = Math.max(arguments.length - startIndex, 0),
+          rest = Array(length),
+          index = 0;
+      for (; index < length; index++) {
+        rest[index] = arguments[index + startIndex];
+      }
+      switch (startIndex) {
+        case 0: return func.call(this, rest);
+        case 1: return func.call(this, arguments[0], rest);
+        case 2: return func.call(this, arguments[0], arguments[1], rest);
+      }
+      var args = Array(startIndex + 1);
+      for (index = 0; index < startIndex; index++) {
+        args[index] = arguments[index];
+      }
+      args[startIndex] = rest;
+      return func.apply(this, args);
+    };
+  }
+
+  // Is a given variable an object?
+  function isObject(obj) {
+    var type = typeof obj;
+    return type === 'function' || type === 'object' && !!obj;
+  }
+
+  // Is a given value equal to null?
+  function isNull(obj) {
+    return obj === null;
+  }
+
+  // Is a given variable undefined?
+  function isUndefined(obj) {
+    return obj === void 0;
+  }
+
+  // Is a given value a boolean?
+  function isBoolean(obj) {
+    return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
+  }
+
+  // Is a given value a DOM element?
+  function isElement(obj) {
+    return !!(obj && obj.nodeType === 1);
+  }
+
+  // Internal function for creating a `toString`-based type tester.
+  function tagTester(name) {
+    var tag = '[object ' + name + ']';
+    return function(obj) {
+      return toString.call(obj) === tag;
+    };
+  }
+
+  var isString = tagTester('String');
+
+  var isNumber = tagTester('Number');
+
+  var isDate = tagTester('Date');
+
+  var isRegExp = tagTester('RegExp');
+
+  var isError = tagTester('Error');
+
+  var isSymbol = tagTester('Symbol');
+
+  var isArrayBuffer = tagTester('ArrayBuffer');
+
+  var isFunction = tagTester('Function');
+
+  // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old
+  // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
+  var nodelist = root.document && root.document.childNodes;
+  if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
+    isFunction = function(obj) {
+      return typeof obj == 'function' || false;
+    };
+  }
+
+  var isFunction$1 = isFunction;
+
+  var hasObjectTag = tagTester('Object');
+
+  // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`.
+  // In IE 11, the most common among them, this problem also applies to
+  // `Map`, `WeakMap` and `Set`.
+  var hasStringTagBug = (
+        supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8)))
+      ),
+      isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map));
+
+  var isDataView = tagTester('DataView');
+
+  // In IE 10 - Edge 13, we need a different heuristic
+  // to determine whether an object is a `DataView`.
+  function ie10IsDataView(obj) {
+    return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);
+  }
+
+  var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView);
+
+  // Is a given value an array?
+  // Delegates to ECMA5's native `Array.isArray`.
+  var isArray = nativeIsArray || tagTester('Array');
+
+  // Internal function to check whether `key` is an own property name of `obj`.
+  function has$1(obj, key) {
+    return obj != null && hasOwnProperty.call(obj, key);
+  }
+
+  var isArguments = tagTester('Arguments');
+
+  // Define a fallback version of the method in browsers (ahem, IE < 9), where
+  // there isn't any inspectable "Arguments" type.
+  (function() {
+    if (!isArguments(arguments)) {
+      isArguments = function(obj) {
+        return has$1(obj, 'callee');
+      };
+    }
+  }());
+
+  var isArguments$1 = isArguments;
+
+  // Is a given object a finite number?
+  function isFinite$1(obj) {
+    return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));
+  }
+
+  // Is the given value `NaN`?
+  function isNaN$1(obj) {
+    return isNumber(obj) && _isNaN(obj);
+  }
+
+  // Predicate-generating function. Often useful outside of Underscore.
+  function constant(value) {
+    return function() {
+      return value;
+    };
+  }
+
+  // Common internal logic for `isArrayLike` and `isBufferLike`.
+  function createSizePropertyCheck(getSizeProperty) {
+    return function(collection) {
+      var sizeProperty = getSizeProperty(collection);
+      return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;
+    }
+  }
+
+  // Internal helper to generate a function to obtain property `key` from `obj`.
+  function shallowProperty(key) {
+    return function(obj) {
+      return obj == null ? void 0 : obj[key];
+    };
+  }
+
+  // Internal helper to obtain the `byteLength` property of an object.
+  var getByteLength = shallowProperty('byteLength');
+
+  // Internal helper to determine whether we should spend extensive checks against
+  // `ArrayBuffer` et al.
+  var isBufferLike = createSizePropertyCheck(getByteLength);
+
+  // Is a given value a typed array?
+  var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
+  function isTypedArray(obj) {
+    // `ArrayBuffer.isView` is the most future-proof, so use it when available.
+    // Otherwise, fall back on the above regular expression.
+    return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) :
+                  isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));
+  }
+
+  var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);
+
+  // Internal helper to obtain the `length` property of an object.
+  var getLength = shallowProperty('length');
+
+  // Internal helper to create a simple lookup structure.
+  // `collectNonEnumProps` used to depend on `_.contains`, but this led to
+  // circular imports. `emulatedSet` is a one-off solution that only works for
+  // arrays of strings.
+  function emulatedSet(keys) {
+    var hash = {};
+    for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true;
+    return {
+      contains: function(key) { return hash[key]; },
+      push: function(key) {
+        hash[key] = true;
+        return keys.push(key);
+      }
+    };
+  }
+
+  // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't
+  // be iterated by `for key in ...` and thus missed. Extends `keys` in place if
+  // needed.
+  function collectNonEnumProps(obj, keys) {
+    keys = emulatedSet(keys);
+    var nonEnumIdx = nonEnumerableProps.length;
+    var constructor = obj.constructor;
+    var proto = isFunction$1(constructor) && constructor.prototype || ObjProto;
+
+    // Constructor is a special case.
+    var prop = 'constructor';
+    if (has$1(obj, prop) && !keys.contains(prop)) keys.push(prop);
+
+    while (nonEnumIdx--) {
+      prop = nonEnumerableProps[nonEnumIdx];
+      if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) {
+        keys.push(prop);
+      }
+    }
+  }
+
+  // Retrieve the names of an object's own properties.
+  // Delegates to **ECMAScript 5**'s native `Object.keys`.
+  function keys(obj) {
+    if (!isObject(obj)) return [];
+    if (nativeKeys) return nativeKeys(obj);
+    var keys = [];
+    for (var key in obj) if (has$1(obj, key)) keys.push(key);
+    // Ahem, IE < 9.
+    if (hasEnumBug) collectNonEnumProps(obj, keys);
+    return keys;
+  }
+
+  // Is a given array, string, or object empty?
+  // An "empty" object has no enumerable own-properties.
+  function isEmpty(obj) {
+    if (obj == null) return true;
+    // Skip the more expensive `toString`-based type checks if `obj` has no
+    // `.length`.
+    var length = getLength(obj);
+    if (typeof length == 'number' && (
+      isArray(obj) || isString(obj) || isArguments$1(obj)
+    )) return length === 0;
+    return getLength(keys(obj)) === 0;
+  }
+
+  // Returns whether an object has a given set of `key:value` pairs.
+  function isMatch(object, attrs) {
+    var _keys = keys(attrs), length = _keys.length;
+    if (object == null) return !length;
+    var obj = Object(object);
+    for (var i = 0; i < length; i++) {
+      var key = _keys[i];
+      if (attrs[key] !== obj[key] || !(key in obj)) return false;
+    }
+    return true;
+  }
+
+  // If Underscore is called as a function, it returns a wrapped object that can
+  // be used OO-style. This wrapper holds altered versions of all functions added
+  // through `_.mixin`. Wrapped objects may be chained.
+  function _$1(obj) {
+    if (obj instanceof _$1) return obj;
+    if (!(this instanceof _$1)) return new _$1(obj);
+    this._wrapped = obj;
+  }
+
+  _$1.VERSION = VERSION;
+
+  // Extracts the result from a wrapped and chained object.
+  _$1.prototype.value = function() {
+    return this._wrapped;
+  };
+
+  // Provide unwrapping proxies for some methods used in engine operations
+  // such as arithmetic and JSON stringification.
+  _$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value;
+
+  _$1.prototype.toString = function() {
+    return String(this._wrapped);
+  };
+
+  // Internal function to wrap or shallow-copy an ArrayBuffer,
+  // typed array or DataView to a new view, reusing the buffer.
+  function toBufferView(bufferSource) {
+    return new Uint8Array(
+      bufferSource.buffer || bufferSource,
+      bufferSource.byteOffset || 0,
+      getByteLength(bufferSource)
+    );
+  }
+
+  // We use this string twice, so give it a name for minification.
+  var tagDataView = '[object DataView]';
+
+  // Internal recursive comparison function for `_.isEqual`.
+  function eq(a, b, aStack, bStack) {
+    // Identical objects are equal. `0 === -0`, but they aren't identical.
+    // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal).
+    if (a === b) return a !== 0 || 1 / a === 1 / b;
+    // `null` or `undefined` only equal to itself (strict comparison).
+    if (a == null || b == null) return false;
+    // `NaN`s are equivalent, but non-reflexive.
+    if (a !== a) return b !== b;
+    // Exhaust primitive checks
+    var type = typeof a;
+    if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
+    return deepEq(a, b, aStack, bStack);
+  }
+
+  // Internal recursive comparison function for `_.isEqual`.
+  function deepEq(a, b, aStack, bStack) {
+    // Unwrap any wrapped objects.
+    if (a instanceof _$1) a = a._wrapped;
+    if (b instanceof _$1) b = b._wrapped;
+    // Compare `[[Class]]` names.
+    var className = toString.call(a);
+    if (className !== toString.call(b)) return false;
+    // Work around a bug in IE 10 - Edge 13.
+    if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) {
+      if (!isDataView$1(b)) return false;
+      className = tagDataView;
+    }
+    switch (className) {
+      // These types are compared by value.
+      case '[object RegExp]':
+        // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
+      case '[object String]':
+        // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
+        // equivalent to `new String("5")`.
+        return '' + a === '' + b;
+      case '[object Number]':
+        // `NaN`s are equivalent, but non-reflexive.
+        // Object(NaN) is equivalent to NaN.
+        if (+a !== +a) return +b !== +b;
+        // An `egal` comparison is performed for other numeric values.
+        return +a === 0 ? 1 / +a === 1 / b : +a === +b;
+      case '[object Date]':
+      case '[object Boolean]':
+        // Coerce dates and booleans to numeric primitive values. Dates are compared by their
+        // millisecond representations. Note that invalid dates with millisecond representations
+        // of `NaN` are not equivalent.
+        return +a === +b;
+      case '[object Symbol]':
+        return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
+      case '[object ArrayBuffer]':
+      case tagDataView:
+        // Coerce to typed array so we can fall through.
+        return deepEq(toBufferView(a), toBufferView(b), aStack, bStack);
+    }
+
+    var areArrays = className === '[object Array]';
+    if (!areArrays && isTypedArray$1(a)) {
+        var byteLength = getByteLength(a);
+        if (byteLength !== getByteLength(b)) return false;
+        if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true;
+        areArrays = true;
+    }
+    if (!areArrays) {
+      if (typeof a != 'object' || typeof b != 'object') return false;
+
+      // Objects with different constructors are not equivalent, but `Object`s or `Array`s
+      // from different frames are.
+      var aCtor = a.constructor, bCtor = b.constructor;
+      if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor &&
+                               isFunction$1(bCtor) && bCtor instanceof bCtor)
+                          && ('constructor' in a && 'constructor' in b)) {
+        return false;
+      }
+    }
+    // Assume equality for cyclic structures. The algorithm for detecting cyclic
+    // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
+
+    // Initializing stack of traversed objects.
+    // It's done here since we only need them for objects and arrays comparison.
+    aStack = aStack || [];
+    bStack = bStack || [];
+    var length = aStack.length;
+    while (length--) {
+      // Linear search. Performance is inversely proportional to the number of
+      // unique nested structures.
+      if (aStack[length] === a) return bStack[length] === b;
+    }
+
+    // Add the first object to the stack of traversed objects.
+    aStack.push(a);
+    bStack.push(b);
+
+    // Recursively compare objects and arrays.
+    if (areArrays) {
+      // Compare array lengths to determine if a deep comparison is necessary.
+      length = a.length;
+      if (length !== b.length) return false;
+      // Deep compare the contents, ignoring non-numeric properties.
+      while (length--) {
+        if (!eq(a[length], b[length], aStack, bStack)) return false;
+      }
+    } else {
+      // Deep compare objects.
+      var _keys = keys(a), key;
+      length = _keys.length;
+      // Ensure that both objects contain the same number of properties before comparing deep equality.
+      if (keys(b).length !== length) return false;
+      while (length--) {
+        // Deep compare each member
+        key = _keys[length];
+        if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
+      }
+    }
+    // Remove the first object from the stack of traversed objects.
+    aStack.pop();
+    bStack.pop();
+    return true;
+  }
+
+  // Perform a deep comparison to check if two objects are equal.
+  function isEqual(a, b) {
+    return eq(a, b);
+  }
+
+  // Retrieve all the enumerable property names of an object.
+  function allKeys(obj) {
+    if (!isObject(obj)) return [];
+    var keys = [];
+    for (var key in obj) keys.push(key);
+    // Ahem, IE < 9.
+    if (hasEnumBug) collectNonEnumProps(obj, keys);
+    return keys;
+  }
+
+  // Since the regular `Object.prototype.toString` type tests don't work for
+  // some types in IE 11, we use a fingerprinting heuristic instead, based
+  // on the methods. It's not great, but it's the best we got.
+  // The fingerprint method lists are defined below.
+  function ie11fingerprint(methods) {
+    var length = getLength(methods);
+    return function(obj) {
+      if (obj == null) return false;
+      // `Map`, `WeakMap` and `Set` have no enumerable keys.
+      var keys = allKeys(obj);
+      if (getLength(keys)) return false;
+      for (var i = 0; i < length; i++) {
+        if (!isFunction$1(obj[methods[i]])) return false;
+      }
+      // If we are testing against `WeakMap`, we need to ensure that
+      // `obj` doesn't have a `forEach` method in order to distinguish
+      // it from a regular `Map`.
+      return methods !== weakMapMethods || !isFunction$1(obj[forEachName]);
+    };
+  }
+
+  // In the interest of compact minification, we write
+  // each string in the fingerprints only once.
+  var forEachName = 'forEach',
+      hasName = 'has',
+      commonInit = ['clear', 'delete'],
+      mapTail = ['get', hasName, 'set'];
+
+  // `Map`, `WeakMap` and `Set` each have slightly different
+  // combinations of the above sublists.
+  var mapMethods = commonInit.concat(forEachName, mapTail),
+      weakMapMethods = commonInit.concat(mapTail),
+      setMethods = ['add'].concat(commonInit, forEachName, hasName);
+
+  var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map');
+
+  var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap');
+
+  var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set');
+
+  var isWeakSet = tagTester('WeakSet');
+
+  // Retrieve the values of an object's properties.
+  function values(obj) {
+    var _keys = keys(obj);
+    var length = _keys.length;
+    var values = Array(length);
+    for (var i = 0; i < length; i++) {
+      values[i] = obj[_keys[i]];
+    }
+    return values;
+  }
+
+  // Convert an object into a list of `[key, value]` pairs.
+  // The opposite of `_.object` with one argument.
+  function pairs(obj) {
+    var _keys = keys(obj);
+    var length = _keys.length;
+    var pairs = Array(length);
+    for (var i = 0; i < length; i++) {
+      pairs[i] = [_keys[i], obj[_keys[i]]];
+    }
+    return pairs;
+  }
+
+  // Invert the keys and values of an object. The values must be serializable.
+  function invert(obj) {
+    var result = {};
+    var _keys = keys(obj);
+    for (var i = 0, length = _keys.length; i < length; i++) {
+      result[obj[_keys[i]]] = _keys[i];
+    }
+    return result;
+  }
+
+  // Return a sorted list of the function names available on the object.
+  function functions(obj) {
+    var names = [];
+    for (var key in obj) {
+      if (isFunction$1(obj[key])) names.push(key);
+    }
+    return names.sort();
+  }
+
+  // An internal function for creating assigner functions.
+  function createAssigner(keysFunc, defaults) {
+    return function(obj) {
+      var length = arguments.length;
+      if (defaults) obj = Object(obj);
+      if (length < 2 || obj == null) return obj;
+      for (var index = 1; index < length; index++) {
+        var source = arguments[index],
+            keys = keysFunc(source),
+            l = keys.length;
+        for (var i = 0; i < l; i++) {
+          var key = keys[i];
+          if (!defaults || obj[key] === void 0) obj[key] = source[key];
+        }
+      }
+      return obj;
+    };
+  }
+
+  // Extend a given object with all the properties in passed-in object(s).
+  var extend = createAssigner(allKeys);
+
+  // Assigns a given object with all the own properties in the passed-in
+  // object(s).
+  // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
+  var extendOwn = createAssigner(keys);
+
+  // Fill in a given object with default properties.
+  var defaults = createAssigner(allKeys, true);
+
+  // Create a naked function reference for surrogate-prototype-swapping.
+  function ctor() {
+    return function(){};
+  }
+
+  // An internal function for creating a new object that inherits from another.
+  function baseCreate(prototype) {
+    if (!isObject(prototype)) return {};
+    if (nativeCreate) return nativeCreate(prototype);
+    var Ctor = ctor();
+    Ctor.prototype = prototype;
+    var result = new Ctor;
+    Ctor.prototype = null;
+    return result;
+  }
+
+  // Creates an object that inherits from the given prototype object.
+  // If additional properties are provided then they will be added to the
+  // created object.
+  function create(prototype, props) {
+    var result = baseCreate(prototype);
+    if (props) extendOwn(result, props);
+    return result;
+  }
+
+  // Create a (shallow-cloned) duplicate of an object.
+  function clone(obj) {
+    if (!isObject(obj)) return obj;
+    return isArray(obj) ? obj.slice() : extend({}, obj);
+  }
+
+  // Invokes `interceptor` with the `obj` and then returns `obj`.
+  // The primary purpose of this method is to "tap into" a method chain, in
+  // order to perform operations on intermediate results within the chain.
+  function tap(obj, interceptor) {
+    interceptor(obj);
+    return obj;
+  }
+
+  // Normalize a (deep) property `path` to array.
+  // Like `_.iteratee`, this function can be customized.
+  function toPath$1(path) {
+    return isArray(path) ? path : [path];
+  }
+  _$1.toPath = toPath$1;
+
+  // Internal wrapper for `_.toPath` to enable minification.
+  // Similar to `cb` for `_.iteratee`.
+  function toPath(path) {
+    return _$1.toPath(path);
+  }
+
+  // Internal function to obtain a nested property in `obj` along `path`.
+  function deepGet(obj, path) {
+    var length = path.length;
+    for (var i = 0; i < length; i++) {
+      if (obj == null) return void 0;
+      obj = obj[path[i]];
+    }
+    return length ? obj : void 0;
+  }
+
+  // Get the value of the (deep) property on `path` from `object`.
+  // If any property in `path` does not exist or if the value is
+  // `undefined`, return `defaultValue` instead.
+  // The `path` is normalized through `_.toPath`.
+  function get(object, path, defaultValue) {
+    var value = deepGet(object, toPath(path));
+    return isUndefined(value) ? defaultValue : value;
+  }
+
+  // Shortcut function for checking if an object has a given property directly on
+  // itself (in other words, not on a prototype). Unlike the internal `has`
+  // function, this public version can also traverse nested properties.
+  function has(obj, path) {
+    path = toPath(path);
+    var length = path.length;
+    for (var i = 0; i < length; i++) {
+      var key = path[i];
+      if (!has$1(obj, key)) return false;
+      obj = obj[key];
+    }
+    return !!length;
+  }
+
+  // Keep the identity function around for default iteratees.
+  function identity(value) {
+    return value;
+  }
+
+  // Returns a predicate for checking whether an object has a given set of
+  // `key:value` pairs.
+  function matcher(attrs) {
+    attrs = extendOwn({}, attrs);
+    return function(obj) {
+      return isMatch(obj, attrs);
+    };
+  }
+
+  // Creates a function that, when passed an object, will traverse that object’s
+  // properties down the given `path`, specified as an array of keys or indices.
+  function property(path) {
+    path = toPath(path);
+    return function(obj) {
+      return deepGet(obj, path);
+    };
+  }
+
+  // Internal function that returns an efficient (for current engines) version
+  // of the passed-in callback, to be repeatedly applied in other Underscore
+  // functions.
+  function optimizeCb(func, context, argCount) {
+    if (context === void 0) return func;
+    switch (argCount == null ? 3 : argCount) {
+      case 1: return function(value) {
+        return func.call(context, value);
+      };
+      // The 2-argument case is omitted because we’re not using it.
+      case 3: return function(value, index, collection) {
+        return func.call(context, value, index, collection);
+      };
+      case 4: return function(accumulator, value, index, collection) {
+        return func.call(context, accumulator, value, index, collection);
+      };
+    }
+    return function() {
+      return func.apply(context, arguments);
+    };
+  }
+
+  // An internal function to generate callbacks that can be applied to each
+  // element in a collection, returning the desired result — either `_.identity`,
+  // an arbitrary callback, a property matcher, or a property accessor.
+  function baseIteratee(value, context, argCount) {
+    if (value == null) return identity;
+    if (isFunction$1(value)) return optimizeCb(value, context, argCount);
+    if (isObject(value) && !isArray(value)) return matcher(value);
+    return property(value);
+  }
+
+  // External wrapper for our callback generator. Users may customize
+  // `_.iteratee` if they want additional predicate/iteratee shorthand styles.
+  // This abstraction hides the internal-only `argCount` argument.
+  function iteratee(value, context) {
+    return baseIteratee(value, context, Infinity);
+  }
+  _$1.iteratee = iteratee;
+
+  // The function we call internally to generate a callback. It invokes
+  // `_.iteratee` if overridden, otherwise `baseIteratee`.
+  function cb(value, context, argCount) {
+    if (_$1.iteratee !== iteratee) return _$1.iteratee(value, context);
+    return baseIteratee(value, context, argCount);
+  }
+
+  // Returns the results of applying the `iteratee` to each element of `obj`.
+  // In contrast to `_.map` it returns an object.
+  function mapObject(obj, iteratee, context) {
+    iteratee = cb(iteratee, context);
+    var _keys = keys(obj),
+        length = _keys.length,
+        results = {};
+    for (var index = 0; index < length; index++) {
+      var currentKey = _keys[index];
+      results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
+    }
+    return results;
+  }
+
+  // Predicate-generating function. Often useful outside of Underscore.
+  function noop(){}
+
+  // Generates a function for a given object that returns a given property.
+  function propertyOf(obj) {
+    if (obj == null) return noop;
+    return function(path) {
+      return get(obj, path);
+    };
+  }
+
+  // Run a function **n** times.
+  function times(n, iteratee, context) {
+    var accum = Array(Math.max(0, n));
+    iteratee = optimizeCb(iteratee, context, 1);
+    for (var i = 0; i < n; i++) accum[i] = iteratee(i);
+    return accum;
+  }
+
+  // Return a random integer between `min` and `max` (inclusive).
+  function random(min, max) {
+    if (max == null) {
+      max = min;
+      min = 0;
+    }
+    return min + Math.floor(Math.random() * (max - min + 1));
+  }
+
+  // A (possibly faster) way to get the current timestamp as an integer.
+  var now = Date.now || function() {
+    return new Date().getTime();
+  };
+
+  // Internal helper to generate functions for escaping and unescaping strings
+  // to/from HTML interpolation.
+  function createEscaper(map) {
+    var escaper = function(match) {
+      return map[match];
+    };
+    // Regexes for identifying a key that needs to be escaped.
+    var source = '(?:' + keys(map).join('|') + ')';
+    var testRegexp = RegExp(source);
+    var replaceRegexp = RegExp(source, 'g');
+    return function(string) {
+      string = string == null ? '' : '' + string;
+      return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
+    };
+  }
+
+  // Internal list of HTML entities for escaping.
+  var escapeMap = {
+    '&': '&amp;',
+    '<': '&lt;',
+    '>': '&gt;',
+    '"': '&quot;',
+    "'": '&#x27;',
+    '`': '&#x60;'
+  };
+
+  // Function for escaping strings to HTML interpolation.
+  var _escape = createEscaper(escapeMap);
+
+  // Internal list of HTML entities for unescaping.
+  var unescapeMap = invert(escapeMap);
+
+  // Function for unescaping strings from HTML interpolation.
+  var _unescape = createEscaper(unescapeMap);
+
+  // By default, Underscore uses ERB-style template delimiters. Change the
+  // following template settings to use alternative delimiters.
+  var templateSettings = _$1.templateSettings = {
+    evaluate: /<%([\s\S]+?)%>/g,
+    interpolate: /<%=([\s\S]+?)%>/g,
+    escape: /<%-([\s\S]+?)%>/g
+  };
+
+  // When customizing `_.templateSettings`, if you don't want to define an
+  // interpolation, evaluation or escaping regex, we need one that is
+  // guaranteed not to match.
+  var noMatch = /(.)^/;
+
+  // Certain characters need to be escaped so that they can be put into a
+  // string literal.
+  var escapes = {
+    "'": "'",
+    '\\': '\\',
+    '\r': 'r',
+    '\n': 'n',
+    '\u2028': 'u2028',
+    '\u2029': 'u2029'
+  };
+
+  var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
+
+  function escapeChar(match) {
+    return '\\' + escapes[match];
+  }
+
+  // In order to prevent third-party code injection through
+  // `_.templateSettings.variable`, we test it against the following regular
+  // expression. It is intentionally a bit more liberal than just matching valid
+  // identifiers, but still prevents possible loopholes through defaults or
+  // destructuring assignment.
+  var bareIdentifier = /^\s*(\w|\$)+\s*$/;
+
+  // JavaScript micro-templating, similar to John Resig's implementation.
+  // Underscore templating handles arbitrary delimiters, preserves whitespace,
+  // and correctly escapes quotes within interpolated code.
+  // NB: `oldSettings` only exists for backwards compatibility.
+  function template(text, settings, oldSettings) {
+    if (!settings && oldSettings) settings = oldSettings;
+    settings = defaults({}, settings, _$1.templateSettings);
+
+    // Combine delimiters into one regular expression via alternation.
+    var matcher = RegExp([
+      (settings.escape || noMatch).source,
+      (settings.interpolate || noMatch).source,
+      (settings.evaluate || noMatch).source
+    ].join('|') + '|$', 'g');
+
+    // Compile the template source, escaping string literals appropriately.
+    var index = 0;
+    var source = "__p+='";
+    text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
+      source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
+      index = offset + match.length;
+
+      if (escape) {
+        source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
+      } else if (interpolate) {
+        source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
+      } else if (evaluate) {
+        source += "';\n" + evaluate + "\n__p+='";
+      }
+
+      // Adobe VMs need the match returned to produce the correct offset.
+      return match;
+    });
+    source += "';\n";
+
+    var argument = settings.variable;
+    if (argument) {
+      // Insure against third-party code injection. (CVE-2021-23358)
+      if (!bareIdentifier.test(argument)) throw new Error(
+        'variable is not a bare identifier: ' + argument
+      );
+    } else {
+      // If a variable is not specified, place data values in local scope.
+      source = 'with(obj||{}){\n' + source + '}\n';
+      argument = 'obj';
+    }
+
+    source = "var __t,__p='',__j=Array.prototype.join," +
+      "print=function(){__p+=__j.call(arguments,'');};\n" +
+      source + 'return __p;\n';
+
+    var render;
+    try {
+      render = new Function(argument, '_', source);
+    } catch (e) {
+      e.source = source;
+      throw e;
+    }
+
+    var template = function(data) {
+      return render.call(this, data, _$1);
+    };
+
+    // Provide the compiled source as a convenience for precompilation.
+    template.source = 'function(' + argument + '){\n' + source + '}';
+
+    return template;
+  }
+
+  // Traverses the children of `obj` along `path`. If a child is a function, it
+  // is invoked with its parent as context. Returns the value of the final
+  // child, or `fallback` if any child is undefined.
+  function result(obj, path, fallback) {
+    path = toPath(path);
+    var length = path.length;
+    if (!length) {
+      return isFunction$1(fallback) ? fallback.call(obj) : fallback;
+    }
+    for (var i = 0; i < length; i++) {
+      var prop = obj == null ? void 0 : obj[path[i]];
+      if (prop === void 0) {
+        prop = fallback;
+        i = length; // Ensure we don't continue iterating.
+      }
+      obj = isFunction$1(prop) ? prop.call(obj) : prop;
+    }
+    return obj;
+  }
+
+  // Generate a unique integer id (unique within the entire client session).
+  // Useful for temporary DOM ids.
+  var idCounter = 0;
+  function uniqueId(prefix) {
+    var id = ++idCounter + '';
+    return prefix ? prefix + id : id;
+  }
+
+  // Start chaining a wrapped Underscore object.
+  function chain(obj) {
+    var instance = _$1(obj);
+    instance._chain = true;
+    return instance;
+  }
+
+  // Internal function to execute `sourceFunc` bound to `context` with optional
+  // `args`. Determines whether to execute a function as a constructor or as a
+  // normal function.
+  function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
+    if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
+    var self = baseCreate(sourceFunc.prototype);
+    var result = sourceFunc.apply(self, args);
+    if (isObject(result)) return result;
+    return self;
+  }
+
+  // Partially apply a function by creating a version that has had some of its
+  // arguments pre-filled, without changing its dynamic `this` context. `_` acts
+  // as a placeholder by default, allowing any combination of arguments to be
+  // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
+  var partial = restArguments(function(func, boundArgs) {
+    var placeholder = partial.placeholder;
+    var bound = function() {
+      var position = 0, length = boundArgs.length;
+      var args = Array(length);
+      for (var i = 0; i < length; i++) {
+        args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
+      }
+      while (position < arguments.length) args.push(arguments[position++]);
+      return executeBound(func, bound, this, this, args);
+    };
+    return bound;
+  });
+
+  partial.placeholder = _$1;
+
+  // Create a function bound to a given object (assigning `this`, and arguments,
+  // optionally).
+  var bind = restArguments(function(func, context, args) {
+    if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function');
+    var bound = restArguments(function(callArgs) {
+      return executeBound(func, bound, context, this, args.concat(callArgs));
+    });
+    return bound;
+  });
+
+  // Internal helper for collection methods to determine whether a collection
+  // should be iterated as an array or as an object.
+  // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
+  // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
+  var isArrayLike = createSizePropertyCheck(getLength);
+
+  // Internal implementation of a recursive `flatten` function.
+  function flatten$1(input, depth, strict, output) {
+    output = output || [];
+    if (!depth && depth !== 0) {
+      depth = Infinity;
+    } else if (depth <= 0) {
+      return output.concat(input);
+    }
+    var idx = output.length;
+    for (var i = 0, length = getLength(input); i < length; i++) {
+      var value = input[i];
+      if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {
+        // Flatten current level of array or arguments object.
+        if (depth > 1) {
+          flatten$1(value, depth - 1, strict, output);
+          idx = output.length;
+        } else {
+          var j = 0, len = value.length;
+          while (j < len) output[idx++] = value[j++];
+        }
+      } else if (!strict) {
+        output[idx++] = value;
+      }
+    }
+    return output;
+  }
+
+  // Bind a number of an object's methods to that object. Remaining arguments
+  // are the method names to be bound. Useful for ensuring that all callbacks
+  // defined on an object belong to it.
+  var bindAll = restArguments(function(obj, keys) {
+    keys = flatten$1(keys, false, false);
+    var index = keys.length;
+    if (index < 1) throw new Error('bindAll must be passed function names');
+    while (index--) {
+      var key = keys[index];
+      obj[key] = bind(obj[key], obj);
+    }
+    return obj;
+  });
+
+  // Memoize an expensive function by storing its results.
+  function memoize(func, hasher) {
+    var memoize = function(key) {
+      var cache = memoize.cache;
+      var address = '' + (hasher ? hasher.apply(this, arguments) : key);
+      if (!has$1(cache, address)) cache[address] = func.apply(this, arguments);
+      return cache[address];
+    };
+    memoize.cache = {};
+    return memoize;
+  }
+
+  // Delays a function for the given number of milliseconds, and then calls
+  // it with the arguments supplied.
+  var delay = restArguments(function(func, wait, args) {
+    return setTimeout(function() {
+      return func.apply(null, args);
+    }, wait);
+  });
+
+  // Defers a function, scheduling it to run after the current call stack has
+  // cleared.
+  var defer = partial(delay, _$1, 1);
+
+  // Returns a function, that, when invoked, will only be triggered at most once
+  // during a given window of time. Normally, the throttled function will run
+  // as much as it can, without ever going more than once per `wait` duration;
+  // but if you'd like to disable the execution on the leading edge, pass
+  // `{leading: false}`. To disable execution on the trailing edge, ditto.
+  function throttle(func, wait, options) {
+    var timeout, context, args, result;
+    var previous = 0;
+    if (!options) options = {};
+
+    var later = function() {
+      previous = options.leading === false ? 0 : now();
+      timeout = null;
+      result = func.apply(context, args);
+      if (!timeout) context = args = null;
+    };
+
+    var throttled = function() {
+      var _now = now();
+      if (!previous && options.leading === false) previous = _now;
+      var remaining = wait - (_now - previous);
+      context = this;
+      args = arguments;
+      if (remaining <= 0 || remaining > wait) {
+        if (timeout) {
+          clearTimeout(timeout);
+          timeout = null;
+        }
+        previous = _now;
+        result = func.apply(context, args);
+        if (!timeout) context = args = null;
+      } else if (!timeout && options.trailing !== false) {
+        timeout = setTimeout(later, remaining);
+      }
+      return result;
+    };
+
+    throttled.cancel = function() {
+      clearTimeout(timeout);
+      previous = 0;
+      timeout = context = args = null;
+    };
+
+    return throttled;
+  }
+
+  // When a sequence of calls of the returned function ends, the argument
+  // function is triggered. The end of a sequence is defined by the `wait`
+  // parameter. If `immediate` is passed, the argument function will be
+  // triggered at the beginning of the sequence instead of at the end.
+  function debounce(func, wait, immediate) {
+    var timeout, previous, args, result, context;
+
+    var later = function() {
+      var passed = now() - previous;
+      if (wait > passed) {
+        timeout = setTimeout(later, wait - passed);
+      } else {
+        timeout = null;
+        if (!immediate) result = func.apply(context, args);
+        // This check is needed because `func` can recursively invoke `debounced`.
+        if (!timeout) args = context = null;
+      }
+    };
+
+    var debounced = restArguments(function(_args) {
+      context = this;
+      args = _args;
+      previous = now();
+      if (!timeout) {
+        timeout = setTimeout(later, wait);
+        if (immediate) result = func.apply(context, args);
+      }
+      return result;
+    });
+
+    debounced.cancel = function() {
+      clearTimeout(timeout);
+      timeout = args = context = null;
+    };
+
+    return debounced;
+  }
+
+  // Returns the first function passed as an argument to the second,
+  // allowing you to adjust arguments, run code before and after, and
+  // conditionally execute the original function.
+  function wrap(func, wrapper) {
+    return partial(wrapper, func);
+  }
+
+  // Returns a negated version of the passed-in predicate.
+  function negate(predicate) {
+    return function() {
+      return !predicate.apply(this, arguments);
+    };
+  }
+
+  // Returns a function that is the composition of a list of functions, each
+  // consuming the return value of the function that follows.
+  function compose() {
+    var args = arguments;
+    var start = args.length - 1;
+    return function() {
+      var i = start;
+      var result = args[start].apply(this, arguments);
+      while (i--) result = args[i].call(this, result);
+      return result;
+    };
+  }
+
+  // Returns a function that will only be executed on and after the Nth call.
+  function after(times, func) {
+    return function() {
+      if (--times < 1) {
+        return func.apply(this, arguments);
+      }
+    };
+  }
+
+  // Returns a function that will only be executed up to (but not including) the
+  // Nth call.
+  function before(times, func) {
+    var memo;
+    return function() {
+      if (--times > 0) {
+        memo = func.apply(this, arguments);
+      }
+      if (times <= 1) func = null;
+      return memo;
+    };
+  }
+
+  // Returns a function that will be executed at most one time, no matter how
+  // often you call it. Useful for lazy initialization.
+  var once = partial(before, 2);
+
+  // Returns the first key on an object that passes a truth test.
+  function findKey(obj, predicate, context) {
+    predicate = cb(predicate, context);
+    var _keys = keys(obj), key;
+    for (var i = 0, length = _keys.length; i < length; i++) {
+      key = _keys[i];
+      if (predicate(obj[key], key, obj)) return key;
+    }
+  }
+
+  // Internal function to generate `_.findIndex` and `_.findLastIndex`.
+  function createPredicateIndexFinder(dir) {
+    return function(array, predicate, context) {
+      predicate = cb(predicate, context);
+      var length = getLength(array);
+      var index = dir > 0 ? 0 : length - 1;
+      for (; index >= 0 && index < length; index += dir) {
+        if (predicate(array[index], index, array)) return index;
+      }
+      return -1;
+    };
+  }
+
+  // Returns the first index on an array-like that passes a truth test.
+  var findIndex = createPredicateIndexFinder(1);
+
+  // Returns the last index on an array-like that passes a truth test.
+  var findLastIndex = createPredicateIndexFinder(-1);
+
+  // Use a comparator function to figure out the smallest index at which
+  // an object should be inserted so as to maintain order. Uses binary search.
+  function sortedIndex(array, obj, iteratee, context) {
+    iteratee = cb(iteratee, context, 1);
+    var value = iteratee(obj);
+    var low = 0, high = getLength(array);
+    while (low < high) {
+      var mid = Math.floor((low + high) / 2);
+      if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
+    }
+    return low;
+  }
+
+  // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
+  function createIndexFinder(dir, predicateFind, sortedIndex) {
+    return function(array, item, idx) {
+      var i = 0, length = getLength(array);
+      if (typeof idx == 'number') {
+        if (dir > 0) {
+          i = idx >= 0 ? idx : Math.max(idx + length, i);
+        } else {
+          length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
+        }
+      } else if (sortedIndex && idx && length) {
+        idx = sortedIndex(array, item);
+        return array[idx] === item ? idx : -1;
+      }
+      if (item !== item) {
+        idx = predicateFind(slice.call(array, i, length), isNaN$1);
+        return idx >= 0 ? idx + i : -1;
+      }
+      for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
+        if (array[idx] === item) return idx;
+      }
+      return -1;
+    };
+  }
+
+  // Return the position of the first occurrence of an item in an array,
+  // or -1 if the item is not included in the array.
+  // If the array is large and already in sort order, pass `true`
+  // for **isSorted** to use binary search.
+  var indexOf = createIndexFinder(1, findIndex, sortedIndex);
+
+  // Return the position of the last occurrence of an item in an array,
+  // or -1 if the item is not included in the array.
+  var lastIndexOf = createIndexFinder(-1, findLastIndex);
+
+  // Return the first value which passes a truth test.
+  function find(obj, predicate, context) {
+    var keyFinder = isArrayLike(obj) ? findIndex : findKey;
+    var key = keyFinder(obj, predicate, context);
+    if (key !== void 0 && key !== -1) return obj[key];
+  }
+
+  // Convenience version of a common use case of `_.find`: getting the first
+  // object containing specific `key:value` pairs.
+  function findWhere(obj, attrs) {
+    return find(obj, matcher(attrs));
+  }
+
+  // The cornerstone for collection functions, an `each`
+  // implementation, aka `forEach`.
+  // Handles raw objects in addition to array-likes. Treats all
+  // sparse array-likes as if they were dense.
+  function each(obj, iteratee, context) {
+    iteratee = optimizeCb(iteratee, context);
+    var i, length;
+    if (isArrayLike(obj)) {
+      for (i = 0, length = obj.length; i < length; i++) {
+        iteratee(obj[i], i, obj);
+      }
+    } else {
+      var _keys = keys(obj);
+      for (i = 0, length = _keys.length; i < length; i++) {
+        iteratee(obj[_keys[i]], _keys[i], obj);
+      }
+    }
+    return obj;
+  }
+
+  // Return the results of applying the iteratee to each element.
+  function map(obj, iteratee, context) {
+    iteratee = cb(iteratee, context);
+    var _keys = !isArrayLike(obj) && keys(obj),
+        length = (_keys || obj).length,
+        results = Array(length);
+    for (var index = 0; index < length; index++) {
+      var currentKey = _keys ? _keys[index] : index;
+      results[index] = iteratee(obj[currentKey], currentKey, obj);
+    }
+    return results;
+  }
+
+  // Internal helper to create a reducing function, iterating left or right.
+  function createReduce(dir) {
+    // Wrap code that reassigns argument variables in a separate function than
+    // the one that accesses `arguments.length` to avoid a perf hit. (#1991)
+    var reducer = function(obj, iteratee, memo, initial) {
+      var _keys = !isArrayLike(obj) && keys(obj),
+          length = (_keys || obj).length,
+          index = dir > 0 ? 0 : length - 1;
+      if (!initial) {
+        memo = obj[_keys ? _keys[index] : index];
+        index += dir;
+      }
+      for (; index >= 0 && index < length; index += dir) {
+        var currentKey = _keys ? _keys[index] : index;
+        memo = iteratee(memo, obj[currentKey], currentKey, obj);
+      }
+      return memo;
+    };
+
+    return function(obj, iteratee, memo, context) {
+      var initial = arguments.length >= 3;
+      return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
+    };
+  }
+
+  // **Reduce** builds up a single result from a list of values, aka `inject`,
+  // or `foldl`.
+  var reduce = createReduce(1);
+
+  // The right-associative version of reduce, also known as `foldr`.
+  var reduceRight = createReduce(-1);
+
+  // Return all the elements that pass a truth test.
+  function filter(obj, predicate, context) {
+    var results = [];
+    predicate = cb(predicate, context);
+    each(obj, function(value, index, list) {
+      if (predicate(value, index, list)) results.push(value);
+    });
+    return results;
+  }
+
+  // Return all the elements for which a truth test fails.
+  function reject(obj, predicate, context) {
+    return filter(obj, negate(cb(predicate)), context);
+  }
+
+  // Determine whether all of the elements pass a truth test.
+  function every(obj, predicate, context) {
+    predicate = cb(predicate, context);
+    var _keys = !isArrayLike(obj) && keys(obj),
+        length = (_keys || obj).length;
+    for (var index = 0; index < length; index++) {
+      var currentKey = _keys ? _keys[index] : index;
+      if (!predicate(obj[currentKey], currentKey, obj)) return false;
+    }
+    return true;
+  }
+
+  // Determine if at least one element in the object passes a truth test.
+  function some(obj, predicate, context) {
+    predicate = cb(predicate, context);
+    var _keys = !isArrayLike(obj) && keys(obj),
+        length = (_keys || obj).length;
+    for (var index = 0; index < length; index++) {
+      var currentKey = _keys ? _keys[index] : index;
+      if (predicate(obj[currentKey], currentKey, obj)) return true;
+    }
+    return false;
+  }
+
+  // Determine if the array or object contains a given item (using `===`).
+  function contains(obj, item, fromIndex, guard) {
+    if (!isArrayLike(obj)) obj = values(obj);
+    if (typeof fromIndex != 'number' || guard) fromIndex = 0;
+    return indexOf(obj, item, fromIndex) >= 0;
+  }
+
+  // Invoke a method (with arguments) on every item in a collection.
+  var invoke = restArguments(function(obj, path, args) {
+    var contextPath, func;
+    if (isFunction$1(path)) {
+      func = path;
+    } else {
+      path = toPath(path);
+      contextPath = path.slice(0, -1);
+      path = path[path.length - 1];
+    }
+    return map(obj, function(context) {
+      var method = func;
+      if (!method) {
+        if (contextPath && contextPath.length) {
+          context = deepGet(context, contextPath);
+        }
+        if (context == null) return void 0;
+        method = context[path];
+      }
+      return method == null ? method : method.apply(context, args);
+    });
+  });
+
+  // Convenience version of a common use case of `_.map`: fetching a property.
+  function pluck(obj, key) {
+    return map(obj, property(key));
+  }
+
+  // Convenience version of a common use case of `_.filter`: selecting only
+  // objects containing specific `key:value` pairs.
+  function where(obj, attrs) {
+    return filter(obj, matcher(attrs));
+  }
+
+  // Return the maximum element (or element-based computation).
+  function max(obj, iteratee, context) {
+    var result = -Infinity, lastComputed = -Infinity,
+        value, computed;
+    if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
+      obj = isArrayLike(obj) ? obj : values(obj);
+      for (var i = 0, length = obj.length; i < length; i++) {
+        value = obj[i];
+        if (value != null && value > result) {
+          result = value;
+        }
+      }
+    } else {
+      iteratee = cb(iteratee, context);
+      each(obj, function(v, index, list) {
+        computed = iteratee(v, index, list);
+        if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
+          result = v;
+          lastComputed = computed;
+        }
+      });
+    }
+    return result;
+  }
+
+  // Return the minimum element (or element-based computation).
+  function min(obj, iteratee, context) {
+    var result = Infinity, lastComputed = Infinity,
+        value, computed;
+    if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
+      obj = isArrayLike(obj) ? obj : values(obj);
+      for (var i = 0, length = obj.length; i < length; i++) {
+        value = obj[i];
+        if (value != null && value < result) {
+          result = value;
+        }
+      }
+    } else {
+      iteratee = cb(iteratee, context);
+      each(obj, function(v, index, list) {
+        computed = iteratee(v, index, list);
+        if (computed < lastComputed || computed === Infinity && result === Infinity) {
+          result = v;
+          lastComputed = computed;
+        }
+      });
+    }
+    return result;
+  }
+
+  // Sample **n** random values from a collection using the modern version of the
+  // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
+  // If **n** is not specified, returns a single random element.
+  // The internal `guard` argument allows it to work with `_.map`.
+  function sample(obj, n, guard) {
+    if (n == null || guard) {
+      if (!isArrayLike(obj)) obj = values(obj);
+      return obj[random(obj.length - 1)];
+    }
+    var sample = isArrayLike(obj) ? clone(obj) : values(obj);
+    var length = getLength(sample);
+    n = Math.max(Math.min(n, length), 0);
+    var last = length - 1;
+    for (var index = 0; index < n; index++) {
+      var rand = random(index, last);
+      var temp = sample[index];
+      sample[index] = sample[rand];
+      sample[rand] = temp;
+    }
+    return sample.slice(0, n);
+  }
+
+  // Shuffle a collection.
+  function shuffle(obj) {
+    return sample(obj, Infinity);
+  }
+
+  // Sort the object's values by a criterion produced by an iteratee.
+  function sortBy(obj, iteratee, context) {
+    var index = 0;
+    iteratee = cb(iteratee, context);
+    return pluck(map(obj, function(value, key, list) {
+      return {
+        value: value,
+        index: index++,
+        criteria: iteratee(value, key, list)
+      };
+    }).sort(function(left, right) {
+      var a = left.criteria;
+      var b = right.criteria;
+      if (a !== b) {
+        if (a > b || a === void 0) return 1;
+        if (a < b || b === void 0) return -1;
+      }
+      return left.index - right.index;
+    }), 'value');
+  }
+
+  // An internal function used for aggregate "group by" operations.
+  function group(behavior, partition) {
+    return function(obj, iteratee, context) {
+      var result = partition ? [[], []] : {};
+      iteratee = cb(iteratee, context);
+      each(obj, function(value, index) {
+        var key = iteratee(value, index, obj);
+        behavior(result, value, key);
+      });
+      return result;
+    };
+  }
+
+  // Groups the object's values by a criterion. Pass either a string attribute
+  // to group by, or a function that returns the criterion.
+  var groupBy = group(function(result, value, key) {
+    if (has$1(result, key)) result[key].push(value); else result[key] = [value];
+  });
+
+  // Indexes the object's values by a criterion, similar to `_.groupBy`, but for
+  // when you know that your index values will be unique.
+  var indexBy = group(function(result, value, key) {
+    result[key] = value;
+  });
+
+  // Counts instances of an object that group by a certain criterion. Pass
+  // either a string attribute to count by, or a function that returns the
+  // criterion.
+  var countBy = group(function(result, value, key) {
+    if (has$1(result, key)) result[key]++; else result[key] = 1;
+  });
+
+  // Split a collection into two arrays: one whose elements all pass the given
+  // truth test, and one whose elements all do not pass the truth test.
+  var partition = group(function(result, value, pass) {
+    result[pass ? 0 : 1].push(value);
+  }, true);
+
+  // Safely create a real, live array from anything iterable.
+  var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
+  function toArray(obj) {
+    if (!obj) return [];
+    if (isArray(obj)) return slice.call(obj);
+    if (isString(obj)) {
+      // Keep surrogate pair characters together.
+      return obj.match(reStrSymbol);
+    }
+    if (isArrayLike(obj)) return map(obj, identity);
+    return values(obj);
+  }
+
+  // Return the number of elements in a collection.
+  function size(obj) {
+    if (obj == null) return 0;
+    return isArrayLike(obj) ? obj.length : keys(obj).length;
+  }
+
+  // Internal `_.pick` helper function to determine whether `key` is an enumerable
+  // property name of `obj`.
+  function keyInObj(value, key, obj) {
+    return key in obj;
+  }
+
+  // Return a copy of the object only containing the allowed properties.
+  var pick = restArguments(function(obj, keys) {
+    var result = {}, iteratee = keys[0];
+    if (obj == null) return result;
+    if (isFunction$1(iteratee)) {
+      if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
+      keys = allKeys(obj);
+    } else {
+      iteratee = keyInObj;
+      keys = flatten$1(keys, false, false);
+      obj = Object(obj);
+    }
+    for (var i = 0, length = keys.length; i < length; i++) {
+      var key = keys[i];
+      var value = obj[key];
+      if (iteratee(value, key, obj)) result[key] = value;
+    }
+    return result;
+  });
+
+  // Return a copy of the object without the disallowed properties.
+  var omit = restArguments(function(obj, keys) {
+    var iteratee = keys[0], context;
+    if (isFunction$1(iteratee)) {
+      iteratee = negate(iteratee);
+      if (keys.length > 1) context = keys[1];
+    } else {
+      keys = map(flatten$1(keys, false, false), String);
+      iteratee = function(value, key) {
+        return !contains(keys, key);
+      };
+    }
+    return pick(obj, iteratee, context);
+  });
+
+  // Returns everything but the last entry of the array. Especially useful on
+  // the arguments object. Passing **n** will return all the values in
+  // the array, excluding the last N.
+  function initial(array, n, guard) {
+    return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
+  }
+
+  // Get the first element of an array. Passing **n** will return the first N
+  // values in the array. The **guard** check allows it to work with `_.map`.
+  function first(array, n, guard) {
+    if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
+    if (n == null || guard) return array[0];
+    return initial(array, array.length - n);
+  }
+
+  // Returns everything but the first entry of the `array`. Especially useful on
+  // the `arguments` object. Passing an **n** will return the rest N values in the
+  // `array`.
+  function rest(array, n, guard) {
+    return slice.call(array, n == null || guard ? 1 : n);
+  }
+
+  // Get the last element of an array. Passing **n** will return the last N
+  // values in the array.
+  function last(array, n, guard) {
+    if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
+    if (n == null || guard) return array[array.length - 1];
+    return rest(array, Math.max(0, array.length - n));
+  }
+
+  // Trim out all falsy values from an array.
+  function compact(array) {
+    return filter(array, Boolean);
+  }
+
+  // Flatten out an array, either recursively (by default), or up to `depth`.
+  // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
+  function flatten(array, depth) {
+    return flatten$1(array, depth, false);
+  }
+
+  // Take the difference between one array and a number of other arrays.
+  // Only the elements present in just the first array will remain.
+  var difference = restArguments(function(array, rest) {
+    rest = flatten$1(rest, true, true);
+    return filter(array, function(value){
+      return !contains(rest, value);
+    });
+  });
+
+  // Return a version of the array that does not contain the specified value(s).
+  var without = restArguments(function(array, otherArrays) {
+    return difference(array, otherArrays);
+  });
+
+  // Produce a duplicate-free version of the array. If the array has already
+  // been sorted, you have the option of using a faster algorithm.
+  // The faster algorithm will not work with an iteratee if the iteratee
+  // is not a one-to-one function, so providing an iteratee will disable
+  // the faster algorithm.
+  function uniq(array, isSorted, iteratee, context) {
+    if (!isBoolean(isSorted)) {
+      context = iteratee;
+      iteratee = isSorted;
+      isSorted = false;
+    }
+    if (iteratee != null) iteratee = cb(iteratee, context);
+    var result = [];
+    var seen = [];
+    for (var i = 0, length = getLength(array); i < length; i++) {
+      var value = array[i],
+          computed = iteratee ? iteratee(value, i, array) : value;
+      if (isSorted && !iteratee) {
+        if (!i || seen !== computed) result.push(value);
+        seen = computed;
+      } else if (iteratee) {
+        if (!contains(seen, computed)) {
+          seen.push(computed);
+          result.push(value);
+        }
+      } else if (!contains(result, value)) {
+        result.push(value);
+      }
+    }
+    return result;
+  }
+
+  // Produce an array that contains the union: each distinct element from all of
+  // the passed-in arrays.
+  var union = restArguments(function(arrays) {
+    return uniq(flatten$1(arrays, true, true));
+  });
+
+  // Produce an array that contains every item shared between all the
+  // passed-in arrays.
+  function intersection(array) {
+    var result = [];
+    var argsLength = arguments.length;
+    for (var i = 0, length = getLength(array); i < length; i++) {
+      var item = array[i];
+      if (contains(result, item)) continue;
+      var j;
+      for (j = 1; j < argsLength; j++) {
+        if (!contains(arguments[j], item)) break;
+      }
+      if (j === argsLength) result.push(item);
+    }
+    return result;
+  }
+
+  // Complement of zip. Unzip accepts an array of arrays and groups
+  // each array's elements on shared indices.
+  function unzip(array) {
+    var length = array && max(array, getLength).length || 0;
+    var result = Array(length);
+
+    for (var index = 0; index < length; index++) {
+      result[index] = pluck(array, index);
+    }
+    return result;
+  }
+
+  // Zip together multiple lists into a single array -- elements that share
+  // an index go together.
+  var zip = restArguments(unzip);
+
+  // Converts lists into objects. Pass either a single array of `[key, value]`
+  // pairs, or two parallel arrays of the same length -- one of keys, and one of
+  // the corresponding values. Passing by pairs is the reverse of `_.pairs`.
+  function object(list, values) {
+    var result = {};
+    for (var i = 0, length = getLength(list); i < length; i++) {
+      if (values) {
+        result[list[i]] = values[i];
+      } else {
+        result[list[i][0]] = list[i][1];
+      }
+    }
+    return result;
+  }
+
+  // Generate an integer Array containing an arithmetic progression. A port of
+  // the native Python `range()` function. See
+  // [the Python documentation](https://docs.python.org/library/functions.html#range).
+  function range(start, stop, step) {
+    if (stop == null) {
+      stop = start || 0;
+      start = 0;
+    }
+    if (!step) {
+      step = stop < start ? -1 : 1;
+    }
+
+    var length = Math.max(Math.ceil((stop - start) / step), 0);
+    var range = Array(length);
+
+    for (var idx = 0; idx < length; idx++, start += step) {
+      range[idx] = start;
+    }
+
+    return range;
+  }
+
+  // Chunk a single array into multiple arrays, each containing `count` or fewer
+  // items.
+  function chunk(array, count) {
+    if (count == null || count < 1) return [];
+    var result = [];
+    var i = 0, length = array.length;
+    while (i < length) {
+      result.push(slice.call(array, i, i += count));
+    }
+    return result;
+  }
+
+  // Helper function to continue chaining intermediate results.
+  function chainResult(instance, obj) {
+    return instance._chain ? _$1(obj).chain() : obj;
+  }
+
+  // Add your own custom functions to the Underscore object.
+  function mixin(obj) {
+    each(functions(obj), function(name) {
+      var func = _$1[name] = obj[name];
+      _$1.prototype[name] = function() {
+        var args = [this._wrapped];
+        push.apply(args, arguments);
+        return chainResult(this, func.apply(_$1, args));
+      };
+    });
+    return _$1;
+  }
+
+  // Add all mutator `Array` functions to the wrapper.
+  each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
+    var method = ArrayProto[name];
+    _$1.prototype[name] = function() {
+      var obj = this._wrapped;
+      if (obj != null) {
+        method.apply(obj, arguments);
+        if ((name === 'shift' || name === 'splice') && obj.length === 0) {
+          delete obj[0];
+        }
+      }
+      return chainResult(this, obj);
+    };
+  });
+
+  // Add all accessor `Array` functions to the wrapper.
+  each(['concat', 'join', 'slice'], function(name) {
+    var method = ArrayProto[name];
+    _$1.prototype[name] = function() {
+      var obj = this._wrapped;
+      if (obj != null) obj = method.apply(obj, arguments);
+      return chainResult(this, obj);
+    };
+  });
+
+  // Named Exports
+
+  var allExports = {
+    __proto__: null,
+    VERSION: VERSION,
+    restArguments: restArguments,
+    isObject: isObject,
+    isNull: isNull,
+    isUndefined: isUndefined,
+    isBoolean: isBoolean,
+    isElement: isElement,
+    isString: isString,
+    isNumber: isNumber,
+    isDate: isDate,
+    isRegExp: isRegExp,
+    isError: isError,
+    isSymbol: isSymbol,
+    isArrayBuffer: isArrayBuffer,
+    isDataView: isDataView$1,
+    isArray: isArray,
+    isFunction: isFunction$1,
+    isArguments: isArguments$1,
+    isFinite: isFinite$1,
+    isNaN: isNaN$1,
+    isTypedArray: isTypedArray$1,
+    isEmpty: isEmpty,
+    isMatch: isMatch,
+    isEqual: isEqual,
+    isMap: isMap,
+    isWeakMap: isWeakMap,
+    isSet: isSet,
+    isWeakSet: isWeakSet,
+    keys: keys,
+    allKeys: allKeys,
+    values: values,
+    pairs: pairs,
+    invert: invert,
+    functions: functions,
+    methods: functions,
+    extend: extend,
+    extendOwn: extendOwn,
+    assign: extendOwn,
+    defaults: defaults,
+    create: create,
+    clone: clone,
+    tap: tap,
+    get: get,
+    has: has,
+    mapObject: mapObject,
+    identity: identity,
+    constant: constant,
+    noop: noop,
+    toPath: toPath$1,
+    property: property,
+    propertyOf: propertyOf,
+    matcher: matcher,
+    matches: matcher,
+    times: times,
+    random: random,
+    now: now,
+    escape: _escape,
+    unescape: _unescape,
+    templateSettings: templateSettings,
+    template: template,
+    result: result,
+    uniqueId: uniqueId,
+    chain: chain,
+    iteratee: iteratee,
+    partial: partial,
+    bind: bind,
+    bindAll: bindAll,
+    memoize: memoize,
+    delay: delay,
+    defer: defer,
+    throttle: throttle,
+    debounce: debounce,
+    wrap: wrap,
+    negate: negate,
+    compose: compose,
+    after: after,
+    before: before,
+    once: once,
+    findKey: findKey,
+    findIndex: findIndex,
+    findLastIndex: findLastIndex,
+    sortedIndex: sortedIndex,
+    indexOf: indexOf,
+    lastIndexOf: lastIndexOf,
+    find: find,
+    detect: find,
+    findWhere: findWhere,
+    each: each,
+    forEach: each,
+    map: map,
+    collect: map,
+    reduce: reduce,
+    foldl: reduce,
+    inject: reduce,
+    reduceRight: reduceRight,
+    foldr: reduceRight,
+    filter: filter,
+    select: filter,
+    reject: reject,
+    every: every,
+    all: every,
+    some: some,
+    any: some,
+    contains: contains,
+    includes: contains,
+    include: contains,
+    invoke: invoke,
+    pluck: pluck,
+    where: where,
+    max: max,
+    min: min,
+    shuffle: shuffle,
+    sample: sample,
+    sortBy: sortBy,
+    groupBy: groupBy,
+    indexBy: indexBy,
+    countBy: countBy,
+    partition: partition,
+    toArray: toArray,
+    size: size,
+    pick: pick,
+    omit: omit,
+    first: first,
+    head: first,
+    take: first,
+    initial: initial,
+    last: last,
+    rest: rest,
+    tail: rest,
+    drop: rest,
+    compact: compact,
+    flatten: flatten,
+    without: without,
+    uniq: uniq,
+    unique: uniq,
+    union: union,
+    intersection: intersection,
+    difference: difference,
+    unzip: unzip,
+    transpose: unzip,
+    zip: zip,
+    object: object,
+    range: range,
+    chunk: chunk,
+    mixin: mixin,
+    'default': _$1
+  };
+
+  // Default Export
+
+  // Add all of the Underscore functions to the wrapper object.
+  var _ = mixin(allExports);
+  // Legacy Node.js API.
+  _._ = _;
+
+  return _;
+
+})));
+//# sourceMappingURL=underscore-umd.js.map
index 5b55f32..cf177d4 100644 (file)
@@ -1,31 +1,6 @@
-// Underscore.js 1.3.1
-// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
-// Underscore is freely distributable under the MIT license.
-// Portions of Underscore are inspired or borrowed from Prototype,
-// Oliver Steele's Functional, and John Resig's Micro-Templating.
-// For all details and documentation:
-// http://documentcloud.github.com/underscore
-(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
-c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
-h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
-b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==
-null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
-function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
-e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
-function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});
-return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
-c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=
-b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);
-return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,
-d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};
-var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,
-c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true:
-a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};
-b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
-1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
-b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
-b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),
-function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
-u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
-function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
-true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
+!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n="undefined"!=typeof globalThis?globalThis:n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){
+//     Underscore.js 1.13.1
+//     https://underscorejs.org
+//     (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
+//     Underscore may be freely distributed under the MIT license.
+var n="1.13.1",r="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},t=Array.prototype,e=Object.prototype,u="undefined"!=typeof Symbol?Symbol.prototype:null,o=t.push,i=t.slice,a=e.toString,f=e.hasOwnProperty,c="undefined"!=typeof ArrayBuffer,l="undefined"!=typeof DataView,s=Array.isArray,p=Object.keys,v=Object.create,h=c&&ArrayBuffer.isView,y=isNaN,d=isFinite,g=!{toString:null}.propertyIsEnumerable("toString"),b=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=Math.pow(2,53)-1;function j(n,r){return r=null==r?n.length-1:+r,function(){for(var t=Math.max(arguments.length-r,0),e=Array(t),u=0;u<t;u++)e[u]=arguments[u+r];switch(r){case 0:return n.call(this,e);case 1:return n.call(this,arguments[0],e);case 2:return n.call(this,arguments[0],arguments[1],e)}var o=Array(r+1);for(u=0;u<r;u++)o[u]=arguments[u];return o[r]=e,n.apply(this,o)}}function _(n){var r=typeof n;return"function"===r||"object"===r&&!!n}function w(n){return void 0===n}function A(n){return!0===n||!1===n||"[object Boolean]"===a.call(n)}function x(n){var r="[object "+n+"]";return function(n){return a.call(n)===r}}var S=x("String"),O=x("Number"),M=x("Date"),E=x("RegExp"),B=x("Error"),N=x("Symbol"),I=x("ArrayBuffer"),T=x("Function"),k=r.document&&r.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof k&&(T=function(n){return"function"==typeof n||!1});var D=T,R=x("Object"),F=l&&R(new DataView(new ArrayBuffer(8))),V="undefined"!=typeof Map&&R(new Map),P=x("DataView");var q=F?function(n){return null!=n&&D(n.getInt8)&&I(n.buffer)}:P,U=s||x("Array");function W(n,r){return null!=n&&f.call(n,r)}var z=x("Arguments");!function(){z(arguments)||(z=function(n){return W(n,"callee")})}();var L=z;function $(n){return O(n)&&y(n)}function C(n){return function(){return n}}function K(n){return function(r){var t=n(r);return"number"==typeof t&&t>=0&&t<=m}}function J(n){return function(r){return null==r?void 0:r[n]}}var G=J("byteLength"),H=K(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:C(!1),Y=J("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e<t;++e)r[n[e]]=!0;return{contains:function(n){return r[n]},push:function(t){return r[t]=!0,n.push(t)}}}(r);var t=b.length,u=n.constructor,o=D(u)&&u.prototype||e,i="constructor";for(W(n,i)&&!r.contains(i)&&r.push(i);t--;)(i=b[t])in n&&n[i]!==o[i]&&!r.contains(i)&&r.push(i)}function nn(n){if(!_(n))return[];if(p)return p(n);var r=[];for(var t in n)W(n,t)&&r.push(t);return g&&Z(n,r),r}function rn(n,r){var t=nn(r),e=t.length;if(null==n)return!e;for(var u=Object(n),o=0;o<e;o++){var i=t[o];if(r[i]!==u[i]||!(i in u))return!1}return!0}function tn(n){return n instanceof tn?n:this instanceof tn?void(this._wrapped=n):new tn(n)}function en(n){return new Uint8Array(n.buffer||n,n.byteOffset||0,G(n))}tn.VERSION=n,tn.prototype.value=function(){return this._wrapped},tn.prototype.valueOf=tn.prototype.toJSON=tn.prototype.value,tn.prototype.toString=function(){return String(this._wrapped)};var un="[object DataView]";function on(n,r,t,e){if(n===r)return 0!==n||1/n==1/r;if(null==n||null==r)return!1;if(n!=n)return r!=r;var o=typeof n;return("function"===o||"object"===o||"object"==typeof r)&&function n(r,t,e,o){r instanceof tn&&(r=r._wrapped);t instanceof tn&&(t=t._wrapped);var i=a.call(r);if(i!==a.call(t))return!1;if(F&&"[object Object]"==i&&q(r)){if(!q(t))return!1;i=un}switch(i){case"[object RegExp]":case"[object String]":return""+r==""+t;case"[object Number]":return+r!=+r?+t!=+t:0==+r?1/+r==1/t:+r==+t;case"[object Date]":case"[object Boolean]":return+r==+t;case"[object Symbol]":return u.valueOf.call(r)===u.valueOf.call(t);case"[object ArrayBuffer]":case un:return n(en(r),en(t),e,o)}var f="[object Array]"===i;if(!f&&X(r)){if(G(r)!==G(t))return!1;if(r.buffer===t.buffer&&r.byteOffset===t.byteOffset)return!0;f=!0}if(!f){if("object"!=typeof r||"object"!=typeof t)return!1;var c=r.constructor,l=t.constructor;if(c!==l&&!(D(c)&&c instanceof c&&D(l)&&l instanceof l)&&"constructor"in r&&"constructor"in t)return!1}o=o||[];var s=(e=e||[]).length;for(;s--;)if(e[s]===r)return o[s]===t;if(e.push(r),o.push(t),f){if((s=r.length)!==t.length)return!1;for(;s--;)if(!on(r[s],t[s],e,o))return!1}else{var p,v=nn(r);if(s=v.length,nn(t).length!==s)return!1;for(;s--;)if(p=v[s],!W(t,p)||!on(r[p],t[p],e,o))return!1}return e.pop(),o.pop(),!0}(n,r,t,e)}function an(n){if(!_(n))return[];var r=[];for(var t in n)r.push(t);return g&&Z(n,r),r}function fn(n){var r=Y(n);return function(t){if(null==t)return!1;var e=an(t);if(Y(e))return!1;for(var u=0;u<r;u++)if(!D(t[n[u]]))return!1;return n!==hn||!D(t[cn])}}var cn="forEach",ln="has",sn=["clear","delete"],pn=["get",ln,"set"],vn=sn.concat(cn,pn),hn=sn.concat(pn),yn=["add"].concat(sn,cn,ln),dn=V?fn(vn):x("Map"),gn=V?fn(hn):x("WeakMap"),bn=V?fn(yn):x("Set"),mn=x("WeakSet");function jn(n){for(var r=nn(n),t=r.length,e=Array(t),u=0;u<t;u++)e[u]=n[r[u]];return e}function _n(n){for(var r={},t=nn(n),e=0,u=t.length;e<u;e++)r[n[t[e]]]=t[e];return r}function wn(n){var r=[];for(var t in n)D(n[t])&&r.push(t);return r.sort()}function An(n,r){return function(t){var e=arguments.length;if(r&&(t=Object(t)),e<2||null==t)return t;for(var u=1;u<e;u++)for(var o=arguments[u],i=n(o),a=i.length,f=0;f<a;f++){var c=i[f];r&&void 0!==t[c]||(t[c]=o[c])}return t}}var xn=An(an),Sn=An(nn),On=An(an,!0);function Mn(n){if(!_(n))return{};if(v)return v(n);var r=function(){};r.prototype=n;var t=new r;return r.prototype=null,t}function En(n){return _(n)?U(n)?n.slice():xn({},n):n}function Bn(n){return U(n)?n:[n]}function Nn(n){return tn.toPath(n)}function In(n,r){for(var t=r.length,e=0;e<t;e++){if(null==n)return;n=n[r[e]]}return t?n:void 0}function Tn(n,r,t){var e=In(n,Nn(r));return w(e)?t:e}function kn(n){return n}function Dn(n){return n=Sn({},n),function(r){return rn(r,n)}}function Rn(n){return n=Nn(n),function(r){return In(r,n)}}function Fn(n,r,t){if(void 0===r)return n;switch(null==t?3:t){case 1:return function(t){return n.call(r,t)};case 3:return function(t,e,u){return n.call(r,t,e,u)};case 4:return function(t,e,u,o){return n.call(r,t,e,u,o)}}return function(){return n.apply(r,arguments)}}function Vn(n,r,t){return null==n?kn:D(n)?Fn(n,r,t):_(n)&&!U(n)?Dn(n):Rn(n)}function Pn(n,r){return Vn(n,r,1/0)}function qn(n,r,t){return tn.iteratee!==Pn?tn.iteratee(n,r):Vn(n,r,t)}function Un(){}function Wn(n,r){return null==r&&(r=n,n=0),n+Math.floor(Math.random()*(r-n+1))}tn.toPath=Bn,tn.iteratee=Pn;var zn=Date.now||function(){return(new Date).getTime()};function Ln(n){var r=function(r){return n[r]},t="(?:"+nn(n).join("|")+")",e=RegExp(t),u=RegExp(t,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,r):n}}var $n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},Cn=Ln($n),Kn=Ln(_n($n)),Jn=tn.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Gn=/(.)^/,Hn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Qn=/\\|'|\r|\n|\u2028|\u2029/g;function Xn(n){return"\\"+Hn[n]}var Yn=/^\s*(\w|\$)+\s*$/;var Zn=0;function nr(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var o=Mn(n.prototype),i=n.apply(o,u);return _(i)?i:o}var rr=j((function(n,r){var t=rr.placeholder,e=function(){for(var u=0,o=r.length,i=Array(o),a=0;a<o;a++)i[a]=r[a]===t?arguments[u++]:r[a];for(;u<arguments.length;)i.push(arguments[u++]);return nr(n,e,this,this,i)};return e}));rr.placeholder=tn;var tr=j((function(n,r,t){if(!D(n))throw new TypeError("Bind must be called on a function");var e=j((function(u){return nr(n,e,r,this,t.concat(u))}));return e})),er=K(Y);function ur(n,r,t,e){if(e=e||[],r||0===r){if(r<=0)return e.concat(n)}else r=1/0;for(var u=e.length,o=0,i=Y(n);o<i;o++){var a=n[o];if(er(a)&&(U(a)||L(a)))if(r>1)ur(a,r-1,t,e),u=e.length;else for(var f=0,c=a.length;f<c;)e[u++]=a[f++];else t||(e[u++]=a)}return e}var or=j((function(n,r){var t=(r=ur(r,!1,!1)).length;if(t<1)throw new Error("bindAll must be passed function names");for(;t--;){var e=r[t];n[e]=tr(n[e],n)}return n}));var ir=j((function(n,r,t){return setTimeout((function(){return n.apply(null,t)}),r)})),ar=rr(ir,tn,1);function fr(n){return function(){return!n.apply(this,arguments)}}function cr(n,r){var t;return function(){return--n>0&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}}var lr=rr(cr,2);function sr(n,r,t){r=qn(r,t);for(var e,u=nn(n),o=0,i=u.length;o<i;o++)if(r(n[e=u[o]],e,n))return e}function pr(n){return function(r,t,e){t=qn(t,e);for(var u=Y(r),o=n>0?0:u-1;o>=0&&o<u;o+=n)if(t(r[o],o,r))return o;return-1}}var vr=pr(1),hr=pr(-1);function yr(n,r,t,e){for(var u=(t=qn(t,e,1))(r),o=0,i=Y(n);o<i;){var a=Math.floor((o+i)/2);t(n[a])<u?o=a+1:i=a}return o}function dr(n,r,t){return function(e,u,o){var a=0,f=Y(e);if("number"==typeof o)n>0?a=o>=0?o:Math.max(o+f,a):f=o>=0?Math.min(o+1,f):o+f+1;else if(t&&o&&f)return e[o=t(e,u)]===u?o:-1;if(u!=u)return(o=r(i.call(e,a,f),$))>=0?o+a:-1;for(o=n>0?a:f-1;o>=0&&o<f;o+=n)if(e[o]===u)return o;return-1}}var gr=dr(1,vr,yr),br=dr(-1,hr);function mr(n,r,t){var e=(er(n)?vr:sr)(n,r,t);if(void 0!==e&&-1!==e)return n[e]}function jr(n,r,t){var e,u;if(r=Fn(r,t),er(n))for(e=0,u=n.length;e<u;e++)r(n[e],e,n);else{var o=nn(n);for(e=0,u=o.length;e<u;e++)r(n[o[e]],o[e],n)}return n}function _r(n,r,t){r=qn(r,t);for(var e=!er(n)&&nn(n),u=(e||n).length,o=Array(u),i=0;i<u;i++){var a=e?e[i]:i;o[i]=r(n[a],a,n)}return o}function wr(n){var r=function(r,t,e,u){var o=!er(r)&&nn(r),i=(o||r).length,a=n>0?0:i-1;for(u||(e=r[o?o[a]:a],a+=n);a>=0&&a<i;a+=n){var f=o?o[a]:a;e=t(e,r[f],f,r)}return e};return function(n,t,e,u){var o=arguments.length>=3;return r(n,Fn(t,u,4),e,o)}}var Ar=wr(1),xr=wr(-1);function Sr(n,r,t){var e=[];return r=qn(r,t),jr(n,(function(n,t,u){r(n,t,u)&&e.push(n)})),e}function Or(n,r,t){r=qn(r,t);for(var e=!er(n)&&nn(n),u=(e||n).length,o=0;o<u;o++){var i=e?e[o]:o;if(!r(n[i],i,n))return!1}return!0}function Mr(n,r,t){r=qn(r,t);for(var e=!er(n)&&nn(n),u=(e||n).length,o=0;o<u;o++){var i=e?e[o]:o;if(r(n[i],i,n))return!0}return!1}function Er(n,r,t,e){return er(n)||(n=jn(n)),("number"!=typeof t||e)&&(t=0),gr(n,r,t)>=0}var Br=j((function(n,r,t){var e,u;return D(r)?u=r:(r=Nn(r),e=r.slice(0,-1),r=r[r.length-1]),_r(n,(function(n){var o=u;if(!o){if(e&&e.length&&(n=In(n,e)),null==n)return;o=n[r]}return null==o?o:o.apply(n,t)}))}));function Nr(n,r){return _r(n,Rn(r))}function Ir(n,r,t){var e,u,o=-1/0,i=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=er(n)?n:jn(n)).length;a<f;a++)null!=(e=n[a])&&e>o&&(o=e);else r=qn(r,t),jr(n,(function(n,t,e){((u=r(n,t,e))>i||u===-1/0&&o===-1/0)&&(o=n,i=u)}));return o}function Tr(n,r,t){if(null==r||t)return er(n)||(n=jn(n)),n[Wn(n.length-1)];var e=er(n)?En(n):jn(n),u=Y(e);r=Math.max(Math.min(r,u),0);for(var o=u-1,i=0;i<r;i++){var a=Wn(i,o),f=e[i];e[i]=e[a],e[a]=f}return e.slice(0,r)}function kr(n,r){return function(t,e,u){var o=r?[[],[]]:{};return e=qn(e,u),jr(t,(function(r,u){var i=e(r,u,t);n(o,r,i)})),o}}var Dr=kr((function(n,r,t){W(n,t)?n[t].push(r):n[t]=[r]})),Rr=kr((function(n,r,t){n[t]=r})),Fr=kr((function(n,r,t){W(n,t)?n[t]++:n[t]=1})),Vr=kr((function(n,r,t){n[t?0:1].push(r)}),!0),Pr=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;function qr(n,r,t){return r in t}var Ur=j((function(n,r){var t={},e=r[0];if(null==n)return t;D(e)?(r.length>1&&(e=Fn(e,r[1])),r=an(n)):(e=qr,r=ur(r,!1,!1),n=Object(n));for(var u=0,o=r.length;u<o;u++){var i=r[u],a=n[i];e(a,i,n)&&(t[i]=a)}return t})),Wr=j((function(n,r){var t,e=r[0];return D(e)?(e=fr(e),r.length>1&&(t=r[1])):(r=_r(ur(r,!1,!1),String),e=function(n,t){return!Er(r,t)}),Ur(n,e,t)}));function zr(n,r,t){return i.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))}function Lr(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[0]:zr(n,n.length-r)}function $r(n,r,t){return i.call(n,null==r||t?1:r)}var Cr=j((function(n,r){return r=ur(r,!0,!0),Sr(n,(function(n){return!Er(r,n)}))})),Kr=j((function(n,r){return Cr(n,r)}));function Jr(n,r,t,e){A(r)||(e=t,t=r,r=!1),null!=t&&(t=qn(t,e));for(var u=[],o=[],i=0,a=Y(n);i<a;i++){var f=n[i],c=t?t(f,i,n):f;r&&!t?(i&&o===c||u.push(f),o=c):t?Er(o,c)||(o.push(c),u.push(f)):Er(u,f)||u.push(f)}return u}var Gr=j((function(n){return Jr(ur(n,!0,!0))}));function Hr(n){for(var r=n&&Ir(n,Y).length||0,t=Array(r),e=0;e<r;e++)t[e]=Nr(n,e);return t}var Qr=j(Hr);function Xr(n,r){return n._chain?tn(r).chain():r}function Yr(n){return jr(wn(n),(function(r){var t=tn[r]=n[r];tn.prototype[r]=function(){var n=[this._wrapped];return o.apply(n,arguments),Xr(this,t.apply(tn,n))}})),tn}jr(["pop","push","reverse","shift","sort","splice","unshift"],(function(n){var r=t[n];tn.prototype[n]=function(){var t=this._wrapped;return null!=t&&(r.apply(t,arguments),"shift"!==n&&"splice"!==n||0!==t.length||delete t[0]),Xr(this,t)}})),jr(["concat","join","slice"],(function(n){var r=t[n];tn.prototype[n]=function(){var n=this._wrapped;return null!=n&&(n=r.apply(n,arguments)),Xr(this,n)}}));var Zr=Yr({__proto__:null,VERSION:n,restArguments:j,isObject:_,isNull:function(n){return null===n},isUndefined:w,isBoolean:A,isElement:function(n){return!(!n||1!==n.nodeType)},isString:S,isNumber:O,isDate:M,isRegExp:E,isError:B,isSymbol:N,isArrayBuffer:I,isDataView:q,isArray:U,isFunction:D,isArguments:L,isFinite:function(n){return!N(n)&&d(n)&&!isNaN(parseFloat(n))},isNaN:$,isTypedArray:X,isEmpty:function(n){if(null==n)return!0;var r=Y(n);return"number"==typeof r&&(U(n)||S(n)||L(n))?0===r:0===Y(nn(n))},isMatch:rn,isEqual:function(n,r){return on(n,r)},isMap:dn,isWeakMap:gn,isSet:bn,isWeakSet:mn,keys:nn,allKeys:an,values:jn,pairs:function(n){for(var r=nn(n),t=r.length,e=Array(t),u=0;u<t;u++)e[u]=[r[u],n[r[u]]];return e},invert:_n,functions:wn,methods:wn,extend:xn,extendOwn:Sn,assign:Sn,defaults:On,create:function(n,r){var t=Mn(n);return r&&Sn(t,r),t},clone:En,tap:function(n,r){return r(n),n},get:Tn,has:function(n,r){for(var t=(r=Nn(r)).length,e=0;e<t;e++){var u=r[e];if(!W(n,u))return!1;n=n[u]}return!!t},mapObject:function(n,r,t){r=qn(r,t);for(var e=nn(n),u=e.length,o={},i=0;i<u;i++){var a=e[i];o[a]=r(n[a],a,n)}return o},identity:kn,constant:C,noop:Un,toPath:Bn,property:Rn,propertyOf:function(n){return null==n?Un:function(r){return Tn(n,r)}},matcher:Dn,matches:Dn,times:function(n,r,t){var e=Array(Math.max(0,n));r=Fn(r,t,1);for(var u=0;u<n;u++)e[u]=r(u);return e},random:Wn,now:zn,escape:Cn,unescape:Kn,templateSettings:Jn,template:function(n,r,t){!r&&t&&(r=t),r=On({},r,tn.templateSettings);var e=RegExp([(r.escape||Gn).source,(r.interpolate||Gn).source,(r.evaluate||Gn).source].join("|")+"|$","g"),u=0,o="__p+='";n.replace(e,(function(r,t,e,i,a){return o+=n.slice(u,a).replace(Qn,Xn),u=a+r.length,t?o+="'+\n((__t=("+t+"))==null?'':_.escape(__t))+\n'":e?o+="'+\n((__t=("+e+"))==null?'':__t)+\n'":i&&(o+="';\n"+i+"\n__p+='"),r})),o+="';\n";var i,a=r.variable;if(a){if(!Yn.test(a))throw new Error("variable is not a bare identifier: "+a)}else o="with(obj||{}){\n"+o+"}\n",a="obj";o="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{i=new Function(a,"_",o)}catch(n){throw n.source=o,n}var f=function(n){return i.call(this,n,tn)};return f.source="function("+a+"){\n"+o+"}",f},result:function(n,r,t){var e=(r=Nn(r)).length;if(!e)return D(t)?t.call(n):t;for(var u=0;u<e;u++){var o=null==n?void 0:n[r[u]];void 0===o&&(o=t,u=e),n=D(o)?o.call(n):o}return n},uniqueId:function(n){var r=++Zn+"";return n?n+r:r},chain:function(n){var r=tn(n);return r._chain=!0,r},iteratee:Pn,partial:rr,bind:tr,bindAll:or,memoize:function(n,r){var t=function(e){var u=t.cache,o=""+(r?r.apply(this,arguments):e);return W(u,o)||(u[o]=n.apply(this,arguments)),u[o]};return t.cache={},t},delay:ir,defer:ar,throttle:function(n,r,t){var e,u,o,i,a=0;t||(t={});var f=function(){a=!1===t.leading?0:zn(),e=null,i=n.apply(u,o),e||(u=o=null)},c=function(){var c=zn();a||!1!==t.leading||(a=c);var l=r-(c-a);return u=this,o=arguments,l<=0||l>r?(e&&(clearTimeout(e),e=null),a=c,i=n.apply(u,o),e||(u=o=null)):e||!1===t.trailing||(e=setTimeout(f,l)),i};return c.cancel=function(){clearTimeout(e),a=0,e=u=o=null},c},debounce:function(n,r,t){var e,u,o,i,a,f=function(){var c=zn()-u;r>c?e=setTimeout(f,r-c):(e=null,t||(i=n.apply(a,o)),e||(o=a=null))},c=j((function(c){return a=this,o=c,u=zn(),e||(e=setTimeout(f,r),t&&(i=n.apply(a,o))),i}));return c.cancel=function(){clearTimeout(e),e=o=a=null},c},wrap:function(n,r){return rr(r,n)},negate:fr,compose:function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},after:function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},before:cr,once:lr,findKey:sr,findIndex:vr,findLastIndex:hr,sortedIndex:yr,indexOf:gr,lastIndexOf:br,find:mr,detect:mr,findWhere:function(n,r){return mr(n,Dn(r))},each:jr,forEach:jr,map:_r,collect:_r,reduce:Ar,foldl:Ar,inject:Ar,reduceRight:xr,foldr:xr,filter:Sr,select:Sr,reject:function(n,r,t){return Sr(n,fr(qn(r)),t)},every:Or,all:Or,some:Mr,any:Mr,contains:Er,includes:Er,include:Er,invoke:Br,pluck:Nr,where:function(n,r){return Sr(n,Dn(r))},max:Ir,min:function(n,r,t){var e,u,o=1/0,i=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=er(n)?n:jn(n)).length;a<f;a++)null!=(e=n[a])&&e<o&&(o=e);else r=qn(r,t),jr(n,(function(n,t,e){((u=r(n,t,e))<i||u===1/0&&o===1/0)&&(o=n,i=u)}));return o},shuffle:function(n){return Tr(n,1/0)},sample:Tr,sortBy:function(n,r,t){var e=0;return r=qn(r,t),Nr(_r(n,(function(n,t,u){return{value:n,index:e++,criteria:r(n,t,u)}})).sort((function(n,r){var t=n.criteria,e=r.criteria;if(t!==e){if(t>e||void 0===t)return 1;if(t<e||void 0===e)return-1}return n.index-r.index})),"value")},groupBy:Dr,indexBy:Rr,countBy:Fr,partition:Vr,toArray:function(n){return n?U(n)?i.call(n):S(n)?n.match(Pr):er(n)?_r(n,kn):jn(n):[]},size:function(n){return null==n?0:er(n)?n.length:nn(n).length},pick:Ur,omit:Wr,first:Lr,head:Lr,take:Lr,initial:zr,last:function(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[n.length-1]:$r(n,Math.max(0,n.length-r))},rest:$r,tail:$r,drop:$r,compact:function(n){return Sr(n,Boolean)},flatten:function(n,r){return ur(n,r,!1)},without:Kr,uniq:Jr,unique:Jr,union:Gr,intersection:function(n){for(var r=[],t=arguments.length,e=0,u=Y(n);e<u;e++){var o=n[e];if(!Er(r,o)){var i;for(i=1;i<t&&Er(arguments[i],o);i++);i===t&&r.push(o)}}return r},difference:Cr,unzip:Hr,transpose:Hr,zip:Qr,object:function(n,r){for(var t={},e=0,u=Y(n);e<u;e++)r?t[n[e]]=r[e]:t[n[e][0]]=n[e][1];return t},range:function(n,r,t){null==r&&(r=n||0,n=0),t||(t=r<n?-1:1);for(var e=Math.max(Math.ceil((r-n)/t),0),u=Array(e),o=0;o<e;o++,n+=t)u[o]=n;return u},chunk:function(n,r){if(null==r||r<1)return[];for(var t=[],e=0,u=n.length;e<u;)t.push(i.call(n,e,e+=r));return t},mixin:Yr,default:tn});return Zr._=Zr,Zr}));
\ No newline at end of file
index 89cb1e9..7962970 100644 (file)
@@ -1,20 +1,17 @@
 
+<!DOCTYPE html>
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Index &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="#" />
     <link rel="search" title="Search" href="search.html" />
    
@@ -29,6 +26,8 @@
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
 
 </li>
       <li><a href="library.html#joy.library.disenstacken">disenstacken() (in module joy.library)</a>
 </li>
+      <li><a href="library.html#joy.library.divmod_">divmod_() (in module joy.library)</a>
+</li>
   </ul></td>
   <td style="width: 33%; vertical-align: top;"><ul>
-      <li><a href="library.html#joy.library.divmod_">divmod_() (in module joy.library)</a>
+      <li><a href="stack.html#joy.utils.stack.dnd">dnd() (in module joy.utils.stack)</a>
 </li>
       <li><a href="library.html#joy.library.drop">drop() (in module joy.library)</a>
 </li>
 </li>
       <li><a href="library.html#joy.library.infra">infra() (in module joy.library)</a>
 </li>
-  </ul></td>
-  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="library.html#joy.library.initialize">initialize() (in module joy.library)</a>
 </li>
+  </ul></td>
+  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="library.html#joy.library.inscribe">inscribe() (in module joy.library)</a>
 </li>
       <li><a href="library.html#joy.library.inscribe_">inscribe_() (in module joy.library)</a>
 </li>
+      <li><a href="joy.html#joy.joy.interp">interp() (in module joy.joy)</a>
+</li>
       <li><a href="stack.html#joy.utils.stack.iter_stack">iter_stack() (in module joy.utils.stack)</a>
 </li>
   </ul></td>
   <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="joy.html#joy.joy.joy">joy() (in module joy.joy)</a>
 </li>
-      <li><a href="joy.html#module-joy.joy">joy.joy (module)</a>
+      <li>
+    joy.joy
+
+      <ul>
+        <li><a href="joy.html#module-joy.joy">module</a>
+</li>
+      </ul></li>
+      <li>
+    joy.library
+
+      <ul>
+        <li><a href="library.html#module-joy.library">module</a>
 </li>
-      <li><a href="library.html#module-joy.library">joy.library (module)</a>
+      </ul></li>
+      <li>
+    joy.parser
+
+      <ul>
+        <li><a href="parser.html#module-joy.parser">module</a>
 </li>
+      </ul></li>
   </ul></td>
   <td style="width: 33%; vertical-align: top;"><ul>
-      <li><a href="parser.html#module-joy.parser">joy.parser (module)</a>
-</li>
-      <li><a href="library.html#module-joy.utils.generated_library">joy.utils.generated_library (module)</a>
+      <li>
+    joy.utils.generated_library
+
+      <ul>
+        <li><a href="library.html#module-joy.utils.generated_library">module</a>
 </li>
-      <li><a href="pretty.html#module-joy.utils.pretty_print">joy.utils.pretty_print (module)</a>
+      </ul></li>
+      <li>
+    joy.utils.pretty_print
+
+      <ul>
+        <li><a href="pretty.html#module-joy.utils.pretty_print">module</a>
 </li>
-      <li><a href="stack.html#module-joy.utils.stack">joy.utils.stack (module)</a>
+      </ul></li>
+      <li>
+    joy.utils.stack
+
+      <ul>
+        <li><a href="stack.html#module-joy.utils.stack">module</a>
 </li>
+      </ul></li>
   </ul></td>
 </tr></table>
 
   <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="library.html#joy.library.map_">map_() (in module joy.library)</a>
 </li>
-  </ul></td>
-  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="library.html#joy.library.max_">max_() (in module joy.library)</a>
 </li>
       <li><a href="library.html#joy.library.min_">min_() (in module joy.library)</a>
 </li>
+      <li>
+    module
+
+      <ul>
+        <li><a href="joy.html#module-joy.joy">joy.joy</a>
+</li>
+        <li><a href="library.html#module-joy.library">joy.library</a>
+</li>
+        <li><a href="parser.html#module-joy.parser">joy.parser</a>
+</li>
+        <li><a href="library.html#module-joy.utils.generated_library">joy.utils.generated_library</a>
+</li>
+        <li><a href="pretty.html#module-joy.utils.pretty_print">joy.utils.pretty_print</a>
+</li>
+        <li><a href="stack.html#module-joy.utils.stack">joy.utils.stack</a>
+</li>
+      </ul></li>
   </ul></td>
 </tr></table>
 
 </li>
       <li><a href="library.html#joy.utils.generated_library.uncons">uncons() (in module joy.utils.generated_library)</a>
 </li>
-  </ul></td>
-  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="library.html#joy.library.unique">unique() (in module joy.library)</a>
 </li>
+  </ul></td>
+  <td style="width: 33%; vertical-align: top;"><ul>
       <li><a href="library.html#joy.utils.generated_library.unit">unit() (in module joy.utils.generated_library)</a>
 </li>
+      <li><a href="joy.html#joy.joy.UnknownSymbolError">UnknownSymbolError</a>
+</li>
       <li><a href="library.html#joy.utils.generated_library.unswons">unswons() (in module joy.utils.generated_library)</a>
 </li>
   </ul></td>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 38d544d..11d58d1 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Thun 0.4.1 Documentation &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Thun: Joy in Python" href="notebooks/Intro.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="thun-release-documentation">
+  <section id="thun-release-documentation">
 <h1>Thun 0.4.1 Documentation<a class="headerlink" href="#thun-release-documentation" title="Permalink to this headline">¶</a></h1>
 <p>Thun is dialect of Joy written in Python.</p>
 <p><a class="reference external" href="https://en.wikipedia.org/wiki/Joy_(programming_language)">Joy</a> is a programming language created by Manfred von Thun that is easy to
@@ -43,17 +44,17 @@ between Thun and the originals, other than being written in Python, is
 that it works by the “Continuation-Passing Style”.</p>
 <p>Joy is:</p>
 <ul class="simple">
-<li><a class="reference external" href="https://en.wikipedia.org/wiki/Purely_functional_programming">Purely Functional</a></li>
-<li><a class="reference external" href="https://en.wikipedia.org/wiki/Stack-oriented_programming_language">Stack-based</a></li>
-<li><a class="reference external" href="https://en.wikipedia.org/wiki/Concatenative_programming_language">Concatinative</a> ( See also <a class="reference external" href="http://www.concatenative.org/wiki/view/Concatenative%20language">concatenative.org</a>)</li>
-<li><a class="reference internal" href="notebooks/Categorical.html"><span class="doc">Categorical</span></a></li>
+<li><p><a class="reference external" href="https://en.wikipedia.org/wiki/Purely_functional_programming">Purely Functional</a></p></li>
+<li><p><a class="reference external" href="https://en.wikipedia.org/wiki/Stack-oriented_programming_language">Stack-based</a></p></li>
+<li><p><a class="reference external" href="https://en.wikipedia.org/wiki/Concatenative_programming_language">Concatinative</a> ( See also <a class="reference external" href="http://www.concatenative.org/wiki/view/Concatenative%20language">concatenative.org</a>)</p></li>
+<li><p><a class="reference internal" href="notebooks/Categorical.html"><span class="doc">Categorical</span></a></p></li>
 </ul>
 <p>I hope that this package is useful in the sense that it provides an
 additional joy interpreter (the binary in the archive from La Trobe seems
 to run just fine on my modern Linux machine!)  But I also hope that you
 can read and understand the Python code and play with the implementation
 itself.</p>
-<div class="section" id="quick-start">
+<section id="quick-start">
 <h2>Quick Start<a class="headerlink" href="#quick-start" title="Permalink to this headline">¶</a></h2>
 <p>Install from <a class="reference external" href="https://pypi.org/project/Thun/">PyPI</a> in the usual way:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pip install Thun
@@ -64,17 +65,17 @@ itself.</p>
 </pre></div>
 </div>
 <p>Continue with <a class="reference internal" href="notebooks/Intro.html"><span class="doc">the introduction</span></a>.</p>
-</div>
-<div class="section" id="project-hosted-on-osdn">
+</section>
+<section id="project-hosted-on-osdn">
 <h2>Project Hosted on <a class="reference external" href="https://osdn.net/projects/joypy/">OSDN</a><a class="headerlink" href="#project-hosted-on-osdn" title="Permalink to this headline">¶</a></h2>
 <ul class="simple">
-<li><a class="reference external" href="https://osdn.net/projects/joypy/scm/hg/Joypy/tree/tip/">Source Repository</a> (Mercurial)</li>
-<li><a class="reference external" href="https://osdn.net/projects/joypy/ticket/">Bug tracker</a></li>
-<li><a class="reference external" href="https://osdn.net/projects/joypy/forums/">Forums</a></li>
-<li><a class="reference external" href="https://osdn.net/projects/joypy/lists/">Mailing list</a></li>
+<li><p><a class="reference external" href="https://osdn.net/projects/joypy/scm/hg/Joypy/tree/tip/">Source Repository</a> (Mercurial)</p></li>
+<li><p><a class="reference external" href="https://osdn.net/projects/joypy/ticket/">Bug tracker</a></p></li>
+<li><p><a class="reference external" href="https://osdn.net/projects/joypy/forums/">Forums</a></p></li>
+<li><p><a class="reference external" href="https://osdn.net/projects/joypy/lists/">Mailing list</a></p></li>
 </ul>
-</div>
-<div class="section" id="information-on-the-joy-language">
+</section>
+<section id="information-on-the-joy-language">
 <h2>Information on the Joy language<a class="headerlink" href="#information-on-the-joy-language" title="Permalink to this headline">¶</a></h2>
 <p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Joy_(programming_language)">the Wikipedia article</a> and <a class="reference external" href="http://www.kevinalbrecht.com/code/joy-mirror/index.html">Kevin Albrecht’s mirror of Manfred von Thun’s original website for the Joy Programming Language</a> for more information on the Joy language.</p>
 <p>The best source (no pun intended) for learning about Joy is the
@@ -84,8 +85,8 @@ original C interpreter, Joy language source code for various functions,
 and a great deal of fascinating material mostly written by Von Thun on
 Joy and its deeper facets as well as how to program in it and several
 interesting aspects.  It’s quite a treasure trove.</p>
-</div>
-<div class="section" id="documentation-on-thun-dialect">
+</section>
+<section id="documentation-on-thun-dialect">
 <h2>Documentation on Thun Dialect<a class="headerlink" href="#documentation-on-thun-dialect" title="Permalink to this headline">¶</a></h2>
 <p>The following is specific information for this dialect of Joy.</p>
 <div class="toctree-wrapper compound">
@@ -155,34 +156,46 @@ interesting aspects.  It’s quite a treasure trove.</p>
 </li>
 </ul>
 </div>
-</div>
-</div>
-<div class="section" id="indices-and-tables">
+</section>
+</section>
+<section id="indices-and-tables">
 <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
 <ul class="simple">
-<li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
-<li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
-<li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
+<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
+<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
+<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
 </ul>
-</div>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="#">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Thun 0.4.1 Documentation</a><ul>
-<li><a class="reference internal" href="#quick-start">Quick Start</a></li>
-<li><a class="reference internal" href="#project-hosted-on-osdn">Project Hosted on OSDN</a></li>
-<li><a class="reference internal" href="#information-on-the-joy-language">Information on the Joy language</a></li>
-<li><a class="reference internal" href="#documentation-on-thun-dialect">Documentation on Thun Dialect</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
+<h1 class="logo"><a href="#">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -191,25 +204,24 @@ interesting aspects.  It’s quite a treasure trove.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/index.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -220,7 +232,7 @@ interesting aspects.  It’s quite a treasure trove.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 4f520c6..4a5a08e 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Joy Interpreter &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Stack or Quote or Sequence or List…" href="stack.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="joy-interpreter">
+  <section id="joy-interpreter">
 <h1>Joy Interpreter<a class="headerlink" href="#joy-interpreter" title="Permalink to this headline">¶</a></h1>
-<div class="section" id="module-joy.joy">
+<section id="module-joy.joy">
 <span id="joy-joy"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.joy</span></code><a class="headerlink" href="#module-joy.joy" title="Permalink to this headline">¶</a></h2>
 <p>This module implements an interpreter for a dialect of Joy that
 attempts to stay very close to the spirit of Joy but does not precisely
 match the behaviour of the original version(s) written in C.</p>
-<dl class="function">
-<dt id="joy.joy.joy">
-<code class="descclassname">joy.joy.</code><code class="descname">joy</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em>, <em>viewer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#joy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.joy.joy" title="Permalink to this definition">¶</a></dt>
+<dl class="py exception">
+<dt class="sig sig-object py" id="joy.joy.UnknownSymbolError">
+<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">joy.joy.</span></span><span class="sig-name descname"><span class="pre">UnknownSymbolError</span></span><a class="reference internal" href="_modules/joy/joy.html#UnknownSymbolError"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.joy.UnknownSymbolError" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.joy.interp">
+<span class="sig-prename descclassname"><span class="pre">joy.joy.</span></span><span class="sig-name descname"><span class="pre">interp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#interp"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.joy.interp" title="Permalink to this definition">¶</a></dt>
+<dd><p>Simple REPL with no extra output, suitable for use in scripts.</p>
+</dd></dl>
+
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.joy.joy">
+<span class="sig-prename descclassname"><span class="pre">joy.joy.</span></span><span class="sig-name descname"><span class="pre">joy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">viewer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#joy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.joy.joy" title="Permalink to this definition">¶</a></dt>
 <dd><p>Evaluate a Joy expression on a stack.</p>
 <p>This function iterates through a sequence of terms which are either
 literals (strings, numbers, sequences of terms) or function symbols.
 Literals are put onto the stack and functions are looked up in the
-disctionary and executed.</p>
-<p>The viewer is a function that is called with the stack and expression
+dictionary and executed.</p>
+<blockquote>
+<div><p>The viewer is a function that is called with the stack and expression
 on every iteration, its return value is ignored.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
-<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
-<li><strong>expression</strong> (<em>stack</em>) – The expression to evaluate.</li>
-<li><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</li>
-<li><strong>viewer</strong> (<em>function</em>) – Optional viewer function.</li>
-</ul>
-</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(stack, (), dictionary)</p>
-</td>
-</tr>
-</tbody>
-</table>
+<dl class="field-list simple">
+<dt class="field-odd">param stack stack</dt>
+<dd class="field-odd"><p>The stack.</p>
+</dd>
+<dt class="field-even">param stack expression</dt>
+<dd class="field-even"><p>The expression to evaluate.</p>
+</dd>
+<dt class="field-odd">param dict dictionary</dt>
+<dd class="field-odd"><p>A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</p>
+</dd>
+<dt class="field-even">param function viewer</dt>
+<dd class="field-even"><p>Optional viewer function.</p>
+</dd>
+<dt class="field-odd">rtype</dt>
+<dd class="field-odd"><p>(stack, (), dictionary)</p>
+</dd>
+</dl>
+</div></blockquote>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.joy.repl">
-<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>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.joy.repl">
+<span class="sig-prename descclassname"><span class="pre">joy.joy.</span></span><span class="sig-name descname"><span class="pre">repl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#repl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.joy.repl" title="Permalink to this definition">¶</a></dt>
 <dd><p>Read-Evaluate-Print Loop</p>
 <p>Accept input and run it on the stack, loop.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
-<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
-<li><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</li>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>stack</strong> (<em>stack</em>) – The stack.</p></li>
+<li><p><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</p></li>
 </ul>
-</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
-</td>
-</tr>
-</tbody>
-</table>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>stack</p>
+</dd>
+</dl>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.joy.run">
-<code class="descclassname">joy.joy.</code><code class="descname">run</code><span class="sig-paren">(</span><em>text</em>, <em>stack</em>, <em>dictionary</em>, <em>viewer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.joy.run" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.joy.run">
+<span class="sig-prename descclassname"><span class="pre">joy.joy.</span></span><span class="sig-name descname"><span class="pre">run</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">viewer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/joy.html#run"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.joy.run" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return the stack resulting from running the Joy code text on the stack.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
-<li><strong>text</strong> (<em>str</em>) – Joy code.</li>
-<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
-<li><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</li>
-<li><strong>viewer</strong> (<em>function</em>) – Optional viewer function.</li>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>text</strong> (<em>str</em>) – Joy code.</p></li>
+<li><p><strong>stack</strong> (<em>stack</em>) – The stack.</p></li>
+<li><p><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</p></li>
+<li><p><strong>viewer</strong> (<em>function</em>) – Optional viewer function.</p></li>
 </ul>
-</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(stack, (), dictionary)</p>
-</td>
-</tr>
-</tbody>
-</table>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>(stack, (), dictionary)</p>
+</dd>
+</dl>
 </dd></dl>
 
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Joy Interpreter</a><ul>
-<li><a class="reference internal" href="#module-joy.joy"><code class="docutils literal notranslate"><span class="pre">joy.joy</span></code></a></li>
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Joy Interpreter</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#module-joy.joy"><code class="docutils literal notranslate"><span class="pre">joy.joy</span></code></a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -138,25 +163,24 @@ on every iteration, its return value is ignored.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/joy.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -167,7 +191,7 @@ on every iteration, its return value is ignored.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 6903842..03f9a10 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Functions Grouped by, er, Function with Examples &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Type Inference of Joy Expressions" href="types.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="functions-grouped-by-er-function-with-examples">
+  <section id="functions-grouped-by-er-function-with-examples">
 <h1>Functions Grouped by, er, Function with Examples<a class="headerlink" href="#functions-grouped-by-er-function-with-examples" title="Permalink to this headline">¶</a></h1>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span>
 </pre></div>
 </div>
-<div class="section" id="stack-chatter">
+<section id="stack-chatter">
 <h2>Stack Chatter<a class="headerlink" href="#stack-chatter" title="Permalink to this headline">¶</a></h2>
 <p>This is what I like to call the functions that just rearrange things on
 the stack. (One thing I want to mention is that during a hypothetical
@@ -45,53 +46,53 @@ compilation phase these “stack chatter” words effectively disappear
 because we can map the logical stack locations to registers that remain
 static for the duration of the computation. This remains to be done but
 it’s “off the shelf” technology.)</p>
-<div class="section" id="clear">
+<section id="clear">
 <h3><code class="docutils literal notranslate"><span class="pre">clear</span></code><a class="headerlink" href="#clear" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 clear&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 clear&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">nothing</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="dup-dupd">
+</section>
+<section id="dup-dupd">
 <h3><code class="docutils literal notranslate"><span class="pre">dup</span></code> <code class="docutils literal notranslate"><span class="pre">dupd</span></code><a class="headerlink" href="#dup-dupd" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 dup&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 dup&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 dupd&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 dupd&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">2</span> <span class="mi">3</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="enstacken-disenstacken-stack-unstack">
+</section>
+<section id="enstacken-disenstacken-stack-unstack">
 <h3><code class="docutils literal notranslate"><span class="pre">enstacken</span></code> <code class="docutils literal notranslate"><span class="pre">disenstacken</span></code> <code class="docutils literal notranslate"><span class="pre">stack</span></code> <code class="docutils literal notranslate"><span class="pre">unstack</span></code><a class="headerlink" href="#enstacken-disenstacken-stack-unstack" title="Permalink to this headline">¶</a></h3>
 <p>(I may have these paired up wrong. I.e. <code class="docutils literal notranslate"><span class="pre">disenstacken</span></code> should be
 <code class="docutils literal notranslate"><span class="pre">unstack</span></code> and vice versa.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 enstacken&#39;</span><span class="p">)</span> <span class="c1"># Replace the stack with a quote of itself.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 enstacken&#39;</span><span class="p">)</span> <span class="c1"># Replace the stack with a quote of itself.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;4 5 6 [3 2 1] disenstacken&#39;</span><span class="p">)</span>  <span class="c1"># Unpack a list onto the stack.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;4 5 6 [3 2 1] disenstacken&#39;</span><span class="p">)</span>  <span class="c1"># Unpack a list onto the stack.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">4</span> <span class="mi">5</span> <span class="mi">6</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 stack&#39;</span><span class="p">)</span>  <span class="c1"># Get the stack on the stack.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 stack&#39;</span><span class="p">)</span>  <span class="c1"># Get the stack on the stack.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 [4 5 6] unstack&#39;</span><span class="p">)</span>  <span class="c1"># Replace the stack with the list on top.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 [4 5 6] unstack&#39;</span><span class="p">)</span>  <span class="c1"># Replace the stack with the list on top.</span>
                             <span class="c1"># The items appear reversed but they are not,</span>
                             <span class="c1"># 4 is on the top of both the list and the stack.</span>
 </pre></div>
@@ -99,90 +100,90 @@ it’s “off the shelf” technology.)</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">6</span> <span class="mi">5</span> <span class="mi">4</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="pop-popd-popop">
+</section>
+<section id="pop-popd-popop">
 <h3><code class="docutils literal notranslate"><span class="pre">pop</span></code> <code class="docutils literal notranslate"><span class="pre">popd</span></code> <code class="docutils literal notranslate"><span class="pre">popop</span></code><a class="headerlink" href="#pop-popd-popop" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 popd&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 popd&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 popop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 popop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="roll-rolldown-roll-rollup">
+</section>
+<section id="roll-rolldown-roll-rollup">
 <h3><code class="docutils literal notranslate"><span class="pre">roll&lt;</span></code> <code class="docutils literal notranslate"><span class="pre">rolldown</span></code> <code class="docutils literal notranslate"><span class="pre">roll&gt;</span></code> <code class="docutils literal notranslate"><span class="pre">rollup</span></code><a class="headerlink" href="#roll-rolldown-roll-rollup" title="Permalink to this headline">¶</a></h3>
 <p>The “down” and “up” refer to the movement of two of the top three items
 (displacing the third.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 roll&lt;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 roll&lt;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span> <span class="mi">3</span> <span class="mi">1</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 roll&gt;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 roll&gt;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="swap">
+</section>
+<section id="swap">
 <h3><code class="docutils literal notranslate"><span class="pre">swap</span></code><a class="headerlink" href="#swap" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 swap&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 swap&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">3</span> <span class="mi">2</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="tuck-over">
+</section>
+<section id="tuck-over">
 <h3><code class="docutils literal notranslate"><span class="pre">tuck</span></code> <code class="docutils literal notranslate"><span class="pre">over</span></code><a class="headerlink" href="#tuck-over" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 tuck&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 tuck&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 over&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 over&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">2</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="unit-quoted-unquoted">
+</section>
+<section id="unit-quoted-unquoted">
 <h3><code class="docutils literal notranslate"><span class="pre">unit</span></code> <code class="docutils literal notranslate"><span class="pre">quoted</span></code> <code class="docutils literal notranslate"><span class="pre">unquoted</span></code><a class="headerlink" href="#unit-quoted-unquoted" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 unit&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 unit&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="p">[</span><span class="mi">3</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 quoted&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 quoted&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 [2] 3 unquoted&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 [2] 3 unquoted&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 [dup] 3 unquoted&#39;</span><span class="p">)</span>  <span class="c1"># Unquoting evaluates.  Be aware.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 [dup] 3 unquoted&#39;</span><span class="p">)</span>  <span class="c1"># Unquoting evaluates.  Be aware.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>              <span class="o">.</span> <span class="mi">1</span> <span class="p">[</span><span class="n">dup</span><span class="p">]</span> <span class="mi">3</span> <span class="n">unquoted</span>
@@ -197,447 +198,447 @@ it’s “off the shelf” technology.)</p>
         <span class="mi">1</span> <span class="mi">1</span> <span class="mi">3</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="list-words">
+</section>
+</section>
+<section id="list-words">
 <h2>List words<a class="headerlink" href="#list-words" title="Permalink to this headline">¶</a></h2>
-<div class="section" id="concat-swoncat-shunt">
+<section id="concat-swoncat-shunt">
 <h3><code class="docutils literal notranslate"><span class="pre">concat</span></code> <code class="docutils literal notranslate"><span class="pre">swoncat</span></code> <code class="docutils literal notranslate"><span class="pre">shunt</span></code><a class="headerlink" href="#concat-swoncat-shunt" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [4 5 6] concat&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [4 5 6] concat&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">5</span> <span class="mi">6</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [4 5 6] swoncat&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [4 5 6] swoncat&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">4</span> <span class="mi">5</span> <span class="mi">6</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [4 5 6] shunt&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [4 5 6] shunt&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">6</span> <span class="mi">5</span> <span class="mi">4</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="cons-swons-uncons">
+</section>
+<section id="cons-swons-uncons">
 <h3><code class="docutils literal notranslate"><span class="pre">cons</span></code> <code class="docutils literal notranslate"><span class="pre">swons</span></code> <code class="docutils literal notranslate"><span class="pre">uncons</span></code><a class="headerlink" href="#cons-swons-uncons" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 [2 3] cons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 [2 3] cons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[2 3] 1 swons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[2 3] 1 swons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] uncons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] uncons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">3</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="first-second-third-rest">
+</section>
+<section id="first-second-third-rest">
 <h3><code class="docutils literal notranslate"><span class="pre">first</span></code> <code class="docutils literal notranslate"><span class="pre">second</span></code> <code class="docutils literal notranslate"><span class="pre">third</span></code> <code class="docutils literal notranslate"><span class="pre">rest</span></code><a class="headerlink" href="#first-second-third-rest" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] first&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] first&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] second&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] second&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] third&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] third&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] rest&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] rest&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="flatten">
+</section>
+<section id="flatten">
 <h3><code class="docutils literal notranslate"><span class="pre">flatten</span></code><a class="headerlink" href="#flatten" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[1] [2 [3] 4] [5 6]] flatten&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[1] [2 [3] 4] [5 6]] flatten&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="mi">4</span> <span class="mi">5</span> <span class="mi">6</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="getitem-at-of-drop-take">
+</section>
+<section id="getitem-at-of-drop-take">
 <h3><code class="docutils literal notranslate"><span class="pre">getitem</span></code> <code class="docutils literal notranslate"><span class="pre">at</span></code> <code class="docutils literal notranslate"><span class="pre">of</span></code> <code class="docutils literal notranslate"><span class="pre">drop</span></code> <code class="docutils literal notranslate"><span class="pre">take</span></code><a class="headerlink" href="#getitem-at-of-drop-take" title="Permalink to this headline">¶</a></h3>
 <p><code class="docutils literal notranslate"><span class="pre">at</span></code> and <code class="docutils literal notranslate"><span class="pre">getitem</span></code> are the same function. <code class="docutils literal notranslate"><span class="pre">of</span> <span class="pre">==</span> <span class="pre">swap</span> <span class="pre">at</span></code></p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[10 11 12 13 14] 2 getitem&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[10 11 12 13 14] 2 getitem&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">12</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] 0 at&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] 0 at&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;2 [1 2 3 4] of&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;2 [1 2 3 4] of&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] 2 drop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] 2 drop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">4</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] 2 take&#39;</span><span class="p">)</span>  <span class="c1"># reverses the order</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] 2 take&#39;</span><span class="p">)</span>  <span class="c1"># reverses the order</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">2</span> <span class="mi">1</span><span class="p">]</span>
 </pre></div>
 </div>
 <p><code class="docutils literal notranslate"><span class="pre">reverse</span></code> could be defines as <code class="docutils literal notranslate"><span class="pre">reverse</span> <span class="pre">==</span> <span class="pre">dup</span> <span class="pre">size</span> <span class="pre">take</span></code></p>
-</div>
-<div class="section" id="remove">
+</section>
+<section id="remove">
 <h3><code class="docutils literal notranslate"><span class="pre">remove</span></code><a class="headerlink" href="#remove" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 1 4] 1 remove&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 1 4] 1 remove&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">2</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">4</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="reverse">
+</section>
+<section id="reverse">
 <h3><code class="docutils literal notranslate"><span class="pre">reverse</span></code><a class="headerlink" href="#reverse" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] reverse&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 4] reverse&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">4</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="size">
+</section>
+<section id="size">
 <h3><code class="docutils literal notranslate"><span class="pre">size</span></code><a class="headerlink" href="#size" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 1 1 1] size&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 1 1 1] size&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">4</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="swaack">
+</section>
+<section id="swaack">
 <h3><code class="docutils literal notranslate"><span class="pre">swaack</span></code><a class="headerlink" href="#swaack" title="Permalink to this headline">¶</a></h3>
 <p>“Swap stack” swap the list on the top of the stack for the stack, and
 put the old stack on top of the new one. Think of it as a context
 switch. Niether of the lists/stacks change their order.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 [4 5 6] swaack&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 [4 5 6] swaack&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">6</span> <span class="mi">5</span> <span class="mi">4</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="choice-select">
+</section>
+<section id="choice-select">
 <h3><code class="docutils literal notranslate"><span class="pre">choice</span></code> <code class="docutils literal notranslate"><span class="pre">select</span></code><a class="headerlink" href="#choice-select" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 1 choice&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 1 choice&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">9</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 0 choice&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 0 choice&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 9 7] 1 select&#39;</span><span class="p">)</span>  <span class="c1"># select is basically getitem, should retire it?</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 9 7] 1 select&#39;</span><span class="p">)</span>  <span class="c1"># select is basically getitem, should retire it?</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">9</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 9 7] 0 select&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 9 7] 0 select&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="zip">
+</section>
+<section id="zip">
 <h3><code class="docutils literal notranslate"><span class="pre">zip</span></code><a class="headerlink" href="#zip" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [6 5 4] zip&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [6 5 4] zip&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[[</span><span class="mi">6</span> <span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">5</span> <span class="mi">2</span><span class="p">]</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">3</span><span class="p">]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [6 5 4] zip [sum] map&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] [6 5 4] zip [sum] map&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">7</span> <span class="mi">7</span> <span class="mi">7</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="math-words">
+</section>
+</section>
+<section id="math-words">
 <h2>Math words<a class="headerlink" href="#math-words" title="Permalink to this headline">¶</a></h2>
-<div class="section" id="add">
+<section id="add">
 <h3><code class="docutils literal notranslate"><span class="pre">+</span></code> <code class="docutils literal notranslate"><span class="pre">add</span></code><a class="headerlink" href="#add" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 +&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 +&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">32</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="sub">
+</section>
+<section id="sub">
 <h3><code class="docutils literal notranslate"><span class="pre">-</span></code> <code class="docutils literal notranslate"><span class="pre">sub</span></code><a class="headerlink" href="#sub" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 -&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 -&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">14</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="mul">
+</section>
+<section id="mul">
 <h3><code class="docutils literal notranslate"><span class="pre">*</span></code> <code class="docutils literal notranslate"><span class="pre">mul</span></code><a class="headerlink" href="#mul" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 *&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 *&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">207</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="div-floordiv-truediv">
+</section>
+<section id="div-floordiv-truediv">
 <h3><code class="docutils literal notranslate"><span class="pre">/</span></code> <code class="docutils literal notranslate"><span class="pre">div</span></code> <code class="docutils literal notranslate"><span class="pre">floordiv</span></code> <code class="docutils literal notranslate"><span class="pre">truediv</span></code><a class="headerlink" href="#div-floordiv-truediv" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 /&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 /&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">2.5555555555555554</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 -9 truediv&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 -9 truediv&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="mf">2.5555555555555554</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 div&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 div&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 floordiv&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 floordiv&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 -9 div&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 -9 div&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 -9 floordiv&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 -9 floordiv&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="mi">3</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="mod-modulus-rem-remainder">
+</section>
+<section id="mod-modulus-rem-remainder">
 <h3><code class="docutils literal notranslate"><span class="pre">%</span></code> <code class="docutils literal notranslate"><span class="pre">mod</span></code> <code class="docutils literal notranslate"><span class="pre">modulus</span></code> <code class="docutils literal notranslate"><span class="pre">rem</span></code> <code class="docutils literal notranslate"><span class="pre">remainder</span></code><a class="headerlink" href="#mod-modulus-rem-remainder" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 %&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 %&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">5</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="neg">
+</section>
+<section id="neg">
 <h3><code class="docutils literal notranslate"><span class="pre">neg</span></code><a class="headerlink" href="#neg" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 neg -5 neg&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 neg -5 neg&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="mi">23</span> <span class="mi">5</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="pow">
+</section>
+<section id="pow">
 <h3><code class="docutils literal notranslate"><span class="pre">pow</span></code><a class="headerlink" href="#pow" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;2 10 pow&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;2 10 pow&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1024</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="sqr-sqrt">
+</section>
+<section id="sqr-sqrt">
 <h3><code class="docutils literal notranslate"><span class="pre">sqr</span></code> <code class="docutils literal notranslate"><span class="pre">sqrt</span></code><a class="headerlink" href="#sqr-sqrt" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 sqr&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 sqr&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">529</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 sqrt&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 sqrt&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="succ-pred">
+</section>
+<section id="succ-pred">
 <h3><code class="docutils literal notranslate"><span class="pre">++</span></code> <code class="docutils literal notranslate"><span class="pre">succ</span></code> <code class="docutils literal notranslate"><span class="pre">--</span></code> <code class="docutils literal notranslate"><span class="pre">pred</span></code><a class="headerlink" href="#succ-pred" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 ++&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 ++&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 --&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 --&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="lshift-rshift">
+</section>
+<section id="lshift-rshift">
 <h3><code class="docutils literal notranslate"><span class="pre">&lt;&lt;</span></code> <code class="docutils literal notranslate"><span class="pre">lshift</span></code> <code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code> <code class="docutils literal notranslate"><span class="pre">rshift</span></code><a class="headerlink" href="#lshift-rshift" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;8 1 &lt;&lt;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;8 1 &lt;&lt;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">16</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;8 1 &gt;&gt;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;8 1 &gt;&gt;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">4</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="average">
+</section>
+<section id="average">
 <h3><code class="docutils literal notranslate"><span class="pre">average</span></code><a class="headerlink" href="#average" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] average&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] average&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">2.75</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="range-range-to-zero-down-to-zero">
+</section>
+<section id="range-range-to-zero-down-to-zero">
 <h3><code class="docutils literal notranslate"><span class="pre">range</span></code> <code class="docutils literal notranslate"><span class="pre">range_to_zero</span></code> <code class="docutils literal notranslate"><span class="pre">down_to_zero</span></code><a class="headerlink" href="#range-range-to-zero-down-to-zero" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">4</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range_to_zero&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range_to_zero&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">0</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">5</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 down_to_zero&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 down_to_zero&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">5</span> <span class="mi">4</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="product">
+</section>
+<section id="product">
 <h3><code class="docutils literal notranslate"><span class="pre">product</span></code><a class="headerlink" href="#product" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] product&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] product&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">30</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="sum">
+</section>
+<section id="sum">
 <h3><code class="docutils literal notranslate"><span class="pre">sum</span></code><a class="headerlink" href="#sum" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">11</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="min">
+</section>
+<section id="min">
 <h3><code class="docutils literal notranslate"><span class="pre">min</span></code><a class="headerlink" href="#min" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] min&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3 5] min&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="gcd">
+</section>
+<section id="gcd">
 <h3><code class="docutils literal notranslate"><span class="pre">gcd</span></code><a class="headerlink" href="#gcd" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;45 30 gcd&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;45 30 gcd&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">15</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="least-fraction">
+</section>
+<section id="least-fraction">
 <h3><code class="docutils literal notranslate"><span class="pre">least_fraction</span></code><a class="headerlink" href="#least-fraction" title="Permalink to this headline">¶</a></h3>
 <p>If we represent fractions as a quoted pair of integers [q d] this word
 reduces them to their … least common factors or whatever.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[45 30] least_fraction&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[45 30] least_fraction&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">2</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 12] least_fraction&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 12] least_fraction&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">23</span> <span class="mi">12</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="logic-and-comparison">
+</section>
+</section>
+<section id="logic-and-comparison">
 <h2>Logic and Comparison<a class="headerlink" href="#logic-and-comparison" title="Permalink to this headline">¶</a></h2>
-<div class="section" id="truthy">
+<section id="truthy">
 <h3><code class="docutils literal notranslate"><span class="pre">?</span></code> <code class="docutils literal notranslate"><span class="pre">truthy</span></code><a class="headerlink" href="#truthy" title="Permalink to this headline">¶</a></h3>
 <p>Get the Boolean value of the item on the top of the stack.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 truthy&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 truthy&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">True</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] truthy&#39;</span><span class="p">)</span>  <span class="c1"># Python semantics.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] truthy&#39;</span><span class="p">)</span>  <span class="c1"># Python semantics.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">False</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 truthy&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 truthy&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">False</span>
@@ -646,7 +647,7 @@ reduces them to their … least common factors or whatever.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>? == dup truthy
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;23 ?&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;23 ?&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>        . 23 ?
@@ -656,31 +657,31 @@ reduces them to their … least common factors or whatever.</p>
 23 True .
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] ?&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] ?&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[]</span> <span class="kc">False</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 ?&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 ?&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span> <span class="kc">False</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="and">
+</section>
+<section id="and">
 <h3><code class="docutils literal notranslate"><span class="pre">&amp;</span></code> <code class="docutils literal notranslate"><span class="pre">and</span></code><a class="headerlink" href="#and" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 &amp;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 &amp;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="ne">
+</section>
+<section id="ne">
 <h3><code class="docutils literal notranslate"><span class="pre">!=</span></code> <code class="docutils literal notranslate"><span class="pre">&lt;&gt;</span></code> <code class="docutils literal notranslate"><span class="pre">ne</span></code><a class="headerlink" href="#ne" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 !=&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 9 !=&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">True</span>
@@ -690,65 +691,65 @@ reduces them to their … least common factors or whatever.</p>
 <div class="line">The usual suspects: - <code class="docutils literal notranslate"><span class="pre">&lt;</span></code> <code class="docutils literal notranslate"><span class="pre">lt</span></code> - <code class="docutils literal notranslate"><span class="pre">&lt;=</span></code> <code class="docutils literal notranslate"><span class="pre">le</span></code></div>
 <div class="line">- <code class="docutils literal notranslate"><span class="pre">=</span></code> <code class="docutils literal notranslate"><span class="pre">eq</span></code> - <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> <code class="docutils literal notranslate"><span class="pre">gt</span></code> - <code class="docutils literal notranslate"><span class="pre">&gt;=</span></code> <code class="docutils literal notranslate"><span class="pre">ge</span></code> - <code class="docutils literal notranslate"><span class="pre">not</span></code> - <code class="docutils literal notranslate"><span class="pre">or</span></code></div>
 </div>
-</div>
-<div class="section" id="xor">
+</section>
+<section id="xor">
 <h3><code class="docutils literal notranslate"><span class="pre">^</span></code> <code class="docutils literal notranslate"><span class="pre">xor</span></code><a class="headerlink" href="#xor" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 1 ^&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 1 ^&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 0 ^&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 0 ^&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="miscellaneous">
+</section>
+</section>
+<section id="miscellaneous">
 <h2>Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline">¶</a></h2>
-<div class="section" id="help">
+<section id="help">
 <h3><code class="docutils literal notranslate"><span class="pre">help</span></code><a class="headerlink" href="#help" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[help] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[help] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Accepts</span> <span class="n">a</span> <span class="n">quoted</span> <span class="n">symbol</span> <span class="n">on</span> <span class="n">the</span> <span class="n">top</span> <span class="n">of</span> <span class="n">the</span> <span class="n">stack</span> <span class="ow">and</span> <span class="n">prints</span> <span class="n">its</span> <span class="n">docs</span><span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="parse">
+</section>
+<section id="parse">
 <h3><code class="docutils literal notranslate"><span class="pre">parse</span></code><a class="headerlink" href="#parse" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[parse] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[parse] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Parse</span> <span class="n">the</span> <span class="n">string</span> <span class="n">on</span> <span class="n">the</span> <span class="n">stack</span> <span class="n">to</span> <span class="n">a</span> <span class="n">Joy</span> <span class="n">expression</span><span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 &quot;2 [3] dup&quot; parse&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 &quot;2 [3] dup&quot; parse&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="p">[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="n">dup</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="run">
+</section>
+<section id="run">
 <h3><code class="docutils literal notranslate"><span class="pre">run</span></code><a class="headerlink" href="#run" title="Permalink to this headline">¶</a></h3>
 <p>Evaluate a quoted Joy sequence.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 dup + +] run&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 dup + +] run&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">5</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="combinators">
+</section>
+</section>
+<section id="combinators">
 <h2>Combinators<a class="headerlink" href="#combinators" title="Permalink to this headline">¶</a></h2>
-<div class="section" id="app1-app2-app3">
+<section id="app1-app2-app3">
 <h3><code class="docutils literal notranslate"><span class="pre">app1</span></code> <code class="docutils literal notranslate"><span class="pre">app2</span></code> <code class="docutils literal notranslate"><span class="pre">app3</span></code><a class="headerlink" href="#app1-app2-app3" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[app1] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[app1] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Given</span> <span class="n">a</span> <span class="n">quoted</span> <span class="n">program</span> <span class="n">on</span> <span class="n">TOS</span> <span class="ow">and</span> <span class="n">anything</span> <span class="k">as</span> <span class="n">the</span> <span class="n">second</span> <span class="n">stack</span> <span class="n">item</span> <span class="n">run</span>
@@ -760,19 +761,19 @@ reduces them to their … least common factors or whatever.</p>
       <span class="o">...</span> <span class="p">[</span><span class="n">x</span> <span class="o">...</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">infra</span> <span class="n">first</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 4 [sqr *] app1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 4 [sqr *] app1&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span> <span class="mi">160</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 3 4 [sqr *] app2&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 3 4 [sqr *] app2&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span> <span class="mi">90</span> <span class="mi">160</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[app2] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[app2] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Like</span> <span class="n">app1</span> <span class="k">with</span> <span class="n">two</span> <span class="n">items</span><span class="o">.</span>
@@ -783,14 +784,14 @@ reduces them to their … least common factors or whatever.</p>
        <span class="p">[</span><span class="n">x</span> <span class="o">...</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span>   <span class="n">infra</span> <span class="n">first</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 2 3 4 [sqr *] app3&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 2 3 4 [sqr *] app3&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span> <span class="mi">40</span> <span class="mi">90</span> <span class="mi">160</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="anamorphism">
+</section>
+<section id="anamorphism">
 <h3><code class="docutils literal notranslate"><span class="pre">anamorphism</span></code><a class="headerlink" href="#anamorphism" title="Permalink to this headline">¶</a></h3>
 <p>Given an initial value, a predicate function <code class="docutils literal notranslate"><span class="pre">[P]</span></code>, and a generator
 function <code class="docutils literal notranslate"><span class="pre">[G]</span></code>, the <code class="docutils literal notranslate"><span class="pre">anamorphism</span></code> combinator creates a sequence.</p>
@@ -803,29 +804,29 @@ function <code class="docutils literal notranslate"><span class="pre">[G]</span>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">range</span> <span class="o">==</span> <span class="p">[</span><span class="mi">0</span> <span class="o">&lt;=</span><span class="p">]</span> <span class="p">[</span><span class="mi">1</span> <span class="o">-</span> <span class="n">dup</span><span class="p">]</span> <span class="n">anamorphism</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 [0 &lt;=] [1 - dup] anamorphism&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 [0 &lt;=] [1 - dup] anamorphism&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="branch">
+</section>
+<section id="branch">
 <h3><code class="docutils literal notranslate"><span class="pre">branch</span></code><a class="headerlink" href="#branch" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 4 1 [+] [*] branch&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 4 1 [+] [*] branch&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">12</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 4 0 [+] [*] branch&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 4 0 [+] [*] branch&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">7</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="cleave">
+</section>
+<section id="cleave">
 <h3><code class="docutils literal notranslate"><span class="pre">cleave</span></code><a class="headerlink" href="#cleave" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">...</span> <span class="n">x</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">cleave</span>
 </pre></div>
@@ -845,42 +846,42 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cleave</span> <span class="o">==</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="n">app2</span> <span class="p">[</span><span class="n">popd</span><span class="p">]</span> <span class="n">dip</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 2 [+] [-] cleave&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 2 [+] [-] cleave&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span> <span class="mi">12</span> <span class="mi">8</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="dip-dipd-dipdd">
+</section>
+<section id="dip-dipd-dipdd">
 <h3><code class="docutils literal notranslate"><span class="pre">dip</span></code> <code class="docutils literal notranslate"><span class="pre">dipd</span></code> <code class="docutils literal notranslate"><span class="pre">dipdd</span></code><a class="headerlink" href="#dip-dipd-dipdd" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] dip&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] dip&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">7</span> <span class="mi">5</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] dipd&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] dipd&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">5</span> <span class="mi">4</span> <span class="mi">5</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] dipdd&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] dipdd&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">5</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="dupdip">
+</section>
+<section id="dupdip">
 <h3><code class="docutils literal notranslate"><span class="pre">dupdip</span></code><a class="headerlink" href="#dupdip" title="Permalink to this headline">¶</a></h3>
 <p>Expects a quoted program <code class="docutils literal notranslate"><span class="pre">[Q]</span></code> on the stack and some item under it,
 <code class="docutils literal notranslate"><span class="pre">dup</span></code> the item and <code class="docutils literal notranslate"><span class="pre">dip</span></code> the quoted program under it.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">n</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">dupdip</span> <span class="o">==</span> <span class="n">n</span> <span class="n">Q</span> <span class="n">n</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;23 [++] dupdip *&#39;</span><span class="p">)</span>  <span class="c1"># N(N + 1)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;23 [++] dupdip *&#39;</span><span class="p">)</span>  <span class="c1"># N(N + 1)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>        <span class="o">.</span> <span class="mi">23</span> <span class="p">[</span><span class="o">++</span><span class="p">]</span> <span class="n">dupdip</span> <span class="o">*</span>
@@ -892,10 +893,10 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
     <span class="mi">552</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="genrec-primrec">
+</section>
+<section id="genrec-primrec">
 <h3><code class="docutils literal notranslate"><span class="pre">genrec</span></code> <code class="docutils literal notranslate"><span class="pre">primrec</span></code><a class="headerlink" href="#genrec-primrec" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[genrec] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[genrec] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">General</span> <span class="n">Recursion</span> <span class="n">Combinator</span><span class="o">.</span>
@@ -944,16 +945,16 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
 <span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 [1 &lt;=] [] [dup --] [i *] genrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 [1 &lt;=] [] [dup --] [i *] genrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">6</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="i">
+</section>
+<section id="i">
 <h3><code class="docutils literal notranslate"><span class="pre">i</span></code><a class="headerlink" href="#i" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 2 3 [+ +] i&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 2 3 [+ +] i&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>            <span class="o">.</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="p">[</span><span class="o">+</span> <span class="o">+</span><span class="p">]</span> <span class="n">i</span>
@@ -966,28 +967,28 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
           <span class="mi">6</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="ifte">
+</section>
+<section id="ifte">
 <h3><code class="docutils literal notranslate"><span class="pre">ifte</span></code><a class="headerlink" href="#ifte" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">predicate</span><span class="p">]</span> <span class="p">[</span><span class="n">then</span><span class="p">]</span> <span class="p">[</span><span class="k">else</span><span class="p">]</span> <span class="n">ifte</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 [1] [+] [*] ifte&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 [1] [+] [*] ifte&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 [0] [+] [*] ifte&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 [0] [+] [*] ifte&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="infra">
+</section>
+<section id="infra">
 <h3><code class="docutils literal notranslate"><span class="pre">infra</span></code><a class="headerlink" href="#infra" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 2 3 [4 5 6] [* +] infra&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 2 3 [4 5 6] [* +] infra&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                    <span class="o">.</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">5</span> <span class="mi">6</span><span class="p">]</span> <span class="p">[</span><span class="o">*</span> <span class="o">+</span><span class="p">]</span> <span class="n">infra</span>
@@ -1003,10 +1004,10 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
          <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">26</span><span class="p">]</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="loop">
+</section>
+<section id="loop">
 <h3><code class="docutils literal notranslate"><span class="pre">loop</span></code><a class="headerlink" href="#loop" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[loop] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[loop] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Basic</span> <span class="n">loop</span> <span class="n">combinator</span><span class="o">.</span>
@@ -1020,7 +1021,7 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
           <span class="o">...</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;3 dup [1 - dup] loop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;3 dup [1 - dup] loop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>              <span class="o">.</span> <span class="mi">3</span> <span class="n">dup</span> <span class="p">[</span><span class="mi">1</span> <span class="o">-</span> <span class="n">dup</span><span class="p">]</span> <span class="n">loop</span>
@@ -1045,54 +1046,54 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
             <span class="mi">0</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="map-pam">
+</section>
+<section id="map-pam">
 <h3><code class="docutils literal notranslate"><span class="pre">map</span></code> <code class="docutils literal notranslate"><span class="pre">pam</span></code><a class="headerlink" href="#map-pam" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 [1 2 3] [*] map&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 [1 2 3] [*] map&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span> <span class="p">[</span><span class="mi">10</span> <span class="mi">20</span> <span class="mi">30</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 5 [[*][/][+][-]] pam&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;10 5 [[*][/][+][-]] pam&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span> <span class="mi">5</span> <span class="p">[</span><span class="mi">50</span> <span class="mf">2.0</span> <span class="mi">15</span> <span class="mi">5</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="nullary-unary-binary-ternary">
+</section>
+<section id="nullary-unary-binary-ternary">
 <h3><code class="docutils literal notranslate"><span class="pre">nullary</span></code> <code class="docutils literal notranslate"><span class="pre">unary</span></code> <code class="docutils literal notranslate"><span class="pre">binary</span></code> <code class="docutils literal notranslate"><span class="pre">ternary</span></code><a class="headerlink" href="#nullary-unary-binary-ternary" title="Permalink to this headline">¶</a></h3>
 <p>Run a quoted program enforcing
 <a class="reference external" href="https://en.wikipedia.org/wiki/Arity">arity</a>.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] nullary&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] nullary&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">5</span> <span class="mi">9</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] unary&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] unary&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">9</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] binary&#39;</span><span class="p">)</span>  <span class="c1"># + has arity 2 so this is technically pointless...</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] binary&#39;</span><span class="p">)</span>  <span class="c1"># + has arity 2 so this is technically pointless...</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">9</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] ternary&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5 [+] ternary&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">9</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="step">
+</section>
+<section id="step">
 <h3><code class="docutils literal notranslate"><span class="pre">step</span></code><a class="headerlink" href="#step" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[step] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[step] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Run</span> <span class="n">a</span> <span class="n">quoted</span> <span class="n">program</span> <span class="n">on</span> <span class="n">each</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">a</span> <span class="n">sequence</span><span class="o">.</span>
@@ -1115,7 +1116,7 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
 <span class="n">on</span> <span class="n">top</span> <span class="n">of</span> <span class="n">the</span> <span class="n">stack</span><span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 [1 2 3] [+] step&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 [1 2 3] [+] step&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>              <span class="o">.</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span><span class="p">]</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="n">step</span>
@@ -1137,10 +1138,10 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
             <span class="mi">6</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="times">
+</section>
+<section id="times">
 <h3><code class="docutils literal notranslate"><span class="pre">times</span></code><a class="headerlink" href="#times" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;3 2 1 2 [+] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;3 2 1 2 [+] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>            <span class="o">.</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">2</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="n">times</span>
@@ -1157,10 +1158,10 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
           <span class="mi">6</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="b">
+</section>
+<section id="b">
 <h3><code class="docutils literal notranslate"><span class="pre">b</span></code><a class="headerlink" href="#b" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[b] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[b] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="o">==</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="n">dip</span> <span class="n">i</span>
@@ -1169,7 +1170,7 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
 <span class="o">...</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">b</span> <span class="o">==</span> <span class="o">...</span> <span class="n">P</span> <span class="n">Q</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 2 [3] [4] b&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 2 [3] [4] b&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>            <span class="o">.</span> <span class="mi">1</span> <span class="mi">2</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="n">b</span>
@@ -1182,22 +1183,22 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
     <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="while">
+</section>
+<section id="while">
 <h3><code class="docutils literal notranslate"><span class="pre">while</span></code><a class="headerlink" href="#while" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">predicate</span><span class="p">]</span> <span class="p">[</span><span class="n">body</span><span class="p">]</span> <span class="k">while</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 [0 &gt;] [dup --] while&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 [0 &gt;] [dup --] while&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="x">
+</section>
+<section id="x">
 <h3><code class="docutils literal notranslate"><span class="pre">x</span></code><a class="headerlink" href="#x" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[x] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[x] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">x</span> <span class="o">==</span> <span class="n">dup</span> <span class="n">i</span>
@@ -1207,7 +1208,7 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
 <span class="o">...</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">x</span> <span class="o">=</span> <span class="o">...</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span>  <span class="n">Q</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 [2] [i 3] x&#39;</span><span class="p">)</span>  <span class="c1"># Kind of a pointless example.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 [2] [i 3] x&#39;</span><span class="p">)</span>  <span class="c1"># Kind of a pointless example.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>            <span class="o">.</span> <span class="mi">1</span> <span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="p">[</span><span class="n">i</span> <span class="mi">3</span><span class="p">]</span> <span class="n">x</span>
@@ -1222,133 +1223,79 @@ in terms of <code class="docutils literal notranslate"><span class="pre">app2</s
     <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="void">
+</section>
+</section>
+<section id="void">
 <h2><code class="docutils literal notranslate"><span class="pre">void</span></code><a class="headerlink" href="#void" title="Permalink to this headline">¶</a></h2>
 <p>Implements <a class="reference external" href="https://en.wikipedia.org/wiki/Laws_of_Form#The_primary_arithmetic_.28Chapter_4.29">**Laws of Form**
 *arithmetic*</a>
 over quote-only datastructures (that is, datastructures that consist
 soley of containers, without strings or numbers or anything else.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] void&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] void&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">False</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[]] void&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[]] void&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">True</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[][[]]] void&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[][[]]] void&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">True</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[[]][[][]]] void&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[[]][[][]]] void&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kc">False</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Functions Grouped by, er, Function with Examples</a><ul>
-<li><a class="reference internal" href="#stack-chatter">Stack Chatter</a><ul>
-<li><a class="reference internal" href="#clear"><code class="docutils literal notranslate"><span class="pre">clear</span></code></a></li>
-<li><a class="reference internal" href="#dup-dupd"><code class="docutils literal notranslate"><span class="pre">dup</span></code> <code class="docutils literal notranslate"><span class="pre">dupd</span></code></a></li>
-<li><a class="reference internal" href="#enstacken-disenstacken-stack-unstack"><code class="docutils literal notranslate"><span class="pre">enstacken</span></code> <code class="docutils literal notranslate"><span class="pre">disenstacken</span></code> <code class="docutils literal notranslate"><span class="pre">stack</span></code> <code class="docutils literal notranslate"><span class="pre">unstack</span></code></a></li>
-<li><a class="reference internal" href="#pop-popd-popop"><code class="docutils literal notranslate"><span class="pre">pop</span></code> <code class="docutils literal notranslate"><span class="pre">popd</span></code> <code class="docutils literal notranslate"><span class="pre">popop</span></code></a></li>
-<li><a class="reference internal" href="#roll-rolldown-roll-rollup"><code class="docutils literal notranslate"><span class="pre">roll&lt;</span></code> <code class="docutils literal notranslate"><span class="pre">rolldown</span></code> <code class="docutils literal notranslate"><span class="pre">roll&gt;</span></code> <code class="docutils literal notranslate"><span class="pre">rollup</span></code></a></li>
-<li><a class="reference internal" href="#swap"><code class="docutils literal notranslate"><span class="pre">swap</span></code></a></li>
-<li><a class="reference internal" href="#tuck-over"><code class="docutils literal notranslate"><span class="pre">tuck</span></code> <code class="docutils literal notranslate"><span class="pre">over</span></code></a></li>
-<li><a class="reference internal" href="#unit-quoted-unquoted"><code class="docutils literal notranslate"><span class="pre">unit</span></code> <code class="docutils literal notranslate"><span class="pre">quoted</span></code> <code class="docutils literal notranslate"><span class="pre">unquoted</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#list-words">List words</a><ul>
-<li><a class="reference internal" href="#concat-swoncat-shunt"><code class="docutils literal notranslate"><span class="pre">concat</span></code> <code class="docutils literal notranslate"><span class="pre">swoncat</span></code> <code class="docutils literal notranslate"><span class="pre">shunt</span></code></a></li>
-<li><a class="reference internal" href="#cons-swons-uncons"><code class="docutils literal notranslate"><span class="pre">cons</span></code> <code class="docutils literal notranslate"><span class="pre">swons</span></code> <code class="docutils literal notranslate"><span class="pre">uncons</span></code></a></li>
-<li><a class="reference internal" href="#first-second-third-rest"><code class="docutils literal notranslate"><span class="pre">first</span></code> <code class="docutils literal notranslate"><span class="pre">second</span></code> <code class="docutils literal notranslate"><span class="pre">third</span></code> <code class="docutils literal notranslate"><span class="pre">rest</span></code></a></li>
-<li><a class="reference internal" href="#flatten"><code class="docutils literal notranslate"><span class="pre">flatten</span></code></a></li>
-<li><a class="reference internal" href="#getitem-at-of-drop-take"><code class="docutils literal notranslate"><span class="pre">getitem</span></code> <code class="docutils literal notranslate"><span class="pre">at</span></code> <code class="docutils literal notranslate"><span class="pre">of</span></code> <code class="docutils literal notranslate"><span class="pre">drop</span></code> <code class="docutils literal notranslate"><span class="pre">take</span></code></a></li>
-<li><a class="reference internal" href="#remove"><code class="docutils literal notranslate"><span class="pre">remove</span></code></a></li>
-<li><a class="reference internal" href="#reverse"><code class="docutils literal notranslate"><span class="pre">reverse</span></code></a></li>
-<li><a class="reference internal" href="#size"><code class="docutils literal notranslate"><span class="pre">size</span></code></a></li>
-<li><a class="reference internal" href="#swaack"><code class="docutils literal notranslate"><span class="pre">swaack</span></code></a></li>
-<li><a class="reference internal" href="#choice-select"><code class="docutils literal notranslate"><span class="pre">choice</span></code> <code class="docutils literal notranslate"><span class="pre">select</span></code></a></li>
-<li><a class="reference internal" href="#zip"><code class="docutils literal notranslate"><span class="pre">zip</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#math-words">Math words</a><ul>
-<li><a class="reference internal" href="#add"><code class="docutils literal notranslate"><span class="pre">+</span></code> <code class="docutils literal notranslate"><span class="pre">add</span></code></a></li>
-<li><a class="reference internal" href="#sub"><code class="docutils literal notranslate"><span class="pre">-</span></code> <code class="docutils literal notranslate"><span class="pre">sub</span></code></a></li>
-<li><a class="reference internal" href="#mul"><code class="docutils literal notranslate"><span class="pre">*</span></code> <code class="docutils literal notranslate"><span class="pre">mul</span></code></a></li>
-<li><a class="reference internal" href="#div-floordiv-truediv"><code class="docutils literal notranslate"><span class="pre">/</span></code> <code class="docutils literal notranslate"><span class="pre">div</span></code> <code class="docutils literal notranslate"><span class="pre">floordiv</span></code> <code class="docutils literal notranslate"><span class="pre">truediv</span></code></a></li>
-<li><a class="reference internal" href="#mod-modulus-rem-remainder"><code class="docutils literal notranslate"><span class="pre">%</span></code> <code class="docutils literal notranslate"><span class="pre">mod</span></code> <code class="docutils literal notranslate"><span class="pre">modulus</span></code> <code class="docutils literal notranslate"><span class="pre">rem</span></code> <code class="docutils literal notranslate"><span class="pre">remainder</span></code></a></li>
-<li><a class="reference internal" href="#neg"><code class="docutils literal notranslate"><span class="pre">neg</span></code></a></li>
-<li><a class="reference internal" href="#pow"><code class="docutils literal notranslate"><span class="pre">pow</span></code></a></li>
-<li><a class="reference internal" href="#sqr-sqrt"><code class="docutils literal notranslate"><span class="pre">sqr</span></code> <code class="docutils literal notranslate"><span class="pre">sqrt</span></code></a></li>
-<li><a class="reference internal" href="#succ-pred"><code class="docutils literal notranslate"><span class="pre">++</span></code> <code class="docutils literal notranslate"><span class="pre">succ</span></code> <code class="docutils literal notranslate"><span class="pre">--</span></code> <code class="docutils literal notranslate"><span class="pre">pred</span></code></a></li>
-<li><a class="reference internal" href="#lshift-rshift"><code class="docutils literal notranslate"><span class="pre">&lt;&lt;</span></code> <code class="docutils literal notranslate"><span class="pre">lshift</span></code> <code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code> <code class="docutils literal notranslate"><span class="pre">rshift</span></code></a></li>
-<li><a class="reference internal" href="#average"><code class="docutils literal notranslate"><span class="pre">average</span></code></a></li>
-<li><a class="reference internal" href="#range-range-to-zero-down-to-zero"><code class="docutils literal notranslate"><span class="pre">range</span></code> <code class="docutils literal notranslate"><span class="pre">range_to_zero</span></code> <code class="docutils literal notranslate"><span class="pre">down_to_zero</span></code></a></li>
-<li><a class="reference internal" href="#product"><code class="docutils literal notranslate"><span class="pre">product</span></code></a></li>
-<li><a class="reference internal" href="#sum"><code class="docutils literal notranslate"><span class="pre">sum</span></code></a></li>
-<li><a class="reference internal" href="#min"><code class="docutils literal notranslate"><span class="pre">min</span></code></a></li>
-<li><a class="reference internal" href="#gcd"><code class="docutils literal notranslate"><span class="pre">gcd</span></code></a></li>
-<li><a class="reference internal" href="#least-fraction"><code class="docutils literal notranslate"><span class="pre">least_fraction</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#logic-and-comparison">Logic and Comparison</a><ul>
-<li><a class="reference internal" href="#truthy"><code class="docutils literal notranslate"><span class="pre">?</span></code> <code class="docutils literal notranslate"><span class="pre">truthy</span></code></a></li>
-<li><a class="reference internal" href="#and"><code class="docutils literal notranslate"><span class="pre">&amp;</span></code> <code class="docutils literal notranslate"><span class="pre">and</span></code></a></li>
-<li><a class="reference internal" href="#ne"><code class="docutils literal notranslate"><span class="pre">!=</span></code> <code class="docutils literal notranslate"><span class="pre">&lt;&gt;</span></code> <code class="docutils literal notranslate"><span class="pre">ne</span></code></a></li>
-<li><a class="reference internal" href="#xor"><code class="docutils literal notranslate"><span class="pre">^</span></code> <code class="docutils literal notranslate"><span class="pre">xor</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#miscellaneous">Miscellaneous</a><ul>
-<li><a class="reference internal" href="#help"><code class="docutils literal notranslate"><span class="pre">help</span></code></a></li>
-<li><a class="reference internal" href="#parse"><code class="docutils literal notranslate"><span class="pre">parse</span></code></a></li>
-<li><a class="reference internal" href="#run"><code class="docutils literal notranslate"><span class="pre">run</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#combinators">Combinators</a><ul>
-<li><a class="reference internal" href="#app1-app2-app3"><code class="docutils literal notranslate"><span class="pre">app1</span></code> <code class="docutils literal notranslate"><span class="pre">app2</span></code> <code class="docutils literal notranslate"><span class="pre">app3</span></code></a></li>
-<li><a class="reference internal" href="#anamorphism"><code class="docutils literal notranslate"><span class="pre">anamorphism</span></code></a></li>
-<li><a class="reference internal" href="#branch"><code class="docutils literal notranslate"><span class="pre">branch</span></code></a></li>
-<li><a class="reference internal" href="#cleave"><code class="docutils literal notranslate"><span class="pre">cleave</span></code></a></li>
-<li><a class="reference internal" href="#dip-dipd-dipdd"><code class="docutils literal notranslate"><span class="pre">dip</span></code> <code class="docutils literal notranslate"><span class="pre">dipd</span></code> <code class="docutils literal notranslate"><span class="pre">dipdd</span></code></a></li>
-<li><a class="reference internal" href="#dupdip"><code class="docutils literal notranslate"><span class="pre">dupdip</span></code></a></li>
-<li><a class="reference internal" href="#genrec-primrec"><code class="docutils literal notranslate"><span class="pre">genrec</span></code> <code class="docutils literal notranslate"><span class="pre">primrec</span></code></a></li>
-<li><a class="reference internal" href="#i"><code class="docutils literal notranslate"><span class="pre">i</span></code></a></li>
-<li><a class="reference internal" href="#ifte"><code class="docutils literal notranslate"><span class="pre">ifte</span></code></a></li>
-<li><a class="reference internal" href="#infra"><code class="docutils literal notranslate"><span class="pre">infra</span></code></a></li>
-<li><a class="reference internal" href="#loop"><code class="docutils literal notranslate"><span class="pre">loop</span></code></a></li>
-<li><a class="reference internal" href="#map-pam"><code class="docutils literal notranslate"><span class="pre">map</span></code> <code class="docutils literal notranslate"><span class="pre">pam</span></code></a></li>
-<li><a class="reference internal" href="#nullary-unary-binary-ternary"><code class="docutils literal notranslate"><span class="pre">nullary</span></code> <code class="docutils literal notranslate"><span class="pre">unary</span></code> <code class="docutils literal notranslate"><span class="pre">binary</span></code> <code class="docutils literal notranslate"><span class="pre">ternary</span></code></a></li>
-<li><a class="reference internal" href="#step"><code class="docutils literal notranslate"><span class="pre">step</span></code></a></li>
-<li><a class="reference internal" href="#times"><code class="docutils literal notranslate"><span class="pre">times</span></code></a></li>
-<li><a class="reference internal" href="#b"><code class="docutils literal notranslate"><span class="pre">b</span></code></a></li>
-<li><a class="reference internal" href="#while"><code class="docutils literal notranslate"><span class="pre">while</span></code></a></li>
-<li><a class="reference internal" href="#x"><code class="docutils literal notranslate"><span class="pre">x</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#void"><code class="docutils literal notranslate"><span class="pre">void</span></code></a></li>
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Functions Grouped by, er, Function with Examples</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#stack-chatter">Stack Chatter</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#list-words">List words</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#math-words">Math words</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#logic-and-comparison">Logic and Comparison</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#miscellaneous">Miscellaneous</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#combinators">Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#void"><code class="docutils literal notranslate"><span class="pre">void</span></code></a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -1358,25 +1305,24 @@ soley of containers, without strings or numbers or anything else.)</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/lib.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -1387,7 +1333,7 @@ soley of containers, without strings or numbers or anything else.)</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 15936ce..4fdfc75 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Function Reference &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Functions Grouped by, er, Function with Examples" href="lib.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="function-reference">
+  <section id="function-reference">
 <h1>Function Reference<a class="headerlink" href="#function-reference" title="Permalink to this headline">¶</a></h1>
-<div class="section" id="module-joy.library">
+<section id="module-joy.library">
 <span id="joy-library"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.library</span></code><a class="headerlink" href="#module-joy.library" title="Permalink to this headline">¶</a></h2>
 <p>This module contains the Joy function infrastructure and a library of
 functions.  Its main export is a Python function initialize() that
 returns a dictionary of Joy functions suitable for use with the joy()
 function.</p>
-<dl class="function">
-<dt id="joy.library.BinaryBuiltinWrapper">
-<code class="descclassname">joy.library.</code><code class="descname">BinaryBuiltinWrapper</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#BinaryBuiltinWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.BinaryBuiltinWrapper" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.BinaryBuiltinWrapper">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">BinaryBuiltinWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#BinaryBuiltinWrapper"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.BinaryBuiltinWrapper" title="Permalink to this definition">¶</a></dt>
 <dd><p>Wrap functions that take two arguments and return a single result.</p>
 </dd></dl>
 
-<dl class="class">
-<dt id="joy.library.DefinitionWrapper">
-<em class="property">class </em><code class="descclassname">joy.library.</code><code class="descname">DefinitionWrapper</code><span class="sig-paren">(</span><em>name</em>, <em>body_text</em>, <em>doc=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.DefinitionWrapper" title="Permalink to this definition">¶</a></dt>
+<dl class="py class">
+<dt class="sig sig-object py" id="joy.library.DefinitionWrapper">
+<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">DefinitionWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">body_text</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">doc</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.DefinitionWrapper" title="Permalink to this definition">¶</a></dt>
 <dd><p>Provide implementation of defined functions, and some helper methods.</p>
-<dl class="classmethod">
-<dt id="joy.library.DefinitionWrapper.add_def">
-<em class="property">classmethod </em><code class="descname">add_def</code><span class="sig-paren">(</span><em>definition</em>, <em>dictionary</em>, <em>fail_fails=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper.add_def"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.DefinitionWrapper.add_def" title="Permalink to this definition">¶</a></dt>
+<dl class="py method">
+<dt class="sig sig-object py" id="joy.library.DefinitionWrapper.add_def">
+<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">add_def</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">definition</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fail_fails</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper.add_def"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.DefinitionWrapper.add_def" title="Permalink to this definition">¶</a></dt>
 <dd><p>Add the definition to the dictionary.</p>
 </dd></dl>
 
-<dl class="classmethod">
-<dt id="joy.library.DefinitionWrapper.add_definitions">
-<em class="property">classmethod </em><code class="descname">add_definitions</code><span class="sig-paren">(</span><em>defs</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper.add_definitions"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.DefinitionWrapper.add_definitions" title="Permalink to this definition">¶</a></dt>
+<dl class="py method">
+<dt class="sig sig-object py" id="joy.library.DefinitionWrapper.add_definitions">
+<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">add_definitions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">defs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper.add_definitions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.DefinitionWrapper.add_definitions" title="Permalink to this definition">¶</a></dt>
 <dd><p>Scan multi-line string defs for definitions and add them to the
 dictionary.</p>
 </dd></dl>
 
-<dl class="classmethod">
-<dt id="joy.library.DefinitionWrapper.parse_definition">
-<em class="property">classmethod </em><code class="descname">parse_definition</code><span class="sig-paren">(</span><em>defi</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper.parse_definition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.DefinitionWrapper.parse_definition" title="Permalink to this definition">¶</a></dt>
+<dl class="py method">
+<dt class="sig sig-object py" id="joy.library.DefinitionWrapper.parse_definition">
+<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_definition</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">defi</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#DefinitionWrapper.parse_definition"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.DefinitionWrapper.parse_definition" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given some text describing a Joy function definition parse it and
 return a DefinitionWrapper.</p>
 </dd></dl>
 
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.FunctionWrapper">
-<code class="descclassname">joy.library.</code><code class="descname">FunctionWrapper</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#FunctionWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.FunctionWrapper" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.FunctionWrapper">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">FunctionWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#FunctionWrapper"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.FunctionWrapper" title="Permalink to this definition">¶</a></dt>
 <dd><p>Set name attribute.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.SimpleFunctionWrapper">
-<code class="descclassname">joy.library.</code><code class="descname">SimpleFunctionWrapper</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#SimpleFunctionWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.SimpleFunctionWrapper" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.SimpleFunctionWrapper">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">SimpleFunctionWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#SimpleFunctionWrapper"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.SimpleFunctionWrapper" title="Permalink to this definition">¶</a></dt>
 <dd><p>Wrap functions that take and return just a stack.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.UnaryBuiltinWrapper">
-<code class="descclassname">joy.library.</code><code class="descname">UnaryBuiltinWrapper</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#UnaryBuiltinWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.UnaryBuiltinWrapper" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.UnaryBuiltinWrapper">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">UnaryBuiltinWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#UnaryBuiltinWrapper"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.UnaryBuiltinWrapper" title="Permalink to this definition">¶</a></dt>
 <dd><p>Wrap functions that take one argument and return a single result.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.add_aliases">
-<code class="descclassname">joy.library.</code><code class="descname">add_aliases</code><span class="sig-paren">(</span><em>D</em>, <em>A</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#add_aliases"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.add_aliases" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.add_aliases">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">add_aliases</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">D</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">A</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#add_aliases"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.add_aliases" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given a dict and a iterable of (name, [alias, …]) pairs, create
 additional entries in the dict mapping each alias to the named function
 if it’s in the dict.  Aliases for functions not in the dict are ignored.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.app1">
-<code class="descclassname">joy.library.</code><code class="descname">app1</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#app1"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.app1" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.app1">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">app1</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#app1"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.app1" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given a quoted program on TOS and anything as the second stack item run
 the program and replace the two args with the first result of the
 program.</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>         <span class="o">...</span> <span class="n">x</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">app1</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>     <span class="o">...</span> <span class="n">x</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">app1</span>
 <span class="o">-----------------------------------</span>
    <span class="o">...</span> <span class="p">[</span><span class="n">x</span> <span class="o">...</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">infra</span> <span class="n">first</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.app2">
-<code class="descclassname">joy.library.</code><code class="descname">app2</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#app2"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.app2" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.app2">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">app2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#app2"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.app2" title="Permalink to this definition">¶</a></dt>
 <dd><p>Like app1 with two items.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>       <span class="o">...</span> <span class="n">y</span> <span class="n">x</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">app2</span>
 <span class="o">-----------------------------------</span>
@@ -123,9 +124,9 @@ program.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.app3">
-<code class="descclassname">joy.library.</code><code class="descname">app3</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#app3"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.app3" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.app3">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">app3</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#app3"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.app3" title="Permalink to this definition">¶</a></dt>
 <dd><p>Like app1 with three items.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>     <span class="o">...</span> <span class="n">z</span> <span class="n">y</span> <span class="n">x</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">app3</span>
 <span class="o">-----------------------------------</span>
@@ -136,9 +137,9 @@ program.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.b">
-<code class="descclassname">joy.library.</code><code class="descname">b</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#b"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.b" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.b">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">b</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#b"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.b" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="o">==</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="n">dip</span> <span class="n">i</span>
 
 <span class="o">...</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">b</span> <span class="o">==</span> <span class="o">...</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="n">i</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">i</span>
@@ -147,27 +148,27 @@ program.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.branch">
-<code class="descclassname">joy.library.</code><code class="descname">branch</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#branch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.branch" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.branch">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">branch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#branch"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.branch" title="Permalink to this definition">¶</a></dt>
 <dd><p>Use a Boolean value to select one of two quoted programs to run.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">branch</span> <span class="o">==</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="n">choice</span> <span class="n">i</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="kc">False</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="n">branch</span>
 <span class="o">--------------------------</span>
-          <span class="n">F</span>
+      <span class="n">F</span>
 
    <span class="kc">True</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="n">branch</span>
 <span class="o">-------------------------</span>
-             <span class="n">T</span>
+         <span class="n">T</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.choice">
-<code class="descclassname">joy.library.</code><code class="descname">choice</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#choice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.choice" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.choice">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">choice</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#choice"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.choice" title="Permalink to this definition">¶</a></dt>
 <dd><p>Use a Boolean value to select one of two items.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">A</span> <span class="n">B</span> <span class="kc">False</span> <span class="n">choice</span>
 <span class="o">----------------------</span>
@@ -183,9 +184,9 @@ program.</p>
 Boolean value (so empty string, zero, etc. are counted as false, etc.)</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.clear">
-<code class="descclassname">joy.library.</code><code class="descname">clear</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#clear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.clear" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.clear">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">clear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#clear"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.clear" title="Permalink to this definition">¶</a></dt>
 <dd><p>Clear everything from the stack.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">clear</span> <span class="o">==</span> <span class="n">stack</span> <span class="p">[</span><span class="n">pop</span> <span class="n">stack</span><span class="p">]</span> <span class="n">loop</span>
 
@@ -195,29 +196,29 @@ Boolean value (so empty string, zero, etc. are counted as false, etc.)</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.cmp_">
-<code class="descclassname">joy.library.</code><code class="descname">cmp_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#cmp_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.cmp_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.cmp_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">cmp_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#cmp_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.cmp_" title="Permalink to this definition">¶</a></dt>
 <dd><p>cmp takes two values and three quoted programs on the stack and runs
 one of the three depending on the results of comparing the two values:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="nb">cmp</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="n">cmp</span>
 <span class="o">-------------------------</span> <span class="n">a</span> <span class="o">&gt;</span> <span class="n">b</span>
-        <span class="n">G</span>
+    <span class="n">G</span>
 
-   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="nb">cmp</span>
+   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="n">cmp</span>
 <span class="o">-------------------------</span> <span class="n">a</span> <span class="o">=</span> <span class="n">b</span>
-            <span class="n">E</span>
+        <span class="n">E</span>
 
-   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="nb">cmp</span>
+   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="n">cmp</span>
 <span class="o">-------------------------</span> <span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span>
-                <span class="n">L</span>
+        <span class="n">L</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.concat_">
-<code class="descclassname">joy.library.</code><code class="descname">concat_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#concat_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.concat_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.concat_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">concat_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#concat_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.concat_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Concatinate the two lists on the top of the stack.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="p">[</span><span class="n">a</span> <span class="n">b</span> <span class="n">c</span><span class="p">]</span> <span class="p">[</span><span class="n">d</span> <span class="n">e</span> <span class="n">f</span><span class="p">]</span> <span class="n">concat</span>
 <span class="o">----------------------------</span>
@@ -226,9 +227,9 @@ one of the three depending on the results of comparing the two values:</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.cond">
-<code class="descclassname">joy.library.</code><code class="descname">cond</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#cond"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.cond" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.cond">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">cond</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#cond"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.cond" title="Permalink to this definition">¶</a></dt>
 <dd><p>This combinator works like a case statement.  It expects a single quote
 on the stack that must contain zero or more condition quotes and a 
 default quote.  Each condition clause should contain a quoted predicate
@@ -242,9 +243,9 @@ true.  If no predicates return true the default function runs.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.dip">
-<code class="descclassname">joy.library.</code><code class="descname">dip</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.dip" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.dip">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">dip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dip"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.dip" title="Permalink to this definition">¶</a></dt>
 <dd><p>The dip combinator expects a quoted program on the stack and below it
 some item, it hoists the item into the expression and runs the program
 on the rest of the stack.</p>
@@ -255,9 +256,9 @@ on the rest of the stack.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.dipd">
-<code class="descclassname">joy.library.</code><code class="descname">dipd</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dipd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.dipd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.dipd">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">dipd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dipd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.dipd" title="Permalink to this definition">¶</a></dt>
 <dd><p>Like dip but expects two items.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="o">...</span> <span class="n">y</span> <span class="n">x</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">dip</span>
 <span class="o">---------------------</span>
@@ -266,9 +267,9 @@ on the rest of the stack.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.dipdd">
-<code class="descclassname">joy.library.</code><code class="descname">dipdd</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dipdd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.dipdd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.dipdd">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">dipdd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dipdd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.dipdd" title="Permalink to this definition">¶</a></dt>
 <dd><p>Like dip but expects three items.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="o">...</span> <span class="n">z</span> <span class="n">y</span> <span class="n">x</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">dip</span>
 <span class="o">-----------------------</span>
@@ -277,23 +278,23 @@ on the rest of the stack.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.disenstacken">
-<code class="descclassname">joy.library.</code><code class="descname">disenstacken</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#disenstacken"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.disenstacken" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.disenstacken">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">disenstacken</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#disenstacken"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.disenstacken" title="Permalink to this definition">¶</a></dt>
 <dd><p>The disenstacken operator expects a list on top of the stack and makes that
 the stack discarding the rest of the stack.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.divmod_">
-<code class="descclassname">joy.library.</code><code class="descname">divmod_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#divmod_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.divmod_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.divmod_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">divmod_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#divmod_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.divmod_" title="Permalink to this definition">¶</a></dt>
 <dd><p>divmod(x, y) -&gt; (quotient, remainder)</p>
 <p>Return the tuple (x//y, x%y).  Invariant: div*y + mod == x.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.drop">
-<code class="descclassname">joy.library.</code><code class="descname">drop</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#drop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.drop" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.drop">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">drop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#drop"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.drop" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">drop</span> <span class="o">==</span> <span class="p">[</span><span class="n">rest</span><span class="p">]</span> <span class="n">times</span>
 </pre></div>
 </div>
@@ -306,9 +307,9 @@ n items removed off the top.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.dupdip">
-<code class="descclassname">joy.library.</code><code class="descname">dupdip</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dupdip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.dupdip" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.dupdip">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">dupdip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#dupdip"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.dupdip" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="n">dupdip</span> <span class="o">==</span> <span class="n">dup</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="n">dip</span>
 
 <span class="o">...</span> <span class="n">a</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="n">dupdip</span>
@@ -319,18 +320,18 @@ n items removed off the top.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.floor">
-<code class="descclassname">joy.library.</code><code class="descname">floor</code><span class="sig-paren">(</span><em>x</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#floor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.floor" title="Permalink to this definition">¶</a></dt>
-<dd><p>Return the floor of x as a float.
-This is the largest integral value &lt;= x.</p>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.floor">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">floor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#floor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.floor" title="Permalink to this definition">¶</a></dt>
+<dd><p>Return the floor of x as an Integral.</p>
+<p>This is the largest integer &lt;= x.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.genrec">
-<code class="descclassname">joy.library.</code><code class="descname">genrec</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#genrec"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.genrec" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.genrec">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">genrec</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#genrec"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.genrec" title="Permalink to this definition">¶</a></dt>
 <dd><p>General Recursion Combinator.</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                      <span class="p">[</span><span class="k">if</span><span class="p">]</span> <span class="p">[</span><span class="n">then</span><span class="p">]</span> <span class="p">[</span><span class="n">rec1</span><span class="p">]</span> <span class="p">[</span><span class="n">rec2</span><span class="p">]</span> <span class="n">genrec</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>          <span class="p">[</span><span class="k">if</span><span class="p">]</span> <span class="p">[</span><span class="n">then</span><span class="p">]</span> <span class="p">[</span><span class="n">rec1</span><span class="p">]</span> <span class="p">[</span><span class="n">rec2</span><span class="p">]</span> <span class="n">genrec</span>
 <span class="o">---------------------------------------------------------------------</span>
    <span class="p">[</span><span class="k">if</span><span class="p">]</span> <span class="p">[</span><span class="n">then</span><span class="p">]</span> <span class="p">[</span><span class="n">rec1</span> <span class="p">[[</span><span class="k">if</span><span class="p">]</span> <span class="p">[</span><span class="n">then</span><span class="p">]</span> <span class="p">[</span><span class="n">rec1</span><span class="p">]</span> <span class="p">[</span><span class="n">rec2</span><span class="p">]</span> <span class="n">genrec</span><span class="p">]</span> <span class="n">rec2</span><span class="p">]</span> <span class="n">ifte</span>
 </pre></div>
@@ -373,9 +374,9 @@ the original definition in the else-part:</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.getitem">
-<code class="descclassname">joy.library.</code><code class="descname">getitem</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#getitem"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.getitem" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.getitem">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">getitem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#getitem"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.getitem" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">getitem</span> <span class="o">==</span> <span class="n">drop</span> <span class="n">first</span>
 </pre></div>
 </div>
@@ -388,15 +389,15 @@ nth position in the quote counting from 0.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.help_">
-<code class="descclassname">joy.library.</code><code class="descname">help_</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#help_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.help_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.help_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">help_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#help_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.help_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Accepts a quoted symbol on the top of the stack and prints its docs.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.i">
-<code class="descclassname">joy.library.</code><code class="descname">i</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#i"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.i" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.i">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">i</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#i"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.i" title="Permalink to this definition">¶</a></dt>
 <dd><p>The i combinator expects a quoted program on the stack and unpacks it
 onto the pending expression for evaluation.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">i</span>
@@ -406,15 +407,15 @@ onto the pending expression for evaluation.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.id_">
-<code class="descclassname">joy.library.</code><code class="descname">id_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#id_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.id_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.id_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">id_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#id_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.id_" title="Permalink to this definition">¶</a></dt>
 <dd><p>The identity function.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.infra">
-<code class="descclassname">joy.library.</code><code class="descname">infra</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#infra"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.infra" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.infra">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">infra</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#infra"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.infra" title="Permalink to this definition">¶</a></dt>
 <dd><p>Accept a quoted program and a list on the stack and run the program
 with the list as its stack.  Does not affect the rest of the stack.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="o">...</span> <span class="p">[</span><span class="n">a</span> <span class="n">b</span> <span class="n">c</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">infra</span>
@@ -424,33 +425,34 @@ with the list as its stack.  Does not affect the rest of the stack.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.initialize">
-<code class="descclassname">joy.library.</code><code class="descname">initialize</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#initialize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.initialize" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.initialize">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">initialize</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#initialize"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.initialize" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return a dictionary of Joy functions for use with joy().</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.inscribe">
-<code class="descclassname">joy.library.</code><code class="descname">inscribe</code><span class="sig-paren">(</span><em>function</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#inscribe"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.inscribe" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.inscribe">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">inscribe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#inscribe"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.inscribe" title="Permalink to this definition">¶</a></dt>
 <dd><p>A decorator to inscribe functions into the default dictionary.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.inscribe_">
-<code class="descclassname">joy.library.</code><code class="descname">inscribe_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#inscribe_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.inscribe_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.inscribe_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">inscribe_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#inscribe_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.inscribe_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Create a new Joy function definition in the Joy dictionary.  A
 definition is given as a string with a name followed by a double
 equal sign then one or more Joy functions, the body. for example:</p>
 <blockquote>
-<div>sqr == dup mul</div></blockquote>
+<div><p>sqr == dup mul</p>
+</div></blockquote>
 <p>If you want the definition to persist over restarts, enter it into
 the definitions.txt resource.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.loop">
-<code class="descclassname">joy.library.</code><code class="descname">loop</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#loop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.loop" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.loop">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">loop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#loop"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.loop" title="Permalink to this definition">¶</a></dt>
 <dd><p>Basic loop combinator.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="o">...</span> <span class="kc">True</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">loop</span>
 <span class="o">-----------------------</span>
@@ -458,39 +460,39 @@ the definitions.txt resource.</p>
 
    <span class="o">...</span> <span class="kc">False</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">loop</span>
 <span class="o">------------------------</span>
-          <span class="o">...</span>
+      <span class="o">...</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.map_">
-<code class="descclassname">joy.library.</code><code class="descname">map_</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#map_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.map_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.map_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">map_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#map_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.map_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Run the quoted program on TOS on the items in the list under it, push a
 new list with the results in place of the program and original list.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.max_">
-<code class="descclassname">joy.library.</code><code class="descname">max_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#max_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.max_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.max_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">max_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#max_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.max_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given a list find the maximum.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.min_">
-<code class="descclassname">joy.library.</code><code class="descname">min_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#min_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.min_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.min_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">min_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#min_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.min_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given a list find the minimum.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.parse">
-<code class="descclassname">joy.library.</code><code class="descname">parse</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#parse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.parse" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.parse">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">parse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#parse"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.parse" title="Permalink to this definition">¶</a></dt>
 <dd><p>Parse the string on the stack to a Joy expression.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.pm">
-<code class="descclassname">joy.library.</code><code class="descname">pm</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#pm"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.pm" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.pm">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">pm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#pm"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.pm" title="Permalink to this definition">¶</a></dt>
 <dd><p>Plus or minus</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="n">b</span> <span class="n">pm</span>
 <span class="o">-------------</span>
@@ -499,15 +501,15 @@ new list with the results in place of the program and original list.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.pred">
-<code class="descclassname">joy.library.</code><code class="descname">pred</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#pred"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.pred" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.pred">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">pred</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#pred"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.pred" title="Permalink to this definition">¶</a></dt>
 <dd><p>Decrement TOS.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.primrec">
-<code class="descclassname">joy.library.</code><code class="descname">primrec</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#primrec"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.primrec" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.primrec">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">primrec</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#primrec"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.primrec" title="Permalink to this definition">¶</a></dt>
 <dd><p>From the “Overview of the language JOY”:</p>
 <p>&gt; The primrec combinator expects two quoted programs in addition to a
 data parameter. For an integer data parameter it works like this: If
@@ -531,16 +533,16 @@ stack by the second element on the stack.:</p>
 <span class="o">------------------------------</span>
       <span class="n">Base</span>
 
-         <span class="n">n</span> <span class="p">[</span><span class="n">Base</span><span class="p">]</span> <span class="p">[</span><span class="n">Recur</span><span class="p">]</span> <span class="n">primrec</span>
+     <span class="n">n</span> <span class="p">[</span><span class="n">Base</span><span class="p">]</span> <span class="p">[</span><span class="n">Recur</span><span class="p">]</span> <span class="n">primrec</span>
 <span class="o">------------------------------------------</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">0</span>
    <span class="n">n</span> <span class="p">(</span><span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">[</span><span class="n">Base</span><span class="p">]</span> <span class="p">[</span><span class="n">Recur</span><span class="p">]</span> <span class="n">primrec</span> <span class="n">Recur</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.remove">
-<code class="descclassname">joy.library.</code><code class="descname">remove</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.remove" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.remove">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">remove</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#remove"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.remove" title="Permalink to this definition">¶</a></dt>
 <dd><p>Expects an item on the stack and a quote under it and removes that item
 from the the quote.  The item is only removed once.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">1</span><span class="p">]</span> <span class="mi">1</span> <span class="n">remove</span>
@@ -550,18 +552,18 @@ from the the quote.  The item is only removed once.</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.reverse">
-<code class="descclassname">joy.library.</code><code class="descname">reverse</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#reverse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.reverse" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.reverse">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">reverse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#reverse"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.reverse" title="Permalink to this definition">¶</a></dt>
 <dd><p>Reverse the list on the top of the stack.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">reverse</span> <span class="o">==</span> <span class="p">[]</span> <span class="n">swap</span> <span class="n">shunt</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.select">
-<code class="descclassname">joy.library.</code><code class="descname">select</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#select"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.select" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.select">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">select</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#select"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.select" title="Permalink to this definition">¶</a></dt>
 <dd><p>Use a Boolean value to select one of two items from a sequence.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="p">[</span><span class="n">A</span> <span class="n">B</span><span class="p">]</span> <span class="kc">False</span> <span class="n">select</span>
 <span class="o">------------------------</span>
@@ -578,15 +580,15 @@ Currently Python semantics are used to evaluate the “truthiness” of the
 Boolean value (so empty string, zero, etc. are counted as false, etc.)</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.sharing">
-<code class="descclassname">joy.library.</code><code class="descname">sharing</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sharing"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.sharing" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.sharing">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">sharing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sharing"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.sharing" title="Permalink to this definition">¶</a></dt>
 <dd><p>Print redistribution information.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.shunt">
-<code class="descclassname">joy.library.</code><code class="descname">shunt</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#shunt"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.shunt" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.shunt">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">shunt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#shunt"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.shunt" title="Permalink to this definition">¶</a></dt>
 <dd><p>Like concat but reverses the top list into the second.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shunt</span> <span class="o">==</span> <span class="p">[</span><span class="n">swons</span><span class="p">]</span> <span class="n">step</span> <span class="o">==</span> <span class="n">reverse</span> <span class="n">swap</span> <span class="n">concat</span>
 
@@ -597,60 +599,60 @@ Boolean value (so empty string, zero, etc. are counted as false, etc.)</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.sort_">
-<code class="descclassname">joy.library.</code><code class="descname">sort_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sort_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.sort_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.sort_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">sort_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sort_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.sort_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given a list return it sorted.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.sqrt">
-<code class="descclassname">joy.library.</code><code class="descname">sqrt</code><span class="sig-paren">(</span><em>a</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sqrt"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.sqrt" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.sqrt">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">sqrt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sqrt"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.sqrt" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return the square root of the number a.
 Negative numbers return complex roots.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.step">
-<code class="descclassname">joy.library.</code><code class="descname">step</code><span class="sig-paren">(</span><em>S</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.step" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.step">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">step</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#step"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.step" title="Permalink to this definition">¶</a></dt>
 <dd><p>Run a quoted program on each item in a sequence.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="o">...</span> <span class="p">[]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">step</span>
 <span class="o">-----------------------</span>
-          <span class="o">...</span> <span class="o">.</span>
+      <span class="o">...</span> <span class="o">.</span>
 
 
    <span class="o">...</span> <span class="p">[</span><span class="n">a</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">step</span>
 <span class="o">------------------------</span>
-         <span class="o">...</span> <span class="n">a</span> <span class="o">.</span> <span class="n">Q</span>
+     <span class="o">...</span> <span class="n">a</span> <span class="o">.</span> <span class="n">Q</span>
 
 
    <span class="o">...</span> <span class="p">[</span><span class="n">a</span> <span class="n">b</span> <span class="n">c</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">step</span>
 <span class="o">----------------------------------------</span>
-             <span class="o">...</span> <span class="n">a</span> <span class="o">.</span> <span class="n">Q</span> <span class="p">[</span><span class="n">b</span> <span class="n">c</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">step</span>
+         <span class="o">...</span> <span class="n">a</span> <span class="o">.</span> <span class="n">Q</span> <span class="p">[</span><span class="n">b</span> <span class="n">c</span><span class="p">]</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">step</span>
 </pre></div>
 </div>
 <p>The step combinator executes the quotation on each member of the list
 on top of the stack.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.succ">
-<code class="descclassname">joy.library.</code><code class="descname">succ</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#succ"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.succ" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.succ">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">succ</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#succ"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.succ" title="Permalink to this definition">¶</a></dt>
 <dd><p>Increment TOS.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.sum_">
-<code class="descclassname">joy.library.</code><code class="descname">sum_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sum_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.sum_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.sum_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">sum_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#sum_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.sum_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given a quoted sequence of numbers return the sum.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">sum</span> <span class="o">==</span> <span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="n">step</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.take">
-<code class="descclassname">joy.library.</code><code class="descname">take</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#take"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.take" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.take">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">take</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#take"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.take" title="Permalink to this definition">¶</a></dt>
 <dd><p>Expects an integer and a quote on the stack and returns the quote with
 just the top n items in reverse order (because that’s easier and you can
 use reverse if needed.)</p>
@@ -661,54 +663,54 @@ use reverse if needed.)</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.times">
-<code class="descclassname">joy.library.</code><code class="descname">times</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#times"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.times" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.times">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">times</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#times"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.times" title="Permalink to this definition">¶</a></dt>
 <dd><p>times == [– dip] cons [swap] infra [0 &gt;] swap while pop</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="o">...</span> <span class="n">n</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">times</span>
 <span class="o">---------------------</span>  <span class="n">w</span><span class="o">/</span> <span class="n">n</span> <span class="o">&lt;=</span> <span class="mi">0</span>
-         <span class="o">...</span> <span class="o">.</span>
+     <span class="o">...</span> <span class="o">.</span>
 
 
    <span class="o">...</span> <span class="mi">1</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">times</span>
 <span class="o">-----------------------</span>
-         <span class="o">...</span> <span class="o">.</span> <span class="n">Q</span>
+     <span class="o">...</span> <span class="o">.</span> <span class="n">Q</span>
 
 
    <span class="o">...</span> <span class="n">n</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="o">.</span> <span class="n">times</span>
 <span class="o">-------------------------------------</span>  <span class="n">w</span><span class="o">/</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">1</span>
-         <span class="o">...</span> <span class="o">.</span> <span class="n">Q</span> <span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">times</span>
+     <span class="o">...</span> <span class="o">.</span> <span class="n">Q</span> <span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">times</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.unique">
-<code class="descclassname">joy.library.</code><code class="descname">unique</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#unique"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.unique" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.unique">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">unique</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#unique"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.unique" title="Permalink to this definition">¶</a></dt>
 <dd><p>Given a list remove duplicate items.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.void">
-<code class="descclassname">joy.library.</code><code class="descname">void</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#void"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.void" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.void">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">void</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#void"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.void" title="Permalink to this definition">¶</a></dt>
 <dd><p>True if the form on TOS is void otherwise False.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.warranty">
-<code class="descclassname">joy.library.</code><code class="descname">warranty</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#warranty"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.warranty" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.warranty">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">warranty</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#warranty"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.warranty" title="Permalink to this definition">¶</a></dt>
 <dd><p>Print warranty information.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.words">
-<code class="descclassname">joy.library.</code><code class="descname">words</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#words"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.words" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.words">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">words</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#words"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.words" title="Permalink to this definition">¶</a></dt>
 <dd><p>Print all the words in alphabetical order.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.x">
-<code class="descclassname">joy.library.</code><code class="descname">x</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#x"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.x" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.x">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">x</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#x"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.x" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">x</span> <span class="o">==</span> <span class="n">dup</span> <span class="n">i</span>
 
 <span class="o">...</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">x</span> <span class="o">=</span> <span class="o">...</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">dup</span> <span class="n">i</span>
@@ -718,281 +720,300 @@ use reverse if needed.)</p>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.library.zip_">
-<code class="descclassname">joy.library.</code><code class="descname">zip_</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#zip_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.library.zip_" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.library.zip_">
+<span class="sig-prename descclassname"><span class="pre">joy.library.</span></span><span class="sig-name descname"><span class="pre">zip_</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">S</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/library.html#zip_"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.library.zip_" title="Permalink to this definition">¶</a></dt>
 <dd><p>Replace the two lists on the top of the stack with a list of the pairs
 from each list.  The smallest list sets the length of the result list.</p>
 </dd></dl>
 
-</div>
-<div class="section" id="module-joy.utils.generated_library">
+</section>
+<section id="module-joy.utils.generated_library">
 <span id="auto-generated-functions"></span><h2>Auto-generated Functions<a class="headerlink" href="#module-joy.utils.generated_library" title="Permalink to this headline">¶</a></h2>
-<dl class="function">
-<dt id="joy.utils.generated_library.ccons">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">ccons</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#ccons"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.ccons" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.ccons">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">ccons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#ccons"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.ccons" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a2</span> <span class="n">a1</span> <span class="p">[</span><span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">...</span><span class="mi">1</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.cons">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">cons</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#cons"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.cons" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.cons">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">cons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#cons"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.cons" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="p">[</span><span class="o">...</span><span class="mi">0</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="n">a1</span> <span class="o">...</span><span class="mi">0</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.dup">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">dup</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#dup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.dup" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.dup">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">dup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#dup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.dup" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="o">--</span> <span class="n">a1</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.dupd">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">dupd</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#dupd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.dupd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.dupd">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">dupd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#dupd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.dupd" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a2</span> <span class="n">a2</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.dupdd">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">dupdd</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#dupdd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.dupdd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.dupdd">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">dupdd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#dupdd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.dupdd" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a3</span> <span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a3</span> <span class="n">a3</span> <span class="n">a2</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.first">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">first</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#first"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.first" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.first">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">first</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#first"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.first" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.first_two">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">first_two</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#first_two"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.first_two" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.first_two">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">first_two</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#first_two"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.first_two" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="n">a2</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="n">a1</span> <span class="n">a2</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.fourth">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">fourth</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#fourth"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.fourth" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.fourth">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">fourth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#fourth"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.fourth" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="n">a2</span> <span class="n">a3</span> <span class="n">a4</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="n">a4</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.over">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">over</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#over"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.over" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.over">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">over</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#over"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.over" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a2</span> <span class="n">a1</span> <span class="n">a2</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.pop">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">pop</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#pop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.pop" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.pop">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">pop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#pop"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.pop" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="o">--</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.popd">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">popd</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.popd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.popd">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">popd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.popd" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.popdd">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">popdd</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popdd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.popdd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.popdd">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">popdd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popdd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.popdd" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a3</span> <span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a2</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.popop">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">popop</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.popop" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.popop">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">popop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popop"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.popop" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.popopd">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">popopd</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popopd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.popopd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.popopd">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">popopd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popopd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.popopd" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a3</span> <span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.popopdd">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">popopdd</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popopdd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.popopdd" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.popopdd">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">popopdd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#popopdd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.popopdd" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a4</span> <span class="n">a3</span> <span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a2</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.rest">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">rest</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rest"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.rest" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.rest">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">rest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rest"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.rest" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="o">...</span><span class="mi">0</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="o">...</span><span class="mi">0</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.rolldown">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">rolldown</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rolldown"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.rolldown" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.rolldown">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">rolldown</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rolldown"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.rolldown" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="n">a2</span> <span class="n">a3</span> <span class="o">--</span> <span class="n">a2</span> <span class="n">a3</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.rollup">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">rollup</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rollup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.rollup" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.rollup">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">rollup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rollup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.rollup" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="n">a2</span> <span class="n">a3</span> <span class="o">--</span> <span class="n">a3</span> <span class="n">a1</span> <span class="n">a2</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.rrest">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">rrest</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rrest"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.rrest" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.rrest">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">rrest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#rrest"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.rrest" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="n">a2</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="o">...</span><span class="mi">1</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.second">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">second</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#second"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.second" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.second">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">second</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#second"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.second" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="n">a2</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="n">a2</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.stack">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">stack</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#stack"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.stack" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.stack">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">stack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#stack"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.stack" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">...</span> <span class="o">--</span> <span class="o">...</span> <span class="p">[</span><span class="o">...</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.stuncons">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">stuncons</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#stuncons"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.stuncons" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.stuncons">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">stuncons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#stuncons"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.stuncons" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">...</span> <span class="n">a1</span> <span class="o">--</span> <span class="o">...</span> <span class="n">a1</span> <span class="n">a1</span> <span class="p">[</span><span class="o">...</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.stununcons">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">stununcons</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#stununcons"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.stununcons" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.stununcons">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">stununcons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#stununcons"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.stununcons" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">...</span> <span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="o">...</span> <span class="n">a2</span> <span class="n">a1</span> <span class="n">a1</span> <span class="n">a2</span> <span class="p">[</span><span class="o">...</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.swaack">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">swaack</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#swaack"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.swaack" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.swaack">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">swaack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#swaack"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.swaack" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="o">...</span><span class="mi">0</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.swap">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">swap</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#swap"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.swap" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.swap">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">swap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#swap"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.swap" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="n">a2</span> <span class="o">--</span> <span class="n">a2</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.swons">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">swons</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#swons"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.swons" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.swons">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">swons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#swons"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.swons" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="n">a1</span> <span class="o">--</span> <span class="p">[</span><span class="n">a1</span> <span class="o">...</span><span class="mi">1</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.third">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">third</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#third"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.third" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.third">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">third</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#third"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.third" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="n">a2</span> <span class="n">a3</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="n">a3</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.tuck">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">tuck</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#tuck"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.tuck" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.tuck">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">tuck</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#tuck"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.tuck" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="n">a1</span> <span class="n">a2</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.uncons">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">uncons</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#uncons"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.uncons" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.uncons">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">uncons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#uncons"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.uncons" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="o">...</span><span class="mi">0</span><span class="p">]</span> <span class="o">--</span> <span class="n">a1</span> <span class="p">[</span><span class="o">...</span><span class="mi">0</span><span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.unit">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">unit</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#unit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.unit" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.unit">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">unit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#unit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.unit" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="o">--</span> <span class="p">[</span><span class="n">a1</span> <span class="p">])</span>
 </pre></div>
 </div>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.generated_library.unswons">
-<code class="descclassname">joy.utils.generated_library.</code><code class="descname">unswons</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#unswons"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.generated_library.unswons" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.generated_library.unswons">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.generated_library.</span></span><span class="sig-name descname"><span class="pre">unswons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/generated_library.html#unswons"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.generated_library.unswons" title="Permalink to this definition">¶</a></dt>
 <dd><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
 </dd></dl>
 
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Function Reference</a><ul>
-<li><a class="reference internal" href="#module-joy.library"><code class="docutils literal notranslate"><span class="pre">joy.library</span></code></a></li>
-<li><a class="reference internal" href="#module-joy.utils.generated_library">Auto-generated Functions</a></li>
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Function Reference</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#module-joy.library"><code class="docutils literal notranslate"><span class="pre">joy.library</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="#module-joy.utils.generated_library">Auto-generated Functions</a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -1002,25 +1023,24 @@ from each list.  The smallest list sets the length of the result list.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/library.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -1031,7 +1051,7 @@ from each list.  The smallest list sets the length of the result list.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index e288c87..420e11c 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Categorical Programming &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="The Four Fundamental Operations of Definite Action" href="The_Four_Operations.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="categorical-programming">
+  <section id="categorical-programming">
 <h1>Categorical Programming<a class="headerlink" href="#categorical-programming" title="Permalink to this headline">¶</a></h1>
 <p>DRAFT</p>
 <p><a class="reference external" href="https://en.wikipedia.org/wiki/Category_theory">Categorical</a></p>
 <p>In Manfred von Thun’s article <a class="reference external" href="http://www.kevinalbrecht.com/code/joy-mirror/j08cnt.html">Joy compared with other functional languages</a> he asks, “Could the language of categories be used for writing programs? Any lambda expression can be translated into a categorical expression, so the language of categories is expressively complete. But this does not make it a suitable language for writing programs. As it stands it is a very low-level language.”</p>
 <p>In <a class="reference external" href="http://conal.net/papers/compiling-to-categories/">Compiling to categories</a> Conal Elliott give a taste of what this might mean.</p>
 <blockquote>
-<div>It is well-known that the simply typed lambda-calculus is modeled by any cartesian closed category (CCC). This correspondence suggests giving typed functional programs a variety of interpretations, each corresponding to a different category. A convenient way to realize this idea is as a collection of meaning-preserving transformations added to an existing compiler, such as GHC for Haskell. This paper describes such an implementation and demonstrates its use for a variety of interpretations including hardware circuits, automatic differentiation, incremental computation, and interval analysis. Each such interpretation is a category easily defined in Haskell (outside of the compiler). The general technique appears to provide a compelling alternative to deeply embedded domain-specific languages.</div></blockquote>
+<div><p>It is well-known that the simply typed lambda-calculus is modeled by any cartesian closed category (CCC). This correspondence suggests giving typed functional programs a variety of interpretations, each corresponding to a different category. A convenient way to realize this idea is as a collection of meaning-preserving transformations added to an existing compiler, such as GHC for Haskell. This paper describes such an implementation and demonstrates its use for a variety of interpretations including hardware circuits, automatic differentiation, incremental computation, and interval analysis. Each such interpretation is a category easily defined in Haskell (outside of the compiler). The general technique appears to provide a compelling alternative to deeply embedded domain-specific languages.</p>
+</div></blockquote>
 <p>What he’s doing is translating lambda forms into a kind of “point-free” style that is very close to Joy code (although more verbose) and then showing how to instantiate that code over different categories to get several different kinds of program out of the same code.</p>
-</div>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
+</ul>
+</li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../index.html">Documentation overview</a><ul>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Categorical.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index daca4c6..57d7180 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>∂RE &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="prev" title="The Four Fundamental Operations of Definite Action" href="The_Four_Operations.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="re">
+  <section id="re">
 <h1>∂RE<a class="headerlink" href="#re" title="Permalink to this headline">¶</a></h1>
-<div class="section" id="brzozowskis-derivatives-of-regular-expressions">
+<section id="brzozowskis-derivatives-of-regular-expressions">
 <h2>Brzozowski’s Derivatives of Regular Expressions<a class="headerlink" href="#brzozowskis-derivatives-of-regular-expressions" title="Permalink to this headline">¶</a></h2>
 <p>Legend:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>∧ intersection
@@ -92,33 +93,33 @@ R∘λ = λ∘R = R
 <p>{a∘b for a in A for b in B}</p>
 <p>E.g.:</p>
 <p>{‘a’, ‘b’}∘{‘c’, ‘d’} → {‘ac’, ‘ad’, ‘bc’, ‘bd’}</p>
-</div>
-<div class="section" id="implementation">
+</section>
+<section id="implementation">
 <h2>Implementation<a class="headerlink" href="#implementation" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">functools</span> <span class="k">import</span> <span class="n">partial</span> <span class="k">as</span> <span class="n">curry</span>
-<span class="kn">from</span> <span class="nn">itertools</span> <span class="k">import</span> <span class="n">product</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">partial</span> <span class="k">as</span> <span class="n">curry</span>
+<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">product</span>
 </pre></div>
 </div>
-<div class="section" id="and">
+<section id="and">
 <h3><code class="docutils literal notranslate"><span class="pre">ϕ</span></code> and <code class="docutils literal notranslate"><span class="pre">λ</span></code><a class="headerlink" href="#and" title="Permalink to this headline">¶</a></h3>
 <p>The empty set and the set of just the empty string.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">phi</span> <span class="o">=</span> <span class="nb">frozenset</span><span class="p">()</span>   <span class="c1"># ϕ</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">phi</span> <span class="o">=</span> <span class="nb">frozenset</span><span class="p">()</span>   <span class="c1"># ϕ</span>
 <span class="n">y</span> <span class="o">=</span> <span class="nb">frozenset</span><span class="p">({</span><span class="s1">&#39;&#39;</span><span class="p">})</span> <span class="c1"># λ</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="two-letter-alphabet">
+</section>
+<section id="two-letter-alphabet">
 <h3>Two-letter Alphabet<a class="headerlink" href="#two-letter-alphabet" title="Permalink to this headline">¶</a></h3>
 <p>I’m only going to use two symbols (at first) becaase this is enough to
 illustrate the algorithm and because you can represent any other
 alphabet with two symbols (if you had to.)</p>
 <p>I chose the names <code class="docutils literal notranslate"><span class="pre">O</span></code> and <code class="docutils literal notranslate"><span class="pre">l</span></code> (uppercase “o” and lowercase “L”) to
 look like <code class="docutils literal notranslate"><span class="pre">0</span></code> and <code class="docutils literal notranslate"><span class="pre">1</span></code> (zero and one) respectively.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">syms</span> <span class="o">=</span> <span class="n">O</span><span class="p">,</span> <span class="n">l</span> <span class="o">=</span> <span class="nb">frozenset</span><span class="p">({</span><span class="s1">&#39;0&#39;</span><span class="p">}),</span> <span class="nb">frozenset</span><span class="p">({</span><span class="s1">&#39;1&#39;</span><span class="p">})</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">syms</span> <span class="o">=</span> <span class="n">O</span><span class="p">,</span> <span class="n">l</span> <span class="o">=</span> <span class="nb">frozenset</span><span class="p">({</span><span class="s1">&#39;0&#39;</span><span class="p">}),</span> <span class="nb">frozenset</span><span class="p">({</span><span class="s1">&#39;1&#39;</span><span class="p">})</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="representing-regular-expressions">
+</section>
+<section id="representing-regular-expressions">
 <h3>Representing Regular Expressions<a class="headerlink" href="#representing-regular-expressions" title="Permalink to this headline">¶</a></h3>
 <p>To represent REs in Python I’m going to use tagged tuples. A <em>regular
 expression</em> is one of:</p>
@@ -132,15 +133,15 @@ expression</em> is one of:</p>
 </pre></div>
 </div>
 <p>Where <code class="docutils literal notranslate"><span class="pre">R</span></code> and <code class="docutils literal notranslate"><span class="pre">S</span></code> stand for <em>regular expressions</em>.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">AND</span><span class="p">,</span> <span class="n">CONS</span><span class="p">,</span> <span class="n">KSTAR</span><span class="p">,</span> <span class="n">NOT</span><span class="p">,</span> <span class="n">OR</span> <span class="o">=</span> <span class="s1">&#39;and cons * not or&#39;</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>  <span class="c1"># Tags are just strings.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">AND</span><span class="p">,</span> <span class="n">CONS</span><span class="p">,</span> <span class="n">KSTAR</span><span class="p">,</span> <span class="n">NOT</span><span class="p">,</span> <span class="n">OR</span> <span class="o">=</span> <span class="s1">&#39;and cons * not or&#39;</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>  <span class="c1"># Tags are just strings.</span>
 </pre></div>
 </div>
 <p>Because they are formed of <code class="docutils literal notranslate"><span class="pre">frozenset</span></code>, <code class="docutils literal notranslate"><span class="pre">tuple</span></code> and <code class="docutils literal notranslate"><span class="pre">str</span></code> objects
 only, these datastructures are immutable.</p>
-</div>
-<div class="section" id="string-representation-of-re-datastructures">
+</section>
+<section id="string-representation-of-re-datastructures">
 <h3>String Representation of RE Datastructures<a class="headerlink" href="#string-representation-of-re-datastructures" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">stringy</span><span class="p">(</span><span class="n">re</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">stringy</span><span class="p">(</span><span class="n">re</span><span class="p">):</span>
     <span class="sd">&#39;&#39;&#39;</span>
 <span class="sd">    Return a nice string repr for a regular expression datastructure.</span>
 <span class="sd">    &#39;&#39;&#39;</span>
@@ -172,24 +173,24 @@ only, these datastructures are immutable.</p>
     <span class="k">raise</span> <span class="ne">ValueError</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="i">
+</section>
+<section id="i">
 <h3><code class="docutils literal notranslate"><span class="pre">I</span></code><a class="headerlink" href="#i" title="Permalink to this headline">¶</a></h3>
 <p>Match anything. Often spelled “.”</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">I</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="o">|</span><span class="mi">1</span><span class="p">)</span><span class="o">*</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">I</span> <span class="o">=</span> <span class="p">(</span><span class="n">KSTAR</span><span class="p">,</span> <span class="p">(</span><span class="n">OR</span><span class="p">,</span> <span class="n">O</span><span class="p">,</span> <span class="n">l</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">I</span> <span class="o">=</span> <span class="p">(</span><span class="n">KSTAR</span><span class="p">,</span> <span class="p">(</span><span class="n">OR</span><span class="p">,</span> <span class="n">O</span><span class="p">,</span> <span class="n">l</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">stringy</span><span class="p">(</span><span class="n">I</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">stringy</span><span class="p">(</span><span class="n">I</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="id1">
+</section>
+<section id="id1">
 <h3><code class="docutils literal notranslate"><span class="pre">(.111.)</span> <span class="pre">&amp;</span> <span class="pre">(.01</span> <span class="pre">+</span> <span class="pre">11*)'</span></code><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
 <p>The example expression from Brzozowski:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">.</span><span class="mf">111.</span><span class="p">)</span> <span class="o">&amp;</span> <span class="p">(</span><span class="o">.</span><span class="mi">01</span> <span class="o">+</span> <span class="mi">11</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;</span>
@@ -197,23 +198,23 @@ only, these datastructures are immutable.</p>
 </pre></div>
 </div>
 <p>Note that it contains one of everything.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">I</span><span class="p">,</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="n">I</span><span class="p">))))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">I</span><span class="p">,</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="n">I</span><span class="p">))))</span>
 <span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">I</span><span class="p">,</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">O</span><span class="p">,</span> <span class="n">l</span><span class="p">))</span>
 <span class="n">c</span> <span class="o">=</span> <span class="p">(</span><span class="n">CONS</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="p">(</span><span class="n">KSTAR</span><span class="p">,</span> <span class="n">l</span><span class="p">))</span>
 <span class="n">it</span> <span class="o">=</span> <span class="p">(</span><span class="n">AND</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">NOT</span><span class="p">,</span> <span class="p">(</span><span class="n">OR</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">)))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">stringy</span><span class="p">(</span><span class="n">it</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">stringy</span><span class="p">(</span><span class="n">it</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">.</span><span class="mf">111.</span><span class="p">)</span> <span class="o">&amp;</span> <span class="p">((</span><span class="o">.</span><span class="mi">01</span> <span class="o">|</span> <span class="mi">11</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="nully">
+</section>
+<section id="nully">
 <h3><code class="docutils literal notranslate"><span class="pre">nully()</span></code><a class="headerlink" href="#nully" title="Permalink to this headline">¶</a></h3>
 <p>Let’s get that auxiliary predicate function <code class="docutils literal notranslate"><span class="pre">δ</span></code> out of the way.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">nully</span><span class="p">(</span><span class="n">R</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">nully</span><span class="p">(</span><span class="n">R</span><span class="p">):</span>
     <span class="sd">&#39;&#39;&#39;</span>
 <span class="sd">    δ - Return λ if λ ⊆ R otherwise ϕ.</span>
 <span class="sd">    &#39;&#39;&#39;</span>
@@ -245,13 +246,13 @@ only, these datastructures are immutable.</p>
     <span class="k">return</span> <span class="n">r</span> <span class="o">&amp;</span> <span class="n">s</span> <span class="k">if</span> <span class="n">tag</span> <span class="ow">in</span> <span class="p">{</span><span class="n">AND</span><span class="p">,</span> <span class="n">CONS</span><span class="p">}</span> <span class="k">else</span> <span class="n">r</span> <span class="o">|</span> <span class="n">s</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="no-compaction">
+</section>
+<section id="no-compaction">
 <h3>No “Compaction”<a class="headerlink" href="#no-compaction" title="Permalink to this headline">¶</a></h3>
 <p>This is the straightforward version with no “compaction”. It works fine,
 but does waaaay too much work because the expressions grow each
 derivation.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">D</span><span class="p">(</span><span class="n">symbol</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">D</span><span class="p">(</span><span class="n">symbol</span><span class="p">):</span>
 
     <span class="k">def</span> <span class="nf">derv</span><span class="p">(</span><span class="n">R</span><span class="p">):</span>
 
@@ -292,10 +293,10 @@ derivation.</p>
     <span class="k">return</span> <span class="n">derv</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="compaction-rules">
+</section>
+<section id="compaction-rules">
 <h3>Compaction Rules<a class="headerlink" href="#compaction-rules" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">_compaction_rule</span><span class="p">(</span><span class="n">relation</span><span class="p">,</span> <span class="n">one</span><span class="p">,</span> <span class="n">zero</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">_compaction_rule</span><span class="p">(</span><span class="n">relation</span><span class="p">,</span> <span class="n">one</span><span class="p">,</span> <span class="n">zero</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
     <span class="k">return</span> <span class="p">(</span>
         <span class="n">b</span> <span class="k">if</span> <span class="n">a</span> <span class="o">==</span> <span class="n">one</span> <span class="k">else</span>  <span class="c1"># R*1 = 1*R = R</span>
         <span class="n">a</span> <span class="k">if</span> <span class="n">b</span> <span class="o">==</span> <span class="n">one</span> <span class="k">else</span>
@@ -305,7 +306,7 @@ derivation.</p>
 </pre></div>
 </div>
 <p>An elegant symmetry.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># R ∧ I = I ∧ R = R</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># R ∧ I = I ∧ R = R</span>
 <span class="c1"># R ∧ ϕ = ϕ ∧ R = ϕ</span>
 <span class="n">_and</span> <span class="o">=</span> <span class="n">curry</span><span class="p">(</span><span class="n">_compaction_rule</span><span class="p">,</span> <span class="n">AND</span><span class="p">,</span> <span class="n">I</span><span class="p">,</span> <span class="n">phi</span><span class="p">)</span>
 
@@ -318,20 +319,20 @@ derivation.</p>
 <span class="n">_cons</span> <span class="o">=</span> <span class="n">curry</span><span class="p">(</span><span class="n">_compaction_rule</span><span class="p">,</span> <span class="n">CONS</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">phi</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="memoizing">
+</section>
+<section id="memoizing">
 <h3>Memoizing<a class="headerlink" href="#memoizing" title="Permalink to this headline">¶</a></h3>
 <p>We can save re-processing by remembering results we have already
 computed. RE datastructures are immutable and the <code class="docutils literal notranslate"><span class="pre">derv()</span></code> functions
 are <em>pure</em> so this is fine.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Memo</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Memo</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
 
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">f</span> <span class="o">=</span> <span class="n">f</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">calls</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">hits</span> <span class="o">=</span> <span class="mi">0</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">mem</span> <span class="o">=</span> <span class="p">{}</span>
 
-    <span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">calls</span> <span class="o">+=</span> <span class="mi">1</span>
         <span class="k">try</span><span class="p">:</span>
             <span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mem</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
@@ -341,12 +342,12 @@ are <em>pure</em> so this is fine.</p>
         <span class="k">return</span> <span class="n">result</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="with-compaction">
+</section>
+<section id="with-compaction">
 <h3>With “Compaction”<a class="headerlink" href="#with-compaction" title="Permalink to this headline">¶</a></h3>
 <p>This version uses the rules above to perform compaction. It keeps the
 expressions from growing too large.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">D_compaction</span><span class="p">(</span><span class="n">symbol</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">D_compaction</span><span class="p">(</span><span class="n">symbol</span><span class="p">):</span>
 
     <span class="nd">@Memo</span>
     <span class="k">def</span> <span class="nf">derv</span><span class="p">(</span><span class="n">R</span><span class="p">):</span>
@@ -389,12 +390,12 @@ expressions from growing too large.</p>
     <span class="k">return</span> <span class="n">derv</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="lets-try-it-out">
+</section>
+</section>
+<section id="lets-try-it-out">
 <h2>Let’s try it out…<a class="headerlink" href="#lets-try-it-out" title="Permalink to this headline">¶</a></h2>
 <p>(FIXME: redo.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">o</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;0&#39;</span><span class="p">),</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">o</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;0&#39;</span><span class="p">),</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;1&#39;</span><span class="p">)</span>
 <span class="n">REs</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
 <span class="n">N</span> <span class="o">=</span> <span class="mi">5</span>
 <span class="n">names</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">product</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="n">N</span> <span class="o">*</span> <span class="p">[(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)])))</span>
@@ -449,10 +450,10 @@ expressions from growing too large.</p>
 <span class="p">(</span><span class="o">.</span><span class="mf">111.</span> <span class="o">|</span> <span class="mf">11.</span> <span class="o">|</span> <span class="mf">1.</span><span class="p">)</span> <span class="o">&amp;</span> <span class="p">((</span><span class="o">.</span><span class="mi">01</span> <span class="o">|</span> <span class="mi">1</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="larger-alphabets">
+</section>
+<section id="larger-alphabets">
 <h2>Larger Alphabets<a class="headerlink" href="#larger-alphabets" title="Permalink to this headline">¶</a></h2>
-<p>We could parse larger alphabets by defining patterns for e.g.&nbsp;each byte
+<p>We could parse larger alphabets by defining patterns for e.g. each byte
 of the ASCII code. Or we can generalize this code. If you study the code
 above you’ll see that we never use the “set-ness” of the symbols <code class="docutils literal notranslate"><span class="pre">O</span></code>
 and <code class="docutils literal notranslate"><span class="pre">l</span></code>. The only time Python set operators (<code class="docutils literal notranslate"><span class="pre">&amp;</span></code> and <code class="docutils literal notranslate"><span class="pre">|</span></code>) appear
@@ -489,8 +490,8 @@ computed) outputs of that function, never <code class="docutils literal notransl
 <p>This suggests that we should be able to alter the functions above to
 detect sets and deal with them appropriately. Exercise for the Reader
 for now.</p>
-</div>
-<div class="section" id="state-machine">
+</section>
+<section id="state-machine">
 <h2>State Machine<a class="headerlink" href="#state-machine" title="Permalink to this headline">¶</a></h2>
 <p>We can drive the regular expressions to flesh out the underlying state
 machine transition table.</p>
@@ -498,9 +499,11 @@ machine transition table.</p>
 </pre></div>
 </div>
 <p>Says, “Three or more 1’s and not ending in 01 nor composed of all 1’s.”</p>
-<div class="figure" id="id2">
-<img alt="omg.svg" src="notebooks/attachment:omg.svg" /><p class="caption"><span class="caption-text">omg.svg</span></p>
-</div>
+<figure class="align-default" id="id2">
+<img alt="State Machine Graph" src="../_images/omg.svg" /><figcaption>
+<p><span class="caption-text">State Machine Graph</span><a class="headerlink" href="#id2" title="Permalink to this image">¶</a></p>
+</figcaption>
+</figure>
 <p>Start at <code class="docutils literal notranslate"><span class="pre">a</span></code> and follow the transition arrows according to their
 labels. Accepting states have a double outline. (Graphic generated with
 <a class="reference external" href="http://www.graphviz.org/">Dot from Graphviz</a>.) You’ll see that only
@@ -525,7 +528,7 @@ row and still be either still at <code class="docutils literal notranslate"><spa
 0’s). If you find yourself at <code class="docutils literal notranslate"><span class="pre">i</span></code> you can see as many 0’s, or
 repetitions of 10, as there are, but if you see just a 1 you move to
 <code class="docutils literal notranslate"><span class="pre">j</span></code>.</p>
-<div class="section" id="re-to-fsm">
+<section id="re-to-fsm">
 <h3>RE to FSM<a class="headerlink" href="#re-to-fsm" title="Permalink to this headline">¶</a></h3>
 <p>So how do we get the state machine from the regular expression?</p>
 <p>It turns out that each RE is effectively a state, and each arrow points
@@ -552,18 +555,18 @@ a --1--&gt; ∂1(a)
 <p>You can see the one-way nature of the <code class="docutils literal notranslate"><span class="pre">g</span></code> state and the <code class="docutils literal notranslate"><span class="pre">hij</span></code> “trap”
 in the way that the <code class="docutils literal notranslate"><span class="pre">.111.</span></code> on the left-hand side of the <code class="docutils literal notranslate"><span class="pre">&amp;</span></code>
 disappears once it has been matched.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">defaultdict</span>
-<span class="kn">from</span> <span class="nn">pprint</span> <span class="k">import</span> <span class="n">pprint</span>
-<span class="kn">from</span> <span class="nn">string</span> <span class="k">import</span> <span class="n">ascii_lowercase</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">defaultdict</span>
+<span class="kn">from</span> <span class="nn">pprint</span> <span class="kn">import</span> <span class="n">pprint</span>
+<span class="kn">from</span> <span class="nn">string</span> <span class="kn">import</span> <span class="n">ascii_lowercase</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">d0</span><span class="p">,</span> <span class="n">d1</span> <span class="o">=</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;0&#39;</span><span class="p">),</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">d0</span><span class="p">,</span> <span class="n">d1</span> <span class="o">=</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;0&#39;</span><span class="p">),</span> <span class="n">D_compaction</span><span class="p">(</span><span class="s1">&#39;1&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="explore">
+</section>
+<section id="explore">
 <h3><code class="docutils literal notranslate"><span class="pre">explore()</span></code><a class="headerlink" href="#explore" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">explore</span><span class="p">(</span><span class="n">re</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">explore</span><span class="p">(</span><span class="n">re</span><span class="p">):</span>
 
     <span class="c1"># Don&#39;t have more than 26 states...</span>
     <span class="n">names</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="n">ascii_lowercase</span><span class="p">)</span><span class="o">.</span><span class="n">next</span><span class="p">)</span>
@@ -589,7 +592,7 @@ disappears once it has been matched.</p>
     <span class="k">return</span> <span class="n">table</span><span class="p">,</span> <span class="n">accepting</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">table</span><span class="p">,</span> <span class="n">accepting</span> <span class="o">=</span> <span class="n">explore</span><span class="p">(</span><span class="n">it</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">table</span><span class="p">,</span> <span class="n">accepting</span> <span class="o">=</span> <span class="n">explore</span><span class="p">(</span><span class="n">it</span><span class="p">)</span>
 <span class="n">table</span>
 </pre></div>
 </div>
@@ -615,18 +618,18 @@ disappears once it has been matched.</p>
  <span class="p">(</span><span class="s1">&#39;j&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span> <span class="s1">&#39;h&#39;</span><span class="p">}</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">accepting</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">accepting</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="s1">&#39;h&#39;</span><span class="p">,</span> <span class="s1">&#39;i&#39;</span><span class="p">}</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="generate-diagram">
+</section>
+<section id="generate-diagram">
 <h3>Generate Diagram<a class="headerlink" href="#generate-diagram" title="Permalink to this headline">¶</a></h3>
 <p>Once we have the FSM table and the set of accepting states we can
 generate the diagram above.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">_template</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">_template</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
 <span class="s1">digraph finite_state_machine {</span>
 <span class="s1">  rankdir=LR;</span>
 <span class="s1">  size=&quot;8,5&quot;</span>
@@ -650,7 +653,7 @@ generate the diagram above.</p>
         <span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">make_graph</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">accepting</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">make_graph</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">accepting</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">digraph</span> <span class="n">finite_state_machine</span> <span class="p">{</span>
@@ -681,8 +684,8 @@ generate the diagram above.</p>
 <span class="p">}</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="drive-a-fsm">
+</section>
+<section id="drive-a-fsm">
 <h3>Drive a FSM<a class="headerlink" href="#drive-a-fsm" title="Permalink to this headline">¶</a></h3>
 <p>There are <em>lots</em> of FSM libraries already. Once you have the state
 transition table they should all be straightforward to use. State
@@ -692,11 +695,11 @@ Python that imitates what “compiled” FSM code might look like in an
 datastructure, the code below instead acts like JMP instructions
 (“jump”, or GOTO in higher-level-but-still-low-level languages) to
 hard-code the information in the table into a little patch of branches.</p>
-<div class="section" id="trampoline-function">
+<section id="trampoline-function">
 <h4>Trampoline Function<a class="headerlink" href="#trampoline-function" title="Permalink to this headline">¶</a></h4>
 <p>Python has no GOTO statement but we can fake it with a “trampoline”
 function.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">trampoline</span><span class="p">(</span><span class="n">input_</span><span class="p">,</span> <span class="n">jump_from</span><span class="p">,</span> <span class="n">accepting</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">trampoline</span><span class="p">(</span><span class="n">input_</span><span class="p">,</span> <span class="n">jump_from</span><span class="p">,</span> <span class="n">accepting</span><span class="p">):</span>
     <span class="n">I</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">input_</span><span class="p">)</span>
     <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
         <span class="k">try</span><span class="p">:</span>
@@ -706,12 +709,12 @@ function.</p>
         <span class="n">jump_from</span> <span class="o">=</span> <span class="n">bounce_to</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="stream-functions">
+</section>
+<section id="stream-functions">
 <h4>Stream Functions<a class="headerlink" href="#stream-functions" title="Permalink to this headline">¶</a></h4>
 <p>Little helpers to process the iterator of our data (a “stream” of “1”
 and “0” characters, not bits.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">getch</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">I</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="n">I</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">getch</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">I</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="n">I</span><span class="p">))</span>
 
 
 <span class="k">def</span> <span class="nf">_1</span><span class="p">(</span><span class="n">I</span><span class="p">):</span>
@@ -724,15 +727,15 @@ and “0” characters, not bits.)</p>
     <span class="k">while</span> <span class="ow">not</span> <span class="n">getch</span><span class="p">(</span><span class="n">I</span><span class="p">):</span> <span class="k">pass</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="a-finite-state-machine">
+</section>
+<section id="a-finite-state-machine">
 <h4>A Finite State Machine<a class="headerlink" href="#a-finite-state-machine" title="Permalink to this headline">¶</a></h4>
 <p>With those preliminaries out of the way, from the state table of
 <code class="docutils literal notranslate"><span class="pre">.111.</span> <span class="pre">&amp;</span> <span class="pre">(.01</span> <span class="pre">+</span> <span class="pre">11*)'</span></code> we can immediately write down state machine
 code. (You have to imagine that these are GOTO statements in C or
 branches in assembly and that the state names are branch destination
 labels.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">I</span><span class="p">:</span> <span class="n">c</span> <span class="k">if</span> <span class="n">getch</span><span class="p">(</span><span class="n">I</span><span class="p">)</span> <span class="k">else</span> <span class="n">b</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">I</span><span class="p">:</span> <span class="n">c</span> <span class="k">if</span> <span class="n">getch</span><span class="p">(</span><span class="n">I</span><span class="p">)</span> <span class="k">else</span> <span class="n">b</span>
 <span class="n">b</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">I</span><span class="p">:</span> <span class="n">_0</span><span class="p">(</span><span class="n">I</span><span class="p">)</span> <span class="ow">or</span> <span class="n">d</span>
 <span class="n">c</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">I</span><span class="p">:</span> <span class="n">e</span> <span class="k">if</span> <span class="n">getch</span><span class="p">(</span><span class="n">I</span><span class="p">)</span> <span class="k">else</span> <span class="n">b</span>
 <span class="n">d</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">I</span><span class="p">:</span> <span class="n">f</span> <span class="k">if</span> <span class="n">getch</span><span class="p">(</span><span class="n">I</span><span class="p">)</span> <span class="k">else</span> <span class="n">b</span>
@@ -747,11 +750,11 @@ labels.)</p>
 <p>Note that the implementations of <code class="docutils literal notranslate"><span class="pre">h</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code> are identical ergo
 <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">g</span></code> and we could eliminate one in the code but <code class="docutils literal notranslate"><span class="pre">h</span></code> is an
 accepting state and <code class="docutils literal notranslate"><span class="pre">g</span></code> isn’t.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">acceptable</span><span class="p">(</span><span class="n">input_</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">acceptable</span><span class="p">(</span><span class="n">input_</span><span class="p">):</span>
     <span class="k">return</span> <span class="n">trampoline</span><span class="p">(</span><span class="n">input_</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="p">{</span><span class="n">h</span><span class="p">,</span> <span class="n">i</span><span class="p">})</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="o">**</span><span class="mi">5</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="o">**</span><span class="mi">5</span><span class="p">):</span>
     <span class="n">s</span> <span class="o">=</span> <span class="nb">bin</span><span class="p">(</span><span class="n">n</span><span class="p">)[</span><span class="mi">2</span><span class="p">:]</span>
     <span class="nb">print</span> <span class="s1">&#39;</span><span class="si">%05s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">s</span><span class="p">,</span> <span class="n">acceptable</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
 </pre></div>
@@ -790,10 +793,10 @@ accepting state and <code class="docutils literal notranslate"><span class="pre"
 <span class="mi">11111</span> <span class="kc">False</span>
 </pre></div>
 </div>
-</div>
-</div>
-</div>
-<div class="section" id="reversing-the-derivatives-to-generate-matching-strings">
+</section>
+</section>
+</section>
+<section id="reversing-the-derivatives-to-generate-matching-strings">
 <h2>Reversing the Derivatives to Generate Matching Strings<a class="headerlink" href="#reversing-the-derivatives-to-generate-matching-strings" title="Permalink to this headline">¶</a></h2>
 <p>(UNFINISHED) Brzozowski also shewed how to go from the state machine to
 strings and expressions…</p>
@@ -837,51 +840,55 @@ derivative-with-respect-to-N of some other state/RE:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">j</span> <span class="o">=</span> <span class="p">(</span><span class="mi">01</span><span class="p">)</span><span class="o">*</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">∂RE</a><ul>
-<li><a class="reference internal" href="#brzozowskis-derivatives-of-regular-expressions">Brzozowski’s Derivatives of Regular Expressions</a></li>
-<li><a class="reference internal" href="#implementation">Implementation</a><ul>
-<li><a class="reference internal" href="#and"><code class="docutils literal notranslate"><span class="pre">ϕ</span></code> and <code class="docutils literal notranslate"><span class="pre">λ</span></code></a></li>
-<li><a class="reference internal" href="#two-letter-alphabet">Two-letter Alphabet</a></li>
-<li><a class="reference internal" href="#representing-regular-expressions">Representing Regular Expressions</a></li>
-<li><a class="reference internal" href="#string-representation-of-re-datastructures">String Representation of RE Datastructures</a></li>
-<li><a class="reference internal" href="#i"><code class="docutils literal notranslate"><span class="pre">I</span></code></a></li>
-<li><a class="reference internal" href="#id1"><code class="docutils literal notranslate"><span class="pre">(.111.)</span> <span class="pre">&amp;</span> <span class="pre">(.01</span> <span class="pre">+</span> <span class="pre">11*)'</span></code></a></li>
-<li><a class="reference internal" href="#nully"><code class="docutils literal notranslate"><span class="pre">nully()</span></code></a></li>
-<li><a class="reference internal" href="#no-compaction">No “Compaction”</a></li>
-<li><a class="reference internal" href="#compaction-rules">Compaction Rules</a></li>
-<li><a class="reference internal" href="#memoizing">Memoizing</a></li>
-<li><a class="reference internal" href="#with-compaction">With “Compaction”</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#lets-try-it-out">Let’s try it out…</a></li>
-<li><a class="reference internal" href="#larger-alphabets">Larger Alphabets</a></li>
-<li><a class="reference internal" href="#state-machine">State Machine</a><ul>
-<li><a class="reference internal" href="#re-to-fsm">RE to FSM</a></li>
-<li><a class="reference internal" href="#explore"><code class="docutils literal notranslate"><span class="pre">explore()</span></code></a></li>
-<li><a class="reference internal" href="#generate-diagram">Generate Diagram</a></li>
-<li><a class="reference internal" href="#drive-a-fsm">Drive a FSM</a><ul>
-<li><a class="reference internal" href="#trampoline-function">Trampoline Function</a></li>
-<li><a class="reference internal" href="#stream-functions">Stream Functions</a></li>
-<li><a class="reference internal" href="#a-finite-state-machine">A Finite State Machine</a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#reversing-the-derivatives-to-generate-matching-strings">Reversing the Derivatives to Generate Matching Strings</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -892,25 +899,24 @@ derivative-with-respect-to-N of some other state/RE:</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Derivatives_of_Regular_Expressions.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -921,7 +927,7 @@ derivative-with-respect-to-N of some other state/RE:</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 92d3588..164db0d 100644 (file)
@@ -1,19 +1,19 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Developing a Program in Joy &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
+    <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Quadratic formula" href="Quadratic.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="developing-a-program-in-joy">
+  <section id="developing-a-program-in-joy">
 <h1>Developing a Program in Joy<a class="headerlink" href="#developing-a-program-in-joy" title="Permalink to this headline">¶</a></h1>
 <p>As an example of developing a program in Joy let’s take the first problem from the Project Euler website.</p>
-<div class="section" id="project-euler-first-problem-multiples-of-3-and-5">
+<section id="project-euler-first-problem-multiples-of-3-and-5">
 <h2><a class="reference external" href="https://projecteuler.net/problem=1">Project Euler, first problem: “Multiples of 3 and 5”</a><a class="headerlink" href="#project-euler-first-problem-multiples-of-3-and-5" title="Permalink to this headline">¶</a></h2>
 <blockquote>
 <div><p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.</p>
 <p>Find the sum of all the multiples of 3 or 5 below 1000.</p>
 </div></blockquote>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
 </pre></div>
 </div>
-<div class="section" id="sum-a-range-filtered-by-a-predicate">
+<section id="sum-a-range-filtered-by-a-predicate">
 <h3>Sum a range filtered by a predicate<a class="headerlink" href="#sum-a-range-filtered-by-a-predicate" title="Permalink to this headline">¶</a></h3>
 <p>Let’s create a predicate that returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if a number is a multiple
 of 3 or 5 and <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;P == [3 % not] dupdip 5 % not or&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;P == [3 % not] dupdip 5 % not or&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;80 P&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;80 P&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>             <span class="o">.</span> <span class="mi">80</span> <span class="n">P</span>
@@ -80,8 +82,8 @@ should be; we generate one thousand integers but actually use less than
 half of them. A better solution would be to generate just the multiples
 we want to sum, and to add them as we go rather than storing them and
 and summing them at the end.</p>
-</div>
-<div class="section" id="generate-just-the-multiples">
+</section>
+<section id="generate-just-the-multiples">
 <h3>Generate just the multiples<a class="headerlink" href="#generate-just-the-multiples" title="Permalink to this headline">¶</a></h3>
 <p>At first I had the idea to use two counters and increase them by three
 and five, respectively. This way we only generate the terms that we
@@ -114,10 +116,10 @@ the counter to the running sum. This function will do that:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">PE1</span><span class="o">.</span><span class="mi">1</span> <span class="o">==</span> <span class="o">+</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="n">dupdip</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.1 == + [+] dupdip&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.1 == + [+] dupdip&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 3 PE1.1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 3 PE1.1&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>        <span class="o">.</span> <span class="mi">0</span> <span class="mi">0</span> <span class="mi">3</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">1</span>
@@ -132,7 +134,7 @@ the counter to the running sum. This function will do that:</p>
     <span class="mi">3</span> <span class="mi">3</span> <span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 [3 2 1 3 1 2 3] [PE1.1] step&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 [3 2 1 3 1 2 3] [PE1.1] step&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                            <span class="o">.</span> <span class="mi">0</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span><span class="p">]</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mi">1</span><span class="p">]</span> <span class="n">step</span>
@@ -212,29 +214,29 @@ the counter to the running sum. This function will do that:</p>
 </div>
 <p>So one <code class="docutils literal notranslate"><span class="pre">step</span></code> through all seven terms brings the counter to 15 and the
 total to 60.</p>
-</div>
-<div class="section" id="how-many-multiples-to-sum">
+</section>
+<section id="how-many-multiples-to-sum">
 <h3>How many multiples to sum?<a class="headerlink" href="#how-many-multiples-to-sum" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1000</span> <span class="o">/</span> <span class="mi">15</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="mi">1000</span> <span class="o">/</span> <span class="mi">15</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">66</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">66</span> <span class="o">*</span> <span class="mi">15</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="mi">66</span> <span class="o">*</span> <span class="mi">15</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">990</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1000</span> <span class="o">-</span> <span class="mi">990</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="mi">1000</span> <span class="o">-</span> <span class="mi">990</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span>
 </pre></div>
 </div>
 <p>We only want the terms <em>less than</em> 1000.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">999</span> <span class="o">-</span> <span class="mi">990</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="mi">999</span> <span class="o">-</span> <span class="mi">990</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">9</span>
@@ -242,17 +244,17 @@ total to 60.</p>
 </div>
 <p>That means we want to run the full list of numbers sixty-six times to
 get to 990 and then the first four numbers 3 2 1 3 to get to 999.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">233168</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="packing-the-terms-into-an-integer">
+</section>
+<section id="packing-the-terms-into-an-integer">
 <h3>Packing the terms into an integer<a class="headerlink" href="#packing-the-terms-into-an-integer" title="Permalink to this headline">¶</a></h3>
 <p>This form uses no extra storage and produces no unused summands. It’s
 good but there’s one more trick we can apply. The list of seven terms
@@ -265,16 +267,16 @@ integer terms from the list.</p>
 <span class="mi">0</span><span class="n">b</span> <span class="mi">11</span> <span class="mi">10</span> <span class="mi">01</span> <span class="mi">11</span> <span class="mi">01</span> <span class="mi">10</span> <span class="mi">11</span> <span class="o">==</span> <span class="mi">14811</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mb">0b11100111011011</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="mb">0b11100111011011</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">14811</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.2 == [3 &amp; PE1.1] dupdip 2 &gt;&gt;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.2 == [3 &amp; PE1.1] dupdip 2 &gt;&gt;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 14811 PE1.2&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 14811 PE1.2&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                      <span class="o">.</span> <span class="mi">0</span> <span class="mi">0</span> <span class="mi">14811</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">2</span>
@@ -297,7 +299,7 @@ integer terms from the list.</p>
              <span class="mi">3</span> <span class="mi">3</span> <span class="mi">3702</span> <span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;3 3 3702 PE1.2&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;3 3 3702 PE1.2&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                     <span class="o">.</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">3702</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">2</span>
@@ -320,7 +322,7 @@ integer terms from the list.</p>
              <span class="mi">8</span> <span class="mi">5</span> <span class="mi">925</span> <span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 14811 7 [PE1.2] times pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;0 0 14811 7 [PE1.2] times pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                      <span class="o">.</span> <span class="mi">0</span> <span class="mi">0</span> <span class="mi">14811</span> <span class="mi">7</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mi">2</span><span class="p">]</span> <span class="n">times</span> <span class="n">pop</span>
@@ -457,17 +459,17 @@ integer terms from the list.</p>
 </pre></div>
 </div>
 <p>And so we have at last:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">233168</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="let-s-refactor">
+</section>
+<section id="let-s-refactor">
 <h3>Let’s refactor<a class="headerlink" href="#let-s-refactor" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>  <span class="mi">14811</span> <span class="mi">7</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mi">2</span><span class="p">]</span> <span class="n">times</span> <span class="n">pop</span>
   <span class="mi">14811</span> <span class="mi">4</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mi">2</span><span class="p">]</span> <span class="n">times</span> <span class="n">pop</span>
@@ -475,14 +477,14 @@ integer terms from the list.</p>
 <span class="n">n</span> <span class="mi">14811</span> <span class="n">swap</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mi">2</span><span class="p">]</span> <span class="n">times</span> <span class="n">pop</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.3 == 14811 swap [PE1.2] times pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.3 == 14811 swap [PE1.2] times pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Now we can simplify the definition above:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">233168</span>
@@ -497,18 +499,18 @@ I hope it’s clear.</p>
 <span class="n">PE1</span> <span class="o">==</span> <span class="mi">0</span> <span class="mi">0</span> <span class="mi">66</span> <span class="p">[</span><span class="mi">7</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">3</span><span class="p">]</span> <span class="n">times</span> <span class="mi">4</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">3</span> <span class="n">pop</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="generator-version">
+</section>
+</section>
+<section id="generator-version">
 <h2>Generator Version<a class="headerlink" href="#generator-version" title="Permalink to this headline">¶</a></h2>
 <p>It’s a little clunky iterating sixty-six times though the seven numbers
 then four more. In the <em>Generator Programs</em> notebook we derive a
 generator that can be repeatedly driven by the <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator to
 produce a stream of the seven numbers repeating over and over again.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &amp;] dupdip 2 &gt;&gt;] dip rest cons]&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &amp;] dupdip 2 &gt;&gt;] dip rest cons]&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1.terms 21 [x] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1.terms 21 [x] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="p">[</span><span class="n">pop</span> <span class="mi">14811</span><span class="p">]</span> <span class="p">[]</span> <span class="n">branch</span> <span class="p">[</span><span class="mi">3</span> <span class="o">&amp;</span><span class="p">]</span> <span class="n">dupdip</span> <span class="mi">2</span> <span class="o">&gt;&gt;</span><span class="p">]</span> <span class="n">dip</span> <span class="n">rest</span> <span class="n">cons</span><span class="p">]</span>
@@ -516,19 +518,19 @@ produce a stream of the seven numbers repeating over and over again.</p>
 </div>
 <p>We know from above that we need sixty-six times seven then four more
 terms to reach up to but not over one thousand.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;7 66 * 4 +&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;7 66 * 4 +&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">466</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1.terms 466 [x] times pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE1.terms 466 [x] times pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[PE1.terms 466 [x] times pop] run sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[PE1.terms 466 [x] times pop] run sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">999</span>
@@ -537,18 +539,18 @@ terms to reach up to but not over one thousand.</p>
 <p>Now we can use <code class="docutils literal notranslate"><span class="pre">PE1.1</span></code> to accumulate the terms as we go, and then
 <code class="docutils literal notranslate"><span class="pre">pop</span></code> the generator and the counter from the stack when we’re done,
 leaving just the sum.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 0 PE1.terms 466 [x [PE1.1] dip] times popop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 0 PE1.terms 466 [x [PE1.1] dip] times popop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">233168</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="a-little-further-analysis-renders-iteration-unnecessary">
+</section>
+<section id="a-little-further-analysis-renders-iteration-unnecessary">
 <h2>A little further analysis renders iteration unnecessary.<a class="headerlink" href="#a-little-further-analysis-renders-iteration-unnecessary" title="Permalink to this headline">¶</a></h2>
 <p>Consider finding the sum of the positive integers less than or equal to
 ten.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[10 9 8 7 6 5 4 3 2 1] sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[10 9 8 7 6 5 4 3 2 1] sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">55</span>
@@ -571,10 +573,10 @@ positive integers is:</p>
 </div>
 <p>(The formula also works for odd values of N, I’ll leave that to you if
 you want to work it out or you can take my word for it.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;F == dup ++ * 2 floordiv&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;F == dup ++ * 2 floordiv&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;10 F&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;10 F&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>      <span class="o">.</span> <span class="mi">10</span> <span class="n">F</span>
@@ -598,13 +600,13 @@ each, starting with:</p>
 </pre></div>
 </div>
 <p>If we reverse one of these two blocks and sum pairs…</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[[</span><span class="mi">978</span> <span class="mi">15</span><span class="p">]</span> <span class="p">[</span><span class="mi">980</span> <span class="mi">12</span><span class="p">]</span> <span class="p">[</span><span class="mi">981</span> <span class="mi">10</span><span class="p">]</span> <span class="p">[</span><span class="mi">984</span> <span class="mi">9</span><span class="p">]</span> <span class="p">[</span><span class="mi">985</span> <span class="mi">6</span><span class="p">]</span> <span class="p">[</span><span class="mi">987</span> <span class="mi">5</span><span class="p">]</span> <span class="p">[</span><span class="mi">990</span> <span class="mi">3</span><span class="p">]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">993</span> <span class="mi">992</span> <span class="mi">991</span> <span class="mi">993</span> <span class="mi">991</span> <span class="mi">992</span> <span class="mi">993</span><span class="p">]</span>
@@ -612,7 +614,7 @@ each, starting with:</p>
 </div>
 <p>(Interesting that the sequence of seven numbers appears again in the
 rightmost digit of each term.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">6945</span>
@@ -626,7 +628,7 @@ additional unpaired terms between 990 and 1000:</p>
 </div>
 <p>So we can give the “sum of all the multiples of 3 or 5 below 1000” like
 so:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;6945 33 * [993 995 996 999] cons sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;6945 33 * [993 995 996 999] cons sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">233168</span>
@@ -648,8 +650,8 @@ directly from the diagram: 4 3 1 4 2 2 4 1 3 4.</p>
 <em>lcm</em> don’t matter, the pattern they make will always be symmetrical
 around its midpoint. The same reasoning holds for multiples of more than
 two numbers.</p>
-</div>
-<div class="section" id="the-simplest-program">
+</section>
+<section id="the-simplest-program">
 <h2>The Simplest Program<a class="headerlink" href="#the-simplest-program" title="Permalink to this headline">¶</a></h2>
 <p>Of course, the simplest joy program for the first Project Euler problem
 is just:</p>
@@ -657,32 +659,55 @@ is just:</p>
 </pre></div>
 </div>
 <p>Fin.</p>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Developing a Program in Joy</a><ul>
-<li><a class="reference internal" href="#project-euler-first-problem-multiples-of-3-and-5">Project Euler, first problem: “Multiples of 3 and 5”</a><ul>
-<li><a class="reference internal" href="#sum-a-range-filtered-by-a-predicate">Sum a range filtered by a predicate</a></li>
-<li><a class="reference internal" href="#generate-just-the-multiples">Generate just the multiples</a></li>
-<li><a class="reference internal" href="#how-many-multiples-to-sum">How many multiples to sum?</a></li>
-<li><a class="reference internal" href="#packing-the-terms-into-an-integer">Packing the terms into an integer</a></li>
-<li><a class="reference internal" href="#let-s-refactor">Let’s refactor</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#generator-version">Generator Version</a></li>
-<li><a class="reference internal" href="#a-little-further-analysis-renders-iteration-unnecessary">A little further analysis renders iteration unnecessary.</a></li>
-<li><a class="reference internal" href="#the-simplest-program">The Simplest Program</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -694,25 +719,24 @@ is just:</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Developing.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -723,7 +747,7 @@ is just:</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 6587f87..19aa59b 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Using x to Generate Values &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Newton’s method" href="Newton-Raphson.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="using-x-to-generate-values">
+  <section id="using-x-to-generate-values">
 <h1>Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values<a class="headerlink" href="#using-x-to-generate-values" title="Permalink to this headline">¶</a></h1>
 <p>Cf. jp-reprod.html</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
 </pre></div>
 </div>
 <p>Consider the <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator:</p>
@@ -75,7 +76,7 @@ function <code class="docutils literal notranslate"><span class="pre">C</span></
 </pre></div>
 </div>
 <p>Let’s try it:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[0 swap [dup ++] dip rest cons] x&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[0 swap [dup ++] dip rest cons] x&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                           <span class="o">.</span> <span class="p">[</span><span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="o">++</span><span class="p">]</span> <span class="n">dip</span> <span class="n">rest</span> <span class="n">cons</span><span class="p">]</span> <span class="n">x</span>
@@ -94,18 +95,18 @@ function <code class="docutils literal notranslate"><span class="pre">C</span></
 </div>
 <p>After one application of <code class="docutils literal notranslate"><span class="pre">x</span></code> the quoted program contains <code class="docutils literal notranslate"><span class="pre">1</span></code> and
 <code class="docutils literal notranslate"><span class="pre">0</span></code> is below it on the stack.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[0 swap [dup ++] dip rest cons] x x x x x pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[0 swap [dup ++] dip rest cons] x x x x x pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span>
 </pre></div>
 </div>
-<div class="section" id="direco">
+<section id="direco">
 <h2><code class="docutils literal notranslate"><span class="pre">direco</span></code><a class="headerlink" href="#direco" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;direco == dip rest cons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;direco == dip rest cons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[0 swap [dup ++] direco] x&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[0 swap [dup ++] direco] x&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                    <span class="o">.</span> <span class="p">[</span><span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="o">++</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span> <span class="n">x</span>
@@ -123,8 +124,8 @@ function <code class="docutils literal notranslate"><span class="pre">C</span></
          <span class="mi">0</span> <span class="p">[</span><span class="mi">1</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="o">++</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="making-generators">
+</section>
+<section id="making-generators">
 <h2>Making Generators<a class="headerlink" href="#making-generators" title="Permalink to this headline">¶</a></h2>
 <p>We want to define a function that accepts <code class="docutils literal notranslate"><span class="pre">a</span></code> and <code class="docutils literal notranslate"><span class="pre">[C]</span></code> and builds
 our quoted program:</p>
@@ -146,44 +147,44 @@ our quoted program:</p>
 <span class="n">G</span> <span class="o">==</span> <span class="p">[</span><span class="n">direco</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">swap</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">cons</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;G == [direco] cons [swap] swoncat cons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;G == [direco] cons [swap] swoncat cons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Let’s try it out:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [dup ++] G&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [dup ++] G&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="o">++</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [dup ++] G x x x pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [dup ++] G x x x pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span> <span class="mi">1</span> <span class="mi">2</span>
 </pre></div>
 </div>
-<div class="section" id="powers-of-2">
+<section id="powers-of-2">
 <h3>Powers of 2<a class="headerlink" href="#powers-of-2" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 [dup 1 &lt;&lt;] G x x x x x x x x x pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;1 [dup 1 &lt;&lt;] G x x x x x x x x x pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">4</span> <span class="mi">8</span> <span class="mi">16</span> <span class="mi">32</span> <span class="mi">64</span> <span class="mi">128</span> <span class="mi">256</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="x-times">
+</section>
+<section id="x-times">
 <h3><code class="docutils literal notranslate"><span class="pre">[x]</span> <span class="pre">times</span></code><a class="headerlink" href="#x-times" title="Permalink to this headline">¶</a></h3>
 <p>If we have one of these quoted programs we can drive it using <code class="docutils literal notranslate"><span class="pre">times</span></code>
 with the <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 [dup ++] G 5 [x] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 [dup ++] G 5 [x] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span> <span class="mi">24</span> <span class="mi">25</span> <span class="mi">26</span> <span class="mi">27</span> <span class="p">[</span><span class="mi">28</span> <span class="n">swap</span> <span class="p">[</span><span class="n">dup</span> <span class="o">++</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="generating-multiples-of-three-and-five">
+</section>
+</section>
+<section id="generating-multiples-of-three-and-five">
 <h2>Generating Multiples of Three and Five<a class="headerlink" href="#generating-multiples-of-three-and-five" title="Permalink to this headline">¶</a></h2>
 <p>Look at the treatment of the Project Euler Problem One in the
 “Developing a Program” notebook and you’ll see that we might be
@@ -199,10 +200,10 @@ int:</p>
 </div>
 <p>And pick them off by masking with 3 (binary 11) and then shifting the
 int right two bits.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.1 == dup [3 &amp;] dip 2 &gt;&gt;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.1 == dup [3 &amp;] dip 2 &gt;&gt;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;14811 PE1.1&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;14811 PE1.1&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                  <span class="o">.</span> <span class="mi">14811</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">1</span>
@@ -219,33 +220,33 @@ int right two bits.</p>
 </pre></div>
 </div>
 <p>If we plug <code class="docutils literal notranslate"><span class="pre">14811</span></code> and <code class="docutils literal notranslate"><span class="pre">[PE1.1]</span></code> into our generator form…</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;14811 [PE1.1] G&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;14811 [PE1.1] G&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">14811</span> <span class="n">swap</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mi">1</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
 </pre></div>
 </div>
 <p>…we get a generator that works for seven cycles before it reaches zero:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1] direco] 7 [x] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1] direco] 7 [x] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mi">1</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="section" id="reset-at-zero">
+<section id="reset-at-zero">
 <h3>Reset at Zero<a class="headerlink" href="#reset-at-zero" title="Permalink to this headline">¶</a></h3>
 <p>We need a function that checks if the int has reached zero and resets it
 if so.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.1.check == dup [pop 14811] [] branch&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.1.check == dup [pop 14811] [] branch&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;14811 [PE1.1.check PE1.1] G&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;14811 [PE1.1.check PE1.1] G&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">14811</span> <span class="n">swap</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mf">1.</span><span class="n">check</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">1</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mf">1.</span><span class="n">check</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">1</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
@@ -255,47 +256,47 @@ if so.</p>
 that’s a little beyond the scope of this article. This solution does
 extra work, but not much, and we’re not using it “in production” as they
 say.)</p>
-</div>
-<div class="section" id="run-466-times">
+</section>
+<section id="run-466-times">
 <h3>Run 466 times<a class="headerlink" href="#run-466-times" title="Permalink to this headline">¶</a></h3>
 <p>In the PE1 problem we are asked to sum all the multiples of three and
 five less than 1000. It’s worked out that we need to use all seven
 numbers sixty-six times and then four more.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;7 66 * 4 +&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;7 66 * 4 +&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">466</span>
 </pre></div>
 </div>
 <p>If we drive our generator 466 times and sum the stack we get 999.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">57</span> <span class="n">swap</span> <span class="p">[</span><span class="n">PE1</span><span class="o">.</span><span class="mf">1.</span><span class="n">check</span> <span class="n">PE1</span><span class="o">.</span><span class="mi">1</span><span class="p">]</span> <span class="n">direco</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">999</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="project-euler-problem-one">
+</section>
+</section>
+<section id="project-euler-problem-one">
 <h2>Project Euler Problem One<a class="headerlink" href="#project-euler-problem-one" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.2 == + dup [+] dip&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE1.2 == + dup [+] dip&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Now we can add <code class="docutils literal notranslate"><span class="pre">PE1.2</span></code> to the quoted program given to <code class="docutils literal notranslate"><span class="pre">G</span></code>.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">233168</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="a-generator-for-the-fibonacci-sequence">
+</section>
+<section id="a-generator-for-the-fibonacci-sequence">
 <h2>A generator for the Fibonacci Sequence.<a class="headerlink" href="#a-generator-for-the-fibonacci-sequence" title="Permalink to this headline">¶</a></h2>
 <p>Consider:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">b</span> <span class="n">a</span> <span class="n">F</span><span class="p">]</span> <span class="n">x</span>
@@ -350,42 +351,43 @@ numbers sixty-six times and then four more.</p>
 <span class="n">fib_gen</span> <span class="o">==</span> <span class="p">[</span><span class="mi">1</span> <span class="mi">1</span> <span class="n">F</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;fib == + [popdd over] cons infra uncons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;fib == + [popdd over] cons infra uncons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;fib_gen == [1 1 fib]&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;fib_gen == [1 1 fib]&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;fib_gen 10 [x] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;fib_gen 10 [x] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">5</span> <span class="mi">8</span> <span class="mi">13</span> <span class="mi">21</span> <span class="mi">34</span> <span class="mi">55</span> <span class="mi">89</span> <span class="p">[</span><span class="mi">144</span> <span class="mi">89</span> <span class="n">fib</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="project-euler-problem-two">
+</section>
+<section id="project-euler-problem-two">
 <h2>Project Euler Problem Two<a class="headerlink" href="#project-euler-problem-two" title="Permalink to this headline">¶</a></h2>
 <blockquote>
-<div>By considering the terms in the Fibonacci sequence whose values do
-not exceed four million, find the sum of the even-valued terms.</div></blockquote>
+<div><p>By considering the terms in the Fibonacci sequence whose values do
+not exceed four million, find the sum of the even-valued terms.</p>
+</div></blockquote>
 <p>Now that we have a generator for the Fibonacci sequence, we need a
 function that adds a term in the sequence to a sum if it is even, and
 <code class="docutils literal notranslate"><span class="pre">pop</span></code>s it otherwise.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE2.1 == dup 2 % [+] [pop] branch&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE2.1 == dup 2 % [+] [pop] branch&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>And a predicate function that detects when the terms in the series
 “exceed four million”.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;&gt;4M == 4000000 &gt;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;&gt;4M == 4000000 &gt;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Now it’s straightforward to define <code class="docutils literal notranslate"><span class="pre">PE2</span></code> as a recursive function that
 generates terms in the Fibonacci sequence until they exceed four million
 and sums the even ones.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE2 == 0 fib_gen x [pop &gt;4M] [popop] [[PE2.1] dip x] primrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE2 == 0 fib_gen x [pop &gt;4M] [popop] [[PE2.1] dip x] primrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE2&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;PE2&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">4613732</span>
@@ -402,7 +404,7 @@ and sums the even ones.</p>
 <span class="n">PE2</span> <span class="o">==</span> <span class="mi">0</span> <span class="n">fib_gen</span> <span class="n">x</span> <span class="p">[</span><span class="n">pop</span> <span class="o">&gt;</span><span class="mi">4</span><span class="n">M</span><span class="p">]</span> <span class="p">[</span><span class="n">popop</span><span class="p">]</span> <span class="p">[[</span><span class="n">PE2</span><span class="o">.</span><span class="mi">1</span><span class="p">]</span> <span class="n">dip</span> <span class="n">x</span><span class="p">]</span> <span class="n">primrec</span>
 </pre></div>
 </div>
-<div class="section" id="even-valued-fibonacci-terms">
+<section id="even-valued-fibonacci-terms">
 <h3>Even-valued Fibonacci Terms<a class="headerlink" href="#even-valued-fibonacci-terms" title="Permalink to this headline">¶</a></h3>
 <p>Using <code class="docutils literal notranslate"><span class="pre">o</span></code> for odd and <code class="docutils literal notranslate"><span class="pre">e</span></code> for even:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">o</span> <span class="o">+</span> <span class="n">o</span> <span class="o">=</span> <span class="n">e</span>
@@ -416,23 +418,23 @@ and sums the even ones.</p>
 </pre></div>
 </div>
 <p>Every third term is even.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 0 fib] x x x&#39;</span><span class="p">)</span>  <span class="c1"># To start the sequence with 1 1 2 3 instead of 1 2 3.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 0 fib] x x x&#39;</span><span class="p">)</span>  <span class="c1"># To start the sequence with 1 1 2 3 instead of 1 2 3.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="mi">1</span> <span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="n">fib</span><span class="p">]</span>
 </pre></div>
 </div>
 <p>Drive the generator three times and <code class="docutils literal notranslate"><span class="pre">popop</span></code> the two odd terms.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 0 fib] x x x [popop] dipd&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 0 fib] x x x [popop] dipd&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="n">fib</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE2.2 == x x x [popop] dipd&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;PE2.2 == x x x [popop] dipd&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 0 fib] 10 [PE2.2] times&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 0 fib] 10 [PE2.2] times&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span> <span class="mi">8</span> <span class="mi">34</span> <span class="mi">144</span> <span class="mi">610</span> <span class="mi">2584</span> <span class="mi">10946</span> <span class="mi">46368</span> <span class="mi">196418</span> <span class="mi">832040</span> <span class="p">[</span><span class="mi">1346269</span> <span class="mi">832040</span> <span class="n">fib</span><span class="p">]</span>
@@ -440,25 +442,25 @@ and sums the even ones.</p>
 </div>
 <p>Replace <code class="docutils literal notranslate"><span class="pre">x</span></code> with our new driver function <code class="docutils literal notranslate"><span class="pre">PE2.2</span></code> and start our
 <code class="docutils literal notranslate"><span class="pre">fib</span></code> generator at <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">0</span></code>.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [1 0 fib] PE2.2 [pop &gt;4M] [popop] [[PE2.1] dip PE2.2] primrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [1 0 fib] PE2.2 [pop &gt;4M] [popop] [[PE2.1] dip PE2.2] primrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">4613732</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="how-to-compile-these">
+</section>
+</section>
+<section id="how-to-compile-these">
 <h2>How to compile these?<a class="headerlink" href="#how-to-compile-these" title="Permalink to this headline">¶</a></h2>
 <p>You would probably start with a special version of <code class="docutils literal notranslate"><span class="pre">G</span></code>, and perhaps
 modifications to the default <code class="docutils literal notranslate"><span class="pre">x</span></code>?</p>
-</div>
-<div class="section" id="an-interesting-variation">
+</section>
+<section id="an-interesting-variation">
 <h2>An Interesting Variation<a class="headerlink" href="#an-interesting-variation" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;codireco == cons dip rest cons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;codireco == cons dip rest cons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[0 [dup ++] codireco] x&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[0 [dup ++] codireco] x&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                 <span class="o">.</span> <span class="p">[</span><span class="mi">0</span> <span class="p">[</span><span class="n">dup</span> <span class="o">++</span><span class="p">]</span> <span class="n">codireco</span><span class="p">]</span> <span class="n">x</span>
@@ -477,49 +479,64 @@ modifications to the default <code class="docutils literal notranslate"><span cl
          <span class="mi">0</span> <span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="n">dup</span> <span class="o">++</span><span class="p">]</span> <span class="n">codireco</span><span class="p">]</span> <span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;G == [codireco] cons cons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;G == [codireco] cons cons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;230 [dup ++] G 5 [x] times pop&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;230 [dup ++] G 5 [x] times pop&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">230</span> <span class="mi">231</span> <span class="mi">232</span> <span class="mi">233</span> <span class="mi">234</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a><ul>
-<li><a class="reference internal" href="#direco"><code class="docutils literal notranslate"><span class="pre">direco</span></code></a></li>
-<li><a class="reference internal" href="#making-generators">Making Generators</a><ul>
-<li><a class="reference internal" href="#powers-of-2">Powers of 2</a></li>
-<li><a class="reference internal" href="#x-times"><code class="docutils literal notranslate"><span class="pre">[x]</span> <span class="pre">times</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#generating-multiples-of-three-and-five">Generating Multiples of Three and Five</a><ul>
-<li><a class="reference internal" href="#reset-at-zero">Reset at Zero</a></li>
-<li><a class="reference internal" href="#run-466-times">Run 466 times</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#project-euler-problem-one">Project Euler Problem One</a></li>
-<li><a class="reference internal" href="#a-generator-for-the-fibonacci-sequence">A generator for the Fibonacci Sequence.</a></li>
-<li><a class="reference internal" href="#project-euler-problem-two">Project Euler Problem Two</a><ul>
-<li><a class="reference internal" href="#even-valued-fibonacci-terms">Even-valued Fibonacci Terms</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#how-to-compile-these">How to compile these?</a></li>
-<li><a class="reference internal" href="#an-interesting-variation">An Interesting Variation</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -531,25 +548,24 @@ modifications to the default <code class="docutils literal notranslate"><span cl
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Generator_Programs.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -560,7 +576,7 @@ modifications to the default <code class="docutils literal notranslate"><span cl
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index c0c812d..658704d 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Thun: Joy in Python &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Joy Interpreter" href="../joy.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="thun-joy-in-python">
+  <section id="thun-joy-in-python">
 <h1>Thun: Joy in Python<a class="headerlink" href="#thun-joy-in-python" title="Permalink to this headline">¶</a></h1>
 <p>This implementation is meant as a tool for exploring the programming
 model and method of Joy. Python seems like a great implementation
 language for Joy for several reasons.</p>
 <ul class="simple">
-<li>We can lean on the Python immutable types for our basic semantics and types: ints, floats, strings, and tuples, which enforces functional purity.</li>
-<li>We get garbage collection for free.</li>
-<li>Compilation via Cython.</li>
-<li>Python is a “glue language” with loads of libraries which we can wrap in Joy functions.</li>
+<li><p>We can lean on the Python immutable types for our basic semantics and types: ints, floats, strings, and tuples, which enforces functional purity.</p></li>
+<li><p>We get garbage collection for free.</p></li>
+<li><p>Compilation via Cython.</p></li>
+<li><p>Python is a “glue language” with loads of libraries which we can wrap in Joy functions.</p></li>
 </ul>
-<div class="section" id="read-eval-print-loop-repl">
+<section id="read-eval-print-loop-repl">
 <h2><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></h2>
 <p>The main way to interact with the Joy interpreter is through a simple
 <a class="reference external" href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop">REPL</a>
@@ -86,8 +87,8 @@ joy?
 joy?
 </pre></div>
 </div>
-</div>
-<div class="section" id="the-stack">
+</section>
+<section id="the-stack">
 <h2>The Stack<a class="headerlink" href="#the-stack" title="Permalink to this headline">¶</a></h2>
 <p>In Joy, in addition to the types Boolean, integer, float, and string,
 there is a <a class="reference internal" href="../stack.html"><span class="doc">single sequence type</span></a> represented by enclosing a sequence of
@@ -95,21 +96,21 @@ terms in brackets <code class="docutils literal notranslate"><span class="pre">[
 both the stack and the expression. It is a <a class="reference external" href="https://en.wikipedia.org/wiki/Cons#Lists">cons
 list</a> made from Python
 tuples.</p>
-</div>
-<div class="section" id="purely-functional-datastructures">
+</section>
+<section id="purely-functional-datastructures">
 <h2>Purely Functional Datastructures<a class="headerlink" href="#purely-functional-datastructures" title="Permalink to this headline">¶</a></h2>
 <p>Because Joy stacks are made out of Python tuples they are immutable, as are the other Python types we “borrow” for Joy, so all Joy datastructures are <a class="reference external" href="https://en.wikipedia.org/wiki/Purely_functional_data_structure">purely functional</a>.</p>
-</div>
-<div class="section" id="the-joy-function">
+</section>
+<section id="the-joy-function">
 <h2>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></h2>
-<div class="section" id="an-interpreter">
+<section id="an-interpreter">
 <h3>An Interpreter<a class="headerlink" href="#an-interpreter" title="Permalink to this headline">¶</a></h3>
 <p>The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> interpreter function is extrememly simple. It accepts a stack, an
 expression, and a dictionary, and it iterates through the expression
 putting values onto the stack and delegating execution to functions which it
 looks up in the dictionary.</p>
-</div>
-<div class="section" id="continuation-passing-style">
+</section>
+<section id="continuation-passing-style">
 <h3><a class="reference external" href="https://en.wikipedia.org/wiki/Continuation-passing_style">Continuation-Passing Style</a><a class="headerlink" href="#continuation-passing-style" title="Permalink to this headline">¶</a></h3>
 <p>One day I thought, What happens if you rewrite Joy to use
 <a class="reference external" href="https://en.wikipedia.org/wiki/Continuation-passing_style">CPS</a>? I
@@ -117,8 +118,8 @@ made all the functions accept and return the expression as well as the
 stack and found that all the combinators could be rewritten to work by
 modifying the expression rather than making recursive calls to the
 <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function.</p>
-</div>
-<div class="section" id="view-function">
+</section>
+<section id="view-function">
 <h3>View function<a class="headerlink" href="#view-function" title="Permalink to this headline">¶</a></h3>
 <p>The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function accepts an optional <code class="docutils literal notranslate"><span class="pre">viewer</span></code> argument that
 is a function which it calls on
@@ -127,48 +128,48 @@ evaluation. This can be used for tracing, breakpoints, retrying after
 exceptions, or interrupting an evaluation and saving to disk or sending
 over the network to resume later. The stack and expression together
 contain all the state of the computation at each step.</p>
-</div>
-<div class="section" id="the-traceprinter">
+</section>
+<section id="the-traceprinter">
 <h3>The <code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code>.<a class="headerlink" href="#the-traceprinter" title="Permalink to this headline">¶</a></h3>
 <p>A <code class="docutils literal notranslate"><span class="pre">viewer</span></code> records each step of the evaluation of a Joy program. The
 <code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code> has a facility for printing out a trace of the
 evaluation, one line per step. Each step is aligned to the current
 interpreter position, signified by a period separating the stack on the
 left from the pending expression (“continuation”) on the right.</p>
-</div>
-</div>
-<div class="section" id="parser">
+</section>
+</section>
+<section id="parser">
 <h2>Parser<a class="headerlink" href="#parser" title="Permalink to this headline">¶</a></h2>
 <p>The parser is extremely simple.  The undocumented <code class="docutils literal notranslate"><span class="pre">re.Scanner</span></code> class
 does the tokenizing and then the parser builds the tuple
 structure out of the tokens. There’s no Abstract Syntax Tree or anything
 like that.</p>
-<div class="section" id="symbols">
+<section id="symbols">
 <h3>Symbols<a class="headerlink" href="#symbols" title="Permalink to this headline">¶</a></h3>
 <p>TODO: Symbols are just a string subclass; used by the parser to represent function names and by the interpreter to look up functions in the dictionary.  N.B.: Symbols are not looked up at parse-time.  You <em>could</em> define recursive functions, er, recusively, without <code class="docutils literal notranslate"><span class="pre">genrec</span></code> or other recursion combinators  <code class="docutils literal notranslate"><span class="pre">foo</span> <span class="pre">==</span> <span class="pre">...</span> <span class="pre">foo</span> <span class="pre">...</span></code> but don’t do that.</p>
-</div>
-<div class="section" id="token-regular-expressions">
+</section>
+<section id="token-regular-expressions">
 <h3>Token Regular Expressions<a class="headerlink" href="#token-regular-expressions" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">123</span>   <span class="mf">1.2</span>   <span class="s1">&#39;single quotes&#39;</span>  <span class="s2">&quot;double quotes&quot;</span>   <span class="n">function</span>
 </pre></div>
 </div>
 <p>TBD (look in the :module: joy.parser  module.)</p>
-</div>
-<div class="section" id="examples">
+</section>
+<section id="examples">
 <h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
-<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>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;1 2 3 4 5&#39;</span><span class="p">)</span>  <span class="c1"># A simple sequence.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="p">())))))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[1 2 3] 4 5&#39;</span><span class="p">)</span>  <span class="c1"># Three items, the first is a list with three items</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[1 2 3] 4 5&#39;</span><span class="p">)</span>  <span class="c1"># Three items, the first is a list with three items</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">()))),</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="p">())))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;1 23 [&quot;four&quot; [-5.0] cons] 8888&#39;</span><span class="p">)</span>  <span class="c1"># A mixed bag. cons is</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;1 23 [&quot;four&quot; [-5.0] cons] 8888&#39;</span><span class="p">)</span>  <span class="c1"># A mixed bag. cons is</span>
                                                                  <span class="c1"># a Symbol, no lookup at</span>
                                                                  <span class="c1"># parse-time.  Haiku docs.</span>
 </pre></div>
@@ -176,21 +177,21 @@ like that.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">23</span><span class="p">,</span> <span class="p">((</span><span class="s1">&#39;four&#39;</span><span class="p">,</span> <span class="p">((</span><span class="o">-</span><span class="mf">5.0</span><span class="p">,</span> <span class="p">()),</span> <span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="p">()))),</span> <span class="p">(</span><span class="mi">8888</span><span class="p">,</span> <span class="p">()))))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[][][][][]&#39;</span><span class="p">)</span>  <span class="c1"># Five empty lists.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[][][][][]&#39;</span><span class="p">)</span>  <span class="c1"># Five empty lists.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((),</span> <span class="p">((),</span> <span class="p">((),</span> <span class="p">((),</span> <span class="p">((),</span> <span class="p">())))))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[[[[[]]]]]&#39;</span><span class="p">)</span>  <span class="c1"># Five nested lists.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[[[[[]]]]]&#39;</span><span class="p">)</span>  <span class="c1"># Five nested lists.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((((((),</span> <span class="p">()),</span> <span class="p">()),</span> <span class="p">()),</span> <span class="p">()),</span> <span class="p">())</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="library">
+</section>
+</section>
+<section id="library">
 <h2>Library<a class="headerlink" href="#library" title="Permalink to this headline">¶</a></h2>
 <p>The Joy library of functions (aka commands, or “words” after Forth
 usage) encapsulates all the actual functionality (no pun intended) of
@@ -198,7 +199,7 @@ the Joy system. There are simple functions such as addition <code class="docutil
 <code class="docutils literal notranslate"><span class="pre">+</span></code>, the library module supports aliases), and combinators which
 provide control-flow and higher-order operations.</p>
 <p>Many of the functions are defined in Python, like <code class="docutils literal notranslate"><span class="pre">dip</span></code>:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getsource</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">library</span><span class="o">.</span><span class="n">dip</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getsource</span><span class="p">(</span><span class="n">joy</span><span class="o">.</span><span class="n">library</span><span class="o">.</span><span class="n">dip</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">dip</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
@@ -211,11 +212,10 @@ provide control-flow and higher-order operations.</p>
 When the interpreter executes a definition function that function just
 pushes its body expression onto the pending expression (the
 continuation) and returns control to the interpreter.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">joy</span><span class="o">.</span><span class="n">library</span><span class="o">.</span><span class="n">definitions</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">joy</span><span class="o">.</span><span class="n">library</span><span class="o">.</span><span class="n">definitions</span>
 </pre></div>
 </div>
-<pre class="literal-block">
-second == rest first
+<pre class="literal-block">second == rest first
 third == rest rest first
 product == 1 swap [*] step
 swons == swap cons
@@ -248,8 +248,7 @@ anamorphism == [pop []] swap [dip swons] genrec
 range == [0 &lt;=] [1 - dup] anamorphism
 while == swap [nullary] cons dup dipd concat loop
 dudipd == dup dipd
-primrec == [i] genrec
-</pre>
+primrec == [i] genrec</pre>
 <p>Currently, there’s no function to add new definitions to the dictionary
 from “within” Joy code itself. Adding new definitions remains a
 meta-interpreter action. You have to do it yourself, in Python, and wash
@@ -260,7 +259,7 @@ stack and expression. There’s an implicit <em>standard dictionary</em> that
 defines the actual semantics of the syntactic stack and expression
 datastructures (which only contain symbols, not the actual functions.
 Pickle some and see for yourself.)</p>
-<div class="section" id="there-should-be-only-one">
+<section id="there-should-be-only-one">
 <h3>“There should be only one.”<a class="headerlink" href="#there-should-be-only-one" title="Permalink to this headline">¶</a></h3>
 <p>Which brings me to talking about one of my hopes and dreams for this
 notation: “There should be only one.” What I mean is that there should
@@ -277,8 +276,8 @@ frameworks, programming languages. It’s a waste of time, a <a class="reference
 “thundering herd”
 attack</a> on
 human mentality.</p>
-</div>
-<div class="section" id="literary-code-library">
+</section>
+<section id="literary-code-library">
 <h3>Literary Code Library<a class="headerlink" href="#literary-code-library" title="Permalink to this headline">¶</a></h3>
 <p>If you read over the other notebooks you’ll see that developing code in
 Joy is a lot like doing simple mathematics, and the descriptions of the
@@ -292,43 +291,47 @@ card is highly desirable. Less code has fewer errors. The structure of
 Joy engenders a kind of thinking that seems to be very effective for
 developing structured processes.</p>
 <p>There seems to be an elegance and power to the notation.</p>
-</div>
-</div>
-</div>
+</section>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Thun: Joy in Python</a><ul>
-<li><a class="reference internal" href="#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
-<li><a class="reference internal" href="#the-stack">The Stack</a></li>
-<li><a class="reference internal" href="#purely-functional-datastructures">Purely Functional Datastructures</a></li>
-<li><a class="reference internal" href="#the-joy-function">The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function</a><ul>
-<li><a class="reference internal" href="#an-interpreter">An Interpreter</a></li>
-<li><a class="reference internal" href="#continuation-passing-style">Continuation-Passing Style</a></li>
-<li><a class="reference internal" href="#view-function">View function</a></li>
-<li><a class="reference internal" href="#the-traceprinter">The <code class="docutils literal notranslate"><span class="pre">TracePrinter</span></code>.</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#parser">Parser</a><ul>
-<li><a class="reference internal" href="#symbols">Symbols</a></li>
-<li><a class="reference internal" href="#token-regular-expressions">Token Regular Expressions</a></li>
-<li><a class="reference internal" href="#examples">Examples</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#library">Library</a><ul>
-<li><a class="reference internal" href="#there-should-be-only-one">“There should be only one.”</a></li>
-<li><a class="reference internal" href="#literary-code-library">Literary Code Library</a></li>
-</ul>
-</li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Thun: Joy in Python</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#read-eval-print-loop-repl">Read-Eval-Print Loop (REPL)</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#the-stack">The Stack</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#purely-functional-datastructures">Purely Functional Datastructures</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#the-joy-function">The <code class="docutils literal notranslate"><span class="pre">joy()</span></code> function</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#parser">Parser</a></li>
+<li class="toctree-l2"><a class="reference internal" href="#library">Library</a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -338,25 +341,24 @@ developing structured processes.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Intro.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -367,7 +369,7 @@ developing structured processes.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 2999601..59279b8 100644 (file)
@@ -1,19 +1,19 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Newton’s method &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
+    <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Traversing Datastructures with Zippers" href="Zipper.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="newton-s-method">
+  <section id="newton-s-method">
 <h1><a class="reference external" href="https://en.wikipedia.org/wiki/Newton%27s_method">Newton’s method</a><a class="headerlink" href="#newton-s-method" title="Permalink to this headline">¶</a></h1>
 <p>Let’s use the Newton-Raphson method for finding the root of an equation
 to write a function that can compute the square root of a number.</p>
 <p>Cf. <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why Functional Programming Matters” by John
 Hughes</a></p>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
 </pre></div>
 </div>
-<div class="section" id="a-generator-for-approximations">
+<section id="a-generator-for-approximations">
 <h2>A Generator for Approximations<a class="headerlink" href="#a-generator-for-approximations" title="Permalink to this headline">¶</a></h2>
 <p>To make a generator that generates successive approximations let’s start
 by assuming an initial approximation and then derive the function that
@@ -51,7 +53,7 @@ computes the next approximation:</p>
     <span class="n">a</span><span class="s1">&#39;</span>
 </pre></div>
 </div>
-<div class="section" id="a-function-to-compute-the-next-approximation">
+<section id="a-function-to-compute-the-next-approximation">
 <h3>A Function to Compute the Next Approximation<a class="headerlink" href="#a-function-to-compute-the-next-approximation" title="Permalink to this headline">¶</a></h3>
 <p>This is the equation for computing the next approximate value of the
 square root:</p>
@@ -67,8 +69,8 @@ square root:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">F</span> <span class="o">==</span> <span class="n">n</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="make-it-into-a-generator">
+</section>
+<section id="make-it-into-a-generator">
 <h3>Make it into a Generator<a class="headerlink" href="#make-it-into-a-generator" title="Permalink to this headline">¶</a></h3>
 <p>Our generator would be created by:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">dup</span> <span class="n">F</span><span class="p">]</span> <span class="n">make_generator</span>
@@ -90,10 +92,10 @@ function we’re writing. If we let 1 be the initial approximation:</p>
 <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>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;gsra 1 swap [over / + 2 /] cons [dup] swoncat make_generator&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;gsra 1 swap [over / + 2 /] cons [dup] swoncat make_generator&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="n">dup</span> <span class="mi">23</span> <span class="n">over</span> <span class="o">/</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">/</span><span class="p">]</span> <span class="n">codireco</span><span class="p">]</span>
@@ -101,23 +103,24 @@ function we’re writing. If we let 1 be the initial approximation:</p>
 </div>
 <p>Let’s drive the generator a few time (with the <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator) and
 square the approximation to see how well it works…</p>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra 6 [x popd] times first sqr&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 gsra 6 [x popd] times first sqr&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">23.0000000001585</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="finding-consecutive-approximations-within-a-tolerance">
+</section>
+</section>
+<section id="finding-consecutive-approximations-within-a-tolerance">
 <h2>Finding Consecutive Approximations within a Tolerance<a class="headerlink" href="#finding-consecutive-approximations-within-a-tolerance" title="Permalink to this headline">¶</a></h2>
 <p>From <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why Functional Programming Matters” by John
 Hughes</a>:</p>
 <blockquote>
-<div>The remainder of a square root finder is a function <em>within</em>, which
+<div><p>The remainder of a square root finder is a function <em>within</em>, which
 takes a tolerance and a list of approximations and looks down the
 list for two successive approximations that differ by no more than
-the given tolerance.</div></blockquote>
+the given tolerance.</p>
+</div></blockquote>
 <p>(And note that by “list” he means a lazily-evaluated list.)</p>
 <p>Using the <em>output</em> <code class="docutils literal notranslate"><span class="pre">[a</span> <span class="pre">G]</span></code> of the above generator for square root
 approximations, and further assuming that the first term a has been
@@ -132,7 +135,7 @@ generated already and epsilon ε is handy on the stack…</p>
    <span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
 </pre></div>
 </div>
-<div class="section" id="predicate">
+<section id="predicate">
 <h3>Predicate<a class="headerlink" href="#predicate" title="Permalink to this headline">¶</a></h3>
 <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="p">[</span><span class="n">first</span> <span class="o">-</span> <span class="nb">abs</span><span class="p">]</span> <span class="n">dip</span> <span class="o">&lt;=</span>
 <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">first</span> <span class="o">-</span> <span class="nb">abs</span> <span class="n">ε</span>                   <span class="o">&lt;=</span>
@@ -142,11 +145,11 @@ generated already and epsilon ε is handy on the stack…</p>
 <span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">a</span><span class="o">-</span><span class="n">b</span><span class="p">)</span><span class="o">&lt;=</span><span class="n">ε</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_P [first - abs] dip &lt;=&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_P [first - abs] dip &lt;=&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="base-case">
+</section>
+<section id="base-case">
 <h3>Base-Case<a class="headerlink" href="#base-case" title="Permalink to this headline">¶</a></h3>
 <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">roll</span><span class="o">&lt;</span> <span class="n">popop</span> <span class="n">first</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">a</span>     <span class="n">popop</span> <span class="n">first</span>
@@ -154,19 +157,19 @@ generated already and epsilon ε is handy on the stack…</p>
    <span class="n">b</span>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_B roll&lt; popop first&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_B roll&lt; popop first&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="recur">
+</section>
+<section id="recur">
 <h3>Recur<a class="headerlink" href="#recur" title="Permalink to this headline">¶</a></h3>
 <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>
 </pre></div>
 </div>
 <ol class="arabic simple">
-<li>Discard a.</li>
-<li>Use <code class="docutils literal notranslate"><span class="pre">x</span></code> combinator to generate next term from <code class="docutils literal notranslate"><span class="pre">G</span></code>.</li>
-<li>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 “tail-recursive” function.)</li>
+<li><p>Discard a.</p></li>
+<li><p>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>.</p></li>
+<li><p>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 “tail-recursive” function.)</p></li>
 </ol>
 <p>Pretty straightforward:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span>        <span class="n">ε</span> <span class="n">R0</span>           <span class="p">[</span><span class="n">within</span><span class="p">]</span> <span class="n">R1</span>
@@ -179,11 +182,11 @@ generated already and epsilon ε is handy on the stack…</p>
 <span class="n">b</span> <span class="p">[</span><span class="n">c</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="n">within</span>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_R [popd x] dip&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;_within_R [popd x] dip&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="setting-up">
+</section>
+<section id="setting-up">
 <h3>Setting up<a class="headerlink" href="#setting-up" title="Permalink to this headline">¶</a></h3>
 <p>The recursive function we have defined so far needs a slight preamble:
 <code class="docutils literal notranslate"><span class="pre">x</span></code> to prime the generator and the epsilon value to use:</p>
@@ -191,31 +194,31 @@ generated already and epsilon ε is handy on the stack…</p>
 <span class="n">a</span> <span class="p">[</span><span class="n">b</span> <span class="n">G</span><span class="p">]</span> <span class="n">ε</span> <span class="o">...</span>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;within x 0.000000001 [_within_P] [_within_B] [_within_R] tailrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;within x 0.000000001 [_within_P] [_within_B] [_within_R] tailrec&#39;</span><span class="p">)</span>
 <span class="n">define</span><span class="p">(</span><span class="s1">&#39;sqrt gsra within&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Try it out…</p>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;36 sqrt&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;36 sqrt&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">6.0</span>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 sqrt&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;23 sqrt&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span>
 </pre></div>
 </div>
 <p>Check it.</p>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span><span class="o">**</span><span class="mi">2</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span><span class="o">**</span><span class="mi">2</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">22.999999999999996</span>
 </pre></div>
 </div>
-<div class="code ipython3 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">math</span> <span class="k">import</span> <span class="n">sqrt</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">sqrt</span>
 
 <span class="n">sqrt</span><span class="p">(</span><span class="mi">23</span><span class="p">)</span>
 </pre></div>
@@ -223,34 +226,56 @@ generated already and epsilon ε is handy on the stack…</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.795831523312719</span>
 </pre></div>
 </div>
-</div>
-</div>
-</div>
+</section>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Newton’s method</a><ul>
-<li><a class="reference internal" href="#a-generator-for-approximations">A Generator for Approximations</a><ul>
-<li><a class="reference internal" href="#a-function-to-compute-the-next-approximation">A Function to Compute the Next Approximation</a></li>
-<li><a class="reference internal" href="#make-it-into-a-generator">Make it into a Generator</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#finding-consecutive-approximations-within-a-tolerance">Finding Consecutive Approximations within a Tolerance</a><ul>
-<li><a class="reference internal" href="#predicate">Predicate</a></li>
-<li><a class="reference internal" href="#base-case">Base-Case</a></li>
-<li><a class="reference internal" href="#recur">Recur</a></li>
-<li><a class="reference internal" href="#setting-up">Setting up</a></li>
-</ul>
-</li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -262,25 +287,24 @@ generated already and epsilon ε is handy on the stack…</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Newton-Raphson.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -291,7 +315,7 @@ generated already and epsilon ε is handy on the stack…</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 56080bc..65498ab 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>No Updates &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Categorical Programming" href="Categorical.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="no-updates">
+  <section id="no-updates">
 <h1>No Updates<a class="headerlink" href="#no-updates" title="Permalink to this headline">¶</a></h1>
 <p>DRAFT</p>
 <ol class="arabic simple">
-<li>Joy doesn’t need to change.</li>
+<li><p>Joy doesn’t need to change.</p></li>
 </ol>
 <blockquote>
 <div><ol class="upperalpha simple">
-<li>The interpreter doesn’t need to change, <code class="docutils literal notranslate"><span class="pre">viewer</span></code> function can customize mainloop.  Or use a sub-interpreter (Joy in Joy.)  The base interpreter remains static.</li>
-<li>Once a function has been named and defined <em>never change that name</em>.  It’s just not allowed.  If you need to change a function <code class="docutils literal notranslate"><span class="pre">foo</span></code> you have to call it <code class="docutils literal notranslate"><span class="pre">foo_II</span></code> or something.  Once a function (name mapped to behavior) is released to the public <em>that’s it</em>, it’s done.</li>
-<li>The language evolves by adding new definitions and refactoring, always choosing new names for new functions.</li>
+<li><p>The interpreter doesn’t need to change, <code class="docutils literal notranslate"><span class="pre">viewer</span></code> function can customize mainloop.  Or use a sub-interpreter (Joy in Joy.)  The base interpreter remains static.</p></li>
+<li><p>Once a function has been named and defined <em>never change that name</em>.  It’s just not allowed.  If you need to change a function <code class="docutils literal notranslate"><span class="pre">foo</span></code> you have to call it <code class="docutils literal notranslate"><span class="pre">foo_II</span></code> or something.  Once a function (name mapped to behavior) is released to the public <em>that’s it</em>, it’s done.</p></li>
+<li><p>The language evolves by adding new definitions and refactoring, always choosing new names for new functions.</p></li>
 </ol>
 </div></blockquote>
 <ol class="arabic simple" start="2">
-<li>Following <a class="reference external" href="https://semver.org">Semantic Versioning</a> there will never be a version 2.0.</li>
+<li><p>Following <a class="reference external" href="https://semver.org">Semantic Versioning</a> there will never be a version 2.0.</p></li>
 </ol>
 <blockquote>
 <div><ol class="upperalpha simple">
-<li><a class="reference external" href="https://semver.org/#spec-item-8">Major version must be incremented if any backwards incompatible changes are introduced to the public API.</a></li>
-<li>We never implement any backwards incompatible changes, so…</li>
-<li>We could see e.g. Thun version 1.273.3!</li>
+<li><p><a class="reference external" href="https://semver.org/#spec-item-8">Major version must be incremented if any backwards incompatible changes are introduced to the public API.</a></p></li>
+<li><p>We never implement any backwards incompatible changes, so…</p></li>
+<li><p>We could see e.g. Thun version 1.273.3!</p></li>
 </ol>
 </div></blockquote>
-</div>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
+</ul>
+</li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../index.html">Documentation overview</a><ul>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/NoUpdates.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index fec9f16..eabfaba 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Treating Trees I: Ordered Binary Trees &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Treating Trees II: treestep" href="Treestep.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="treating-trees-i-ordered-binary-trees">
+  <section id="treating-trees-i-ordered-binary-trees">
 <h1>Treating Trees I: Ordered Binary Trees<a class="headerlink" href="#treating-trees-i-ordered-binary-trees" title="Permalink to this headline">¶</a></h1>
 <p>Although any expression in Joy can be considered to describe a
 <a class="reference external" href="https://en.wikipedia.org/wiki/Tree_structure">tree</a> with the quotes
@@ -62,10 +63,10 @@ the Sufficiently Smart Compiler can be modified to use an optimized
 implementation under the hood. (Where does the “type” come from? It has
 a contingent existence predicated on the disciplined use of these
 functions on otherwise undistinguished Joy datastructures.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span><span class="p">,</span> <span class="n">DefinitionWrapper</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span><span class="p">,</span> <span class="n">DefinitionWrapper</span>
 </pre></div>
 </div>
-<div class="section" id="adding-nodes-to-the-tree">
+<section id="adding-nodes-to-the-tree">
 <h2>Adding Nodes to the Tree<a class="headerlink" href="#adding-nodes-to-the-tree" title="Permalink to this headline">¶</a></h2>
 <p>Let’s consider adding nodes to a Tree structure.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   Tree value key Tree-add
@@ -73,14 +74,14 @@ functions on otherwise undistinguished Joy datastructures.)</p>
             Tree′
 </pre></div>
 </div>
-<div class="section" id="adding-to-an-empty-node">
+<section id="adding-to-an-empty-node">
 <h3>Adding to an empty node.<a class="headerlink" href="#adding-to-an-empty-node" title="Permalink to this headline">¶</a></h3>
 <p>If the current node is <code class="docutils literal notranslate"><span class="pre">[]</span></code> then you just return
 <code class="docutils literal notranslate"><span class="pre">[key</span> <span class="pre">value</span> <span class="pre">[]</span> <span class="pre">[]]</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span> <span class="o">==</span> <span class="p">[</span><span class="n">popop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[[</span><span class="n">pop</span><span class="p">]</span> <span class="n">dipd</span> <span class="n">Tree</span><span class="o">-</span><span class="n">new</span><span class="p">]</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="section" id="tree-new">
+<section id="tree-new">
 <h4><code class="docutils literal notranslate"><span class="pre">Tree-new</span></code><a class="headerlink" href="#tree-new" title="Permalink to this headline">¶</a></h4>
 <p>Where <code class="docutils literal notranslate"><span class="pre">Tree-new</span></code> is defined as:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">value</span> <span class="n">key</span> <span class="n">Tree</span><span class="o">-</span><span class="n">new</span>
@@ -99,10 +100,10 @@ functions on otherwise undistinguished Joy datastructures.)</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="n">new</span> <span class="o">==</span> <span class="n">swap</span> <span class="p">[[]</span> <span class="p">[]]</span> <span class="n">cons</span> <span class="n">cons</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-new == swap [[] []] cons cons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-new == swap [[] []] cons cons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&quot;v&quot; &quot;k&quot; Tree-new&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&quot;v&quot; &quot;k&quot; Tree-new&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;k&#39;</span> <span class="s1">&#39;v&#39;</span> <span class="p">[]</span> <span class="p">[]]</span>
@@ -117,9 +118,9 @@ Because the tail, which is <code class="docutils literal notranslate"><span clas
 and embedded in the definition body for <code class="docutils literal notranslate"><span class="pre">Tree-new</span></code>, all new nodes can
 reuse it as their own tail without fear that some other code somewhere
 will change it.)</p>
-</div>
-</div>
-<div class="section" id="adding-to-a-non-empty-node">
+</section>
+</section>
+<section id="adding-to-a-non-empty-node">
 <h3>Adding to a non-empty node.<a class="headerlink" href="#adding-to-a-non-empty-node" title="Permalink to this headline">¶</a></h3>
 <p>We now have to derive <code class="docutils literal notranslate"><span class="pre">R0</span></code> and <code class="docutils literal notranslate"><span class="pre">R1</span></code>, consider:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key_n</span> <span class="n">value_n</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="n">R0</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">R1</span>
@@ -132,7 +133,7 @@ picture.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="o">==</span> <span class="p">[]</span>
 </pre></div>
 </div>
-<div class="section" id="a-predicate-to-compare-keys">
+<section id="a-predicate-to-compare-keys">
 <h4>A predicate to compare keys.<a class="headerlink" href="#a-predicate-to-compare-keys" title="Permalink to this headline">¶</a></h4>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key_n</span> <span class="n">value_n</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">R1</span>
 </pre></div>
@@ -158,17 +159,17 @@ comparison operator:</p>
 <span class="n">P</span>   <span class="o">==</span> <span class="n">pop</span> <span class="n">roll</span><span class="o">&gt;</span> <span class="n">pop</span> <span class="n">first</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;P == pop roll&gt; pop first&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;P == pop roll&gt; pop first&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;old_key&quot; 23 [] []] 17 &quot;new_key&quot; [&quot;...&quot;] P&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;old_key&quot; 23 [] []] 17 &quot;new_key&quot; [&quot;...&quot;] P&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;new_key&#39;</span> <span class="s1">&#39;old_key&#39;</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="if-the-key-were-adding-is-greater-than-the-nodes-key">
+</section>
+<section id="if-the-key-were-adding-is-greater-than-the-nodes-key">
 <h4>If the key we’re adding is greater than the node’s key.<a class="headerlink" href="#if-the-key-were-adding-is-greater-than-the-nodes-key" title="Permalink to this headline">¶</a></h4>
 <p>Here the parentheses are meant to signify that the expression is not
 literal, the code in the parentheses is meant to have been evaluated:</p>
@@ -216,24 +217,24 @@ stack:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">T</span> <span class="o">==</span> <span class="n">cons</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dipdd</span><span class="p">]</span> <span class="n">cons</span> <span class="n">infra</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;T == cons cons [dipdd] cons infra&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;T == cons cons [dipdd] cons infra&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;old_k&quot; &quot;old_value&quot; &quot;left&quot; &quot;right&quot;] &quot;new_value&quot; &quot;new_key&quot; [&quot;Tree-add&quot;] T&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;old_k&quot; &quot;old_value&quot; &quot;left&quot; &quot;right&quot;] &quot;new_value&quot; &quot;new_key&quot; [&quot;Tree-add&quot;] T&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;old_k&#39;</span> <span class="s1">&#39;old_value&#39;</span> <span class="s1">&#39;left&#39;</span> <span class="s1">&#39;Tree-add&#39;</span> <span class="s1">&#39;new_key&#39;</span> <span class="s1">&#39;new_value&#39;</span> <span class="s1">&#39;right&#39;</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="if-the-key-were-adding-is-less-than-the-nodes-key">
+</section>
+<section id="if-the-key-were-adding-is-less-than-the-nodes-key">
 <h4>If the key we’re adding is less than the node’s key.<a class="headerlink" href="#if-the-key-were-adding-is-less-than-the-nodes-key" title="Permalink to this headline">¶</a></h4>
 <p>This is very very similar to the above:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key_n</span> <span class="n">value_n</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">E</span>
 <span class="p">[</span><span class="n">key_n</span> <span class="n">value_n</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="p">[</span><span class="n">P</span> <span class="o">&lt;</span><span class="p">]</span> <span class="p">[</span><span class="n">Te</span><span class="p">]</span> <span class="p">[</span><span class="n">Ee</span><span class="p">]</span> <span class="n">ifte</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;E == [P &lt;] [Te] [Ee] ifte&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;E == [P &lt;] [Te] [Ee] ifte&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>In this case <code class="docutils literal notranslate"><span class="pre">Te</span></code> works that same as <code class="docutils literal notranslate"><span class="pre">T</span></code> but on the left child tree
@@ -242,17 +243,17 @@ instead of the right, so the only difference is that it must use
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Te</span> <span class="o">==</span> <span class="n">cons</span> <span class="n">cons</span> <span class="p">[</span><span class="n">dipd</span><span class="p">]</span> <span class="n">cons</span> <span class="n">infra</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Te == cons cons [dipd] cons infra&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Te == cons cons [dipd] cons infra&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;old_k&quot; &quot;old_value&quot; &quot;left&quot; &quot;right&quot;] &quot;new_value&quot; &quot;new_key&quot; [&quot;Tree-add&quot;] Te&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;old_k&quot; &quot;old_value&quot; &quot;left&quot; &quot;right&quot;] &quot;new_value&quot; &quot;new_key&quot; [&quot;Tree-add&quot;] Te&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;old_k&#39;</span> <span class="s1">&#39;old_value&#39;</span> <span class="s1">&#39;Tree-add&#39;</span> <span class="s1">&#39;new_key&#39;</span> <span class="s1">&#39;new_value&#39;</span> <span class="s1">&#39;left&#39;</span> <span class="s1">&#39;right&#39;</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="else-the-keys-must-be-equal">
+</section>
+<section id="else-the-keys-must-be-equal">
 <h4>Else the keys must be equal.<a class="headerlink" href="#else-the-keys-must-be-equal" title="Permalink to this headline">¶</a></h4>
 <p>This means we must find:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="p">[</span><span class="n">key</span> <span class="n">old_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">new_value</span> <span class="n">key</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">Ee</span>
@@ -273,18 +274,18 @@ instead of the right, so the only difference is that it must use
               <span class="p">[</span><span class="n">key</span> <span class="n">new_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Ee == pop swap roll&lt; rest rest cons cons&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Ee == pop swap roll&lt; rest rest cons cons&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;k&quot; &quot;old_value&quot; &quot;left&quot; &quot;right&quot;] &quot;new_value&quot; &quot;k&quot; [&quot;Tree-add&quot;] Ee&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;k&quot; &quot;old_value&quot; &quot;left&quot; &quot;right&quot;] &quot;new_value&quot; &quot;k&quot; [&quot;Tree-add&quot;] Ee&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;k&#39;</span> <span class="s1">&#39;new_value&#39;</span> <span class="s1">&#39;left&#39;</span> <span class="s1">&#39;right&#39;</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="now-we-can-define-tree-add">
+</section>
+</section>
+<section id="now-we-can-define-tree-add">
 <h3>Now we can define <code class="docutils literal notranslate"><span class="pre">Tree-add</span></code><a class="headerlink" href="#now-we-can-define-tree-add" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span> <span class="o">==</span> <span class="p">[</span><span class="n">popop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[[</span><span class="n">pop</span><span class="p">]</span> <span class="n">dipd</span> <span class="n">Tree</span><span class="o">-</span><span class="n">new</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[[</span><span class="n">P</span> <span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="n">ifte</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
@@ -301,88 +302,88 @@ instead of the right, so the only difference is that it must use
 <span class="n">Tree</span><span class="o">-</span><span class="n">add</span> <span class="o">==</span> <span class="p">[</span><span class="n">popop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[[</span><span class="n">pop</span><span class="p">]</span> <span class="n">dipd</span> <span class="n">Tree</span><span class="o">-</span><span class="n">new</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[</span><span class="n">R</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-add == [popop not] [[pop] dipd Tree-new] [] [[P &gt;] [T] [E] ifte] genrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-add == [popop not] [[pop] dipd Tree-new] [] [[P &gt;] [T] [E] ifte] genrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="examples">
+</section>
+<section id="examples">
 <h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] 23 &quot;b&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Initial</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] 23 &quot;b&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Initial</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">23</span> <span class="p">[]</span> <span class="p">[]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;b&quot; 23 [] []] 88 &quot;c&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Greater than</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;b&quot; 23 [] []] 88 &quot;c&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Greater than</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">23</span> <span class="p">[]</span> <span class="p">[</span><span class="s1">&#39;c&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;b&quot; 23 [] []] 88 &quot;a&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Less than</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;b&quot; 23 [] []] 88 &quot;a&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Less than</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">23</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;b&quot; 23 [] []] 88 &quot;b&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Equal to</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;b&quot; 23 [] []] 88 &quot;b&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Equal to</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] 23 &quot;b&quot; Tree-add 88 &quot;a&quot; Tree-add 44 &quot;c&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Series.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] 23 &quot;b&quot; Tree-add 88 &quot;a&quot; Tree-add 44 &quot;c&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Series.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">23</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="s1">&#39;c&#39;</span> <span class="mi">44</span> <span class="p">[]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [[23 &quot;b&quot;] [88 &quot;a&quot;] [44 &quot;c&quot;]] [i Tree-add] step&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [[23 &quot;b&quot;] [88 &quot;a&quot;] [44 &quot;c&quot;]] [i Tree-add] step&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">23</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="s1">&#39;c&#39;</span> <span class="mi">44</span> <span class="p">[]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="interlude-cmp-combinator">
+</section>
+</section>
+<section id="interlude-cmp-combinator">
 <h2>Interlude: <code class="docutils literal notranslate"><span class="pre">cmp</span></code> combinator<a class="headerlink" href="#interlude-cmp-combinator" title="Permalink to this headline">¶</a></h2>
 <p>Instead of mucking about with nested <code class="docutils literal notranslate"><span class="pre">ifte</span></code> combinators let’s use
 <code class="docutils literal notranslate"><span class="pre">cmp</span></code> which takes two values and three quoted programs on the stack
 and runs one of the three depending on the results of comparing the two
 values:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="nb">cmp</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="n">cmp</span>
 <span class="o">-------------------------</span> <span class="n">a</span> <span class="o">&gt;</span> <span class="n">b</span>
         <span class="n">G</span>
 
-   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="nb">cmp</span>
+   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="n">cmp</span>
 <span class="o">-------------------------</span> <span class="n">a</span> <span class="o">=</span> <span class="n">b</span>
             <span class="n">E</span>
 
-   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="nb">cmp</span>
+   <span class="n">a</span> <span class="n">b</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">L</span><span class="p">]</span> <span class="n">cmp</span>
 <span class="o">-------------------------</span> <span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span>
                 <span class="n">L</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;1 0 [&#39;G&#39;] [&#39;E&#39;] [&#39;L&#39;] cmp&quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;1 0 [&#39;G&#39;] [&#39;E&#39;] [&#39;L&#39;] cmp&quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;G&#39;</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;1 1 [&#39;G&#39;] [&#39;E&#39;] [&#39;L&#39;] cmp&quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;1 1 [&#39;G&#39;] [&#39;E&#39;] [&#39;L&#39;] cmp&quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;E&#39;</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;0 1 [&#39;G&#39;] [&#39;E&#39;] [&#39;L&#39;] cmp&quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;0 1 [&#39;G&#39;] [&#39;E&#39;] [&#39;L&#39;] cmp&quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;L&#39;</span>
 </pre></div>
 </div>
-<div class="section" id="redefine-tree-add">
+<section id="redefine-tree-add">
 <h3>Redefine <code class="docutils literal notranslate"><span class="pre">Tree-add</span></code><a class="headerlink" href="#redefine-tree-add" title="Permalink to this headline">¶</a></h3>
 <p>We need a new non-destructive predicate <code class="docutils literal notranslate"><span class="pre">P</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">P</span>
@@ -413,13 +414,13 @@ node key (by throwing everything else away):</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">P</span> <span class="o">==</span> <span class="n">over</span> <span class="p">[</span><span class="n">popop</span> <span class="n">popop</span> <span class="n">first</span><span class="p">]</span> <span class="n">nullary</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;P == over [popop popop first] nullary&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;P == over [popop popop first] nullary&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Using <code class="docutils literal notranslate"><span class="pre">cmp</span></code> to simplify <cite>our code above at
 ``R1`</cite> &lt;#Adding-to-a-non-empty-node.&gt;`__:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">R1</span>
-<span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">Te</span><span class="p">]</span> <span class="nb">cmp</span>
+<span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">value</span> <span class="n">key</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span><span class="p">]</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">Te</span><span class="p">]</span> <span class="n">cmp</span>
 </pre></div>
 </div>
 <p>The line above becomes one of the three lines below:</p>
@@ -430,25 +431,25 @@ node key (by throwing everything else away):</p>
 </div>
 <p>The definition is a little longer but, I think, more elegant and easier
 to understand:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span> <span class="o">==</span> <span class="p">[</span><span class="n">popop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[[</span><span class="n">pop</span><span class="p">]</span> <span class="n">dipd</span> <span class="n">Tree</span><span class="o">-</span><span class="n">new</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[</span><span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="p">[</span><span class="n">Ee</span><span class="p">]</span> <span class="p">[</span><span class="n">Te</span><span class="p">]</span> <span class="nb">cmp</span><span class="p">]</span> <span class="n">genrec</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="n">add</span> <span class="o">==</span> <span class="p">[</span><span class="n">popop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[[</span><span class="n">pop</span><span class="p">]</span> <span class="n">dipd</span> <span class="n">Tree</span><span class="o">-</span><span class="n">new</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[</span><span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="p">[</span><span class="n">Ee</span><span class="p">]</span> <span class="p">[</span><span class="n">Te</span><span class="p">]</span> <span class="n">cmp</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-add == [popop not] [[pop] dipd Tree-new] [] [P [T] [Ee] [Te] cmp] genrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-add == [popop not] [[pop] dipd Tree-new] [] [P [T] [Ee] [Te] cmp] genrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] 23 &quot;b&quot; Tree-add 88 &quot;a&quot; Tree-add 44 &quot;c&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Still works.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] 23 &quot;b&quot; Tree-add 88 &quot;a&quot; Tree-add 44 &quot;c&quot; Tree-add&#39;</span><span class="p">)</span>  <span class="c1"># Still works.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">23</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="s1">&#39;c&#39;</span> <span class="mi">44</span> <span class="p">[]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="a-function-to-traverse-this-structure">
+</section>
+</section>
+<section id="a-function-to-traverse-this-structure">
 <h2>A Function to Traverse this Structure<a class="headerlink" href="#a-function-to-traverse-this-structure" title="Permalink to this headline">¶</a></h2>
 <p>Let’s take a crack at writing a function that can recursively iterate or
 traverse these trees.</p>
-<div class="section" id="base-case">
+<section id="base-case">
 <h3>Base case <code class="docutils literal notranslate"><span class="pre">[]</span></code><a class="headerlink" href="#base-case" title="Permalink to this headline">¶</a></h3>
 <p>The stopping predicate just has to detect the empty list:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
@@ -458,8 +459,8 @@ traverse these trees.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="node-case-key-value-left-right">
+</section>
+<section id="node-case-key-value-left-right">
 <h3>Node case <code class="docutils literal notranslate"><span class="pre">[key</span> <span class="pre">value</span> <span class="pre">left</span> <span class="pre">right]</span></code><a class="headerlink" href="#node-case-key-value-left-right" title="Permalink to this headline">¶</a></h3>
 <p>Now we need to figure out <code class="docutils literal notranslate"><span class="pre">R0</span></code> and <code class="docutils literal notranslate"><span class="pre">R1</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span>           <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
@@ -470,7 +471,7 @@ traverse these trees.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">R0</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="p">]</span> <span class="n">R1</span>
 </pre></div>
 </div>
-<div class="section" id="processing-the-current-node">
+<section id="processing-the-current-node">
 <h4>Processing the current node.<a class="headerlink" href="#processing-the-current-node" title="Permalink to this headline">¶</a></h4>
 <p><code class="docutils literal notranslate"><span class="pre">R0</span></code> is almost certainly going to use <code class="docutils literal notranslate"><span class="pre">dup</span></code> to make a copy of the
 node and then <code class="docutils literal notranslate"><span class="pre">dip</span></code> on some function to process the copy with it:</p>
@@ -486,8 +487,8 @@ node and then <code class="docutils literal notranslate"><span class="pre">dip</
 <span class="n">key</span>                            <span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="p">]</span> <span class="n">R1</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="recur">
+</section>
+<section id="recur">
 <h4>Recur<a class="headerlink" href="#recur" title="Permalink to this headline">¶</a></h4>
 <p>Now <code class="docutils literal notranslate"><span class="pre">R1</span></code> needs to apply <code class="docutils literal notranslate"><span class="pre">[Tree-iter]</span></code> to <code class="docutils literal notranslate"><span class="pre">left</span></code> and <code class="docutils literal notranslate"><span class="pre">right</span></code>. If
 we drop the key and value from the node using <code class="docutils literal notranslate"><span class="pre">rest</span></code> twice we are left
@@ -510,9 +511,9 @@ with an interesting situation:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">R1</span> <span class="o">==</span> <span class="p">[</span><span class="n">rest</span> <span class="n">rest</span><span class="p">]</span> <span class="n">dip</span> <span class="n">step</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="putting-it-together">
+</section>
+</section>
+<section id="putting-it-together">
 <h3>Putting it together<a class="headerlink" href="#putting-it-together" title="Permalink to this headline">¶</a></h3>
 <p>We have:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[[</span><span class="n">F</span><span class="p">]</span> <span class="n">dupdip</span><span class="p">]</span> <span class="p">[[</span><span class="n">rest</span> <span class="n">rest</span><span class="p">]</span> <span class="n">dip</span> <span class="n">step</span><span class="p">]</span> <span class="n">genrec</span>
@@ -524,8 +525,8 @@ with an interesting situation:</p>
 </pre></div>
 </div>
 <p>(And <code class="docutils literal notranslate"><span class="pre">[step]</span> <span class="pre">genrec</span></code> is such a cool and suggestive combinator!)</p>
-</div>
-<div class="section" id="parameterizing-the-f-per-node-processing-function">
+</section>
+<section id="parameterizing-the-f-per-node-processing-function">
 <h3>Parameterizing the <code class="docutils literal notranslate"><span class="pre">F</span></code> per-node processing function.<a class="headerlink" href="#parameterizing-the-f-per-node-processing-function" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span>
 <span class="o">------------------------------------------------------</span>
@@ -538,52 +539,52 @@ with an interesting situation:</p>
 <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="p">[</span><span class="n">dupdip</span> <span class="n">rest</span> <span class="n">rest</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">step</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="tree-iter">
+</section>
+<section id="tree-iter">
 <h3><code class="docutils literal notranslate"><span class="pre">Tree-iter</span></code><a class="headerlink" href="#tree-iter" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="p">[</span><span class="n">dupdip</span> <span class="n">rest</span> <span class="n">rest</span><span class="p">]</span> <span class="n">cons</span> <span class="p">[</span><span class="n">step</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-iter == [not] [pop] roll&lt; [dupdip rest rest] cons [step] genrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Tree-iter == [not] [pop] roll&lt; [dupdip rest rest] cons [step] genrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="id1">
+</section>
+<section id="id1">
 <h3>Examples<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [foo] Tree-iter&#39;</span><span class="p">)</span>  <span class="c1">#  It doesn&#39;t matter what F is as it won&#39;t be used.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [foo] Tree-iter&#39;</span><span class="p">)</span>  <span class="c1">#  It doesn&#39;t matter what F is as it won&#39;t be used.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;b&#39; 23 [&#39;a&#39; 88 [] []] [&#39;c&#39; 44 [] []]] [first] Tree-iter&quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;b&#39; 23 [&#39;a&#39; 88 [] []] [&#39;c&#39; 44 [] []]] [first] Tree-iter&quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;b&#39;</span> <span class="s1">&#39;a&#39;</span> <span class="s1">&#39;c&#39;</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;b&#39; 23 [&#39;a&#39; 88 [] []] [&#39;c&#39; 44 [] []]] [second] Tree-iter&quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;b&#39; 23 [&#39;a&#39; 88 [] []] [&#39;c&#39; 44 [] []]] [second] Tree-iter&quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span> <span class="mi">88</span> <span class="mi">44</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="interlude-a-set-like-datastructure">
+</section>
+</section>
+<section id="interlude-a-set-like-datastructure">
 <h2>Interlude: A Set-like Datastructure<a class="headerlink" href="#interlude-a-set-like-datastructure" title="Permalink to this headline">¶</a></h2>
 <p>We can use this to make a set-like datastructure by just setting values
-to e.g.&nbsp;0 and ignoring them. It’s set-like in that duplicate items added
+to e.g. 0 and ignoring them. It’s set-like in that duplicate items added
 to it will only occur once within it, and we can query it in
 <cite>:math:`O(log_2 N)</cite> &lt;<a class="reference external" href="https://en.wikipedia.org/wiki/Binary_search_tree#cite_note-2">https://en.wikipedia.org/wiki/Binary_search_tree#cite_note-2</a>&gt;`__
 time.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [3 9 5 2 8 6 7 8 4] [0 swap Tree-add] step&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [3 9 5 2 8 6 7 8 4] [0 swap Tree-add] step&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">9</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">5</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">8</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">6</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[</span><span class="mi">7</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]]</span> <span class="p">[]]]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;to_set == [] swap [0 swap Tree-add] step&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;to_set == [] swap [0 swap Tree-add] step&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 9 5 2 8 6 7 8 4] to_set&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 9 5 2 8 6 7 8 4] to_set&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">9</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">5</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">8</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">6</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[</span><span class="mi">7</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]]</span> <span class="p">[]]]</span> <span class="p">[]]]</span>
@@ -591,17 +592,17 @@ time.</p>
 </div>
 <p>And with that we can write a little program <code class="docutils literal notranslate"><span class="pre">unique</span></code> to remove
 duplicate items from a list.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;unique == [to_set [first] Tree-iter] cons run&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;unique == [to_set [first] Tree-iter] cons run&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 9 3 5 2 9 8 8 8 6 2 7 8 4 3] unique&#39;</span><span class="p">)</span>  <span class="c1"># Filter duplicate items.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 9 3 5 2 9 8 8 8 6 2 7 8 4 3] unique&#39;</span><span class="p">)</span>  <span class="c1"># Filter duplicate items.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">7</span> <span class="mi">6</span> <span class="mi">8</span> <span class="mi">4</span> <span class="mi">5</span> <span class="mi">9</span> <span class="mi">2</span> <span class="mi">3</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="a-version-of-tree-iter-that-does-in-order-traversal">
+</section>
+<section id="a-version-of-tree-iter-that-does-in-order-traversal">
 <h2>A Version of <code class="docutils literal notranslate"><span class="pre">Tree-iter</span></code> that does In-Order Traversal<a class="headerlink" href="#a-version-of-tree-iter-that-does-in-order-traversal" title="Permalink to this headline">¶</a></h2>
 <p>If you look back to the <cite>non-empty case of the ``Tree-iter`</cite>
 function &lt;#Node-case-%5Bkey-value-left-right%5D&gt;`__ we can design a
@@ -615,7 +616,7 @@ when they run:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">R0</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span><span class="p">]</span> <span class="n">R1</span>
 </pre></div>
 </div>
-<div class="section" id="process-the-left-child">
+<section id="process-the-left-child">
 <h3>Process the left child.<a class="headerlink" href="#process-the-left-child" title="Permalink to this headline">¶</a></h3>
 <p>Staring at this for a bit suggests <code class="docutils literal notranslate"><span class="pre">dup</span> <span class="pre">third</span></code> to start:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">R0</span>        <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span><span class="p">]</span> <span class="n">R1</span>
@@ -630,8 +631,8 @@ when they run:</p>
 <span class="n">left</span> <span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span> <span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span>             <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="process-the-current-node">
+</section>
+<section id="process-the-current-node">
 <h3>Process the current node.<a class="headerlink" href="#process-the-current-node" title="Permalink to this headline">¶</a></h3>
 <p>So far, so good. Now we need to process the current node’s values:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">left</span> <span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span> <span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span><span class="p">]</span> <span class="p">[[</span><span class="n">F</span><span class="p">]</span> <span class="n">dupdip</span><span class="p">]</span> <span class="n">dip</span>
@@ -646,8 +647,8 @@ it works fine as-is.</p>
 <span class="n">left</span> <span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span> <span class="n">key</span> <span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="process-the-right-child">
+</section>
+<section id="process-the-right-child">
 <h3>Process the right child.<a class="headerlink" href="#process-the-right-child" title="Permalink to this headline">¶</a></h3>
 <p>First ditch the rest of the node and get the right child:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">left</span> <span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span> <span class="n">key</span> <span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span><span class="p">]</span> <span class="p">[</span><span class="n">rest</span> <span class="n">rest</span> <span class="n">rest</span> <span class="n">first</span><span class="p">]</span> <span class="n">dip</span>
@@ -660,8 +661,8 @@ right side:</p>
 <span class="n">left</span> <span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span> <span class="n">key</span> <span class="n">right</span> <span class="n">Tree</span><span class="o">-</span><span class="nb">iter</span><span class="o">-</span><span class="n">order</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="defining-tree-iter-order">
+</section>
+<section id="defining-tree-iter-order">
 <h3>Defining <code class="docutils literal notranslate"><span class="pre">Tree-iter-order</span></code><a class="headerlink" href="#defining-tree-iter-order" title="Permalink to this headline">¶</a></h3>
 <p>The result is a little awkward:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">R1</span> <span class="o">==</span> <span class="p">[</span><span class="n">cons</span> <span class="n">dip</span><span class="p">]</span> <span class="n">dupdip</span> <span class="p">[[</span><span class="n">F</span><span class="p">]</span> <span class="n">dupdip</span><span class="p">]</span> <span class="n">dip</span> <span class="p">[</span><span class="n">rest</span> <span class="n">rest</span> <span class="n">rest</span> <span class="n">first</span><span class="p">]</span> <span class="n">dip</span> <span class="n">i</span>
@@ -678,7 +679,7 @@ right side:</p>
 </pre></div>
 </div>
 <p>Now we can sort sequences.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#define(&#39;Tree-iter-order == [not] [pop] [dup third] [[cons dip] dupdip [[first] dupdip] dip [rest rest rest first] dip i] genrec&#39;)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1">#define(&#39;Tree-iter-order == [not] [pop] [dup third] [[cons dip] dupdip [[first] dupdip] dip [rest rest rest first] dip i] genrec&#39;)</span>
 
 
 <span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
@@ -694,7 +695,7 @@ right side:</p>
 <span class="s1">&#39;&#39;&#39;</span><span class="p">,</span> <span class="n">D</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 9 5 2 8 6 7 8 4] to_set Tree-iter-order&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[3 9 5 2 8 6 7 8 4] to_set Tree-iter-order&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">5</span> <span class="mi">6</span> <span class="mi">7</span> <span class="mi">8</span> <span class="mi">9</span>
@@ -702,9 +703,9 @@ right side:</p>
 </div>
 <p>Parameterizing the <code class="docutils literal notranslate"><span class="pre">[F]</span></code> function is left as an exercise for the
 reader.</p>
-</div>
-</div>
-<div class="section" id="getting-values-by-key">
+</section>
+</section>
+<section id="getting-values-by-key">
 <h2>Getting values by key<a class="headerlink" href="#getting-values-by-key" title="Permalink to this headline">¶</a></h2>
 <p>Let’s derive a function that accepts a tree and a key and returns the
 value associated with that key.</p>
@@ -729,7 +730,7 @@ have to decide for yourself what <code class="docutils literal notranslate"><spa
          <span class="p">[]</span> <span class="n">key</span> <span class="n">E</span>
 </pre></div>
 </div>
-<div class="section" id="the-base-case">
+<section id="the-base-case">
 <h3>The base case <code class="docutils literal notranslate"><span class="pre">[]</span></code><a class="headerlink" href="#the-base-case" title="Permalink to this headline">¶</a></h3>
 <p>As before, the stopping predicate just has to detect the empty list:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="n">get</span> <span class="o">==</span> <span class="p">[</span><span class="n">pop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
@@ -751,8 +752,8 @@ Joy.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">pop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="id2">
+</section>
+<section id="id2">
 <h3>Node case <code class="docutils literal notranslate"><span class="pre">[key</span> <span class="pre">value</span> <span class="pre">left</span> <span class="pre">right]</span></code><a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
 <p>Now we need to figure out <code class="docutils literal notranslate"><span class="pre">R0</span></code> and <code class="docutils literal notranslate"><span class="pre">R1</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">key</span> <span class="n">R0</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="n">get</span><span class="p">]</span> <span class="n">R1</span>
@@ -762,10 +763,10 @@ Joy.</p>
 are the same return the value, otherwise recur on one of the child
 nodes. So it’s very similar to the above funtion, with <code class="docutils literal notranslate"><span class="pre">[R0]</span> <span class="pre">==</span> <span class="pre">[]</span></code>
 and <code class="docutils literal notranslate"><span class="pre">R1</span> <span class="pre">==</span> <span class="pre">P</span> <span class="pre">[T&gt;]</span> <span class="pre">[E]</span> <span class="pre">[T&lt;]</span> <span class="pre">cmp</span></code>:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">key</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="n">get</span><span class="p">]</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">key</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="n">get</span><span class="p">]</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span>
 </pre></div>
 </div>
-<div class="section" id="predicate">
+<section id="predicate">
 <h4>Predicate<a class="headerlink" href="#predicate" title="Permalink to this headline">¶</a></h4>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">P</span> <span class="o">==</span> <span class="n">over</span> <span class="p">[</span><span class="n">get</span><span class="o">-</span><span class="n">node</span><span class="o">-</span><span class="n">key</span><span class="p">]</span> <span class="n">nullary</span>
 <span class="n">get</span><span class="o">-</span><span class="n">node</span><span class="o">-</span><span class="n">key</span> <span class="o">==</span> <span class="n">pop</span> <span class="n">popop</span> <span class="n">first</span>
@@ -773,8 +774,8 @@ and <code class="docutils literal notranslate"><span class="pre">R1</span> <span
 </div>
 <p>The only difference is that <code class="docutils literal notranslate"><span class="pre">get-node-key</span></code> does one less <code class="docutils literal notranslate"><span class="pre">pop</span></code>
 because there’s no value to discard.</p>
-</div>
-<div class="section" id="branches">
+</section>
+<section id="branches">
 <h4>Branches<a class="headerlink" href="#branches" title="Permalink to this headline">¶</a></h4>
 <p>Now we have to derive the branches:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key_n</span> <span class="n">value_n</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">key</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="n">get</span><span class="p">]</span> <span class="n">T</span><span class="o">&gt;</span>
@@ -782,8 +783,8 @@ because there’s no value to discard.</p>
 <span class="p">[</span><span class="n">key_n</span> <span class="n">value_n</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">key</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="n">get</span><span class="p">]</span> <span class="n">T</span><span class="o">&lt;</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="greater-than-and-less-than">
+</section>
+<section id="greater-than-and-less-than">
 <h4>Greater than and less than<a class="headerlink" href="#greater-than-and-less-than" title="Permalink to this headline">¶</a></h4>
 <p>The cases of <code class="docutils literal notranslate"><span class="pre">T&gt;</span></code> and <code class="docutils literal notranslate"><span class="pre">T&lt;</span></code> are similar to above but instead of using
 <code class="docutils literal notranslate"><span class="pre">infra</span></code> we have to discard the rest of the structure:</p>
@@ -810,8 +811,8 @@ because there’s no value to discard.</p>
                     <span class="n">right</span>         <span class="n">key</span>  <span class="n">BTree</span><span class="o">-</span><span class="n">get</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="equal-keys">
+</section>
+<section id="equal-keys">
 <h4>Equal keys<a class="headerlink" href="#equal-keys" title="Permalink to this headline">¶</a></h4>
 <p>Return the node’s value:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key_n</span> <span class="n">value_n</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="n">key</span> <span class="p">[</span><span class="n">BTree</span><span class="o">-</span><span class="n">get</span><span class="p">]</span> <span class="n">E</span> <span class="o">==</span> <span class="n">value_n</span>
@@ -819,9 +820,9 @@ because there’s no value to discard.</p>
 <span class="n">E</span> <span class="o">==</span> <span class="n">popop</span> <span class="n">second</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="tree-get">
+</section>
+</section>
+<section id="tree-get">
 <h3><code class="docutils literal notranslate"><span class="pre">Tree-get</span></code><a class="headerlink" href="#tree-get" title="Permalink to this headline">¶</a></h3>
 <p>So:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fourth</span> <span class="o">==</span> <span class="n">rest</span> <span class="n">rest</span> <span class="n">rest</span> <span class="n">first</span>
@@ -831,10 +832,10 @@ because there’s no value to discard.</p>
 <span class="n">T</span><span class="o">&lt;</span> <span class="o">==</span> <span class="p">[</span><span class="n">third</span><span class="p">]</span> <span class="n">dipd</span> <span class="n">i</span>
 <span class="n">E</span> <span class="o">==</span> <span class="n">popop</span> <span class="n">second</span>
 
-<span class="n">Tree</span><span class="o">-</span><span class="n">get</span> <span class="o">==</span> <span class="p">[</span><span class="n">pop</span> <span class="ow">not</span><span class="p">]</span> <span class="n">swap</span> <span class="p">[]</span> <span class="p">[</span><span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span><span class="p">]</span> <span class="n">genrec</span>
+<span class="n">Tree</span><span class="o">-</span><span class="n">get</span> <span class="o">==</span> <span class="p">[</span><span class="n">pop</span> <span class="ow">not</span><span class="p">]</span> <span class="n">swap</span> <span class="p">[]</span> <span class="p">[</span><span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># I don&#39;t want to deal with name conflicts with the above so I&#39;m inlining everything here.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># I don&#39;t want to deal with name conflicts with the above so I&#39;m inlining everything here.</span>
 <span class="c1"># The original Joy system has &quot;hide&quot; which is a meta-command which allows you to use named</span>
 <span class="c1"># definitions that are only in scope for a given definition.  I don&#39;t want to implement</span>
 <span class="c1"># that (yet) so...</span>
@@ -851,19 +852,19 @@ because there’s no value to discard.</p>
 <span class="s1">&#39;&#39;&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;gary&quot; 23 [] []] &quot;mike&quot; [popd &quot; not in tree&quot; +] Tree-get&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;gary&quot; 23 [] []] &quot;mike&quot; [popd &quot; not in tree&quot; +] Tree-get&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;mike not in tree&#39;</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;gary&quot; 23 [] []] &quot;gary&quot; [popop &quot;err&quot;] Tree-get&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[&quot;gary&quot; 23 [] []] &quot;gary&quot; [popop &quot;err&quot;] Tree-get&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
 
 <span class="s1">    [] [[0 &#39;a&#39;] [1 &#39;b&#39;] [2 &#39;c&#39;]] [i Tree-add] step</span>
 
@@ -875,7 +876,7 @@ because there’s no value to discard.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
 
 <span class="s1">    [] [[0 &#39;a&#39;] [1 &#39;b&#39;] [2 &#39;c&#39;]] [i Tree-add] step</span>
 
@@ -887,9 +888,9 @@ because there’s no value to discard.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;not found&#39;</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="tree-delete">
+</section>
+</section>
+<section id="tree-delete">
 <h2>Tree-delete<a class="headerlink" href="#tree-delete" title="Permalink to this headline">¶</a></h2>
 <p>Now let’s write a function that can return a tree datastructure with a
 key, value pair deleted:</p>
@@ -899,14 +900,14 @@ key, value pair deleted:</p>
 </pre></div>
 </div>
 <p>If the key is not in tree it just returns the tree unchanged.</p>
-<div class="section" id="id3">
+<section id="id3">
 <h3>Base case<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
 <p>Same as above.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span><span class="o">-</span><span class="n">Delete</span> <span class="o">==</span> <span class="p">[</span><span class="n">pop</span> <span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="id4">
+</section>
+<section id="id4">
 <h3>Recur<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
 <p>Now we get to figure out the recursive case. We need the node’s key to
 compare and we need to carry the key into recursive branches. Let <code class="docutils literal notranslate"><span class="pre">D</span></code>
@@ -931,14 +932,14 @@ be shorthand for <code class="docutils literal notranslate"><span class="pre">Tr
 </div>
 <p>So:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">R0</span> <span class="o">==</span> <span class="n">over</span> <span class="n">first</span> <span class="n">swap</span> <span class="n">dup</span>
-<span class="n">R1</span> <span class="o">==</span> <span class="n">cons</span> <span class="n">roll</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span>
+<span class="n">R1</span> <span class="o">==</span> <span class="n">cons</span> <span class="n">roll</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="compare-keys">
+</section>
+<section id="compare-keys">
 <h3>Compare Keys<a class="headerlink" href="#compare-keys" title="Permalink to this headline">¶</a></h3>
 <p>The last line above:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">key</span> <span class="n">D</span><span class="p">]</span> <span class="n">node_key</span> <span class="n">key</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">key</span> <span class="n">D</span><span class="p">]</span> <span class="n">node_key</span> <span class="n">key</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span>
 </pre></div>
 </div>
 <p>Then becomes one of these three:</p>
@@ -947,8 +948,8 @@ be shorthand for <code class="docutils literal notranslate"><span class="pre">Tr
 <span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">key</span> <span class="n">D</span><span class="p">]</span> <span class="n">T</span><span class="o">&lt;</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="greater-than-case-and-less-than-case">
+</section>
+<section id="greater-than-case-and-less-than-case">
 <h3>Greater than case and less than case<a class="headerlink" href="#greater-than-case-and-less-than-case" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>   <span class="p">[</span><span class="n">node_key</span> <span class="n">node_value</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="n">T</span><span class="o">&gt;</span>
 <span class="o">-------------------------------------------------</span>
@@ -975,8 +976,8 @@ be shorthand for <code class="docutils literal notranslate"><span class="pre">Tr
 <span class="n">T</span><span class="o">&lt;</span> <span class="o">==</span> <span class="p">[</span><span class="n">dipdd</span><span class="p">]</span> <span class="n">cons</span> <span class="n">infra</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="the-else-case">
+</section>
+<section id="the-else-case">
 <h3>The else case<a class="headerlink" href="#the-else-case" title="Permalink to this headline">¶</a></h3>
 <p>We have found the node in the tree where <code class="docutils literal notranslate"><span class="pre">key</span></code> equals <code class="docutils literal notranslate"><span class="pre">node_key</span></code>. We
 need to replace the current node with something</p>
@@ -986,7 +987,7 @@ need to replace the current node with something</p>
 </pre></div>
 </div>
 <p>We have to handle three cases, so let’s use <code class="docutils literal notranslate"><span class="pre">cond</span></code>.</p>
-<div class="section" id="one-or-more-child-nodes-are">
+<section id="one-or-more-child-nodes-are">
 <h4>One or more child nodes are <code class="docutils literal notranslate"><span class="pre">[]</span></code><a class="headerlink" href="#one-or-more-child-nodes-are" title="Permalink to this headline">¶</a></h4>
 <p>The first two cases are symmetrical: if we only have one non-empty child
 node return it. If both child nodes are empty return an empty node.</p>
@@ -997,8 +998,8 @@ node return it. If both child nodes are empty return an empty node.</p>
 <span class="p">]</span> <span class="n">cond</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="both-child-nodes-are-non-empty">
+</section>
+<section id="both-child-nodes-are-non-empty">
 <h4>Both child nodes are non-empty.<a class="headerlink" href="#both-child-nodes-are-non-empty" title="Permalink to this headline">¶</a></h4>
 <p>If both child nodes are non-empty, we find the highest node in our lower
 sub-tree, take its key and value to replace (delete) our own, then get
@@ -1024,8 +1025,8 @@ right left [key D] node_value node_key       popop E″
 right left [key D]                                 E″
 </pre></div>
 </div>
-</div>
-<div class="section" id="we-have-to-we-find-the-highest-right-most-node-in-our-lower-left-sub-tree">
+</section>
+<section id="we-have-to-we-find-the-highest-right-most-node-in-our-lower-left-sub-tree">
 <h4>We have to we find the highest (right-most) node in our lower (left) sub-tree:<a class="headerlink" href="#we-have-to-we-find-the-highest-right-most-node-in-our-lower-left-sub-tree" title="Permalink to this headline">¶</a></h4>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>right left [key D] E″
 </pre></div>
@@ -1075,8 +1076,8 @@ rightest                      W′
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>W.rightmost == [?fourth] [fourth] while
 </pre></div>
 </div>
-</div>
-<div class="section" id="found-right-most-node-in-our-left-sub-tree">
+</section>
+<section id="found-right-most-node-in-our-left-sub-tree">
 <h4>Found right-most node in our left sub-tree<a class="headerlink" href="#found-right-most-node-in-our-left-sub-tree" title="Permalink to this headline">¶</a></h4>
 <p>We know rightest is not empty:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>[R_key R_value R_left R_right] W′
@@ -1096,8 +1097,8 @@ R_key R_value
 right left R_key R_value [D] E⁗
 </pre></div>
 </div>
-</div>
-<div class="section" id="replace-current-node-key-and-value-recursively-delete-rightmost">
+</section>
+<section id="replace-current-node-key-and-value-recursively-delete-rightmost">
 <h4>Replace current node key and value, recursively delete rightmost<a class="headerlink" href="#replace-current-node-key-and-value-recursively-delete-rightmost" title="Permalink to this headline">¶</a></h4>
 <p>Final stretch. We want to end up with something like:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>right left [R_key D] i R_value R_key
@@ -1150,9 +1151,9 @@ E == [
 ] cond
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="refactoring">
+</section>
+</section>
+<section id="refactoring">
 <h3>Refactoring<a class="headerlink" href="#refactoring" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">W</span><span class="o">.</span><span class="n">rightmost</span> <span class="o">==</span> <span class="p">[</span><span class="n">fourth</span><span class="p">]</span> <span class="p">[</span><span class="n">fourth</span><span class="p">]</span> <span class="k">while</span>
 <span class="n">W</span><span class="o">.</span><span class="n">unpack</span> <span class="o">==</span> <span class="n">uncons</span> <span class="n">uncons</span> <span class="n">pop</span>
@@ -1168,13 +1169,13 @@ E == [
 <span class="n">T</span><span class="o">&gt;</span> <span class="o">==</span> <span class="p">[</span><span class="n">dipd</span><span class="p">]</span> <span class="n">cons</span> <span class="n">infra</span>
 <span class="n">T</span><span class="o">&lt;</span> <span class="o">==</span> <span class="p">[</span><span class="n">dipdd</span><span class="p">]</span> <span class="n">cons</span> <span class="n">infra</span>
 <span class="n">R0</span> <span class="o">==</span> <span class="n">over</span> <span class="n">first</span> <span class="n">swap</span> <span class="n">dup</span>
-<span class="n">R1</span> <span class="o">==</span> <span class="n">cons</span> <span class="n">roll</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span>
+<span class="n">R1</span> <span class="o">==</span> <span class="n">cons</span> <span class="n">roll</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span>
 <span class="n">BTree</span><span class="o">-</span><span class="n">Delete</span> <span class="o">==</span> <span class="p">[</span><span class="n">pop</span> <span class="ow">not</span><span class="p">]</span> <span class="n">swap</span> <span class="p">[</span><span class="n">R0</span><span class="p">]</span> <span class="p">[</span><span class="n">R1</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
 <p>By the standards of the code I’ve written so far, this is a <em>huge</em> Joy
 program.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
 <span class="s1">first_two == uncons uncons pop</span>
 <span class="s1">fourth == rest rest rest first</span>
 <span class="s1">?fourth == [] [fourth] [] ifte</span>
@@ -1192,51 +1193,51 @@ program.</p>
 <span class="s1">&#39;&#39;&#39;</span><span class="p">,</span> <span class="n">D</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;c&#39; Tree-Delete &quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;c&#39; Tree-Delete &quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;a&#39;</span> <span class="mi">23</span> <span class="p">[]</span> <span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;b&#39; Tree-Delete &quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;b&#39; Tree-Delete &quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;a&#39;</span> <span class="mi">23</span> <span class="p">[]</span> <span class="p">[</span><span class="s1">&#39;c&#39;</span> <span class="mi">44</span> <span class="p">[]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;a&#39; Tree-Delete &quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;a&#39; Tree-Delete &quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[</span><span class="s1">&#39;c&#39;</span> <span class="mi">44</span> <span class="p">[]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;der&#39; Tree-Delete &quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[&#39;a&#39; 23 [] [&#39;b&#39; 88 [] [&#39;c&#39; 44 [] []]]] &#39;der&#39; Tree-Delete &quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;a&#39;</span> <span class="mi">23</span> <span class="p">[]</span> <span class="p">[</span><span class="s1">&#39;b&#39;</span> <span class="mi">88</span> <span class="p">[]</span> <span class="p">[</span><span class="s1">&#39;c&#39;</span> <span class="mi">44</span> <span class="p">[]</span> <span class="p">[]]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [4 2 3 1 6 7 5 ] [0 swap Tree-add] step&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] [4 2 3 1 6 7 5 ] [0 swap Tree-add] step&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">4</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">1</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]]</span> <span class="p">[</span><span class="mi">6</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">5</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">7</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 3 Tree-Delete &quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 3 Tree-Delete &quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">4</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">1</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">6</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">5</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">7</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 4 Tree-Delete &quot;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s2">&quot;[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 4 Tree-Delete &quot;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">1</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">6</span> <span class="mi">0</span> <span class="p">[</span><span class="mi">5</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[</span><span class="mi">7</span> <span class="mi">0</span> <span class="p">[]</span> <span class="p">[]]]]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="appendix-the-source-code">
+</section>
+</section>
+<section id="appendix-the-source-code">
 <h2>Appendix: The source code.<a class="headerlink" href="#appendix-the-source-code" title="Permalink to this headline">¶</a></h2>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>fourth == rest_two rest first
 ?fourth == [] [fourth] [] ifte
@@ -1283,91 +1284,55 @@ Tree-get == [pop not] swap [] [_Tree_get_R] genrec
 Tree-delete == [pop not] [pop] [_Tree_delete_R0] [_Tree_delete_R1] genrec
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Treating Trees I: Ordered Binary Trees</a><ul>
-<li><a class="reference internal" href="#adding-nodes-to-the-tree">Adding Nodes to the Tree</a><ul>
-<li><a class="reference internal" href="#adding-to-an-empty-node">Adding to an empty node.</a><ul>
-<li><a class="reference internal" href="#tree-new"><code class="docutils literal notranslate"><span class="pre">Tree-new</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#adding-to-a-non-empty-node">Adding to a non-empty node.</a><ul>
-<li><a class="reference internal" href="#a-predicate-to-compare-keys">A predicate to compare keys.</a></li>
-<li><a class="reference internal" href="#if-the-key-were-adding-is-greater-than-the-nodes-key">If the key we’re adding is greater than the node’s key.</a></li>
-<li><a class="reference internal" href="#if-the-key-were-adding-is-less-than-the-nodes-key">If the key we’re adding is less than the node’s key.</a></li>
-<li><a class="reference internal" href="#else-the-keys-must-be-equal">Else the keys must be equal.</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#now-we-can-define-tree-add">Now we can define <code class="docutils literal notranslate"><span class="pre">Tree-add</span></code></a></li>
-<li><a class="reference internal" href="#examples">Examples</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#interlude-cmp-combinator">Interlude: <code class="docutils literal notranslate"><span class="pre">cmp</span></code> combinator</a><ul>
-<li><a class="reference internal" href="#redefine-tree-add">Redefine <code class="docutils literal notranslate"><span class="pre">Tree-add</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#a-function-to-traverse-this-structure">A Function to Traverse this Structure</a><ul>
-<li><a class="reference internal" href="#base-case">Base case <code class="docutils literal notranslate"><span class="pre">[]</span></code></a></li>
-<li><a class="reference internal" href="#node-case-key-value-left-right">Node case <code class="docutils literal notranslate"><span class="pre">[key</span> <span class="pre">value</span> <span class="pre">left</span> <span class="pre">right]</span></code></a><ul>
-<li><a class="reference internal" href="#processing-the-current-node">Processing the current node.</a></li>
-<li><a class="reference internal" href="#recur">Recur</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#putting-it-together">Putting it together</a></li>
-<li><a class="reference internal" href="#parameterizing-the-f-per-node-processing-function">Parameterizing the <code class="docutils literal notranslate"><span class="pre">F</span></code> per-node processing function.</a></li>
-<li><a class="reference internal" href="#tree-iter"><code class="docutils literal notranslate"><span class="pre">Tree-iter</span></code></a></li>
-<li><a class="reference internal" href="#id1">Examples</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#interlude-a-set-like-datastructure">Interlude: A Set-like Datastructure</a></li>
-<li><a class="reference internal" href="#a-version-of-tree-iter-that-does-in-order-traversal">A Version of <code class="docutils literal notranslate"><span class="pre">Tree-iter</span></code> that does In-Order Traversal</a><ul>
-<li><a class="reference internal" href="#process-the-left-child">Process the left child.</a></li>
-<li><a class="reference internal" href="#process-the-current-node">Process the current node.</a></li>
-<li><a class="reference internal" href="#process-the-right-child">Process the right child.</a></li>
-<li><a class="reference internal" href="#defining-tree-iter-order">Defining <code class="docutils literal notranslate"><span class="pre">Tree-iter-order</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#getting-values-by-key">Getting values by key</a><ul>
-<li><a class="reference internal" href="#the-base-case">The base case <code class="docutils literal notranslate"><span class="pre">[]</span></code></a></li>
-<li><a class="reference internal" href="#id2">Node case <code class="docutils literal notranslate"><span class="pre">[key</span> <span class="pre">value</span> <span class="pre">left</span> <span class="pre">right]</span></code></a><ul>
-<li><a class="reference internal" href="#predicate">Predicate</a></li>
-<li><a class="reference internal" href="#branches">Branches</a></li>
-<li><a class="reference internal" href="#greater-than-and-less-than">Greater than and less than</a></li>
-<li><a class="reference internal" href="#equal-keys">Equal keys</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#tree-get"><code class="docutils literal notranslate"><span class="pre">Tree-get</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#tree-delete">Tree-delete</a><ul>
-<li><a class="reference internal" href="#id3">Base case</a></li>
-<li><a class="reference internal" href="#id4">Recur</a></li>
-<li><a class="reference internal" href="#compare-keys">Compare Keys</a></li>
-<li><a class="reference internal" href="#greater-than-case-and-less-than-case">Greater than case and less than case</a></li>
-<li><a class="reference internal" href="#the-else-case">The else case</a><ul>
-<li><a class="reference internal" href="#one-or-more-child-nodes-are">One or more child nodes are <code class="docutils literal notranslate"><span class="pre">[]</span></code></a></li>
-<li><a class="reference internal" href="#both-child-nodes-are-non-empty">Both child nodes are non-empty.</a></li>
-<li><a class="reference internal" href="#we-have-to-we-find-the-highest-right-most-node-in-our-lower-left-sub-tree">We have to we find the highest (right-most) node in our lower (left) sub-tree:</a></li>
-<li><a class="reference internal" href="#found-right-most-node-in-our-left-sub-tree">Found right-most node in our left sub-tree</a></li>
-<li><a class="reference internal" href="#replace-current-node-key-and-value-recursively-delete-rightmost">Replace current node key and value, recursively delete rightmost</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#refactoring">Refactoring</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#appendix-the-source-code">Appendix: The source code.</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -1379,25 +1344,24 @@ Tree-delete == [pop not] [pop] [_Tree_delete_R0] [_Tree_delete_R1] genrec
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Ordered_Binary_Trees.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -1408,7 +1372,7 @@ Tree-delete == [pop not] [pop] [_Tree_delete_R0] [_Tree_delete_R1] genrec
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index b6a2169..40c3b6d 100644 (file)
@@ -1,19 +1,19 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Quadratic formula &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
+    <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Replacing Functions in the Dictionary" href="Replacing.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
+  <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
 </pre></div>
 </div>
-<div class="section" id="quadratic-formula">
+<section id="quadratic-formula">
 <h1><a class="reference external" href="https://en.wikipedia.org/wiki/Quadratic_formula">Quadratic formula</a><a class="headerlink" href="#quadratic-formula" title="Permalink to this headline">¶</a></h1>
 <p>Cf.
 <a class="reference external" href="http://www.kevinalbrecht.com/code/joy-mirror/jp-quadratic.html">jp-quadratic.html</a></p>
 </pre></div>
 </div>
 <p><span class="math notranslate nohighlight">\(\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\)</span></p>
-<div class="section" id="write-a-straightforward-program-with-variable-names">
+<section id="write-a-straightforward-program-with-variable-names">
 <h2>Write a straightforward program with variable names.<a class="headerlink" href="#write-a-straightforward-program-with-variable-names" title="Permalink to this headline">¶</a></h2>
 <p>This math translates to Joy code in a straightforward manner. We are
 going to use named variables to keep track of the arguments, then write
 a definition without them.</p>
-<div class="section" id="b">
+<section id="b">
 <h3><code class="docutils literal notranslate"><span class="pre">-b</span></code><a class="headerlink" href="#b" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="n">neg</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="sqrt-b-2-4-a-c">
+</section>
+<section id="sqrt-b-2-4-a-c">
 <h3><code class="docutils literal notranslate"><span class="pre">sqrt(b^2</span> <span class="pre">-</span> <span class="pre">4</span> <span class="pre">*</span> <span class="pre">a</span> <span class="pre">*</span> <span class="pre">c)</span></code><a class="headerlink" href="#sqrt-b-2-4-a-c" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="n">sqr</span> <span class="mi">4</span> <span class="n">a</span> <span class="n">c</span> <span class="o">*</span> <span class="o">*</span> <span class="o">-</span> <span class="n">sqrt</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="a">
+</section>
+<section id="a">
 <h3><code class="docutils literal notranslate"><span class="pre">/2a</span></code><a class="headerlink" href="#a" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="mi">2</span> <span class="o">*</span> <span class="o">/</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="id1">
+</section>
+<section id="id1">
 <h3><code class="docutils literal notranslate"><span class="pre">±</span></code><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
 <p>There is a function <code class="docutils literal notranslate"><span class="pre">pm</span></code> that accepts two values on the stack and
 replaces them with their sum and difference.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pm</span> <span class="o">==</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="p">]</span> <span class="n">cleave</span> <span class="n">popdd</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="putting-them-together">
+</section>
+<section id="putting-them-together">
 <h3>Putting Them Together<a class="headerlink" href="#putting-them-together" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="n">neg</span> <span class="n">b</span> <span class="n">sqr</span> <span class="mi">4</span> <span class="n">a</span> <span class="n">c</span> <span class="o">*</span> <span class="o">*</span> <span class="o">-</span> <span class="n">sqrt</span> <span class="n">pm</span> <span class="n">a</span> <span class="mi">2</span> <span class="o">*</span> <span class="p">[</span><span class="o">/</span><span class="p">]</span> <span class="n">cons</span> <span class="n">app2</span>
 </pre></div>
 </div>
 <p>We use <code class="docutils literal notranslate"><span class="pre">app2</span></code> to compute both roots by using a quoted program
 <code class="docutils literal notranslate"><span class="pre">[2a</span> <span class="pre">/]</span></code> built with <code class="docutils literal notranslate"><span class="pre">cons</span></code>.</p>
-</div>
-</div>
-<div class="section" id="derive-a-definition">
+</section>
+</section>
+<section id="derive-a-definition">
 <h2>Derive a definition.<a class="headerlink" href="#derive-a-definition" title="Permalink to this headline">¶</a></h2>
 <p>Working backwards we use <code class="docutils literal notranslate"><span class="pre">dip</span></code> and <code class="docutils literal notranslate"><span class="pre">dipd</span></code> to extract the code from
 the variables:</p>
@@ -98,11 +100,11 @@ the variables:</p>
 </div>
 <p>The three arguments are to the left, so we can “chop off” everything to
 the right and say it’s the definition of the <code class="docutils literal notranslate"><span class="pre">quadratic</span></code> function:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Let’s try it out:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 1 1 quadratic&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;3 1 1 quadratic&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="mf">0.3819660112501051</span> <span class="o">-</span><span class="mf">2.618033988749895</span>
@@ -112,7 +114,7 @@ the right and say it’s the definition of the <code class="docutils literal not
 lines are the <code class="docutils literal notranslate"><span class="pre">dip</span></code> and <code class="docutils literal notranslate"><span class="pre">dipd</span></code> combinators building the main program
 by incorporating the values on the stack. Then that program runs and you
 get the results. This is pretty typical of Joy code.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;-5 1 4 quadratic&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;-5 1 4 quadratic&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                                   <span class="o">.</span> <span class="o">-</span><span class="mi">5</span> <span class="mi">1</span> <span class="mi">4</span> <span class="n">quadratic</span>
@@ -162,30 +164,55 @@ get the results. This is pretty typical of Joy code.</p>
                                            <span class="mf">4.0</span> <span class="mf">1.0</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Quadratic formula</a><ul>
-<li><a class="reference internal" href="#write-a-straightforward-program-with-variable-names">Write a straightforward program with variable names.</a><ul>
-<li><a class="reference internal" href="#b"><code class="docutils literal notranslate"><span class="pre">-b</span></code></a></li>
-<li><a class="reference internal" href="#sqrt-b-2-4-a-c"><code class="docutils literal notranslate"><span class="pre">sqrt(b^2</span> <span class="pre">-</span> <span class="pre">4</span> <span class="pre">*</span> <span class="pre">a</span> <span class="pre">*</span> <span class="pre">c)</span></code></a></li>
-<li><a class="reference internal" href="#a"><code class="docutils literal notranslate"><span class="pre">/2a</span></code></a></li>
-<li><a class="reference internal" href="#id1"><code class="docutils literal notranslate"><span class="pre">±</span></code></a></li>
-<li><a class="reference internal" href="#putting-them-together">Putting Them Together</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#derive-a-definition">Derive a definition.</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -197,25 +224,24 @@ get the results. This is pretty typical of Joy code.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Quadratic.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -226,7 +252,7 @@ get the results. This is pretty typical of Joy code.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 977b2bb..e1cdc26 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Recursion Combinators &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Treating Trees I: Ordered Binary Trees" href="Ordered_Binary_Trees.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">DefinitionWrapper</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
+  <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">DefinitionWrapper</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
 </pre></div>
 </div>
-<div class="section" id="recursion-combinators">
+<section id="recursion-combinators">
 <h1>Recursion Combinators<a class="headerlink" href="#recursion-combinators" title="Permalink to this headline">¶</a></h1>
 <p>This article describes the <code class="docutils literal notranslate"><span class="pre">genrec</span></code> combinator, how to use it, and
 several generic specializations.</p>
@@ -46,7 +47,7 @@ several generic specializations.</p>
 </div>
 <p>From “Recursion Theory and Joy” (j05cmp.html) by Manfred von Thun:</p>
 <blockquote>
-<div>“The genrec combinator takes four program parameters in addition to
+<div><p>“The genrec combinator takes four program parameters in addition to
 whatever data parameters it needs. Fourth from the top is an if-part,
 followed by a then-part. If the if-part yields true, then the
 then-part is executed and the combinator terminates. The other two
@@ -55,8 +56,9 @@ false, the rec1-part is executed. Following that the four program
 parameters and the combinator are again pushed onto the stack bundled
 up in a quoted form. Then the rec2-part is executed, where it will
 find the bundled form. Typically it will then execute the bundled
-form, either with i or with app2, or some other combinator.”</div></blockquote>
-<div class="section" id="designing-recursive-functions">
+form, either with i or with app2, or some other combinator.”</p>
+</div></blockquote>
+<section id="designing-recursive-functions">
 <h2>Designing Recursive Functions<a class="headerlink" href="#designing-recursive-functions" title="Permalink to this headline">¶</a></h2>
 <p>The way to design one of these is to fix your base case and test and
 then treat <code class="docutils literal notranslate"><span class="pre">R1</span></code> and <code class="docutils literal notranslate"><span class="pre">R2</span></code> as an else-part “sandwiching” a quotation
@@ -73,8 +75,8 @@ from:</p>
 </div>
 <p>Set the stack arguments in front and figure out what <code class="docutils literal notranslate"><span class="pre">R1</span></code> and <code class="docutils literal notranslate"><span class="pre">R2</span></code>
 have to do to apply the quoted <code class="docutils literal notranslate"><span class="pre">[F]</span></code> in the proper way.</p>
-</div>
-<div class="section" id="primitive-recursive-functions">
+</section>
+<section id="primitive-recursive-functions">
 <h2>Primitive Recursive Functions<a class="headerlink" href="#primitive-recursive-functions" title="Permalink to this headline">¶</a></h2>
 <p>Primitive recursive functions are those where <code class="docutils literal notranslate"><span class="pre">R2</span> <span class="pre">==</span> <span class="pre">i</span></code>.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">P</span> <span class="o">==</span> <span class="p">[</span><span class="n">I</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="p">[</span><span class="n">R</span><span class="p">]</span> <span class="n">primrec</span>
@@ -82,24 +84,24 @@ have to do to apply the quoted <code class="docutils literal notranslate"><span
   <span class="o">==</span> <span class="p">[</span><span class="n">I</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="p">[</span><span class="n">R</span> <span class="n">P</span><span class="p">]</span> <span class="n">ifte</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="hylomorphism">
+</section>
+<section id="hylomorphism">
 <h2><a class="reference external" href="https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29">Hylomorphism</a><a class="headerlink" href="#hylomorphism" title="Permalink to this headline">¶</a></h2>
 <p>A
 <a class="reference external" href="https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29">hylomorphism</a>
 is a recursive function <code class="docutils literal notranslate"><span class="pre">H</span> <span class="pre">::</span> <span class="pre">A</span> <span class="pre">-&gt;</span> <span class="pre">C</span></code> that converts a value of type
 <code class="docutils literal notranslate"><span class="pre">A</span></code> into a value of type <code class="docutils literal notranslate"><span class="pre">C</span></code> by means of:</p>
 <ul class="simple">
-<li>A generator <code class="docutils literal notranslate"><span class="pre">G</span> <span class="pre">::</span> <span class="pre">A</span> <span class="pre">-&gt;</span> <span class="pre">(B,</span> <span class="pre">A)</span></code></li>
-<li>A combiner <code class="docutils literal notranslate"><span class="pre">F</span> <span class="pre">::</span> <span class="pre">(B,</span> <span class="pre">C)</span> <span class="pre">-&gt;</span> <span class="pre">C</span></code></li>
-<li>A predicate <code class="docutils literal notranslate"><span class="pre">P</span> <span class="pre">::</span> <span class="pre">A</span> <span class="pre">-&gt;</span> <span class="pre">Bool</span></code> to detect the base case</li>
-<li>A base case value <code class="docutils literal notranslate"><span class="pre">c</span> <span class="pre">::</span> <span class="pre">C</span></code></li>
-<li>Recursive calls (zero or more); it has a “call stack in the form of a
-cons list”.</li>
+<li><p>A generator <code class="docutils literal notranslate"><span class="pre">G</span> <span class="pre">::</span> <span class="pre">A</span> <span class="pre">-&gt;</span> <span class="pre">(B,</span> <span class="pre">A)</span></code></p></li>
+<li><p>A combiner <code class="docutils literal notranslate"><span class="pre">F</span> <span class="pre">::</span> <span class="pre">(B,</span> <span class="pre">C)</span> <span class="pre">-&gt;</span> <span class="pre">C</span></code></p></li>
+<li><p>A predicate <code class="docutils literal notranslate"><span class="pre">P</span> <span class="pre">::</span> <span class="pre">A</span> <span class="pre">-&gt;</span> <span class="pre">Bool</span></code> to detect the base case</p></li>
+<li><p>A base case value <code class="docutils literal notranslate"><span class="pre">c</span> <span class="pre">::</span> <span class="pre">C</span></code></p></li>
+<li><p>Recursive calls (zero or more); it has a “call stack in the form of a
+cons list”.</p></li>
 </ul>
 <p>It may be helpful to see this function implemented in imperative Python
 code.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">hylomorphism</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">F</span><span class="p">,</span> <span class="n">P</span><span class="p">,</span> <span class="n">G</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">hylomorphism</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">F</span><span class="p">,</span> <span class="n">P</span><span class="p">,</span> <span class="n">G</span><span class="p">):</span>
     <span class="sd">&#39;&#39;&#39;Return a hylomorphism function H.&#39;&#39;&#39;</span>
 
     <span class="k">def</span> <span class="nf">H</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
@@ -118,8 +120,8 @@ Wire”</a></p>
 <p>Note that during evaluation of <code class="docutils literal notranslate"><span class="pre">H()</span></code> the intermediate <code class="docutils literal notranslate"><span class="pre">b</span></code> values are
 stored in the Python call stack. This is what is meant by “call stack in
 the form of a cons list”.</p>
-</div>
-<div class="section" id="hylomorphism-in-joy">
+</section>
+<section id="hylomorphism-in-joy">
 <h2>Hylomorphism in Joy<a class="headerlink" href="#hylomorphism-in-joy" title="Permalink to this headline">¶</a></h2>
 <p>We can define a combinator <code class="docutils literal notranslate"><span class="pre">hylomorphism</span></code> that will make a
 hylomorphism combinator <code class="docutils literal notranslate"><span class="pre">H</span></code> from constituent parts.</p>
@@ -155,8 +157,8 @@ it is a simple specialization of the general recursion combinator.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="n">c</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="n">hylomorphism</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="n">c</span><span class="p">]</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">F</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="derivation-of-hylomorphism-combinator">
+</section>
+<section id="derivation-of-hylomorphism-combinator">
 <h2>Derivation of <code class="docutils literal notranslate"><span class="pre">hylomorphism</span></code> combinator<a class="headerlink" href="#derivation-of-hylomorphism-combinator" title="Permalink to this headline">¶</a></h2>
 <p>Now we just need to derive a definition that builds the <code class="docutils literal notranslate"><span class="pre">genrec</span></code>
 arguments out of the pieces given to the <code class="docutils literal notranslate"><span class="pre">hylomorphism</span></code> combinator.</p>
@@ -167,9 +169,9 @@ arguments out of the pieces given to the <code class="docutils literal notransla
 </div>
 <p>Working in reverse:</p>
 <ul class="simple">
-<li>Use <code class="docutils literal notranslate"><span class="pre">swoncat</span></code> twice to decouple <code class="docutils literal notranslate"><span class="pre">[c]</span></code> and <code class="docutils literal notranslate"><span class="pre">[F]</span></code>.</li>
-<li>Use <code class="docutils literal notranslate"><span class="pre">unit</span></code> to dequote <code class="docutils literal notranslate"><span class="pre">c</span></code>.</li>
-<li>Use <code class="docutils literal notranslate"><span class="pre">dipd</span></code> to untangle <code class="docutils literal notranslate"><span class="pre">[unit</span> <span class="pre">[pop]</span> <span class="pre">swoncat]</span></code> from the givens.</li>
+<li><p>Use <code class="docutils literal notranslate"><span class="pre">swoncat</span></code> twice to decouple <code class="docutils literal notranslate"><span class="pre">[c]</span></code> and <code class="docutils literal notranslate"><span class="pre">[F]</span></code>.</p></li>
+<li><p>Use <code class="docutils literal notranslate"><span class="pre">unit</span></code> to dequote <code class="docutils literal notranslate"><span class="pre">c</span></code>.</p></li>
+<li><p>Use <code class="docutils literal notranslate"><span class="pre">dipd</span></code> to untangle <code class="docutils literal notranslate"><span class="pre">[unit</span> <span class="pre">[pop]</span> <span class="pre">swoncat]</span></code> from the givens.</p></li>
 </ul>
 <p>So:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="n">c</span><span class="p">]</span>              <span class="p">[</span><span class="n">G</span><span class="p">]</span>                  <span class="p">[</span><span class="n">dip</span> <span class="n">F</span><span class="p">]</span> <span class="n">genrec</span>
@@ -183,40 +185,40 @@ the left so we have a definition for <code class="docutils literal notranslate">
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">hylomorphism</span> <span class="o">==</span> <span class="p">[</span><span class="n">unit</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="n">swoncat</span><span class="p">]</span> <span class="n">dipd</span> <span class="p">[</span><span class="n">dip</span><span class="p">]</span> <span class="n">swoncat</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="section" id="example-finding-triangular-numbers">
+<section id="example-finding-triangular-numbers">
 <h3>Example: Finding <a class="reference external" href="https://en.wikipedia.org/wiki/Triangular_number">Triangular Numbers</a><a class="headerlink" href="#example-finding-triangular-numbers" title="Permalink to this headline">¶</a></h3>
 <p>Let’s write a function that, given a positive integer, returns the sum
 of all positive integers less than that one. (In this case the types
 <code class="docutils literal notranslate"><span class="pre">A</span></code>, <code class="docutils literal notranslate"><span class="pre">B</span></code> and <code class="docutils literal notranslate"><span class="pre">C</span></code> are all <code class="docutils literal notranslate"><span class="pre">int</span></code>.)</p>
 <p>To sum a range of integers from 0 to <em>n</em> - 1:</p>
 <ul class="simple">
-<li><code class="docutils literal notranslate"><span class="pre">[P]</span></code> is <code class="docutils literal notranslate"><span class="pre">[1</span> <span class="pre">&lt;=]</span></code></li>
-<li><code class="docutils literal notranslate"><span class="pre">c</span></code> is <code class="docutils literal notranslate"><span class="pre">0</span></code></li>
-<li><code class="docutils literal notranslate"><span class="pre">[G]</span></code> is <code class="docutils literal notranslate"><span class="pre">[--</span> <span class="pre">dup]</span></code></li>
-<li><code class="docutils literal notranslate"><span class="pre">[F]</span></code> is <code class="docutils literal notranslate"><span class="pre">[+]</span></code></li>
+<li><p><code class="docutils literal notranslate"><span class="pre">[P]</span></code> is <code class="docutils literal notranslate"><span class="pre">[1</span> <span class="pre">&lt;=]</span></code></p></li>
+<li><p><code class="docutils literal notranslate"><span class="pre">c</span></code> is <code class="docutils literal notranslate"><span class="pre">0</span></code></p></li>
+<li><p><code class="docutils literal notranslate"><span class="pre">[G]</span></code> is <code class="docutils literal notranslate"><span class="pre">[--</span> <span class="pre">dup]</span></code></p></li>
+<li><p><code class="docutils literal notranslate"><span class="pre">[F]</span></code> is <code class="docutils literal notranslate"><span class="pre">[+]</span></code></p></li>
 </ul>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;triangular_number == [1 &lt;=] 0 [-- dup] [+] hylomorphism&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;triangular_number == [1 &lt;=] 0 [-- dup] [+] hylomorphism&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Let’s try it:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 triangular_number&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 triangular_number&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[0 1 2 3 4 5 6] [triangular_number] map&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[0 1 2 3 4 5 6] [triangular_number] map&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">0</span> <span class="mi">0</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">6</span> <span class="mi">10</span> <span class="mi">15</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="four-specializations">
+</section>
+</section>
+<section id="four-specializations">
 <h2>Four Specializations<a class="headerlink" href="#four-specializations" title="Permalink to this headline">¶</a></h2>
 <p>There are at least four kinds of recursive combinator, depending on two
 choices. The first choice is whether the combiner function <code class="docutils literal notranslate"><span class="pre">F</span></code> should
@@ -244,7 +246,7 @@ Consider the recursive branches:</p>
 </div>
 <p>The following four sections illustrate how these work, omitting the
 predicate evaluation.</p>
-<div class="section" id="h1">
+<section id="h1">
 <h3><code class="docutils literal notranslate"><span class="pre">H1</span></code><a class="headerlink" href="#h1" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H1</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="n">c</span><span class="p">]</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">F</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
@@ -271,8 +273,8 @@ the intermediate results along with the pending combiner functions. When
 the base case is reached the last term is replaced by the identity value
 <code class="docutils literal notranslate"><span class="pre">c</span></code> and the continuation “collapses” into the final result using the
 combiner <code class="docutils literal notranslate"><span class="pre">F</span></code>.</p>
-</div>
-<div class="section" id="h2">
+</section>
+<section id="h2">
 <h3><code class="docutils literal notranslate"><span class="pre">H2</span></code><a class="headerlink" href="#h2" title="Permalink to this headline">¶</a></h3>
 <p>When you can start with the identity value <code class="docutils literal notranslate"><span class="pre">c</span></code> on the stack and the
 combiner <code class="docutils literal notranslate"><span class="pre">F</span></code> can operate as you go using the intermediate results
@@ -297,8 +299,8 @@ reverse order.</p>
 ... d″
 </pre></div>
 </div>
-</div>
-<div class="section" id="h3">
+</section>
+<section id="h3">
 <h3><code class="docutils literal notranslate"><span class="pre">H3</span></code><a class="headerlink" href="#h3" title="Permalink to this headline">¶</a></h3>
 <p>If you examine the traces above you’ll see that the combiner <code class="docutils literal notranslate"><span class="pre">F</span></code> only
 gets to operate on the results of <code class="docutils literal notranslate"><span class="pre">G</span></code>, it never “sees” the first value
@@ -326,8 +328,8 @@ one item instead of two (the b is instead the duplicate of a.)</p>
 ...        d″
 </pre></div>
 </div>
-</div>
-<div class="section" id="h4">
+</section>
+<section id="h4">
 <h3><code class="docutils literal notranslate"><span class="pre">H4</span></code><a class="headerlink" href="#h4" title="Permalink to this headline">¶</a></h3>
 <p>And, last but not least, if you can combine as you go, starting with
 <code class="docutils literal notranslate"><span class="pre">c</span></code>, and the combiner <code class="docutils literal notranslate"><span class="pre">F</span></code> needs to work on the current item, this is
@@ -350,9 +352,9 @@ the form:</p>
 ... d″
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="anamorphism">
+</section>
+</section>
+<section id="anamorphism">
 <h2>Anamorphism<a class="headerlink" href="#anamorphism" title="Permalink to this headline">¶</a></h2>
 <p>An anamorphism can be defined as a hylomorphism that uses <code class="docutils literal notranslate"><span class="pre">[]</span></code> for
 <code class="docutils literal notranslate"><span class="pre">c</span></code> and <code class="docutils literal notranslate"><span class="pre">swons</span></code> for <code class="docutils literal notranslate"><span class="pre">F</span></code>. An anamorphic function builds a list of
@@ -360,68 +362,69 @@ values.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[</span><span class="n">G</span><span class="p">]</span> <span class="p">[</span><span class="n">swons</span><span class="p">]</span> <span class="n">hylomorphism</span>
 </pre></div>
 </div>
-<div class="section" id="range-et-al-an-example-of-an-anamorphism-is-the-range-function-which-generates-the-list-of-integers-from-0-to-n-1-given-n">
-<h3><code class="docutils literal notranslate"><span class="pre">range</span></code> et. al.&nbsp;An example of an anamorphism is the <code class="docutils literal notranslate"><span class="pre">range</span></code> function which generates the list of integers from 0 to <em>n</em> - 1 given <em>n</em>.<a class="headerlink" href="#range-et-al-an-example-of-an-anamorphism-is-the-range-function-which-generates-the-list-of-integers-from-0-to-n-1-given-n" title="Permalink to this headline">¶</a></h3>
+<section id="range-et-al">
+<h3><code class="docutils literal notranslate"><span class="pre">range</span></code> et. al.<a class="headerlink" href="#range-et-al" title="Permalink to this headline">¶</a></h3>
+<p>An example of an anamorphism is the <code class="docutils literal notranslate"><span class="pre">range</span></code> function which generates the list of integers from 0 to <em>n</em> - 1 given <em>n</em>.</p>
 <p>Each of the above variations can be used to make four slightly different
 <code class="docutils literal notranslate"><span class="pre">range</span></code> functions.</p>
-<div class="section" id="range-with-h1">
+<section id="range-with-h1">
 <h4><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H1</span></code><a class="headerlink" href="#range-with-h1" title="Permalink to this headline">¶</a></h4>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H1</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span>    <span class="p">[</span><span class="n">pop</span> <span class="n">c</span><span class="p">]</span>  <span class="p">[</span><span class="n">G</span><span class="p">]</span>      <span class="p">[</span><span class="n">dip</span> <span class="n">F</span><span class="p">]</span>     <span class="n">genrec</span>
    <span class="o">==</span> <span class="p">[</span><span class="mi">0</span> <span class="o">&lt;=</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="p">[]]</span> <span class="p">[</span><span class="o">--</span> <span class="n">dup</span><span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">swons</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;range == [0 &lt;=] [] [-- dup] [swons] hylomorphism&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;range == [0 &lt;=] [] [-- dup] [swons] hylomorphism&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">4</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="range-with-h2">
+</section>
+<section id="range-with-h2">
 <h4><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H2</span></code><a class="headerlink" href="#range-with-h2" title="Permalink to this headline">¶</a></h4>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H2</span> <span class="o">==</span> <span class="n">c</span>  <span class="n">swap</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span>    <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[</span><span class="n">G</span>      <span class="p">[</span><span class="n">F</span><span class="p">]</span>     <span class="n">dip</span><span class="p">]</span> <span class="n">primrec</span>
    <span class="o">==</span> <span class="p">[]</span> <span class="n">swap</span> <span class="p">[</span><span class="mi">0</span> <span class="o">&lt;=</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[</span><span class="o">--</span> <span class="n">dup</span> <span class="p">[</span><span class="n">swons</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span> <span class="n">primrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;range_reverse == [] swap [0 &lt;=] [pop] [-- dup [swons] dip] primrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;range_reverse == [] swap [0 &lt;=] [pop] [-- dup [swons] dip] primrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range_reverse&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 range_reverse&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">0</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="range-with-h3">
+</section>
+<section id="range-with-h3">
 <h4><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H3</span></code><a class="headerlink" href="#range-with-h3" title="Permalink to this headline">¶</a></h4>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H3</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span>    <span class="p">[</span><span class="n">pop</span> <span class="n">c</span><span class="p">]</span>  <span class="p">[[</span><span class="n">G</span><span class="p">]</span>  <span class="n">dupdip</span><span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">F</span><span class="p">]</span>     <span class="n">genrec</span>
    <span class="o">==</span> <span class="p">[</span><span class="mi">0</span> <span class="o">&lt;=</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="p">[]]</span> <span class="p">[[</span><span class="o">--</span><span class="p">]</span> <span class="n">dupdip</span><span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">swons</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;ranger == [0 &lt;=] [pop []] [[--] dupdip] [dip swons] genrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;ranger == [0 &lt;=] [pop []] [[--] dupdip] [dip swons] genrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 ranger&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 ranger&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">5</span> <span class="mi">4</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="range-with-h4">
+</section>
+<section id="range-with-h4">
 <h4><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H4</span></code><a class="headerlink" href="#range-with-h4" title="Permalink to this headline">¶</a></h4>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H4</span> <span class="o">==</span> <span class="n">c</span>  <span class="n">swap</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span>    <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[[</span><span class="n">F</span><span class="p">]</span>     <span class="n">dupdip</span> <span class="n">G</span> <span class="p">]</span> <span class="n">primrec</span>
    <span class="o">==</span> <span class="p">[]</span> <span class="n">swap</span> <span class="p">[</span><span class="mi">0</span> <span class="o">&lt;=</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[[</span><span class="n">swons</span><span class="p">]</span> <span class="n">dupdip</span> <span class="o">--</span><span class="p">]</span> <span class="n">primrec</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;ranger_reverse == [] swap [0 &lt;=] [pop] [[swons] dupdip --] primrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;ranger_reverse == [] swap [0 &lt;=] [pop] [[swons] dupdip --] primrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 ranger_reverse&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 ranger_reverse&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">5</span><span class="p">]</span>
@@ -430,10 +433,10 @@ values.</p>
 <p>Hopefully this illustrates the workings of the variations. For more
 insight you can run the cells using the <code class="docutils literal notranslate"><span class="pre">V()</span></code> function instead of the
 <code class="docutils literal notranslate"><span class="pre">J()</span></code> function to get a trace of the Joy evaluation.</p>
-</div>
-</div>
-</div>
-<div class="section" id="catamorphism">
+</section>
+</section>
+</section>
+<section id="catamorphism">
 <h2>Catamorphism<a class="headerlink" href="#catamorphism" title="Permalink to this headline">¶</a></h2>
 <p>A catamorphism can be defined as a hylomorphism that uses
 <code class="docutils literal notranslate"><span class="pre">[uncons</span> <span class="pre">swap]</span></code> for <code class="docutils literal notranslate"><span class="pre">[G]</span></code> and <code class="docutils literal notranslate"><span class="pre">[[]</span> <span class="pre">=]</span></code> (or just <code class="docutils literal notranslate"><span class="pre">[not]</span></code>) for the
@@ -442,27 +445,27 @@ and makes some new value.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="n">c</span> <span class="p">[</span><span class="n">uncons</span> <span class="n">swap</span><span class="p">]</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="n">hylomorphism</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;swuncons == uncons swap&#39;</span><span class="p">)</span>  <span class="c1"># Awkward name.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;swuncons == uncons swap&#39;</span><span class="p">)</span>  <span class="c1"># Awkward name.</span>
 </pre></div>
 </div>
 <p>An example of a catamorphism is the sum function.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">sum</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="mi">0</span> <span class="p">[</span><span class="n">swuncons</span><span class="p">]</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="n">hylomorphism</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;sum == [not] 0 [swuncons] [+] hylomorphism&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;sum == [not] 0 [swuncons] [+] hylomorphism&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[5 4 3 2 1] sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[5 4 3 2 1] sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">15</span>
 </pre></div>
 </div>
-<div class="section" id="the-step-combinator">
+<section id="the-step-combinator">
 <h3>The <code class="docutils literal notranslate"><span class="pre">step</span></code> combinator<a class="headerlink" href="#the-step-combinator" title="Permalink to this headline">¶</a></h3>
 <p>The <code class="docutils literal notranslate"><span class="pre">step</span></code> combinator will usually be better to use than
 <code class="docutils literal notranslate"><span class="pre">catamorphism</span></code>.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[step] help&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[step] help&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Run</span> <span class="n">a</span> <span class="n">quoted</span> <span class="n">program</span> <span class="n">on</span> <span class="n">each</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">a</span> <span class="n">sequence</span><span class="o">.</span>
@@ -486,18 +489,18 @@ and makes some new value.</p>
 <span class="n">on</span> <span class="n">top</span> <span class="n">of</span> <span class="n">the</span> <span class="n">stack</span><span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;sum == 0 swap [+] step&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;sum == 0 swap [+] step&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[5 4 3 2 1] sum&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[5 4 3 2 1] sum&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">15</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="example-factorial-function">
+</section>
+</section>
+<section id="example-factorial-function">
 <h2>Example: Factorial Function<a class="headerlink" href="#example-factorial-function" title="Permalink to this headline">¶</a></h2>
 <p>For the Factorial function:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H4</span> <span class="o">==</span> <span class="n">c</span> <span class="n">swap</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span><span class="p">]</span> <span class="p">[[</span><span class="n">F</span><span class="p">]</span> <span class="n">dupdip</span> <span class="n">G</span><span class="p">]</span> <span class="n">primrec</span>
@@ -510,17 +513,17 @@ and makes some new value.</p>
 <span class="n">P</span> <span class="o">==</span> <span class="mi">1</span> <span class="o">&lt;=</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;factorial == 1 swap [1 &lt;=] [pop] [[*] dupdip --] primrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;factorial == 1 swap [1 &lt;=] [pop] [[*] dupdip --] primrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 factorial&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;5 factorial&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">120</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="example-tails">
+</section>
+<section id="example-tails">
 <h2>Example: <code class="docutils literal notranslate"><span class="pre">tails</span></code><a class="headerlink" href="#example-tails" title="Permalink to this headline">¶</a></h2>
 <p>An example of a paramorphism for lists given in the <a class="reference external" href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125">“Bananas…”
 paper</a>
@@ -542,37 +545,37 @@ pattern <code class="docutils literal notranslate"><span class="pre">H2</span></
 <span class="n">P</span> <span class="o">==</span> <span class="ow">not</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;tails == [] swap [not] [pop] [rest dup [swons] dip] primrec&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;tails == [] swap [not] [pop] [rest dup [swons] dip] primrec&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] tails&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 2 3] tails&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[[]</span> <span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">3</span><span class="p">]]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="conclusion-patterns-of-recursion">
+</section>
+<section id="conclusion-patterns-of-recursion">
 <h2>Conclusion: Patterns of Recursion<a class="headerlink" href="#conclusion-patterns-of-recursion" title="Permalink to this headline">¶</a></h2>
 <p>Our story so far…</p>
-<div class="section" id="hylo-ana-cata">
+<section id="hylo-ana-cata">
 <h3>Hylo-, Ana-, Cata-<a class="headerlink" href="#hylo-ana-cata" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">H</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span>  <span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="n">c</span> <span class="p">]</span> <span class="p">[</span><span class="n">G</span>          <span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">F</span>        <span class="p">]</span> <span class="n">genrec</span>
 <span class="n">A</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span>  <span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="p">[]]</span> <span class="p">[</span><span class="n">G</span>          <span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">swap</span> <span class="n">cons</span><span class="p">]</span> <span class="n">genrec</span>
 <span class="n">C</span> <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">pop</span> <span class="n">c</span> <span class="p">]</span> <span class="p">[</span><span class="n">uncons</span> <span class="n">swap</span><span class="p">]</span> <span class="p">[</span><span class="n">dip</span> <span class="n">F</span>        <span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="para">
+</section>
+<section id="para">
 <h3>Para-, ?-, ?-<a class="headerlink" href="#para" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>P == c  swap [P  ] [pop] [[F        ] dupdip G          ] primrec
 ? == [] swap [P  ] [pop] [[swap cons] dupdip G          ] primrec
 ? == c  swap [not] [pop] [[F        ] dupdip uncons swap] primrec
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="appendix-fun-with-symbols">
+</section>
+</section>
+<section id="appendix-fun-with-symbols">
 <h2>Appendix: Fun with Symbols<a class="headerlink" href="#appendix-fun-with-symbols" title="Permalink to this headline">¶</a></h2>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>|[ (c, F), (G, P) ]| == (|c, F|) • [(G, P)]
 </pre></div>
@@ -584,58 +587,55 @@ Wire”</a></p>
 </div>
 <p>I think they are having slightly too much fun with the symbols. However,
 “Too much is always better than not enough.”</p>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Recursion Combinators</a><ul>
-<li><a class="reference internal" href="#designing-recursive-functions">Designing Recursive Functions</a></li>
-<li><a class="reference internal" href="#primitive-recursive-functions">Primitive Recursive Functions</a></li>
-<li><a class="reference internal" href="#hylomorphism">Hylomorphism</a></li>
-<li><a class="reference internal" href="#hylomorphism-in-joy">Hylomorphism in Joy</a></li>
-<li><a class="reference internal" href="#derivation-of-hylomorphism-combinator">Derivation of <code class="docutils literal notranslate"><span class="pre">hylomorphism</span></code> combinator</a><ul>
-<li><a class="reference internal" href="#example-finding-triangular-numbers">Example: Finding Triangular Numbers</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#four-specializations">Four Specializations</a><ul>
-<li><a class="reference internal" href="#h1"><code class="docutils literal notranslate"><span class="pre">H1</span></code></a></li>
-<li><a class="reference internal" href="#h2"><code class="docutils literal notranslate"><span class="pre">H2</span></code></a></li>
-<li><a class="reference internal" href="#h3"><code class="docutils literal notranslate"><span class="pre">H3</span></code></a></li>
-<li><a class="reference internal" href="#h4"><code class="docutils literal notranslate"><span class="pre">H4</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#anamorphism">Anamorphism</a><ul>
-<li><a class="reference internal" href="#range-et-al-an-example-of-an-anamorphism-is-the-range-function-which-generates-the-list-of-integers-from-0-to-n-1-given-n"><code class="docutils literal notranslate"><span class="pre">range</span></code> et. al.&nbsp;An example of an anamorphism is the <code class="docutils literal notranslate"><span class="pre">range</span></code> function which generates the list of integers from 0 to <em>n</em> - 1 given <em>n</em>.</a><ul>
-<li><a class="reference internal" href="#range-with-h1"><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H1</span></code></a></li>
-<li><a class="reference internal" href="#range-with-h2"><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H2</span></code></a></li>
-<li><a class="reference internal" href="#range-with-h3"><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H3</span></code></a></li>
-<li><a class="reference internal" href="#range-with-h4"><code class="docutils literal notranslate"><span class="pre">range</span></code> with <code class="docutils literal notranslate"><span class="pre">H4</span></code></a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#catamorphism">Catamorphism</a><ul>
-<li><a class="reference internal" href="#the-step-combinator">The <code class="docutils literal notranslate"><span class="pre">step</span></code> combinator</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#example-factorial-function">Example: Factorial Function</a></li>
-<li><a class="reference internal" href="#example-tails">Example: <code class="docutils literal notranslate"><span class="pre">tails</span></code></a></li>
-<li><a class="reference internal" href="#conclusion-patterns-of-recursion">Conclusion: Patterns of Recursion</a><ul>
-<li><a class="reference internal" href="#hylo-ana-cata">Hylo-, Ana-, Cata-</a></li>
-<li><a class="reference internal" href="#para">Para-, ?-, ?-</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#appendix-fun-with-symbols">Appendix: Fun with Symbols</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -647,25 +647,24 @@ Wire”</a></p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Recursion_Combinators.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -676,7 +675,7 @@ Wire”</a></p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index de93cab..6f1aaf6 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Replacing Functions in the Dictionary &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Recursion Combinators" href="Recursion_Combinators.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="replacing-functions-in-the-dictionary">
+  <section id="replacing-functions-in-the-dictionary">
 <h1>Replacing Functions in the Dictionary<a class="headerlink" href="#replacing-functions-in-the-dictionary" title="Permalink to this headline">¶</a></h1>
 <p>For now, there is no way to define new functions from within the Joy
 language. All functions (and the interpreter) all accept and return a
 dictionary parameter (in addition to the stack and expression) so that
-we can implement e.g.&nbsp;a function that adds new functions to the
+we can implement e.g. a function that adds new functions to the
 dictionary. However, there’s no function that does that. Adding a new
 function to the dictionary is a meta-interpreter action, you have to do
 it in Python, not Joy.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span>
 </pre></div>
 </div>
-<div class="section" id="a-long-trace">
+<section id="a-long-trace">
 <h2>A long trace<a class="headerlink" href="#a-long-trace" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[23 18] average&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[23 18] average&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                  <span class="o">.</span> <span class="p">[</span><span class="mi">23</span> <span class="mi">18</span><span class="p">]</span> <span class="n">average</span>
@@ -93,8 +94,8 @@ it in Python, not Joy.</p>
                              <span class="mf">20.5</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="replacing-size-with-a-python-version">
+</section>
+<section id="replacing-size-with-a-python-version">
 <h2>Replacing <code class="docutils literal notranslate"><span class="pre">size</span></code> with a Python version<a class="headerlink" href="#replacing-size-with-a-python-version" title="Permalink to this headline">¶</a></h2>
 <p>Both <code class="docutils literal notranslate"><span class="pre">sum</span></code> and <code class="docutils literal notranslate"><span class="pre">size</span></code> each convert a sequence to a single value.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="nb">sum</span> <span class="o">==</span> <span class="mi">0</span> <span class="n">swap</span> <span class="p">[</span><span class="o">+</span><span class="p">]</span> <span class="n">step</span>
@@ -104,8 +105,8 @@ it in Python, not Joy.</p>
 <p>An efficient <code class="docutils literal notranslate"><span class="pre">sum</span></code> function is already in the library. But for
 <code class="docutils literal notranslate"><span class="pre">size</span></code> we can use a “compiled” version hand-written in Python to speed
 up evaluation and make the trace more readable.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.library</span> <span class="k">import</span> <span class="n">SimpleFunctionWrapper</span>
-<span class="kn">from</span> <span class="nn">joy.utils.stack</span> <span class="k">import</span> <span class="n">iter_stack</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.library</span> <span class="kn">import</span> <span class="n">SimpleFunctionWrapper</span>
+<span class="kn">from</span> <span class="nn">joy.utils.stack</span> <span class="kn">import</span> <span class="n">iter_stack</span>
 
 
 <span class="nd">@SimpleFunctionWrapper</span>
@@ -120,14 +121,14 @@ up evaluation and make the trace more readable.</p>
 </div>
 <p>Now we replace the old version in the dictionary with the new version,
 and re-evaluate the expression.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">D</span><span class="p">[</span><span class="s1">&#39;size&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">size</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">D</span><span class="p">[</span><span class="s1">&#39;size&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">size</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="a-shorter-trace">
+</section>
+<section id="a-shorter-trace">
 <h2>A shorter trace<a class="headerlink" href="#a-shorter-trace" title="Permalink to this headline">¶</a></h2>
 <p>You can see that <code class="docutils literal notranslate"><span class="pre">size</span></code> now executes in a single step.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[23 18] average&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[23 18] average&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                  <span class="o">.</span> <span class="p">[</span><span class="mi">23</span> <span class="mi">18</span><span class="p">]</span> <span class="n">average</span>
@@ -161,24 +162,55 @@ and re-evaluate the expression.</p>
                              <span class="mf">20.5</span> <span class="o">.</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Replacing Functions in the Dictionary</a><ul>
-<li><a class="reference internal" href="#a-long-trace">A long trace</a></li>
-<li><a class="reference internal" href="#replacing-size-with-a-python-version">Replacing <code class="docutils literal notranslate"><span class="pre">size</span></code> with a Python version</a></li>
-<li><a class="reference internal" href="#a-shorter-trace">A shorter trace</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -190,25 +222,24 @@ and re-evaluate the expression.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Replacing.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -219,7 +250,7 @@ and re-evaluate the expression.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index ea7e116..1554228 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>The Four Fundamental Operations of Definite Action &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="∂RE" href="Derivatives_of_Regular_Expressions.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="the-four-fundamental-operations-of-definite-action">
+  <section id="the-four-fundamental-operations-of-definite-action">
 <h1>The Four Fundamental Operations of Definite Action<a class="headerlink" href="#the-four-fundamental-operations-of-definite-action" title="Permalink to this headline">¶</a></h1>
 <p>All definite actions (computer program) can be defined by four
 fundamental patterns of combination:</p>
 <ol class="arabic simple">
-<li>Sequence</li>
-<li>Branch</li>
-<li>Loop</li>
-<li>Parallel</li>
+<li><p>Sequence</p></li>
+<li><p>Branch</p></li>
+<li><p>Loop</p></li>
+<li><p>Parallel</p></li>
 </ol>
-<div class="section" id="sequence">
+<section id="sequence">
 <h2>Sequence<a class="headerlink" href="#sequence" title="Permalink to this headline">¶</a></h2>
 <p>Do one thing after another. In joy this is represented by putting two
 symbols together, juxtaposition:</p>
@@ -51,8 +52,8 @@ symbols together, juxtaposition:</p>
 </div>
 <p>Operations have inputs and outputs. The outputs of <code class="docutils literal notranslate"><span class="pre">foo</span></code> must be
 compatible in “arity”, type, and shape with the inputs of <code class="docutils literal notranslate"><span class="pre">bar</span></code>.</p>
-</div>
-<div class="section" id="branch">
+</section>
+<section id="branch">
 <h2>Branch<a class="headerlink" href="#branch" title="Permalink to this headline">¶</a></h2>
 <p>Do one thing or another.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">boolean</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="n">branch</span>
@@ -93,7 +94,7 @@ outputs for <code class="docutils literal notranslate"><span class="pre">foo</sp
 <span class="n">foo</span> <span class="n">T</span> <span class="n">bar</span>
 </pre></div>
 </div>
-<div class="section" id="ifte">
+<section id="ifte">
 <h3><code class="docutils literal notranslate"><span class="pre">ifte</span></code><a class="headerlink" href="#ifte" title="Permalink to this headline">¶</a></h3>
 <p>Often it will be easier on the programmer to write branching code with
 the predicate specified in a quote. The <code class="docutils literal notranslate"><span class="pre">ifte</span></code> combinator provides
@@ -115,9 +116,9 @@ evaluate it. I reflect this in the structure of the stack effect comment
 of <code class="docutils literal notranslate"><span class="pre">branch</span></code>, it will only accept Boolean values, and in the definition
 of <code class="docutils literal notranslate"><span class="pre">ifte</span></code> above by including <code class="docutils literal notranslate"><span class="pre">not</span></code> in the quote, which also has the
 effect that the subject quotes are in the proper order for <code class="docutils literal notranslate"><span class="pre">branch</span></code>.)</p>
-</div>
-</div>
-<div class="section" id="loop">
+</section>
+</section>
+<section id="loop">
 <h2>Loop<a class="headerlink" href="#loop" title="Permalink to this headline">¶</a></h2>
 <p>Do one thing zero or more times.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">boolean</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">loop</span>
@@ -168,7 +169,7 @@ boolean flag for the next iteration:</p>
 <span class="n">G</span> <span class="n">G</span> <span class="n">G</span>
 </pre></div>
 </div>
-<div class="section" id="while">
+<section id="while">
 <h3><code class="docutils literal notranslate"><span class="pre">while</span></code><a class="headerlink" href="#while" title="Permalink to this headline">¶</a></h3>
 <p>Keep doing <code class="docutils literal notranslate"><span class="pre">B</span></code> <em>while</em> some predicate <code class="docutils literal notranslate"><span class="pre">P</span></code> is true. This is
 convenient as the predicate function is made nullary automatically and
@@ -191,9 +192,9 @@ flag for the next iteration:</p>
 <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="n">nullary</span> <span class="p">[</span><span class="n">B</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="n">nullary</span><span class="p">]</span> <span class="n">loop</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="parallel">
+</section>
+</section>
+<section id="parallel">
 <h2>Parallel<a class="headerlink" href="#parallel" title="Permalink to this headline">¶</a></h2>
 <p>The <em>parallel</em> operation indicates that two (or more) functions <em>do not
 interfere</em> with each other and so can run in parallel. The main
@@ -201,10 +202,10 @@ difficulty in this sort of thing is orchestrating the recombining
 (“join” or “wait”) of the results of the functions after they finish.</p>
 <p>The current implementaions and the following definitions <em>are not
 actually parallel</em> (yet), but there is no reason they couldn’t be
-reimplemented in terms of e.g.&nbsp;Python threads. I am not concerned with
+reimplemented in terms of e.g. Python threads. I am not concerned with
 performance of the system just yet, only the elegance of the code it
 allows us to write.</p>
-<div class="section" id="cleave">
+<section id="cleave">
 <h3><code class="docutils literal notranslate"><span class="pre">cleave</span></code><a class="headerlink" href="#cleave" title="Permalink to this headline">¶</a></h3>
 <p>Joy has a few parallel combinators, the main one being <code class="docutils literal notranslate"><span class="pre">cleave</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>               <span class="o">...</span> <span class="n">x</span> <span class="p">[</span><span class="n">A</span><span class="p">]</span> <span class="p">[</span><span class="n">B</span><span class="p">]</span> <span class="n">cleave</span>
@@ -225,8 +226,8 @@ Elliott’s “Compiling to Categories” paper, et. al.)</p>
 <p>Just a thought, if you <code class="docutils literal notranslate"><span class="pre">cleave</span></code> two jobs and one requires more time to
 finish than the other you’d like to be able to assign resources
 accordingly so that they both finish at the same time.</p>
-</div>
-<div class="section" id="apply-functions">
+</section>
+<section id="apply-functions">
 <h3>“Apply” Functions<a class="headerlink" href="#apply-functions" title="Permalink to this headline">¶</a></h3>
 <p>There are also <code class="docutils literal notranslate"><span class="pre">app2</span></code> and <code class="docutils literal notranslate"><span class="pre">app3</span></code> which run a single quote on more
 than one value:</p>
@@ -257,8 +258,8 @@ value.)</p>
      <span class="n">a</span> <span class="n">b</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="map">
+</section>
+<section id="map">
 <h3><code class="docutils literal notranslate"><span class="pre">map</span></code><a class="headerlink" href="#map" title="Permalink to this headline">¶</a></h3>
 <p>The common <code class="docutils literal notranslate"><span class="pre">map</span></code> function in Joy should also be though of as a
 <em>parallel</em> operator:</p>
@@ -266,9 +267,9 @@ value.)</p>
 </pre></div>
 </div>
 <p>There is no reason why the implementation of <code class="docutils literal notranslate"><span class="pre">map</span></code> couldn’t distribute
-the <code class="docutils literal notranslate"><span class="pre">Q</span></code> function over e.g.&nbsp;a pool of worker CPUs.</p>
-</div>
-<div class="section" id="pam">
+the <code class="docutils literal notranslate"><span class="pre">Q</span></code> function over e.g. a pool of worker CPUs.</p>
+</section>
+<section id="pam">
 <h3><code class="docutils literal notranslate"><span class="pre">pam</span></code><a class="headerlink" href="#pam" title="Permalink to this headline">¶</a></h3>
 <p>One of my favorite combinators, the <code class="docutils literal notranslate"><span class="pre">pam</span></code> combinator is just:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pam</span> <span class="o">==</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="nb">map</span>
@@ -281,21 +282,21 @@ stack and combine their (first) outputs in a result list.</p>
    <span class="p">[</span> <span class="n">a</span>   <span class="n">b</span>   <span class="n">c</span>  <span class="o">...</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="handling-other-kinds-of-join">
+</section>
+<section id="handling-other-kinds-of-join">
 <h3>Handling Other Kinds of Join<a class="headerlink" href="#handling-other-kinds-of-join" title="Permalink to this headline">¶</a></h3>
 <p>The <code class="docutils literal notranslate"><span class="pre">cleave</span></code> operators and others all have pretty brutal join
 semantics: everything works and we always wait for every
 sub-computation. We can imagine a few different potentially useful
 patterns of “joining” results from parallel combinators.</p>
-<div class="section" id="first-to-finish">
+<section id="first-to-finish">
 <h4>first-to-finish<a class="headerlink" href="#first-to-finish" title="Permalink to this headline">¶</a></h4>
 <p>Thinking about variations of <code class="docutils literal notranslate"><span class="pre">pam</span></code> there could be one that only
 returns the first result of the first-to-finish sub-program, or the
 stack could be replaced by its output stack.</p>
 <p>The other sub-programs would be cancelled.</p>
-</div>
-<div class="section" id="fulminators">
+</section>
+<section id="fulminators">
 <h4>“Fulminators”<a class="headerlink" href="#fulminators" title="Permalink to this headline">¶</a></h4>
 <p>Also known as “Futures” or “Promises” (by <em>everybody</em> else. “Fulinators”
 is what I was going to call them when I was thinking about implementing
@@ -312,44 +313,57 @@ with “asyncronous” … events?</p>
 sort of thing works perfectly in Joy code I’m not going to worry about
 it. (And I think the Categories can deal with it anyhow? Incremental
 evaluation, yeah?)</p>
-</div>
-</div>
-</div>
-</div>
+</section>
+</section>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">The Four Fundamental Operations of Definite Action</a><ul>
-<li><a class="reference internal" href="#sequence">Sequence</a></li>
-<li><a class="reference internal" href="#branch">Branch</a><ul>
-<li><a class="reference internal" href="#ifte"><code class="docutils literal notranslate"><span class="pre">ifte</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#loop">Loop</a><ul>
-<li><a class="reference internal" href="#while"><code class="docutils literal notranslate"><span class="pre">while</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#parallel">Parallel</a><ul>
-<li><a class="reference internal" href="#cleave"><code class="docutils literal notranslate"><span class="pre">cleave</span></code></a></li>
-<li><a class="reference internal" href="#apply-functions">“Apply” Functions</a></li>
-<li><a class="reference internal" href="#map"><code class="docutils literal notranslate"><span class="pre">map</span></code></a></li>
-<li><a class="reference internal" href="#pam"><code class="docutils literal notranslate"><span class="pre">pam</span></code></a></li>
-<li><a class="reference internal" href="#handling-other-kinds-of-join">Handling Other Kinds of Join</a><ul>
-<li><a class="reference internal" href="#first-to-finish">first-to-finish</a></li>
-<li><a class="reference internal" href="#fulminators">“Fulminators”</a></li>
-</ul>
-</li>
-</ul>
-</li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -361,25 +375,24 @@ evaluation, yeah?)</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/The_Four_Operations.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -390,7 +403,7 @@ evaluation, yeah?)</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 8811efa..91fea34 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Treating Trees II: treestep &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Using x to Generate Values" href="Generator_Programs.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="treating-trees-ii-treestep">
+  <section id="treating-trees-ii-treestep">
 <h1>Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code><a class="headerlink" href="#treating-trees-ii-treestep" title="Permalink to this headline">¶</a></h1>
 <p>Let’s consider a tree structure, similar to one described <a class="reference external" href="https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf">“Why
 functional programming matters” by John
@@ -65,7 +66,7 @@ combine the result with <code class="docutils literal notranslate"><span class="
 </div>
 <p>(Later on we’ll experiment with making <code class="docutils literal notranslate"><span class="pre">map</span></code> part of <code class="docutils literal notranslate"><span class="pre">C</span></code> so you can
 use other combinators.)</p>
-<div class="section" id="derive-the-recursive-function">
+<section id="derive-the-recursive-function">
 <h2>Derive the recursive function.<a class="headerlink" href="#derive-the-recursive-function" title="Permalink to this headline">¶</a></h2>
 <p>We can begin to derive it by finding the <code class="docutils literal notranslate"><span class="pre">ifte</span></code> stage that <code class="docutils literal notranslate"><span class="pre">genrec</span></code>
 will produce.</p>
@@ -110,8 +111,8 @@ the desired outcome.</p>
   <span class="o">==</span> <span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">B</span><span class="p">]</span> <span class="p">[</span><span class="n">uncons</span> <span class="p">[</span><span class="n">N</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span>   <span class="p">[</span><span class="nb">map</span> <span class="n">C</span><span class="p">]</span> <span class="n">genrec</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="extract-the-givens-to-parameterize-the-program">
+</section>
+<section id="extract-the-givens-to-parameterize-the-program">
 <h2>Extract the givens to parameterize the program.<a class="headerlink" href="#extract-the-givens-to-parameterize-the-program" title="Permalink to this headline">¶</a></h2>
 <p>Working backwards:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">B</span><span class="p">]</span>          <span class="p">[</span><span class="n">uncons</span> <span class="p">[</span><span class="n">N</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span>                  <span class="p">[</span><span class="nb">map</span> <span class="n">C</span><span class="p">]</span> <span class="n">genrec</span>
@@ -134,7 +135,7 @@ the desired outcome.</p>
 </pre></div>
 </div>
 <p>The givens are all to the left so we have our definition.</p>
-<div class="section" id="alternate-extract-the-givens-to-parameterize-the-program">
+<section id="alternate-extract-the-givens-to-parameterize-the-program">
 <h3>(alternate) Extract the givens to parameterize the program.<a class="headerlink" href="#alternate-extract-the-givens-to-parameterize-the-program" title="Permalink to this headline">¶</a></h3>
 <p>Working backwards:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="n">B</span><span class="p">]</span>           <span class="p">[</span><span class="n">uncons</span> <span class="p">[</span><span class="n">N</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span>            <span class="p">[</span><span class="nb">map</span> <span class="n">C</span><span class="p">]</span> <span class="n">genrec</span>
@@ -143,14 +144,14 @@ the desired outcome.</p>
         <span class="o">^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="define-treestep">
+</section>
+</section>
+<section id="define-treestep">
 <h2>Define <code class="docutils literal notranslate"><span class="pre">treestep</span></code><a class="headerlink" href="#define-treestep" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span><span class="p">,</span> <span class="n">DefinitionWrapper</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span><span class="p">,</span> <span class="n">DefinitionWrapper</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
 
 <span class="s1">    _treestep_0 == [[not] swap] dip</span>
 <span class="s1">    _treestep_1 == [dip] cons [uncons] swoncat</span>
@@ -160,15 +161,15 @@ the desired outcome.</p>
 <span class="s1">&#39;&#39;&#39;</span><span class="p">,</span> <span class="n">D</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="examples">
+</section>
+<section id="examples">
 <h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
 <p>Consider trees, the nodes of which are integers. We can find the sum of
 all nodes in a tree with this function:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sumtree</span> <span class="o">==</span> <span class="p">[</span><span class="n">pop</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[</span><span class="nb">sum</span> <span class="o">+</span><span class="p">]</span> <span class="n">treestep</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;sumtree == [pop 0] [] [sum +] treestep&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;sumtree == [pop 0] [] [sum +] treestep&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Running this function on an empty tree value gives zero:</p>
@@ -177,7 +178,7 @@ all nodes in a tree with this function:</p>
            <span class="mi">0</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Empty tree.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Empty tree.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span>
@@ -191,68 +192,68 @@ all nodes in a tree with this function:</p>
 <span class="n">n</span><span class="o">+</span><span class="n">m</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># No child trees.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># No child trees.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 []] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Child tree, empty.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 []] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Child tree, empty.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">23</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [4]] [3]] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Non-empty child trees.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [4]] [3]] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Non-empty child trees.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">32</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Etc...</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] sumtree&#39;</span><span class="p">)</span>  <span class="c1"># Etc...</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">49</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [pop 0] [] [cons sum] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Alternate &quot;spelling&quot;.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [pop 0] [] [cons sum] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Alternate &quot;spelling&quot;.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">49</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [] [pop 23] [cons] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Replace each node.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [] [pop 23] [cons] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Replace each node.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">23</span> <span class="p">[</span><span class="mi">23</span> <span class="p">[</span><span class="mi">23</span><span class="p">]</span> <span class="p">[</span><span class="mi">23</span><span class="p">]]</span> <span class="p">[</span><span class="mi">23</span><span class="p">]</span> <span class="p">[</span><span class="mi">23</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">1</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep sumtree&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep sumtree&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">6</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [pop 0] [pop 1] [sum +] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Combine replace and sum into one function.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[23 [2 [8] [9]] [3] [4 []]] [pop 0] [pop 1] [sum +] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Combine replace and sum into one function.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">6</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[4 [3 [] [7]]] [pop 0] [pop 1] [sum +] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Combine replace and sum into one function.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[4 [3 [] [7]]] [pop 0] [pop 1] [sum +] treestep&#39;</span><span class="p">)</span>  <span class="c1"># Combine replace and sum into one function.</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="redefining-the-ordered-binary-tree-in-terms-of-treestep">
+</section>
+<section id="redefining-the-ordered-binary-tree-in-terms-of-treestep">
 <h2>Redefining the Ordered Binary Tree in terms of <code class="docutils literal notranslate"><span class="pre">treestep</span></code>.<a class="headerlink" href="#redefining-the-ordered-binary-tree-in-terms-of-treestep" title="Permalink to this headline">¶</a></h2>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Tree</span> <span class="o">=</span> <span class="p">[]</span> <span class="o">|</span> <span class="p">[[</span><span class="n">key</span> <span class="n">value</span><span class="p">]</span> <span class="n">left</span> <span class="n">right</span><span class="p">]</span>
 </pre></div>
@@ -266,7 +267,7 @@ all nodes in a tree with this function:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span><span class="p">]</span> <span class="n">N</span> <span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="nb">map</span> <span class="n">C</span>
 </pre></div>
 </div>
-<div class="section" id="traversal">
+<section id="traversal">
 <h3>Traversal<a class="headerlink" href="#traversal" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span><span class="p">]</span> <span class="n">first</span> <span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="nb">map</span> <span class="n">i</span>
 <span class="n">key</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span>       <span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="nb">map</span> <span class="n">i</span>
@@ -276,7 +277,7 @@ all nodes in a tree with this function:</p>
 </pre></div>
 </div>
 <p>This doesn’t quite work:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [][]] [[9 0] [[5 0] [[4 0] [][]] [[8 0] [[6 0] [] [[7 0] [][]]][]]][]]] [&quot;B&quot;] [first] [i] treestep&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [][]] [[9 0] [[5 0] [[4 0] [][]] [[8 0] [[6 0] [] [[7 0] [][]]][]]][]]] [&quot;B&quot;] [first] [i] treestep&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="s1">&#39;B&#39;</span> <span class="s1">&#39;B&#39;</span>
@@ -298,15 +299,15 @@ depositing our results directly on the stack.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[]</span> <span class="p">[</span><span class="n">first</span><span class="p">]</span> <span class="p">[</span><span class="n">flatten</span> <span class="n">cons</span><span class="p">]</span> <span class="n">treestep</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [first] [flatten cons] treestep&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [first] [flatten cons] treestep&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="mi">9</span> <span class="mi">5</span> <span class="mi">4</span> <span class="mi">8</span> <span class="mi">6</span> <span class="mi">7</span><span class="p">]</span>
 </pre></div>
 </div>
 <p>There we go.</p>
-</div>
-<div class="section" id="in-order-traversal">
+</section>
+<section id="in-order-traversal">
 <h3>In-order traversal<a class="headerlink" href="#in-order-traversal" title="Permalink to this headline">¶</a></h3>
 <p>From here:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">key</span> <span class="p">[[</span><span class="n">lk</span><span class="p">]</span> <span class="p">[</span><span class="n">rk</span><span class="p">]]</span> <span class="n">C</span>
@@ -321,15 +322,15 @@ depositing our results directly on the stack.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[]</span> <span class="p">[</span><span class="n">i</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="n">swons</span> <span class="n">concat</span><span class="p">]</span> <span class="p">[</span><span class="n">first</span><span class="p">]</span> <span class="n">treestep</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [uncons pop] [i roll&lt; swons concat] treestep&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [uncons pop] [i roll&lt; swons concat] treestep&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span> <span class="mi">5</span> <span class="mi">6</span> <span class="mi">7</span> <span class="mi">8</span> <span class="mi">9</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="with-treegrind">
+</section>
+</section>
+<section id="with-treegrind">
 <h2>With <code class="docutils literal notranslate"><span class="pre">treegrind</span></code>?<a class="headerlink" href="#with-treegrind" title="Permalink to this headline">¶</a></h2>
 <p>The <code class="docutils literal notranslate"><span class="pre">treegrind</span></code> function doesn’t include the <code class="docutils literal notranslate"><span class="pre">map</span></code> combinator, so
 the <code class="docutils literal notranslate"><span class="pre">[C]</span></code> function must arrange to use some combinator on the quoted
@@ -342,38 +343,38 @@ non-empty node is:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">key</span> <span class="n">value</span><span class="p">]</span> <span class="n">N</span> <span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="n">C</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[&quot;key&quot; &quot;value&quot;] [&quot;left&quot;] [&quot;right&quot;] ] [&quot;B&quot;] [&quot;N&quot;] [&quot;C&quot;] treegrind&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[&quot;key&quot; &quot;value&quot;] [&quot;left&quot;] [&quot;right&quot;] ] [&quot;B&quot;] [&quot;N&quot;] [&quot;C&quot;] treegrind&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;key&#39;</span> <span class="s1">&#39;value&#39;</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[[</span><span class="s1">&#39;left&#39;</span><span class="p">]</span> <span class="p">[</span><span class="s1">&#39;right&#39;</span><span class="p">]]</span> <span class="p">[[</span><span class="ow">not</span><span class="p">]</span> <span class="p">[</span><span class="s1">&#39;B&#39;</span><span class="p">]</span> <span class="p">[</span><span class="n">uncons</span> <span class="p">[</span><span class="s1">&#39;N&#39;</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span> <span class="p">[</span><span class="s1">&#39;C&#39;</span><span class="p">]</span> <span class="n">genrec</span><span class="p">]</span> <span class="s1">&#39;C&#39;</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="treegrind-with-step">
+</section>
+<section id="treegrind-with-step">
 <h2><code class="docutils literal notranslate"><span class="pre">treegrind</span></code> with <code class="docutils literal notranslate"><span class="pre">step</span></code><a class="headerlink" href="#treegrind-with-step" title="Permalink to this headline">¶</a></h2>
 <p>Iteration through the nodes</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] [&quot;N&quot;] [step] treegrind&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] [&quot;N&quot;] [step] treegrind&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[</span><span class="mi">9</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[</span><span class="mi">5</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[</span><span class="mi">8</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[</span><span class="mi">6</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span> <span class="p">[</span><span class="mi">7</span> <span class="mi">0</span><span class="p">]</span> <span class="s1">&#39;N&#39;</span>
 </pre></div>
 </div>
 <p>Sum the nodes’ keys.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] [first +] [step] treegrind&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;0 [[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] [first +] [step] treegrind&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">44</span>
 </pre></div>
 </div>
 <p>Rebuild the tree using <code class="docutils literal notranslate"><span class="pre">map</span></code> (imitating <code class="docutils literal notranslate"><span class="pre">treestep</span></code>.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [[100 +] infra] [map cons] treegrind&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [[100 +] infra] [map cons] treegrind&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[[</span><span class="mi">103</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[[</span><span class="mi">102</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[[</span><span class="mi">109</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[[</span><span class="mi">105</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[[</span><span class="mi">104</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[]]</span> <span class="p">[[</span><span class="mi">108</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[[</span><span class="mi">106</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[[</span><span class="mi">107</span> <span class="mi">0</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[]]]</span> <span class="p">[]]]</span> <span class="p">[]]]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="do-we-have-the-flexibility-to-reimplement-tree-get">
+</section>
+<section id="do-we-have-the-flexibility-to-reimplement-tree-get">
 <h2>Do we have the flexibility to reimplement <code class="docutils literal notranslate"><span class="pre">Tree-get</span></code>?<a class="headerlink" href="#do-we-have-the-flexibility-to-reimplement-tree-get" title="Permalink to this headline">¶</a></h2>
 <p>I think we do:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">B</span><span class="p">]</span> <span class="p">[</span><span class="n">N</span><span class="p">]</span> <span class="p">[</span><span class="n">C</span><span class="p">]</span> <span class="n">treegrind</span>
@@ -389,12 +390,12 @@ user defined, and the per-node function is just the query key literal:</p>
 </pre></div>
 </div>
 <p>Let’s try <code class="docutils literal notranslate"><span class="pre">cmp</span></code>:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span> <span class="o">==</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span> <span class="o">==</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span>
 
-<span class="p">[</span><span class="n">key</span> <span class="n">value</span><span class="p">]</span> <span class="n">query_key</span> <span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span>
+<span class="p">[</span><span class="n">key</span> <span class="n">value</span><span class="p">]</span> <span class="n">query_key</span> <span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span>
 </pre></div>
 </div>
-<div class="section" id="the-predicate-p">
+<section id="the-predicate-p">
 <h3>The predicate <code class="docutils literal notranslate"><span class="pre">P</span></code><a class="headerlink" href="#the-predicate-p" title="Permalink to this headline">¶</a></h3>
 <p>Seems pretty easy (we must preserve the value in case the keys are
 equal):</p>
@@ -412,7 +413,7 @@ equal):</p>
 </div>
 <p>(Possibly with a swap at the end? Or just swap <code class="docutils literal notranslate"><span class="pre">T&lt;</span></code> and <code class="docutils literal notranslate"><span class="pre">T&gt;</span></code>.)</p>
 <p>So now:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="n">key</span> <span class="n">query_key</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="n">key</span> <span class="n">query_key</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span>
 </pre></div>
 </div>
 <p>Becomes one of these three:</p>
@@ -421,34 +422,34 @@ equal):</p>
 <span class="p">[</span><span class="n">left</span> <span class="n">right</span><span class="p">]</span> <span class="p">[</span><span class="n">K</span><span class="p">]</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="n">T</span><span class="o">&lt;</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="e">
+</section>
+<section id="e">
 <h3><code class="docutils literal notranslate"><span class="pre">E</span></code><a class="headerlink" href="#e" title="Permalink to this headline">¶</a></h3>
 <p>Easy.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">E</span> <span class="o">==</span> <span class="n">roll</span><span class="o">&gt;</span> <span class="n">popop</span> <span class="n">first</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="t-and-t">
+</section>
+<section id="t-and-t">
 <h3><code class="docutils literal notranslate"><span class="pre">T&lt;</span></code> and <code class="docutils literal notranslate"><span class="pre">T&gt;</span></code><a class="headerlink" href="#t-and-t" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">T</span><span class="o">&lt;</span> <span class="o">==</span> <span class="n">pop</span> <span class="p">[</span><span class="n">first</span><span class="p">]</span> <span class="n">dip</span> <span class="n">i</span>
 <span class="n">T</span><span class="o">&gt;</span> <span class="o">==</span> <span class="n">pop</span> <span class="p">[</span><span class="n">second</span><span class="p">]</span> <span class="n">dip</span> <span class="n">i</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="putting-it-together">
+</section>
+</section>
+<section id="putting-it-together">
 <h2>Putting it together<a class="headerlink" href="#putting-it-together" title="Permalink to this headline">¶</a></h2>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">T</span><span class="o">&gt;</span> <span class="o">==</span> <span class="n">pop</span> <span class="p">[</span><span class="n">first</span><span class="p">]</span> <span class="n">dip</span> <span class="n">i</span>
 <span class="n">T</span><span class="o">&lt;</span> <span class="o">==</span> <span class="n">pop</span> <span class="p">[</span><span class="n">second</span><span class="p">]</span> <span class="n">dip</span> <span class="n">i</span>
 <span class="n">E</span> <span class="o">==</span> <span class="n">roll</span><span class="o">&gt;</span> <span class="n">popop</span> <span class="n">first</span>
 <span class="n">P</span> <span class="o">==</span> <span class="n">roll</span><span class="o">&lt;</span> <span class="p">[</span><span class="n">roll</span><span class="o">&lt;</span> <span class="n">uncons</span> <span class="n">swap</span><span class="p">]</span> <span class="n">dip</span>
 
-<span class="n">Tree</span><span class="o">-</span><span class="n">get</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="nb">cmp</span><span class="p">]</span> <span class="n">treegrind</span>
+<span class="n">Tree</span><span class="o">-</span><span class="n">get</span> <span class="o">==</span> <span class="p">[</span><span class="n">P</span> <span class="p">[</span><span class="n">T</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="n">E</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="o">&lt;</span><span class="p">]</span> <span class="n">cmp</span><span class="p">]</span> <span class="n">treegrind</span>
 </pre></div>
 </div>
 <p>To me, that seems simpler than the <code class="docutils literal notranslate"><span class="pre">genrec</span></code> version.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">DefinitionWrapper</span><span class="o">.</span><span class="n">add_definitions</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
 
 <span class="s1">    T&gt; == pop [first] dip i</span>
 <span class="s1">    T&lt; == pop [second] dip i</span>
@@ -460,7 +461,7 @@ equal):</p>
 <span class="s1">&#39;&#39;&#39;</span><span class="p">,</span> <span class="n">D</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
 
 <span class="s1">[[3 13] [[2 12] [] []] [[9 19] [[5 15] [[4 14] [] []] [[8 18] [[6 16] [] [[7 17] [] []]] []]] []]]</span>
 
@@ -472,7 +473,7 @@ equal):</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">15</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span><span class="se">\</span>
 
 <span class="s1">[[3 13] [[2 12] [] []] [[9 19] [[5 15] [[4 14] [] []] [[8 18] [[6 16] [] [[7 17] [] []]] []]] []]]</span>
 
@@ -484,42 +485,55 @@ equal):</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;nope&#39;</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a><ul>
-<li><a class="reference internal" href="#derive-the-recursive-function">Derive the recursive function.</a></li>
-<li><a class="reference internal" href="#extract-the-givens-to-parameterize-the-program">Extract the givens to parameterize the program.</a><ul>
-<li><a class="reference internal" href="#alternate-extract-the-givens-to-parameterize-the-program">(alternate) Extract the givens to parameterize the program.</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#define-treestep">Define <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
-<li><a class="reference internal" href="#examples">Examples</a></li>
-<li><a class="reference internal" href="#redefining-the-ordered-binary-tree-in-terms-of-treestep">Redefining the Ordered Binary Tree in terms of <code class="docutils literal notranslate"><span class="pre">treestep</span></code>.</a><ul>
-<li><a class="reference internal" href="#traversal">Traversal</a></li>
-<li><a class="reference internal" href="#in-order-traversal">In-order traversal</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#with-treegrind">With <code class="docutils literal notranslate"><span class="pre">treegrind</span></code>?</a></li>
-<li><a class="reference internal" href="#treegrind-with-step"><code class="docutils literal notranslate"><span class="pre">treegrind</span></code> with <code class="docutils literal notranslate"><span class="pre">step</span></code></a></li>
-<li><a class="reference internal" href="#do-we-have-the-flexibility-to-reimplement-tree-get">Do we have the flexibility to reimplement <code class="docutils literal notranslate"><span class="pre">Tree-get</span></code>?</a><ul>
-<li><a class="reference internal" href="#the-predicate-p">The predicate <code class="docutils literal notranslate"><span class="pre">P</span></code></a></li>
-<li><a class="reference internal" href="#e"><code class="docutils literal notranslate"><span class="pre">E</span></code></a></li>
-<li><a class="reference internal" href="#t-and-t"><code class="docutils literal notranslate"><span class="pre">T&lt;</span></code> and <code class="docutils literal notranslate"><span class="pre">T&gt;</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#putting-it-together">Putting it together</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -531,25 +545,24 @@ equal):</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Treestep.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -560,7 +573,7 @@ equal):</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index e374f2c..6e5002d 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Type Checking &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="No Updates" href="NoUpdates.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="type-checking">
+  <section id="type-checking">
 <h1>Type Checking<a class="headerlink" href="#type-checking" title="Permalink to this headline">¶</a></h1>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">logging</span><span class="o">,</span> <span class="nn">sys</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">logging</span><span class="o">,</span> <span class="nn">sys</span>
 
 <span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">(</span>
   <span class="nb">format</span><span class="o">=</span><span class="s1">&#39;</span><span class="si">%(message)s</span><span class="s1">&#39;</span><span class="p">,</span>
@@ -43,7 +44,7 @@
   <span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.utils.types</span> <span class="k">import</span> <span class="p">(</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.utils.types</span> <span class="kn">import</span> <span class="p">(</span>
     <span class="n">doc_from_stack_effect</span><span class="p">,</span>
     <span class="n">infer</span><span class="p">,</span>
     <span class="n">reify</span><span class="p">,</span>
 <span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">D</span> <span class="o">=</span> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">D</span> <span class="o">=</span> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
 <span class="k">del</span> <span class="n">D</span><span class="p">[</span><span class="s1">&#39;product&#39;</span><span class="p">]</span>
 <span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">D</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="section" id="an-example">
+<section id="an-example">
 <h2>An Example<a class="headerlink" href="#an-example" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span> <span class="o">=</span> <span class="n">infer</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">rolldown</span><span class="p">,</span> <span class="n">rrest</span><span class="p">,</span> <span class="n">ccons</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span> <span class="o">=</span> <span class="n">infer</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">rolldown</span><span class="p">,</span> <span class="n">rrest</span><span class="p">,</span> <span class="n">ccons</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>25 (--) ∘ pop swap rolldown rrest ccons
 40 ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1]) ∘
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a4</span> <span class="n">a5</span> <span class="o">...</span><span class="mi">1</span><span class="p">]</span> <span class="n">a3</span> <span class="n">a2</span> <span class="n">a1</span> <span class="o">--</span> <span class="p">[</span><span class="n">a2</span> <span class="n">a3</span> <span class="o">...</span><span class="mi">1</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.parser</span> <span class="k">import</span> <span class="n">text_to_expression</span>
-<span class="kn">from</span> <span class="nn">joy.utils.stack</span> <span class="k">import</span> <span class="n">stack_to_string</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.parser</span> <span class="kn">import</span> <span class="n">text_to_expression</span>
+<span class="kn">from</span> <span class="nn">joy.utils.stack</span> <span class="kn">import</span> <span class="n">stack_to_string</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;0 1 2 [3 4]&#39;</span><span class="p">)</span>  <span class="c1"># reverse order</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;0 1 2 [3 4]&#39;</span><span class="p">)</span>  <span class="c1"># reverse order</span>
 <span class="nb">print</span> <span class="n">stack_to_string</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">4</span><span class="p">]</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">u</span> <span class="o">=</span> <span class="n">unify</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">fi</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">u</span> <span class="o">=</span> <span class="n">unify</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">fi</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
 <span class="n">u</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="n">a1</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="n">a2</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="n">a3</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="n">a4</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="n">a5</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span> <span class="n">s2</span><span class="p">:</span> <span class="p">(),</span> <span class="n">s1</span><span class="p">:</span> <span class="p">()}</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="o">=</span> <span class="n">reify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="o">=</span> <span class="n">reify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span><span class="p">))</span>
 <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">g</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">...</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="p">]</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span> <span class="o">--</span> <span class="o">...</span> <span class="p">[</span><span class="mi">1</span> <span class="mi">2</span> <span class="p">])</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="unification-works-in-reverse">
+</section>
+<section id="unification-works-in-reverse">
 <h2>Unification Works “in Reverse”<a class="headerlink" href="#unification-works-in-reverse" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[2 3]&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;[2 3]&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">u</span> <span class="o">=</span> <span class="n">unify</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">fo</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># output side, not input side</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">u</span> <span class="o">=</span> <span class="n">unify</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">fo</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># output side, not input side</span>
 <span class="n">u</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="n">a2</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="n">a3</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="n">s2</span><span class="p">:</span> <span class="p">(),</span> <span class="n">s1</span><span class="p">:</span> <span class="p">()}</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="o">=</span> <span class="n">reify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="o">=</span> <span class="n">reify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span><span class="p">))</span>
 <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">g</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">...</span> <span class="p">[</span><span class="n">a4</span> <span class="n">a5</span> <span class="p">]</span> <span class="mi">3</span> <span class="mi">2</span> <span class="n">a1</span> <span class="o">--</span> <span class="o">...</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">3</span> <span class="p">])</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="failing-a-check">
+</section>
+<section id="failing-a-check">
 <h2>Failing a Check<a class="headerlink" href="#failing-a-check" title="Permalink to this headline">¶</a></h2>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span> <span class="o">=</span> <span class="n">infer</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span> <span class="o">=</span> <span class="n">infer</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>25 (--) ∘ dup mul
 31 (i1 -- i2) ∘
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;&quot;two&quot;&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="o">=</span> <span class="n">text_to_expression</span><span class="p">(</span><span class="s1">&#39;&quot;two&quot;&#39;</span><span class="p">)</span>
 <span class="nb">print</span> <span class="n">stack_to_string</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;two&#39;</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
     <span class="n">unify</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">fi</span><span class="p">)</span>
 <span class="k">except</span> <span class="n">JoyTypeError</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
     <span class="nb">print</span> <span class="n">err</span>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Cannot</span> <span class="n">unify</span> <span class="s1">&#39;two&#39;</span> <span class="ow">and</span> <span class="n">f1</span><span class="o">.</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Type Checking</a><ul>
-<li><a class="reference internal" href="#an-example">An Example</a></li>
-<li><a class="reference internal" href="#unification-works-in-reverse">Unification Works “in Reverse”</a></li>
-<li><a class="reference internal" href="#failing-a-check">Failing a Check</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/TypeChecking.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 192b714..92d9131 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>The Blissful Elegance of Typing Joy &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Type Checking" href="TypeChecking.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="the-blissful-elegance-of-typing-joy">
+  <section id="the-blissful-elegance-of-typing-joy">
 <h1>The Blissful Elegance of Typing Joy<a class="headerlink" href="#the-blissful-elegance-of-typing-joy" title="Permalink to this headline">¶</a></h1>
 <p>This notebook presents a simple type inferencer for Joy code. It can
 infer the stack effect of most Joy expressions. It’s built largely by
@@ -47,7 +48,7 @@ Along the way we write a simple “compiler” that emits Python code for
 what I like to call Yin functions. (Yin functions are those that only
 rearrange values in stacks, as opposed to Yang functions that actually
 work on the values themselves.)</p>
-<div class="section" id="part-i-poials-rules">
+<section id="part-i-poials-rules">
 <h2>Part I: Pöial’s Rules<a class="headerlink" href="#part-i-poials-rules" title="Permalink to this headline">¶</a></h2>
 <p><a class="reference external" href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.212.6026">“Typing Tools for Typeless Stack Languages” by Jaanus
 Pöial</a></p>
@@ -60,7 +61,7 @@ Pöial</a></p>
 <span class="p">}</span>
 </pre></div>
 </div>
-<div class="section" id="first-rule">
+<section id="first-rule">
 <h3>First Rule<a class="headerlink" href="#first-rule" title="Permalink to this headline">¶</a></h3>
 <p>This rule deals with functions (and literals) that put items on the
 stack <code class="docutils literal notranslate"><span class="pre">(--</span> <span class="pre">d)</span></code>:</p>
@@ -69,8 +70,8 @@ stack <code class="docutils literal notranslate"><span class="pre">(--</span> <s
      (a -- b d)
 </pre></div>
 </div>
-</div>
-<div class="section" id="second-rule">
+</section>
+<section id="second-rule">
 <h3>Second Rule<a class="headerlink" href="#second-rule" title="Permalink to this headline">¶</a></h3>
 <p>This rule deals with functions that consume items from the stack
 <code class="docutils literal notranslate"><span class="pre">(a</span> <span class="pre">--)</span></code>:</p>
@@ -79,8 +80,8 @@ stack <code class="docutils literal notranslate"><span class="pre">(--</span> <s
      (c a -- d)
 </pre></div>
 </div>
-</div>
-<div class="section" id="third-rule">
+</section>
+<section id="third-rule">
 <h3>Third Rule<a class="headerlink" href="#third-rule" title="Permalink to this headline">¶</a></h3>
 <p>The third rule is actually two rules. These two rules deal with
 composing functions when the second one will consume one of items the
@@ -105,8 +106,8 @@ algorithm.</p>
 </div>
 <p>It’s all “stack chatter” and list manipulation so we should be able to
 deduce its type.</p>
-</div>
-<div class="section" id="stack-effect-comments">
+</section>
+<section id="stack-effect-comments">
 <h3>Stack Effect Comments<a class="headerlink" href="#stack-effect-comments" title="Permalink to this headline">¶</a></h3>
 <p>Joy function types will be represented by Forth-style stack effect
 comments. I’m going to use numbers instead of names to keep track of the
@@ -122,8 +123,8 @@ reminds me of them):</p>
 </div>
 <p>These commands alter the stack but don’t “look at” the values so these
 numbers represent an “Any type”.</p>
-</div>
-<div class="section" id="pop-swap">
+</section>
+<section id="pop-swap">
 <h3><code class="docutils literal notranslate"><span class="pre">pop</span> <span class="pre">swap</span></code><a class="headerlink" href="#pop-swap" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span> <span class="o">--</span><span class="p">)</span> <span class="p">(</span><span class="mi">1</span> <span class="mi">2</span> <span class="o">--</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">)</span>
 </pre></div>
@@ -137,8 +138,8 @@ unique among both sides. For this let’s change <code class="docutils literal n
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">0</span> <span class="o">--</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="popswap-roll">
+</section>
+<section id="popswap-roll">
 <h3><code class="docutils literal notranslate"><span class="pre">pop∘swap</span> <span class="pre">roll&lt;</span></code><a class="headerlink" href="#popswap-roll" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">0</span> <span class="o">--</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">)</span> <span class="p">(</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="o">--</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">1</span><span class="p">)</span>
 </pre></div>
@@ -177,11 +178,11 @@ terms in the forms:</p>
 </pre></div>
 </div>
 <p>And now we have the stack effect comment for <code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;</span></code>.</p>
-</div>
-<div class="section" id="compiling-popswaproll">
+</section>
+<section id="compiling-popswaproll">
 <h3>Compiling <code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;</span></code><a class="headerlink" href="#compiling-popswaproll" title="Permalink to this headline">¶</a></h3>
 <p>The simplest way to “compile” this function would be something like:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">poswrd</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">poswrd</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
     <span class="k">return</span> <span class="n">rolldown</span><span class="p">(</span><span class="o">*</span><span class="n">swap</span><span class="p">(</span><span class="o">*</span><span class="n">pop</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="n">d</span><span class="p">)))</span>
 </pre></div>
 </div>
@@ -192,7 +193,7 @@ terms in the forms:</p>
 </pre></div>
 </div>
 <p>We should be able to directly write out a Python function like:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">poswrd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">poswrd</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
     <span class="p">(</span><span class="n">_</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="k">return</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span>
 </pre></div>
@@ -201,8 +202,8 @@ terms in the forms:</p>
 function only rearranges the stack and doesn’t do any actual processing
 on the stack items themselves all the information needed to implement it
 is in the stack effect comment.</p>
-</div>
-<div class="section" id="functions-on-stacks">
+</section>
+<section id="functions-on-stacks">
 <h3>Functions on Stacks<a class="headerlink" href="#functions-on-stacks" title="Permalink to this headline">¶</a></h3>
 <p>These are slightly tricky.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rest</span> <span class="p">(</span> <span class="p">[</span><span class="mi">1</span> <span class="o">...</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="o">...</span><span class="p">]</span> <span class="p">)</span>
@@ -210,8 +211,8 @@ is in the stack effect comment.</p>
 <span class="n">cons</span> <span class="p">(</span> <span class="mi">1</span> <span class="p">[</span><span class="o">...</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="mi">1</span> <span class="o">...</span><span class="p">]</span> <span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="popswaproll-rest">
+</section>
+<section id="popswaproll-rest">
 <h3><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;</span> <span class="pre">rest</span></code><a class="headerlink" href="#popswaproll-rest" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">0</span> <span class="o">--</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span><span class="p">)</span> <span class="p">([</span><span class="mi">1</span> <span class="o">...</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="o">...</span><span class="p">])</span>
 </pre></div>
@@ -234,8 +235,8 @@ available index number for the right-side stack effect comment):</p>
 </pre></div>
 </div>
 <p>And there we are.</p>
-</div>
-<div class="section" id="popswaproll-rest-rest">
+</section>
+<section id="popswaproll-rest-rest">
 <h3><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;∘rest</span> <span class="pre">rest</span></code><a class="headerlink" href="#popswaproll-rest-rest" title="Permalink to this headline">¶</a></h3>
 <p>Let’s do it again.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="mi">4</span> <span class="o">...</span><span class="p">]</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">0</span> <span class="o">--</span> <span class="mi">3</span> <span class="mi">2</span> <span class="p">[</span><span class="o">...</span><span class="p">])</span> <span class="p">([</span><span class="mi">1</span> <span class="o">...</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="o">...</span><span class="p">])</span>
@@ -273,8 +274,8 @@ actually pretty easy. I’ll explain below.</p>
 </pre></div>
 </div>
 <p>This is the stack effect of <code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;∘rest∘rest</span></code>.</p>
-</div>
-<div class="section" id="popswaproll-restrest-cons">
+</section>
+<section id="popswaproll-restrest-cons">
 <h3><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;∘rest∘rest</span> <span class="pre">cons</span></code><a class="headerlink" href="#popswaproll-restrest-cons" title="Permalink to this headline">¶</a></h3>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="mi">4</span> <span class="mi">5</span> <span class="o">...</span><span class="p">]</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">1</span> <span class="o">--</span> <span class="mi">3</span> <span class="mi">2</span> <span class="p">[</span><span class="o">...</span><span class="p">])</span> <span class="p">(</span><span class="mi">1</span> <span class="p">[</span><span class="o">...</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="mi">1</span> <span class="o">...</span><span class="p">])</span>
 </pre></div>
@@ -300,8 +301,8 @@ actually pretty easy. I’ll explain below.</p>
 </pre></div>
 </div>
 <p>Done.</p>
-</div>
-<div class="section" id="popswaproll-restrestcons-cons">
+</section>
+<section id="popswaproll-restrestcons-cons">
 <h3><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;∘rest∘rest∘cons</span> <span class="pre">cons</span></code><a class="headerlink" href="#popswaproll-restrestcons-cons" title="Permalink to this headline">¶</a></h3>
 <p>One more time.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="mi">4</span> <span class="mi">5</span> <span class="o">...</span><span class="p">]</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">1</span> <span class="o">--</span> <span class="mi">3</span> <span class="p">[</span><span class="mi">2</span> <span class="o">...</span><span class="p">])</span> <span class="p">(</span><span class="mi">1</span> <span class="p">[</span><span class="o">...</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="mi">1</span> <span class="o">...</span><span class="p">])</span>
@@ -334,30 +335,30 @@ actually pretty easy. I’ll explain below.</p>
 </div>
 <p>From this stack effect comment it should be possible to construct the
 following Python code:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">F</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">F</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
     <span class="p">(</span><span class="n">_</span><span class="p">,</span> <span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">((</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">S0</span><span class="p">)),</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="k">return</span> <span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">S0</span><span class="p">)),</span> <span class="n">stack</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="part-ii-implementation">
+</section>
+</section>
+<section id="part-ii-implementation">
 <h2>Part II: Implementation<a class="headerlink" href="#part-ii-implementation" title="Permalink to this headline">¶</a></h2>
-<div class="section" id="representing-stack-effect-comments-in-python">
+<section id="representing-stack-effect-comments-in-python">
 <h3>Representing Stack Effect Comments in Python<a class="headerlink" href="#representing-stack-effect-comments-in-python" title="Permalink to this headline">¶</a></h3>
 <p>I’m going to use pairs of tuples of type descriptors, which will be
 integers or tuples of type descriptors:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">roll_dn</span> <span class="o">=</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="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">roll_dn</span> <span class="o">=</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="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
 
 <span class="n">pop</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,),</span> <span class="p">()</span>
 
 <span class="n">swap</span> <span class="o">=</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="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="compose">
+</section>
+<section id="compose">
 <h3><code class="docutils literal notranslate"><span class="pre">compose()</span></code><a class="headerlink" href="#compose" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compose</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compose</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
 
     <span class="p">(</span><span class="n">f_in</span><span class="p">,</span> <span class="n">f_out</span><span class="p">),</span> <span class="p">(</span><span class="n">g_in</span><span class="p">,</span> <span class="n">g_out</span><span class="p">)</span> <span class="o">=</span> <span class="n">f</span><span class="p">,</span> <span class="n">g</span>
 
@@ -399,10 +400,10 @@ integers or tuples of type descriptors:</p>
     <span class="k">return</span> <span class="n">fg_in</span><span class="p">,</span> <span class="n">fg_out</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="unify">
+</section>
+<section id="unify">
 <h3><code class="docutils literal notranslate"><span class="pre">unify()</span></code><a class="headerlink" href="#unify" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
     <span class="k">if</span> <span class="n">s</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="n">s</span> <span class="o">=</span> <span class="p">{}</span>
 
@@ -416,19 +417,19 @@ integers or tuples of type descriptors:</p>
     <span class="k">return</span> <span class="n">s</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="update">
+</section>
+<section id="update">
 <h3><code class="docutils literal notranslate"><span class="pre">update()</span></code><a class="headerlink" href="#update" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">term</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">term</span><span class="p">):</span>
     <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
         <span class="k">return</span> <span class="n">s</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="n">term</span><span class="p">)</span>
     <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">update</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">inner</span><span class="p">)</span> <span class="k">for</span> <span class="n">inner</span> <span class="ow">in</span> <span class="n">term</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="relabel">
+</section>
+<section id="relabel">
 <h3><code class="docutils literal notranslate"><span class="pre">relabel()</span></code><a class="headerlink" href="#relabel" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">relabel</span><span class="p">(</span><span class="n">left</span><span class="p">,</span> <span class="n">right</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">relabel</span><span class="p">(</span><span class="n">left</span><span class="p">,</span> <span class="n">right</span><span class="p">):</span>
     <span class="k">return</span> <span class="n">left</span><span class="p">,</span> <span class="n">_1000</span><span class="p">(</span><span class="n">right</span><span class="p">)</span>
 
 <span class="k">def</span> <span class="nf">_1000</span><span class="p">(</span><span class="n">right</span><span class="p">):</span>
@@ -442,10 +443,10 @@ integers or tuples of type descriptors:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(((</span><span class="mi">1</span><span class="p">,),</span> <span class="p">()),</span> <span class="p">((</span><span class="mi">1001</span><span class="p">,</span> <span class="mi">1002</span><span class="p">),</span> <span class="p">(</span><span class="mi">1002</span><span class="p">,</span> <span class="mi">1001</span><span class="p">)))</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="delabel">
+</section>
+<section id="delabel">
 <h3><code class="docutils literal notranslate"><span class="pre">delabel()</span></code><a class="headerlink" href="#delabel" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">delabel</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">delabel</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
     <span class="n">s</span> <span class="o">=</span> <span class="p">{</span><span class="n">u</span><span class="p">:</span> <span class="n">i</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">u</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">_unique</span><span class="p">(</span><span class="n">f</span><span class="p">)))}</span>
     <span class="k">return</span> <span class="n">update</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
 
@@ -465,62 +466,62 @@ integers or tuples of type descriptors:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(((</span><span class="mi">0</span><span class="p">,),</span> <span class="p">()),</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="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)))</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="c">
+</section>
+<section id="c">
 <h3><code class="docutils literal notranslate"><span class="pre">C()</span></code><a class="headerlink" href="#c" title="Permalink to this headline">¶</a></h3>
 <p>At last we put it all together in a function <code class="docutils literal notranslate"><span class="pre">C()</span></code> that accepts two
 stack effect comments and returns their composition (or raises and
 exception if they can’t be composed due to type conflicts.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">C</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">C</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
     <span class="n">f</span><span class="p">,</span> <span class="n">g</span> <span class="o">=</span> <span class="n">relabel</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
     <span class="n">fg</span> <span class="o">=</span> <span class="n">compose</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
     <span class="k">return</span> <span class="n">delabel</span><span class="p">(</span><span class="n">fg</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Let’s try it out.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">),</span> <span class="n">roll_dn</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">C</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">),</span> <span class="n">roll_dn</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">C</span><span class="p">(</span><span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">C</span><span class="p">(</span><span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">))</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">poswrd</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">poswrd</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">))</span>
 <span class="n">poswrd</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="stack-functions">
+</section>
+<section id="stack-functions">
 <h3>Stack Functions<a class="headerlink" href="#stack-functions" title="Permalink to this headline">¶</a></h3>
 <p>Here’s that trick to represent functions like <code class="docutils literal notranslate"><span class="pre">rest</span></code> and <code class="docutils literal notranslate"><span class="pre">cons</span></code> that
 manipulate stacks. We use a cons-list of tuples and give the tails their
 own numbers. Then everything above already works.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rest</span> <span class="o">=</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="p">(</span><span class="mi">2</span><span class="p">,)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">rest</span> <span class="o">=</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="p">(</span><span class="mi">2</span><span class="p">,)</span>
 
 <span class="n">cons</span> <span class="o">=</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="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">poswrd</span><span class="p">,</span> <span class="n">rest</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">poswrd</span><span class="p">,</span> <span class="n">rest</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</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">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
@@ -541,7 +542,7 @@ own numbers. Then everything above already works.</p>
 <span class="p">}</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">F</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">cons</span><span class="p">,</span> <span class="n">cons</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">F</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">roll_dn</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">cons</span><span class="p">,</span> <span class="n">cons</span><span class="p">))</span>
 
 <span class="n">F</span>
 </pre></div>
@@ -554,15 +555,15 @@ own numbers. Then everything above already works.</p>
   <span class="mi">3</span> <span class="mi">4</span>  <span class="mi">5</span>   <span class="mi">1</span> <span class="mi">2</span> <span class="mi">0</span>     <span class="mi">2</span> <span class="mi">1</span>  <span class="mi">5</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="dealing-with-cons-and-uncons">
+</section>
+<section id="dealing-with-cons-and-uncons">
 <h3>Dealing with <code class="docutils literal notranslate"><span class="pre">cons</span></code> and <code class="docutils literal notranslate"><span class="pre">uncons</span></code><a class="headerlink" href="#dealing-with-cons-and-uncons" title="Permalink to this headline">¶</a></h3>
 <p>However, if we try to compose e.g. <code class="docutils literal notranslate"><span class="pre">cons</span></code> and <code class="docutils literal notranslate"><span class="pre">uncons</span></code> it won’t
 work:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">uncons</span> <span class="o">=</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="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">uncons</span> <span class="o">=</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="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
     <span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">uncons</span><span class="p">)</span>
 <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span>
     <span class="nb">print</span> <span class="n">e</span>
@@ -571,12 +572,12 @@ work:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Cannot</span> <span class="n">unify</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="ow">and</span> <span class="p">(</span><span class="mi">1001</span><span class="p">,</span> <span class="mi">1002</span><span class="p">)</span><span class="o">.</span>
 </pre></div>
 </div>
-<div class="section" id="unify-version-2">
+<section id="unify-version-2">
 <h4><code class="docutils literal notranslate"><span class="pre">unify()</span></code> version 2<a class="headerlink" href="#unify-version-2" title="Permalink to this headline">¶</a></h4>
 <p>The problem is that the <code class="docutils literal notranslate"><span class="pre">unify()</span></code> function as written doesn’t handle
 the case when both terms are tuples. We just have to add a clause to
 deal with this recursively:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
     <span class="k">if</span> <span class="n">s</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="n">s</span> <span class="o">=</span> <span class="p">{}</span>
     <span class="k">elif</span> <span class="n">s</span><span class="p">:</span>
@@ -605,25 +606,25 @@ deal with this recursively:</p>
     <span class="k">return</span> <span class="n">s</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">uncons</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">uncons</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
 </pre></div>
 </div>
-</div>
-</div>
-</div>
-<div class="section" id="part-iii-compiling-yin-functions">
+</section>
+</section>
+</section>
+<section id="part-iii-compiling-yin-functions">
 <h2>Part III: Compiling Yin Functions<a class="headerlink" href="#part-iii-compiling-yin-functions" title="Permalink to this headline">¶</a></h2>
 <p>Now consider the Python function we would like to derive:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">F_python</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">F_python</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
     <span class="p">(</span><span class="n">_</span><span class="p">,</span> <span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">((</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">S0</span><span class="p">)),</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="k">return</span> <span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">S0</span><span class="p">)),</span> <span class="n">stack</span>
 </pre></div>
 </div>
 <p>And compare it to the input stack effect comment tuple we just computed:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">F</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">F</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</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">0</span><span class="p">)</span>
@@ -645,7 +646,7 @@ stack effect comment tuple, just in the reverse order:</p>
 </div>
 <p>Eh?</p>
 <p>And the return tuple</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">F</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">F</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">)),)</span>
@@ -661,12 +662,12 @@ the stack effect comment tuples and returns a new Python function
 (either as a string of code or a function object ready to use) that
 performs the semantics of that Joy function (described by the stack
 effect.)</p>
-<div class="section" id="python-identifiers">
+<section id="python-identifiers">
 <h3>Python Identifiers<a class="headerlink" href="#python-identifiers" title="Permalink to this headline">¶</a></h3>
 <p>We want to substitute Python identifiers for the integers. I’m going to
 repurpose <code class="docutils literal notranslate"><span class="pre">joy.parser.Symbol</span></code> class for this:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">defaultdict</span>
-<span class="kn">from</span> <span class="nn">joy.parser</span> <span class="k">import</span> <span class="n">Symbol</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">defaultdict</span>
+<span class="kn">from</span> <span class="nn">joy.parser</span> <span class="kn">import</span> <span class="n">Symbol</span>
 
 
 <span class="k">def</span> <span class="nf">_names_for</span><span class="p">():</span>
@@ -682,14 +683,14 @@ repurpose <code class="docutils literal notranslate"><span class="pre">joy.parse
     <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">identifiers</span><span class="p">(</span><span class="n">inner</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span> <span class="k">for</span> <span class="n">inner</span> <span class="ow">in</span> <span class="n">term</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="doc-from-stack-effect">
+</section>
+<section id="doc-from-stack-effect">
 <h3><code class="docutils literal notranslate"><span class="pre">doc_from_stack_effect()</span></code><a class="headerlink" href="#doc-from-stack-effect" title="Permalink to this headline">¶</a></h3>
 <p>As a convenience I’ve implemented a function to convert the Python stack
 effect comment tuples to reasonable text format. There are some details
 in how this code works that related to stuff later in the notebook, so
 you should skip it for now and read it later if you’re interested.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">doc_from_stack_effect</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">doc_from_stack_effect</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span><span class="p">):</span>
     <span class="k">return</span> <span class="s1">&#39;(</span><span class="si">%s</span><span class="s1">--</span><span class="si">%s</span><span class="s1">)&#39;</span> <span class="o">%</span> <span class="p">(</span>
         <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">_to_str</span><span class="p">,</span> <span class="n">inputs</span> <span class="o">+</span> <span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,))),</span>
         <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">_to_str</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,)</span> <span class="o">+</span> <span class="n">outputs</span><span class="p">))</span>
@@ -721,13 +722,13 @@ you should skip it for now and read it later if you’re interested.</p>
     <span class="k">return</span> <span class="s1">&#39;[</span><span class="si">%s</span><span class="s1">]&#39;</span> <span class="o">%</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="compile">
+</section>
+<section id="compile">
 <h3><code class="docutils literal notranslate"><span class="pre">compile_()</span></code><a class="headerlink" href="#compile" title="Permalink to this headline">¶</a></h3>
 <p>Now we can write a compiler function to emit Python source code. (The
 underscore suffix distiguishes it from the built-in <code class="docutils literal notranslate"><span class="pre">compile()</span></code>
 function.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compile_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compile_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
     <span class="k">if</span> <span class="n">doc</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="n">doc</span> <span class="o">=</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">f</span><span class="p">)</span>
     <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> <span class="n">identifiers</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
@@ -743,7 +744,7 @@ function.)</p>
 </pre></div>
 </div>
 <p>Here it is in action:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="o">=</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;F&#39;</span><span class="p">,</span> <span class="n">F</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="o">=</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;F&#39;</span><span class="p">,</span> <span class="n">F</span><span class="p">)</span>
 
 <span class="nb">print</span> <span class="n">source</span>
 </pre></div>
@@ -755,13 +756,13 @@ function.)</p>
 </pre></div>
 </div>
 <p>Compare:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">F_python</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">F_python</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
     <span class="p">(</span><span class="n">_</span><span class="p">,</span> <span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="p">((</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">S0</span><span class="p">)),</span> <span class="n">stack</span><span class="p">))))</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="k">return</span> <span class="p">((</span><span class="n">d</span><span class="p">,</span> <span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">S0</span><span class="p">)),</span> <span class="n">stack</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Next steps:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">L</span> <span class="o">=</span> <span class="p">{}</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">L</span> <span class="o">=</span> <span class="p">{}</span>
 
 <span class="nb">eval</span><span class="p">(</span><span class="nb">compile</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="s1">&#39;__main__&#39;</span><span class="p">,</span> <span class="s1">&#39;single&#39;</span><span class="p">),</span> <span class="p">{},</span> <span class="n">L</span><span class="p">)</span>
 
@@ -772,14 +773,14 @@ function.)</p>
 </pre></div>
 </div>
 <p>Let’s try it out:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span>
-<span class="kn">from</span> <span class="nn">joy.library</span> <span class="k">import</span> <span class="n">SimpleFunctionWrapper</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span>
+<span class="kn">from</span> <span class="nn">joy.library</span> <span class="kn">import</span> <span class="n">SimpleFunctionWrapper</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">D</span><span class="p">[</span><span class="s1">&#39;F&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">SimpleFunctionWrapper</span><span class="p">(</span><span class="n">L</span><span class="p">[</span><span class="s1">&#39;F&#39;</span><span class="p">])</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">D</span><span class="p">[</span><span class="s1">&#39;F&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">SimpleFunctionWrapper</span><span class="p">(</span><span class="n">L</span><span class="p">[</span><span class="s1">&#39;F&#39;</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[4 5 ...] 2 3 1 F&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[4 5 ...] 2 3 1 F&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">3</span> <span class="mi">2</span> <span class="o">...</span><span class="p">]</span>
@@ -794,12 +795,12 @@ automatically. It might be a reasonable idea to detect sequences of
 compilable functions in definitions that have uncompilable functions in
 them and just compile those. However, if your library is well-factored
 this might be less helpful.</p>
-</div>
-<div class="section" id="compiling-library-functions">
+</section>
+<section id="compiling-library-functions">
 <h3>Compiling Library Functions<a class="headerlink" href="#compiling-library-functions" title="Permalink to this headline">¶</a></h3>
 <p>We can use <code class="docutils literal notranslate"><span class="pre">compile_()</span></code> to generate many primitives in the library
 from their stack effect comments:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">defs</span><span class="p">():</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">defs</span><span class="p">():</span>
 
     <span class="n">rolldown</span> <span class="o">=</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="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
 
@@ -822,7 +823,7 @@ from their stack effect comments:</p>
     <span class="k">return</span> <span class="nb">locals</span><span class="p">()</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">defs</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">defs</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
     <span class="nb">print</span>
     <span class="nb">print</span> <span class="n">compile_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span><span class="p">)</span>
     <span class="nb">print</span>
@@ -882,14 +883,14 @@ from their stack effect comments:</p>
     <span class="k">return</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a0</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="part-iv-types-and-subtypes-of-arguments">
+</section>
+</section>
+<section id="part-iv-types-and-subtypes-of-arguments">
 <h2>Part IV: Types and Subtypes of Arguments<a class="headerlink" href="#part-iv-types-and-subtypes-of-arguments" title="Permalink to this headline">¶</a></h2>
 <p>So far we have dealt with types of functions, those dealing with simple
 stack manipulation. Let’s extend our machinery to deal with types of
 arguments.</p>
-<div class="section" id="number-type">
+<section id="number-type">
 <h3>“Number” Type<a class="headerlink" href="#number-type" title="Permalink to this headline">¶</a></h3>
 <p>Consider the definition of <code class="docutils literal notranslate"><span class="pre">sqr</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sqr</span> <span class="o">==</span> <span class="n">dup</span> <span class="n">mul</span>
@@ -899,8 +900,8 @@ arguments.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">dup</span> <span class="p">(</span><span class="mi">1</span> <span class="o">--</span> <span class="mi">1</span> <span class="mi">1</span><span class="p">)</span>
 </pre></div>
 </div>
-<p>And <code class="docutils literal notranslate"><span class="pre">mul</span></code> accepts two “numbers” (we’re ignoring ints vs.&nbsp;floats
-vs.&nbsp;complex, etc., for now) and returns just one:</p>
+<p>And <code class="docutils literal notranslate"><span class="pre">mul</span></code> accepts two “numbers” (we’re ignoring ints vs. floats
+vs. complex, etc., for now) and returns just one:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mul</span> <span class="p">(</span><span class="n">n</span> <span class="n">n</span> <span class="o">--</span> <span class="n">n</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -924,8 +925,8 @@ the case:</p>
 </div>
 <p>The important thing here is that the mapping is going the same way in
 both cases, from the “any” integer to the number</p>
-</div>
-<div class="section" id="distinguishing-numbers">
+</section>
+<section id="distinguishing-numbers">
 <h3>Distinguishing Numbers<a class="headerlink" href="#distinguishing-numbers" title="Permalink to this headline">¶</a></h3>
 <p>We should also mind that the number that <code class="docutils literal notranslate"><span class="pre">mul</span></code> produces is not
 (necessarily) the same as either of its inputs, which are not
@@ -943,8 +944,8 @@ both cases, from the “any” integer to the number</p>
    (n2 n1 --   )∘(  -- n3 n3)
 </pre></div>
 </div>
-</div>
-<div class="section" id="distinguishing-types">
+</section>
+<section id="distinguishing-types">
 <h3>Distinguishing Types<a class="headerlink" href="#distinguishing-types" title="Permalink to this headline">¶</a></h3>
 <p>So we need separate domains of “any” numbers and “number” numbers, and
 we need to be able to ask the order of these domains. Now the notes on
@@ -965,31 +966,31 @@ and <code class="docutils literal notranslate"><span class="pre">t</span></code>
 Python class hierarchy of Joy types and use the <code class="docutils literal notranslate"><span class="pre">issubclass()</span></code> method
 to establish domain ordering, as well as other handy behaviour that will
 make it fairly easy to reuse most of the code above.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">AnyJoyType</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">AnyJoyType</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
 
     <span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
 
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">number</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">number</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">=</span> <span class="n">number</span>
 
-    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number</span><span class="p">)</span>
 
-    <span class="k">def</span> <span class="nf">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
         <span class="k">return</span> <span class="p">(</span>
             <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span>
             <span class="ow">and</span> <span class="n">other</span><span class="o">.</span><span class="n">prefix</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span>
             <span class="ow">and</span> <span class="n">other</span><span class="o">.</span><span class="n">number</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">number</span>
         <span class="p">)</span>
 
-    <span class="k">def</span> <span class="nf">__ge__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__ge__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
         <span class="k">return</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">other</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span>
 
-    <span class="k">def</span> <span class="nf">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
         <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">+</span> <span class="n">other</span><span class="p">)</span>
     <span class="fm">__radd__</span> <span class="o">=</span> <span class="fm">__add__</span>
 
-    <span class="k">def</span> <span class="nf">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
 
 
@@ -1009,12 +1010,12 @@ make it fairly easy to reuse most of the code above.</p>
 </pre></div>
 </div>
 <p>Mess with it a little:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="k">import</span> <span class="n">permutations</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">permutations</span>
 </pre></div>
 </div>
 <p>“Any” types can be specialized to numbers and stacks, but not vice
 versa:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">permutations</span><span class="p">((</span><span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="mi">2</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">permutations</span><span class="p">((</span><span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="mi">2</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">a</span><span class="p">,</span> <span class="s1">&#39;&gt;=&#39;</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="n">a</span> <span class="o">&gt;=</span> <span class="n">b</span>
 </pre></div>
 </div>
@@ -1029,7 +1030,7 @@ versa:</p>
 <p>Our crude <a class="reference external" href="https://en.wikipedia.org/wiki/Numerical_tower">Numerical
 Tower</a> of <em>numbers</em> &gt;
 <em>floats</em> &gt; <em>integers</em> works as well (but we’re not going to use it yet):</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">permutations</span><span class="p">((</span><span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">FloatJoyType</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">IntJoyType</span><span class="p">(</span><span class="mi">0</span><span class="p">)),</span> <span class="mi">2</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">permutations</span><span class="p">((</span><span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">FloatJoyType</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">IntJoyType</span><span class="p">(</span><span class="mi">0</span><span class="p">)),</span> <span class="mi">2</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">a</span><span class="p">,</span> <span class="s1">&#39;&gt;=&#39;</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="n">a</span> <span class="o">&gt;=</span> <span class="n">b</span>
 </pre></div>
 </div>
@@ -1047,31 +1048,31 @@ Tower</a> of <em>numbers</em> &gt;
 <span class="n">i0</span> <span class="o">&gt;=</span> <span class="n">f0</span> <span class="o">-&gt;</span> <span class="kc">False</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="typing-sqr">
+</section>
+<section id="typing-sqr">
 <h3>Typing <code class="docutils literal notranslate"><span class="pre">sqr</span></code><a class="headerlink" href="#typing-sqr" title="Permalink to this headline">¶</a></h3>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">dup</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],),</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">dup</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],),</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
 
 <span class="n">mul</span> <span class="o">=</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">N</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">3</span><span class="p">],)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">dup</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">dup</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="n">a1</span><span class="p">,),</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a1</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mul</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">mul</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="n">n1</span><span class="p">,</span> <span class="n">n2</span><span class="p">),</span> <span class="p">(</span><span class="n">n3</span><span class="p">,))</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="modifying-the-inferencer">
+</section>
+<section id="modifying-the-inferencer">
 <h3>Modifying the Inferencer<a class="headerlink" href="#modifying-the-inferencer" title="Permalink to this headline">¶</a></h3>
 <p>Re-labeling still works fine:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">foo</span> <span class="o">=</span> <span class="n">relabel</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">foo</span> <span class="o">=</span> <span class="n">relabel</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">)</span>
 
 <span class="n">foo</span>
 </pre></div>
@@ -1079,11 +1080,11 @@ Tower</a> of <em>numbers</em> &gt;
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(((</span><span class="n">a1</span><span class="p">,),</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a1</span><span class="p">)),</span> <span class="p">((</span><span class="n">n1001</span><span class="p">,</span> <span class="n">n1002</span><span class="p">),</span> <span class="p">(</span><span class="n">n1003</span><span class="p">,)))</span>
 </pre></div>
 </div>
-<div class="section" id="delabel-version-2">
+<section id="delabel-version-2">
 <h4><code class="docutils literal notranslate"><span class="pre">delabel()</span></code> version 2<a class="headerlink" href="#delabel-version-2" title="Permalink to this headline">¶</a></h4>
 <p>The <code class="docutils literal notranslate"><span class="pre">delabel()</span></code> function needs an overhaul. It now has to keep track
 of how many labels of each domain it has “seen”.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">Counter</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">Counter</span>
 
 
 <span class="k">def</span> <span class="nf">delabel</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">seen</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
@@ -1104,16 +1105,16 @@ of how many labels of each domain it has “seen”.</p>
     <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">delabel</span><span class="p">(</span><span class="n">inner</span><span class="p">,</span> <span class="n">seen</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span> <span class="k">for</span> <span class="n">inner</span> <span class="ow">in</span> <span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">delabel</span><span class="p">(</span><span class="n">foo</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">delabel</span><span class="p">(</span><span class="n">foo</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(((</span><span class="n">a1</span><span class="p">,),</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a1</span><span class="p">)),</span> <span class="p">((</span><span class="n">n1</span><span class="p">,</span> <span class="n">n2</span><span class="p">),</span> <span class="p">(</span><span class="n">n3</span><span class="p">,)))</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="unify-version-3">
+</section>
+<section id="unify-version-3">
 <h4><code class="docutils literal notranslate"><span class="pre">unify()</span></code> version 3<a class="headerlink" href="#unify-version-3" title="Permalink to this headline">¶</a></h4>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
     <span class="k">if</span> <span class="n">s</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="n">s</span> <span class="o">=</span> <span class="p">{}</span>
     <span class="k">elif</span> <span class="n">s</span><span class="p">:</span>
@@ -1161,7 +1162,7 @@ of how many labels of each domain it has “seen”.</p>
 </pre></div>
 </div>
 <p>Rewrite the stack effect comments:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">defs</span><span class="p">():</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">defs</span><span class="p">():</span>
 
     <span class="n">rolldown</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">A</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">A</span><span class="p">[</span><span class="mi">3</span><span class="p">]),</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">A</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
 
@@ -1214,10 +1215,10 @@ of how many labels of each domain it has “seen”.</p>
     <span class="k">return</span> <span class="nb">locals</span><span class="p">()</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">DEFS</span> <span class="o">=</span> <span class="n">defs</span><span class="p">()</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">DEFS</span> <span class="o">=</span> <span class="n">defs</span><span class="p">()</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">DEFS</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">DEFS</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
     <span class="nb">print</span> <span class="n">name</span><span class="p">,</span> <span class="s1">&#39;=&#39;</span><span class="p">,</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">stack_effect_comment</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -1249,27 +1250,27 @@ of how many labels of each domain it has “seen”.</p>
 <span class="n">uncons</span> <span class="o">=</span> <span class="p">([</span><span class="n">a1</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">a1</span> <span class="p">[</span><span class="o">.</span><span class="mf">1.</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">DEFS</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">DEFS</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="compose-dup-and-mul">
+</section>
+<section id="compose-dup-and-mul">
 <h4>Compose <code class="docutils literal notranslate"><span class="pre">dup</span></code> and <code class="docutils literal notranslate"><span class="pre">mul</span></code><a class="headerlink" href="#compose-dup-and-mul" title="Permalink to this headline">¶</a></h4>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="n">n1</span><span class="p">,),</span> <span class="p">(</span><span class="n">n2</span><span class="p">,))</span>
 </pre></div>
 </div>
 <p>Revisit the <code class="docutils literal notranslate"><span class="pre">F</span></code> function, works fine.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">F</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">rolldown</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">cons</span><span class="p">,</span> <span class="n">cons</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">F</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">pop</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">rolldown</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">rest</span><span class="p">,</span> <span class="n">cons</span><span class="p">,</span> <span class="n">cons</span><span class="p">))</span>
 <span class="n">F</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(((</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">a3</span><span class="p">,</span> <span class="n">a4</span><span class="p">,</span> <span class="n">a5</span><span class="p">),</span> <span class="p">((</span><span class="n">a4</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">F</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">F</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">a1</span> <span class="n">a2</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="n">a3</span> <span class="n">a4</span> <span class="n">a5</span> <span class="o">--</span> <span class="p">[</span><span class="n">a4</span> <span class="n">a3</span> <span class="o">.</span><span class="mf">1.</span><span class="p">])</span>
@@ -1277,37 +1278,37 @@ of how many labels of each domain it has “seen”.</p>
 </div>
 <p>Some otherwise inefficient functions are no longer to be feared. We can
 also get the effect of combinators in some limited cases.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">neato</span><span class="p">(</span><span class="o">*</span><span class="n">funcs</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">neato</span><span class="p">(</span><span class="o">*</span><span class="n">funcs</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="n">funcs</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># e.g. [swap] dip</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># e.g. [swap] dip</span>
 <span class="n">neato</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="n">swap</span><span class="p">,</span> <span class="n">rolldown</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="n">a2</span> <span class="n">a3</span> <span class="o">--</span> <span class="n">a2</span> <span class="n">a1</span> <span class="n">a3</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># e.g. [popop] dipd</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># e.g. [popop] dipd</span>
 <span class="n">neato</span><span class="p">(</span><span class="n">popdd</span><span class="p">,</span> <span class="n">rolldown</span><span class="p">,</span> <span class="n">pop</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="n">a2</span> <span class="n">a3</span> <span class="n">a4</span> <span class="o">--</span> <span class="n">a3</span> <span class="n">a4</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># Reverse the order of the top three items.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Reverse the order of the top three items.</span>
 <span class="n">neato</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="n">swap</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="n">a2</span> <span class="n">a3</span> <span class="o">--</span> <span class="n">a3</span> <span class="n">a2</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="compile-version-2">
+</section>
+<section id="compile-version-2">
 <h4><code class="docutils literal notranslate"><span class="pre">compile_()</span></code> version 2<a class="headerlink" href="#compile-version-2" title="Permalink to this headline">¶</a></h4>
 <p>Because the type labels represent themselves as valid Python identifiers
 the <code class="docutils literal notranslate"><span class="pre">compile_()</span></code> function doesn’t need to generate them anymore:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compile_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compile_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
     <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> <span class="n">f</span>
     <span class="k">if</span> <span class="n">doc</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="n">doc</span> <span class="o">=</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span><span class="p">)</span>
@@ -1322,7 +1323,7 @@ the <code class="docutils literal notranslate"><span class="pre">compile_()</spa
 <span class="s1">    return </span><span class="si">%s</span><span class="s1">&#39;&#39;&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">doc</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">o</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;F&#39;</span><span class="p">,</span> <span class="n">F</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;F&#39;</span><span class="p">,</span> <span class="n">F</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">F</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
@@ -1331,9 +1332,9 @@ the <code class="docutils literal notranslate"><span class="pre">compile_()</spa
     <span class="k">return</span> <span class="p">((</span><span class="n">a4</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">stack</span><span class="p">)</span>
 </pre></div>
 </div>
-<p>But it cannot magically create new functions that involve e.g.&nbsp;math and
+<p>But it cannot magically create new functions that involve e.g. math and
 such. Note that this is <em>not</em> a <code class="docutils literal notranslate"><span class="pre">sqr</span></code> function implementation:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;sqr&#39;</span><span class="p">,</span> <span class="n">C</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;sqr&#39;</span><span class="p">,</span> <span class="n">C</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">mul</span><span class="p">))</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">sqr</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
@@ -1349,20 +1350,20 @@ insert it in the right place. It requires a little more support from the
 library functions, in that we need to know to call <code class="docutils literal notranslate"><span class="pre">mul()</span></code> the Python
 function for <code class="docutils literal notranslate"><span class="pre">mul</span></code> the Joy function, but since <em>most</em> of the math
 functions (at least) are already wrappers it should be straightforward.)</p>
-</div>
-<div class="section" id="compilable">
+</section>
+<section id="compilable">
 <h4><code class="docutils literal notranslate"><span class="pre">compilable()</span></code><a class="headerlink" href="#compilable" title="Permalink to this headline">¶</a></h4>
 <p>The functions that <em>can</em> be compiled are the ones that have only
 <code class="docutils literal notranslate"><span class="pre">AnyJoyType</span></code> and <code class="docutils literal notranslate"><span class="pre">StackJoyType</span></code> labels in their stack effect
 comments. We can write a function to check that:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="k">import</span> <span class="n">imap</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">imap</span>
 
 
 <span class="k">def</span> <span class="nf">compilable</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
     <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">all</span><span class="p">(</span><span class="n">imap</span><span class="p">(</span><span class="n">compilable</span><span class="p">,</span> <span class="n">f</span><span class="p">))</span> <span class="ow">or</span> <span class="n">stacky</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">defs</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">defs</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
     <span class="k">if</span> <span class="n">compilable</span><span class="p">(</span><span class="n">stack_effect_comment</span><span class="p">):</span>
         <span class="nb">print</span> <span class="n">name</span><span class="p">,</span> <span class="s1">&#39;=&#39;</span><span class="p">,</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">stack_effect_comment</span><span class="p">)</span>
 </pre></div>
@@ -1389,10 +1390,10 @@ comments. We can write a function to check that:</p>
 <span class="n">uncons</span> <span class="o">=</span> <span class="p">([</span><span class="n">a1</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">a1</span> <span class="p">[</span><span class="o">.</span><span class="mf">1.</span><span class="p">])</span>
 </pre></div>
 </div>
-</div>
-</div>
-</div>
-<div class="section" id="part-v-functions-that-use-the-stack">
+</section>
+</section>
+</section>
+<section id="part-v-functions-that-use-the-stack">
 <h2>Part V: Functions that use the Stack<a class="headerlink" href="#part-v-functions-that-use-the-stack" title="Permalink to this headline">¶</a></h2>
 <p>Consider the <code class="docutils literal notranslate"><span class="pre">stack</span></code> function which grabs the whole stack, quotes it,
 and puts it on itself:</p>
@@ -1411,7 +1412,7 @@ simple, elegant trick.</p>
 <p>Instead of representing the stack effect comments as a single tuple
 (with N items in it) we use the same cons-list structure to hold the
 sequence and <code class="docutils literal notranslate"><span class="pre">unify()</span></code> the whole comments.</p>
-<div class="section" id="stackuncons">
+<section id="stackuncons">
 <h3><code class="docutils literal notranslate"><span class="pre">stack∘uncons</span></code><a class="headerlink" href="#stackuncons" title="Permalink to this headline">¶</a></h3>
 <p>Let’s try composing <code class="docutils literal notranslate"><span class="pre">stack</span></code> and <code class="docutils literal notranslate"><span class="pre">uncons</span></code>. We want this result:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>stack∘uncons (... a -- ... a a [...])
@@ -1434,8 +1435,8 @@ sequence and <code class="docutils literal notranslate"><span class="pre">unify(
 </pre></div>
 </div>
 <p>It works.</p>
-</div>
-<div class="section" id="stackunconsuncons">
+</section>
+<section id="stackunconsuncons">
 <h3><code class="docutils literal notranslate"><span class="pre">stack∘uncons∘uncons</span></code><a class="headerlink" href="#stackunconsuncons" title="Permalink to this headline">¶</a></h3>
 <p>Let’s try <code class="docutils literal notranslate"><span class="pre">stack∘uncons∘uncons</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>(a, S     ) -- (S,      (a, (a, S     ))) ∘ ((b, Z),  S`             ) -- (Z, (b,   S`   ))
@@ -1452,7 +1453,7 @@ sequence and <code class="docutils literal notranslate"><span class="pre">unify(
 </pre></div>
 </div>
 <p>It works.</p>
-<div class="section" id="compose-version-2">
+<section id="compose-version-2">
 <h4><code class="docutils literal notranslate"><span class="pre">compose()</span></code> version 2<a class="headerlink" href="#compose-version-2" title="Permalink to this headline">¶</a></h4>
 <p>This function has to be modified to use the new datastructures and it is
 no longer recursive, instead recursion happens as part of unification.
@@ -1464,7 +1465,7 @@ first two rules’ <code class="docutils literal notranslate"><span class="pre">
 the “truthiness” of <code class="docutils literal notranslate"><span class="pre">StackJoyType</span></code> to false to let e.g.
 <code class="docutils literal notranslate"><span class="pre">joy.utils.stack.concat</span></code> work with our stack effect comment cons-list
 tuples.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compose</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compose</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
     <span class="p">(</span><span class="n">f_in</span><span class="p">,</span> <span class="n">f_out</span><span class="p">),</span> <span class="p">(</span><span class="n">g_in</span><span class="p">,</span> <span class="n">g_out</span><span class="p">)</span> <span class="o">=</span> <span class="n">f</span><span class="p">,</span> <span class="n">g</span>
     <span class="n">s</span> <span class="o">=</span> <span class="n">unify</span><span class="p">(</span><span class="n">g_in</span><span class="p">,</span> <span class="n">f_out</span><span class="p">)</span>
     <span class="k">if</span> <span class="n">s</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span>  <span class="c1"># s can also be the empty dict, which is ok.</span>
@@ -1474,7 +1475,7 @@ tuples.)</p>
 </div>
 <p>I don’t want to rewrite all the defs myself, so I’ll write a little
 conversion function instead. This is programmer’s laziness.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">sequence_to_stack</span><span class="p">(</span><span class="n">seq</span><span class="p">,</span> <span class="n">stack</span><span class="o">=</span><span class="n">StackJoyType</span><span class="p">(</span><span class="mi">23</span><span class="p">)):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">sequence_to_stack</span><span class="p">(</span><span class="n">seq</span><span class="p">,</span> <span class="n">stack</span><span class="o">=</span><span class="n">StackJoyType</span><span class="p">(</span><span class="mi">23</span><span class="p">)):</span>
     <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">seq</span><span class="p">:</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">item</span><span class="p">,</span> <span class="n">stack</span>
     <span class="k">return</span> <span class="n">stack</span>
 
@@ -1487,25 +1488,25 @@ conversion function instead. This is programmer’s laziness.</p>
 <span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">NEW_DEFS</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">uncons</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">uncons</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">))))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">uncons</span><span class="p">,</span> <span class="n">uncons</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">uncons</span><span class="p">,</span> <span class="n">uncons</span><span class="p">))</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s1</span><span class="p">))))))</span>
 </pre></div>
 </div>
 <p>The display function should be changed too.</p>
-</div>
-</div>
-<div class="section" id="doc-from-stack-effect-version-2">
+</section>
+</section>
+<section id="doc-from-stack-effect-version-2">
 <h3><code class="docutils literal notranslate"><span class="pre">doc_from_stack_effect()</span></code> version 2<a class="headerlink" href="#doc-from-stack-effect-version-2" title="Permalink to this headline">¶</a></h3>
 <p>Clunky junk, but it will suffice for now.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">doc_from_stack_effect</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">doc_from_stack_effect</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span><span class="p">):</span>
     <span class="n">switch</span> <span class="o">=</span> <span class="p">[</span><span class="kc">False</span><span class="p">]</span>  <span class="c1"># Do we need to display the &#39;...&#39; for the rest of the main stack?</span>
     <span class="n">i</span><span class="p">,</span> <span class="n">o</span> <span class="o">=</span> <span class="n">_f</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">switch</span><span class="p">),</span> <span class="n">_f</span><span class="p">(</span><span class="n">outputs</span><span class="p">,</span> <span class="n">switch</span><span class="p">)</span>
     <span class="k">if</span> <span class="n">switch</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
@@ -1552,7 +1553,7 @@ conversion function instead. This is programmer’s laziness.</p>
     <span class="k">return</span> <span class="s1">&#39;[</span><span class="si">%s</span><span class="s1">]&#39;</span> <span class="o">%</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">NEW_DEFS</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">stack_effect_comment</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">NEW_DEFS</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
     <span class="nb">print</span> <span class="n">name</span><span class="p">,</span> <span class="s1">&#39;=&#39;</span><span class="p">,</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">stack_effect_comment</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -1586,7 +1587,7 @@ conversion function instead. This is programmer’s laziness.</p>
 <span class="n">uncons</span> <span class="o">=</span> <span class="p">([</span><span class="n">a1</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">a1</span> <span class="p">[</span><span class="o">.</span><span class="mf">1.</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="p">;</span> <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">stack</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="p">;</span> <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">stack</span><span class="p">)</span>
 <span class="nb">print</span> <span class="p">;</span> <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">C</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">uncons</span><span class="p">))</span>
 <span class="nb">print</span> <span class="p">;</span> <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">uncons</span><span class="p">,</span> <span class="n">uncons</span><span class="p">)))</span>
 <span class="nb">print</span> <span class="p">;</span> <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">reduce</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">uncons</span><span class="p">,</span> <span class="n">cons</span><span class="p">)))</span>
@@ -1601,13 +1602,13 @@ conversion function instead. This is programmer’s laziness.</p>
 <span class="p">(</span><span class="o">...</span> <span class="n">a1</span> <span class="o">--</span> <span class="o">...</span> <span class="n">a1</span> <span class="p">[</span><span class="n">a1</span> <span class="o">...</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">C</span><span class="p">(</span><span class="n">ccons</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">C</span><span class="p">(</span><span class="n">ccons</span><span class="p">,</span> <span class="n">stack</span><span class="p">))</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">...</span> <span class="n">a2</span> <span class="n">a1</span> <span class="p">[</span><span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="o">...</span> <span class="p">[</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="p">[[</span><span class="n">a2</span> <span class="n">a1</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">...</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Q</span> <span class="o">=</span> <span class="n">C</span><span class="p">(</span><span class="n">ccons</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">Q</span> <span class="o">=</span> <span class="n">C</span><span class="p">(</span><span class="n">ccons</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
 
 <span class="n">Q</span>
 </pre></div>
@@ -1615,11 +1616,11 @@ conversion function instead. This is programmer’s laziness.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="n">s1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s2</span><span class="p">))),</span> <span class="p">(((</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">),</span> <span class="p">((</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">)))</span>
 </pre></div>
 </div>
-<div class="section" id="compile-version-3">
+<section id="compile-version-3">
 <h4><code class="docutils literal notranslate"><span class="pre">compile_()</span></code> version 3<a class="headerlink" href="#compile-version-3" title="Permalink to this headline">¶</a></h4>
 <p>This makes the <code class="docutils literal notranslate"><span class="pre">compile_()</span></code> function pretty simple as the stack effect
 comments are now already in the form needed for the Python code:</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compile_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compile_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
     <span class="n">i</span><span class="p">,</span> <span class="n">o</span> <span class="o">=</span> <span class="n">f</span>
     <span class="k">if</span> <span class="n">doc</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="n">doc</span> <span class="o">=</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">o</span><span class="p">)</span>
@@ -1629,7 +1630,7 @@ comments are now already in the form needed for the Python code:</p>
 <span class="s1">    return </span><span class="si">%s</span><span class="s1">&#39;&#39;&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">doc</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">o</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="n">Q</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">compile_</span><span class="p">(</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="n">Q</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">Q</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
@@ -1638,54 +1639,54 @@ comments are now already in the form needed for the Python code:</p>
     <span class="k">return</span> <span class="p">(((</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">),</span> <span class="p">((</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">s2</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">unstack</span> <span class="o">=</span> <span class="p">(</span><span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">unstack</span> <span class="o">=</span> <span class="p">(</span><span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
 <span class="n">enstacken</span> <span class="o">=</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">unstack</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">unstack</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">enstacken</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">enstacken</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">--</span> <span class="p">[</span><span class="o">.</span><span class="mf">0.</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">unstack</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">unstack</span><span class="p">))</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="p">[</span><span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">a1</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">enstacken</span><span class="p">))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">enstacken</span><span class="p">))</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="p">[</span><span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="p">[[</span><span class="n">a1</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">.</span><span class="mf">2.</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">unstack</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">(</span><span class="n">cons</span><span class="p">,</span> <span class="n">unstack</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="n">s1</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s2</span><span class="p">)),</span> <span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s1</span><span class="p">))</span>
 </pre></div>
 </div>
-</div>
-</div>
-</div>
-<div class="section" id="part-vi-multiple-stack-effects">
+</section>
+</section>
+</section>
+<section id="part-vi-multiple-stack-effects">
 <h2>Part VI: Multiple Stack Effects<a class="headerlink" href="#part-vi-multiple-stack-effects" title="Permalink to this headline">¶</a></h2>
 <p>…</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">IntJoyType</span><span class="p">(</span><span class="n">NumberJoyType</span><span class="p">):</span> <span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;i&#39;</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">IntJoyType</span><span class="p">(</span><span class="n">NumberJoyType</span><span class="p">):</span> <span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;i&#39;</span>
 
 
 <span class="n">F</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">FloatJoyType</span><span class="p">,</span> <span class="n">_R</span><span class="p">)</span>
 <span class="n">I</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">IntJoyType</span><span class="p">,</span> <span class="n">_R</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">muls</span> <span class="o">=</span> <span class="p">[</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">muls</span> <span class="o">=</span> <span class="p">[</span>
      <span class="p">((</span><span class="n">I</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">(</span><span class="n">I</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span> <span class="p">(</span><span class="n">I</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span>
      <span class="p">((</span><span class="n">F</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">(</span><span class="n">I</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span> <span class="p">(</span><span class="n">F</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span>
      <span class="p">((</span><span class="n">I</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">(</span><span class="n">F</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span> <span class="p">(</span><span class="n">F</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span>
@@ -1693,7 +1694,7 @@ comments are now already in the form needed for the Python code:</p>
 <span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">muls</span><span class="p">:</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">muls</span><span class="p">:</span>
     <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -1703,7 +1704,7 @@ comments are now already in the form needed for the Python code:</p>
 <span class="p">(</span><span class="n">f1</span> <span class="n">f2</span> <span class="o">--</span> <span class="n">f3</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">muls</span><span class="p">:</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">muls</span><span class="p">:</span>
     <span class="k">try</span><span class="p">:</span>
         <span class="n">e</span> <span class="o">=</span> <span class="n">C</span><span class="p">(</span><span class="n">dup</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
     <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
@@ -1715,7 +1716,7 @@ comments are now already in the form needed for the Python code:</p>
 <span class="p">(</span><span class="n">a1</span> <span class="o">--</span> <span class="n">a1</span> <span class="n">a1</span><span class="p">)</span> <span class="p">(</span><span class="n">f1</span> <span class="n">f2</span> <span class="o">--</span> <span class="n">f3</span><span class="p">)</span> <span class="p">(</span><span class="n">f1</span> <span class="o">--</span> <span class="n">f2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="k">import</span> <span class="n">product</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">product</span>
 
 
 <span class="k">def</span> <span class="nf">meta_compose</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">G</span><span class="p">):</span>
@@ -1730,14 +1731,14 @@ comments are now already in the form needed for the Python code:</p>
     <span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">meta_compose</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">G</span><span class="p">)))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="p">[</span><span class="n">mul</span><span class="p">]):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="p">[</span><span class="n">mul</span><span class="p">]):</span>
     <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">n1</span> <span class="o">--</span> <span class="n">n2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="n">muls</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="n">muls</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -1745,7 +1746,7 @@ comments are now already in the form needed for the Python code:</p>
 <span class="p">(</span><span class="n">i1</span> <span class="o">--</span> <span class="n">i2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="section" id="representing-an-unbounded-sequence-of-types">
+<section id="representing-an-unbounded-sequence-of-types">
 <h3>Representing an Unbounded Sequence of Types<a class="headerlink" href="#representing-an-unbounded-sequence-of-types" title="Permalink to this headline">¶</a></h3>
 <p>We can borrow a trick from <a class="reference external" href="https://en.wikipedia.org/wiki/Brzozowski_derivative">Brzozowski’s Derivatives of Regular
 Expressions</a> to
@@ -1792,36 +1793,36 @@ disappears:</p>
 <span class="p">{</span><span class="n">c</span><span class="p">:</span> <span class="n">a</span><span class="p">,</span>  <span class="n">d</span><span class="p">:</span> <span class="n">e</span><span class="p">,</span>  <span class="o">.</span><span class="mf">1.</span><span class="p">:</span> <span class="n">A</span><span class="o">*</span> <span class="n">b</span> <span class="o">.</span><span class="mf">0.</span><span class="p">}</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">KleeneStar</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">KleeneStar</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
 
     <span class="n">kind</span> <span class="o">=</span> <span class="n">AnyJoyType</span>
 
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">number</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">number</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">=</span> <span class="n">number</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">count</span> <span class="o">=</span> <span class="mi">0</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="o">=</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
 
-    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="k">return</span> <span class="s1">&#39;</span><span class="si">%s%i</span><span class="s1">*&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kind</span><span class="o">.</span><span class="n">prefix</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">number</span><span class="p">)</span>
 
     <span class="k">def</span> <span class="nf">another</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
         <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">kind</span><span class="p">(</span><span class="mi">10000</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">count</span><span class="p">)</span>
 
-    <span class="k">def</span> <span class="nf">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
         <span class="k">return</span> <span class="p">(</span>
             <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span>
             <span class="ow">and</span> <span class="n">other</span><span class="o">.</span><span class="n">number</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">number</span>
         <span class="p">)</span>
 
-    <span class="k">def</span> <span class="nf">__ge__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__ge__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
         <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">kind</span> <span class="o">&gt;=</span> <span class="n">other</span><span class="o">.</span><span class="n">kind</span>
 
-    <span class="k">def</span> <span class="nf">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
         <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">+</span> <span class="n">other</span><span class="p">)</span>
     <span class="fm">__radd__</span> <span class="o">=</span> <span class="fm">__add__</span>
 
-    <span class="k">def</span> <span class="nf">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
 
 <span class="k">class</span> <span class="nc">AnyStarJoyType</span><span class="p">(</span><span class="n">KleeneStar</span><span class="p">):</span> <span class="n">kind</span> <span class="o">=</span> <span class="n">AnyJoyType</span>
@@ -1836,10 +1837,10 @@ disappears:</p>
 <span class="n">Ss</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">StackStarJoyType</span><span class="p">,</span> <span class="n">_R</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="section" id="unify-version-4">
+<section id="unify-version-4">
 <h4><code class="docutils literal notranslate"><span class="pre">unify()</span></code> version 4<a class="headerlink" href="#unify-version-4" title="Permalink to this headline">¶</a></h4>
 <p>Can now return multiple results…</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">unify</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
     <span class="k">if</span> <span class="n">s</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="n">s</span> <span class="o">=</span> <span class="p">{}</span>
     <span class="k">elif</span> <span class="n">s</span><span class="p">:</span>
@@ -1910,21 +1911,21 @@ disappears:</p>
     <span class="k">return</span> <span class="n">thing</span><span class="o">.</span><span class="vm">__class__</span> <span class="ow">in</span> <span class="p">{</span><span class="n">AnyJoyType</span><span class="p">,</span> <span class="n">StackJoyType</span><span class="p">}</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">As</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">As</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
 <span class="n">a</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="n">s1</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
 <span class="n">b</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">result</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="n">update</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">a</span><span class="p">),</span> <span class="n">update</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -1932,7 +1933,7 @@ disappears:</p>
 <span class="p">{</span><span class="n">a1</span><span class="p">:</span> <span class="n">a10001</span><span class="p">,</span> <span class="n">s2</span><span class="p">:</span> <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="n">s1</span><span class="p">)}</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="n">s1</span><span class="p">)</span> <span class="p">(</span><span class="n">a10001</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="n">s1</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">result</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="n">update</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">a</span><span class="p">),</span> <span class="n">update</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -1947,7 +1948,7 @@ disappears:</p>
 <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="n">s1</span><span class="p">)</span>       <span class="p">[</span><span class="n">a1</span><span class="o">*</span><span class="p">]</span>       <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="n">s1</span><span class="p">))</span> <span class="p">[</span><span class="n">a2</span> <span class="n">a1</span><span class="o">*</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sum_</span> <span class="o">=</span> <span class="p">((</span><span class="n">Ns</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sum_</span> <span class="o">=</span> <span class="p">((</span><span class="n">Ns</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
 
 <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">sum_</span><span class="p">)</span>
 </pre></div>
@@ -1955,7 +1956,7 @@ disappears:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">n1</span><span class="o">*</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">n0</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">]))),</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">]))),</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
 
 <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">f</span><span class="p">)</span>
 </pre></div>
@@ -1963,7 +1964,7 @@ disappears:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="o">--</span> <span class="p">[</span><span class="n">n1</span> <span class="n">n2</span> <span class="n">n3</span> <span class="o">.</span><span class="mf">1.</span><span class="p">])</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">sum_</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">f</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">sum_</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">f</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">result</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="n">update</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">sum_</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
 </pre></div>
 </div>
@@ -1973,11 +1974,11 @@ disappears:</p>
 <span class="p">{</span><span class="n">n1</span><span class="p">:</span> <span class="n">n10001</span><span class="p">,</span> <span class="n">s1</span><span class="p">:</span> <span class="p">(</span><span class="n">n1</span><span class="o">*</span><span class="p">,</span> <span class="n">s1</span><span class="p">),</span> <span class="n">n3</span><span class="p">:</span> <span class="n">n10003</span><span class="p">,</span> <span class="n">n2</span><span class="p">:</span> <span class="n">n10002</span><span class="p">}</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="n">n0</span><span class="p">,</span> <span class="n">s0</span><span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="compose-version-3">
+</section>
+<section id="compose-version-3">
 <h4><code class="docutils literal notranslate"><span class="pre">compose()</span></code> version 3<a class="headerlink" href="#compose-version-3" title="Permalink to this headline">¶</a></h4>
 <p>This function has to be modified to yield multiple results.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compose</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">compose</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
     <span class="p">(</span><span class="n">f_in</span><span class="p">,</span> <span class="n">f_out</span><span class="p">),</span> <span class="p">(</span><span class="n">g_in</span><span class="p">,</span> <span class="n">g_out</span><span class="p">)</span> <span class="o">=</span> <span class="n">f</span><span class="p">,</span> <span class="n">g</span>
     <span class="n">s</span> <span class="o">=</span> <span class="n">unify</span><span class="p">(</span><span class="n">g_in</span><span class="p">,</span> <span class="n">f_out</span><span class="p">)</span>
     <span class="k">if</span> <span class="ow">not</span> <span class="n">s</span><span class="p">:</span>
@@ -1986,7 +1987,7 @@ disappears:</p>
         <span class="k">yield</span> <span class="n">update</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="p">(</span><span class="n">f_in</span><span class="p">,</span> <span class="n">g_out</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">meta_compose</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">G</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">meta_compose</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">G</span><span class="p">):</span>
     <span class="k">for</span> <span class="n">f</span><span class="p">,</span> <span class="n">g</span> <span class="ow">in</span> <span class="n">product</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">G</span><span class="p">):</span>
         <span class="k">try</span><span class="p">:</span>
             <span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">C</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">):</span>
@@ -2001,7 +2002,7 @@ disappears:</p>
         <span class="k">yield</span> <span class="n">delabel</span><span class="p">(</span><span class="n">fg</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="n">muls</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="n">muls</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -2009,14 +2010,14 @@ disappears:</p>
 <span class="p">(</span><span class="n">i1</span> <span class="o">--</span> <span class="n">i2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="p">[</span><span class="n">sum_</span><span class="p">]):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">dup</span><span class="p">],</span> <span class="p">[</span><span class="n">sum_</span><span class="p">]):</span>
     <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">([</span><span class="n">n1</span><span class="o">*</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="n">n1</span><span class="o">*</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="n">n1</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">cons</span><span class="p">],</span> <span class="p">[</span><span class="n">sum_</span><span class="p">]):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">MC</span><span class="p">([</span><span class="n">cons</span><span class="p">],</span> <span class="p">[</span><span class="n">sum_</span><span class="p">]):</span>
     <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">f</span><span class="p">)</span>
 </pre></div>
 </div>
@@ -2024,7 +2025,7 @@ disappears:</p>
 <span class="p">(</span><span class="n">n1</span> <span class="p">[</span><span class="n">n1</span><span class="o">*</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">n2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sum_</span> <span class="o">=</span> <span class="p">(((</span><span class="n">N</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">Ns</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">])),</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sum_</span> <span class="o">=</span> <span class="p">(((</span><span class="n">N</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">Ns</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">])),</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="p">(</span><span class="n">N</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
 <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">cons</span><span class="p">),</span>
 <span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="o">*</span><span class="n">sum_</span><span class="p">),</span>
 
@@ -2035,21 +2036,21 @@ disappears:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span> <span class="p">[</span><span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="p">[</span><span class="n">a1</span> <span class="o">.</span><span class="mf">1.</span><span class="p">])</span> <span class="p">([</span><span class="n">n1</span> <span class="n">n1</span><span class="o">*</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">n0</span><span class="p">)</span> <span class="p">(</span><span class="n">n1</span> <span class="p">[</span><span class="n">n1</span><span class="o">*</span> <span class="o">.</span><span class="mf">1.</span><span class="p">]</span> <span class="o">--</span> <span class="n">n2</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">4</span><span class="p">],</span> <span class="p">(</span><span class="n">As</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">])))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">4</span><span class="p">],</span> <span class="p">(</span><span class="n">As</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">1</span><span class="p">])))</span>
 <span class="n">a</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a4</span><span class="p">,</span> <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s1</span><span class="p">)))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span>
 <span class="n">b</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="p">(</span><span class="n">a2</span><span class="p">,</span> <span class="n">s2</span><span class="p">))</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">result</span>
 </pre></div>
 </div>
@@ -2057,7 +2058,7 @@ disappears:</p>
 <span class="p">{</span><span class="n">a1</span><span class="p">:</span> <span class="n">a4</span><span class="p">,</span> <span class="n">s2</span><span class="p">:</span> <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">a2</span><span class="p">:</span> <span class="n">a10003</span><span class="p">}</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">unify</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
     <span class="nb">print</span> <span class="n">result</span>
 </pre></div>
 </div>
@@ -2065,10 +2066,10 @@ disappears:</p>
 <span class="p">{</span><span class="n">s2</span><span class="p">:</span> <span class="p">(</span><span class="n">a1</span><span class="o">*</span><span class="p">,</span> <span class="p">(</span><span class="n">a3</span><span class="p">,</span> <span class="n">s1</span><span class="p">)),</span> <span class="n">a2</span><span class="p">:</span> <span class="n">a10004</span><span class="p">,</span> <span class="n">a4</span><span class="p">:</span> <span class="n">a1</span><span class="p">}</span>
 </pre></div>
 </div>
-</div>
-</div>
-</div>
-<div class="section" id="part-vii-typing-combinators">
+</section>
+</section>
+</section>
+<section id="part-vii-typing-combinators">
 <h2>Part VII: Typing Combinators<a class="headerlink" href="#part-vii-typing-combinators" title="Permalink to this headline">¶</a></h2>
 <p>In order to compute the stack effect of combinators you kinda have to
 have the quoted programs they expect available. In the most general
@@ -2095,7 +2096,7 @@ effect other than it expects one quote:</p>
 </div>
 <p>Without any information about the contents of the quote we can’t say
 much about the result.</p>
-<div class="section" id="hybrid-inferencer-interpreter">
+<section id="hybrid-inferencer-interpreter">
 <h3>Hybrid Inferencer/Interpreter<a class="headerlink" href="#hybrid-inferencer-interpreter" title="Permalink to this headline">¶</a></h3>
 <p>I think there’s a way forward. If we convert our list (of terms we are
 composing) into a stack structure we can use it as a <em>Joy expression</em>,
@@ -2105,41 +2106,41 @@ can hybridize the compostition function with an interpreter to evaluate
 combinators, compose non-combinator functions, and put type variables on
 the stack. For combinators like <code class="docutils literal notranslate"><span class="pre">branch</span></code> that can have more than one
 stack effect we have to “split universes” again and return both.</p>
-<div class="section" id="joy-types-for-functions">
+<section id="joy-types-for-functions">
 <h4>Joy Types for Functions<a class="headerlink" href="#joy-types-for-functions" title="Permalink to this headline">¶</a></h4>
 <p>We need a type variable for Joy functions that can go in our expressions
 and be used by the hybrid inferencer/interpreter. They have to store a
 name and a list of stack effects.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">FunctionJoyType</span><span class="p">(</span><span class="n">AnyJoyType</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">FunctionJoyType</span><span class="p">(</span><span class="n">AnyJoyType</span><span class="p">):</span>
 
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">sec</span><span class="p">,</span> <span class="n">number</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">sec</span><span class="p">,</span> <span class="n">number</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">stack_effects</span> <span class="o">=</span> <span class="n">sec</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">=</span> <span class="n">number</span>
 
-    <span class="k">def</span> <span class="nf">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
         <span class="k">return</span> <span class="bp">self</span>
     <span class="fm">__radd__</span> <span class="o">=</span> <span class="fm">__add__</span>
 
-    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="specialized-for-simple-functions-and-combinators">
+</section>
+<section id="specialized-for-simple-functions-and-combinators">
 <h4>Specialized for Simple Functions and Combinators<a class="headerlink" href="#specialized-for-simple-functions-and-combinators" title="Permalink to this headline">¶</a></h4>
 <p>For non-combinator functions the stack effects list contains stack
 effect comments (represented by pairs of cons-lists as described above.)</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">SymbolJoyType</span><span class="p">(</span><span class="n">FunctionJoyType</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">SymbolJoyType</span><span class="p">(</span><span class="n">FunctionJoyType</span><span class="p">):</span>
     <span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;F&#39;</span>
 </pre></div>
 </div>
 <p>For combinators the list contains Python functions.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">CombinatorJoyType</span><span class="p">(</span><span class="n">FunctionJoyType</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">CombinatorJoyType</span><span class="p">(</span><span class="n">FunctionJoyType</span><span class="p">):</span>
 
     <span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;C&#39;</span>
 
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">sec</span><span class="p">,</span> <span class="n">number</span><span class="p">,</span> <span class="n">expect</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">sec</span><span class="p">,</span> <span class="n">number</span><span class="p">,</span> <span class="n">expect</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
         <span class="nb">super</span><span class="p">(</span><span class="n">CombinatorJoyType</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">sec</span><span class="p">,</span> <span class="n">number</span><span class="p">)</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">expect</span> <span class="o">=</span> <span class="n">expect</span>
 
@@ -2154,7 +2155,7 @@ effect comments (represented by pairs of cons-lists as described above.)</p>
 </div>
 <p>For simple combinators that have only one effect (like <code class="docutils literal notranslate"><span class="pre">dip</span></code>) you only
 need one function and it can be the combinator itself.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.library</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">joy.library</span>
 
 <span class="n">dip</span> <span class="o">=</span> <span class="n">CombinatorJoyType</span><span class="p">(</span><span class="s1">&#39;dip&#39;</span><span class="p">,</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> <span class="mi">23</span><span class="p">)</span>
 </pre></div>
@@ -2162,7 +2163,7 @@ need one function and it can be the combinator itself.</p>
 <p>For combinators that can have more than one effect (like <code class="docutils literal notranslate"><span class="pre">branch</span></code>) you
 have to write functions that each implement the action of one of the
 effects.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">branch_true</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>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">branch_true</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">):</span>
     <span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="p">(</span><span class="n">else_</span><span class="p">,</span> <span class="p">(</span><span class="n">flag</span><span class="p">,</span> <span class="n">stack</span><span class="p">)))</span> <span class="o">=</span> <span class="n">stack</span>
     <span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">concat</span><span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">expression</span><span class="p">),</span> <span class="n">dictionary</span>
 
@@ -2177,8 +2178,8 @@ effects.</p>
 will then be used as an identity function (that accepts and returns
 stacks that match the “guard” stack effect) which will be used to guard
 against type mismatches going into the evaluation of the combinator.</p>
-</div>
-<div class="section" id="infer">
+</section>
+<section id="infer">
 <h4><code class="docutils literal notranslate"><span class="pre">infer()</span></code><a class="headerlink" href="#infer" title="Permalink to this headline">¶</a></h4>
 <p>With those in place, we can define a function that accepts a sequence of
 Joy type variables, including ones representing functions (not just
@@ -2188,7 +2189,7 @@ that expression.</p>
 updated along with the stack effects after doing unification or we risk
 losing useful information. This was a straightforward, if awkward,
 modification to the call structure of <code class="docutils literal notranslate"><span class="pre">meta_compose()</span></code> et. al.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ID</span> <span class="o">=</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># Identity function.</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">ID</span> <span class="o">=</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># Identity function.</span>
 
 
 <span class="k">def</span> <span class="nf">infer</span><span class="p">(</span><span class="o">*</span><span class="n">expression</span><span class="p">):</span>
@@ -2238,8 +2239,8 @@ modification to the call structure of <code class="docutils literal notranslate"
         <span class="p">)</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="work-in-progress">
+</section>
+<section id="work-in-progress">
 <h4>Work in Progress<a class="headerlink" href="#work-in-progress" title="Permalink to this headline">¶</a></h4>
 <p>And that brings us to current Work-In-Progress. The mixed-mode
 inferencer/interpreter <code class="docutils literal notranslate"><span class="pre">infer()</span></code> function seems to work well. There
@@ -2248,7 +2249,7 @@ module (FIXME link to its docs here!) should be explained… There is
 cruft to convert the definitions in <code class="docutils literal notranslate"><span class="pre">DEFS</span></code> to the new
 <code class="docutils literal notranslate"><span class="pre">SymbolJoyType</span></code> objects, and some combinators. Here is an example of
 output from the current code :</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span><span class="o">/</span><span class="mi">0</span>  <span class="c1"># (Don&#39;t try to run this cell!  It&#39;s not going to work.  This is &quot;read only&quot; code heh..)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span><span class="o">/</span><span class="mi">0</span>  <span class="c1"># (Don&#39;t try to run this cell!  It&#39;s not going to work.  This is &quot;read only&quot; code heh..)</span>
 
 <span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">(</span><span class="nb">format</span><span class="o">=</span><span class="s1">&#39;</span><span class="si">%(message)s</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">stream</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
 
@@ -2322,39 +2323,41 @@ implementation in action.</p>
 (i2 i1 -- i3)
 </pre></div>
 </div>
-</div>
-</div>
-</div>
-<div class="section" id="conclusion">
+</section>
+</section>
+</section>
+<section id="conclusion">
 <h2>Conclusion<a class="headerlink" href="#conclusion" title="Permalink to this headline">¶</a></h2>
 <p>We built a simple type inferencer, and a kind of crude “compiler” for a
 subset of Joy functions. Then we built a more powerful inferencer that
 actually does some evaluation and explores branching code paths</p>
 <p>Work remains to be done:</p>
 <ul class="simple">
-<li>the rest of the library has to be covered</li>
-<li>figure out how to deal with <code class="docutils literal notranslate"><span class="pre">loop</span></code> and <code class="docutils literal notranslate"><span class="pre">genrec</span></code>, etc..</li>
-<li>extend the types to check values (see the appendix)</li>
-<li>other kinds of “higher order” type variables, OR, AND, etc..</li>
-<li>maybe rewrite in Prolog for great good?</li>
-<li>definitions<ul>
-<li>don’t permit composition of functions that don’t compose</li>
-<li>auto-compile compilable functions</li>
+<li><p>the rest of the library has to be covered</p></li>
+<li><p>figure out how to deal with <code class="docutils literal notranslate"><span class="pre">loop</span></code> and <code class="docutils literal notranslate"><span class="pre">genrec</span></code>, etc..</p></li>
+<li><p>extend the types to check values (see the appendix)</p></li>
+<li><p>other kinds of “higher order” type variables, OR, AND, etc..</p></li>
+<li><p>maybe rewrite in Prolog for great good?</p></li>
+<li><p>definitions</p>
+<ul>
+<li><p>don’t permit composition of functions that don’t compose</p></li>
+<li><p>auto-compile compilable functions</p></li>
 </ul>
 </li>
-<li>Compiling more than just the Yin functions.</li>
-<li>getting better visibility (than Python debugger.)</li>
-<li>DOOOOCS!!!! Lots of docs!<ul>
-<li>docstrings all around</li>
-<li>improve this notebook (it kinda falls apart at the end
+<li><p>Compiling more than just the Yin functions.</p></li>
+<li><p>getting better visibility (than Python debugger.)</p></li>
+<li><p>DOOOOCS!!!! Lots of docs!</p>
+<ul>
+<li><p>docstrings all around</p></li>
+<li><p>improve this notebook (it kinda falls apart at the end
 narratively. I went off and just started writing code to see if it
 would work. It does, but now I have to come back and describe here
-what I did.</li>
+what I did.</p></li>
 </ul>
 </li>
 </ul>
-</div>
-<div class="section" id="appendix-joy-in-the-logical-paradigm">
+</section>
+<section id="appendix-joy-in-the-logical-paradigm">
 <h2>Appendix: Joy in the Logical Paradigm<a class="headerlink" href="#appendix-joy-in-the-logical-paradigm" title="Permalink to this headline">¶</a></h2>
 <p>For <em>type checking</em> to work the type label classes have to be modified
 to let <code class="docutils literal notranslate"><span class="pre">T</span> <span class="pre">&gt;=</span> <span class="pre">t</span></code> succeed, where e.g. <code class="docutils literal notranslate"><span class="pre">T</span></code> is <code class="docutils literal notranslate"><span class="pre">IntJoyType</span></code> and <code class="docutils literal notranslate"><span class="pre">t</span></code>
@@ -2363,7 +2366,7 @@ relational</em> nature of the stack effect comments to “compute in reverse”
 as it were. There’s a working demo of this at the end of the <code class="docutils literal notranslate"><span class="pre">types</span></code>
 module. But if you’re interested in all that you should just use Prolog!</p>
 <p>Anyhow, type <em>checking</em> is a few easy steps away.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">_ge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">_ge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
     <span class="k">return</span> <span class="p">(</span><span class="nb">issubclass</span><span class="p">(</span><span class="n">other</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span>
             <span class="ow">or</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">&#39;accept&#39;</span><span class="p">)</span>
             <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">accept</span><span class="p">))</span>
@@ -2373,105 +2376,55 @@ module. But if you’re interested in all that you should just use Prolog!</p>
 <span class="n">StackJoyType</span><span class="o">.</span><span class="n">accept</span> <span class="o">=</span> <span class="nb">tuple</span>
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">The Blissful Elegance of Typing Joy</a><ul>
-<li><a class="reference internal" href="#part-i-poials-rules">Part I: Pöial’s Rules</a><ul>
-<li><a class="reference internal" href="#first-rule">First Rule</a></li>
-<li><a class="reference internal" href="#second-rule">Second Rule</a></li>
-<li><a class="reference internal" href="#third-rule">Third Rule</a></li>
-<li><a class="reference internal" href="#stack-effect-comments">Stack Effect Comments</a></li>
-<li><a class="reference internal" href="#pop-swap"><code class="docutils literal notranslate"><span class="pre">pop</span> <span class="pre">swap</span></code></a></li>
-<li><a class="reference internal" href="#popswap-roll"><code class="docutils literal notranslate"><span class="pre">pop∘swap</span> <span class="pre">roll&lt;</span></code></a></li>
-<li><a class="reference internal" href="#compiling-popswaproll">Compiling <code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;</span></code></a></li>
-<li><a class="reference internal" href="#functions-on-stacks">Functions on Stacks</a></li>
-<li><a class="reference internal" href="#popswaproll-rest"><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;</span> <span class="pre">rest</span></code></a></li>
-<li><a class="reference internal" href="#popswaproll-rest-rest"><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;∘rest</span> <span class="pre">rest</span></code></a></li>
-<li><a class="reference internal" href="#popswaproll-restrest-cons"><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;∘rest∘rest</span> <span class="pre">cons</span></code></a></li>
-<li><a class="reference internal" href="#popswaproll-restrestcons-cons"><code class="docutils literal notranslate"><span class="pre">pop∘swap∘roll&lt;∘rest∘rest∘cons</span> <span class="pre">cons</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#part-ii-implementation">Part II: Implementation</a><ul>
-<li><a class="reference internal" href="#representing-stack-effect-comments-in-python">Representing Stack Effect Comments in Python</a></li>
-<li><a class="reference internal" href="#compose"><code class="docutils literal notranslate"><span class="pre">compose()</span></code></a></li>
-<li><a class="reference internal" href="#unify"><code class="docutils literal notranslate"><span class="pre">unify()</span></code></a></li>
-<li><a class="reference internal" href="#update"><code class="docutils literal notranslate"><span class="pre">update()</span></code></a></li>
-<li><a class="reference internal" href="#relabel"><code class="docutils literal notranslate"><span class="pre">relabel()</span></code></a></li>
-<li><a class="reference internal" href="#delabel"><code class="docutils literal notranslate"><span class="pre">delabel()</span></code></a></li>
-<li><a class="reference internal" href="#c"><code class="docutils literal notranslate"><span class="pre">C()</span></code></a></li>
-<li><a class="reference internal" href="#stack-functions">Stack Functions</a></li>
-<li><a class="reference internal" href="#dealing-with-cons-and-uncons">Dealing with <code class="docutils literal notranslate"><span class="pre">cons</span></code> and <code class="docutils literal notranslate"><span class="pre">uncons</span></code></a><ul>
-<li><a class="reference internal" href="#unify-version-2"><code class="docutils literal notranslate"><span class="pre">unify()</span></code> version 2</a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#part-iii-compiling-yin-functions">Part III: Compiling Yin Functions</a><ul>
-<li><a class="reference internal" href="#python-identifiers">Python Identifiers</a></li>
-<li><a class="reference internal" href="#doc-from-stack-effect"><code class="docutils literal notranslate"><span class="pre">doc_from_stack_effect()</span></code></a></li>
-<li><a class="reference internal" href="#compile"><code class="docutils literal notranslate"><span class="pre">compile_()</span></code></a></li>
-<li><a class="reference internal" href="#compiling-library-functions">Compiling Library Functions</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#part-iv-types-and-subtypes-of-arguments">Part IV: Types and Subtypes of Arguments</a><ul>
-<li><a class="reference internal" href="#number-type">“Number” Type</a></li>
-<li><a class="reference internal" href="#distinguishing-numbers">Distinguishing Numbers</a></li>
-<li><a class="reference internal" href="#distinguishing-types">Distinguishing Types</a></li>
-<li><a class="reference internal" href="#typing-sqr">Typing <code class="docutils literal notranslate"><span class="pre">sqr</span></code></a></li>
-<li><a class="reference internal" href="#modifying-the-inferencer">Modifying the Inferencer</a><ul>
-<li><a class="reference internal" href="#delabel-version-2"><code class="docutils literal notranslate"><span class="pre">delabel()</span></code> version 2</a></li>
-<li><a class="reference internal" href="#unify-version-3"><code class="docutils literal notranslate"><span class="pre">unify()</span></code> version 3</a></li>
-<li><a class="reference internal" href="#compose-dup-and-mul">Compose <code class="docutils literal notranslate"><span class="pre">dup</span></code> and <code class="docutils literal notranslate"><span class="pre">mul</span></code></a></li>
-<li><a class="reference internal" href="#compile-version-2"><code class="docutils literal notranslate"><span class="pre">compile_()</span></code> version 2</a></li>
-<li><a class="reference internal" href="#compilable"><code class="docutils literal notranslate"><span class="pre">compilable()</span></code></a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#part-v-functions-that-use-the-stack">Part V: Functions that use the Stack</a><ul>
-<li><a class="reference internal" href="#stackuncons"><code class="docutils literal notranslate"><span class="pre">stack∘uncons</span></code></a></li>
-<li><a class="reference internal" href="#stackunconsuncons"><code class="docutils literal notranslate"><span class="pre">stack∘uncons∘uncons</span></code></a><ul>
-<li><a class="reference internal" href="#compose-version-2"><code class="docutils literal notranslate"><span class="pre">compose()</span></code> version 2</a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#doc-from-stack-effect-version-2"><code class="docutils literal notranslate"><span class="pre">doc_from_stack_effect()</span></code> version 2</a><ul>
-<li><a class="reference internal" href="#compile-version-3"><code class="docutils literal notranslate"><span class="pre">compile_()</span></code> version 3</a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#part-vi-multiple-stack-effects">Part VI: Multiple Stack Effects</a><ul>
-<li><a class="reference internal" href="#representing-an-unbounded-sequence-of-types">Representing an Unbounded Sequence of Types</a><ul>
-<li><a class="reference internal" href="#unify-version-4"><code class="docutils literal notranslate"><span class="pre">unify()</span></code> version 4</a></li>
-<li><a class="reference internal" href="#compose-version-3"><code class="docutils literal notranslate"><span class="pre">compose()</span></code> version 3</a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#part-vii-typing-combinators">Part VII: Typing Combinators</a><ul>
-<li><a class="reference internal" href="#hybrid-inferencer-interpreter">Hybrid Inferencer/Interpreter</a><ul>
-<li><a class="reference internal" href="#joy-types-for-functions">Joy Types for Functions</a></li>
-<li><a class="reference internal" href="#specialized-for-simple-functions-and-combinators">Specialized for Simple Functions and Combinators</a></li>
-<li><a class="reference internal" href="#infer"><code class="docutils literal notranslate"><span class="pre">infer()</span></code></a></li>
-<li><a class="reference internal" href="#work-in-progress">Work in Progress</a></li>
-</ul>
-</li>
-</ul>
-</li>
-<li><a class="reference internal" href="#conclusion">Conclusion</a></li>
-<li><a class="reference internal" href="#appendix-joy-in-the-logical-paradigm">Appendix: Joy in the Logical Paradigm</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -2483,25 +2436,24 @@ module. But if you’re interested in all that you should just use Prolog!</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Types.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -2512,7 +2464,7 @@ module. But if you’re interested in all that you should just use Prolog!</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index d38e5b8..4653021 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Traversing Datastructures with Zippers &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="The Blissful Elegance of Typing Joy" href="Types.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="traversing-datastructures-with-zippers">
+  <section id="traversing-datastructures-with-zippers">
 <h1>Traversing Datastructures with Zippers<a class="headerlink" href="#traversing-datastructures-with-zippers" title="Permalink to this headline">¶</a></h1>
 <p>This notebook is about using the “zipper” with joy datastructures. See
 the <a class="reference external" href="https://en.wikipedia.org/wiki/Zipper_%28data_structure%29">Zipper wikipedia
@@ -41,24 +42,24 @@ the original paper: <a class="reference external" href="https://www.st.cs.uni-sa
 Huet</a></p>
 <p>Given a datastructure on the stack we can navigate through it, modify
 it, and rebuild it using the “zipper” technique.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="k">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">notebook_preamble</span> <span class="kn">import</span> <span class="n">J</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">define</span>
 </pre></div>
 </div>
-<div class="section" id="trees">
+<section id="trees">
 <h2>Trees<a class="headerlink" href="#trees" title="Permalink to this headline">¶</a></h2>
 <p>In Joypy there aren’t any complex datastructures, just ints, floats,
 strings, Symbols (strings that are names of functions) and sequences
 (aka lists, aka quoted literals, aka aggregates, etc…), but we can build
 <a class="reference external" href="https://en.wikipedia.org/wiki/Tree_%28data_structure%29">trees</a> out
 of sequences.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8]&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8]&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">8</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="zipper-in-joy">
+</section>
+<section id="zipper-in-joy">
 <h2>Zipper in Joy<a class="headerlink" href="#zipper-in-joy" title="Permalink to this headline">¶</a></h2>
 <p>Zippers work by keeping track of the current item, the already-seen
 items, and the yet-to-be seen items as you traverse a datastructure (the
@@ -74,13 +75,13 @@ datastructure used to keep track of these items is the zipper.)</p>
 show the trace so you can see how it works. If we were going to use
 these a lot it would make sense to write Python versions for efficiency,
 but see below.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;z-down == [] swap uncons swap&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;z-down == [] swap uncons swap&#39;</span><span class="p">)</span>
 <span class="n">define</span><span class="p">(</span><span class="s1">&#39;z-up == swons swap shunt&#39;</span><span class="p">)</span>
 <span class="n">define</span><span class="p">(</span><span class="s1">&#39;z-right == [swons] cons dip uncons swap&#39;</span><span class="p">)</span>
 <span class="n">define</span><span class="p">(</span><span class="s1">&#39;z-left == swons [uncons swap] dip swap&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8] z-down&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8] z-down&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                          <span class="o">.</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="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">8</span><span class="p">]</span> <span class="n">z</span><span class="o">-</span><span class="n">down</span>
@@ -92,7 +93,7 @@ but see below.</p>
 <span class="p">[]</span> <span class="p">[[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">8</span><span class="p">]</span> <span class="mi">1</span> <span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[] [[2 [3 4 25 6] 7] 8] 1 z-right&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[] [[2 [3 4 25 6] 7] 8] 1 z-right&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                  <span class="o">.</span> <span class="p">[]</span> <span class="p">[[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">8</span><span class="p">]</span> <span class="mi">1</span> <span class="n">z</span><span class="o">-</span><span class="n">right</span>
@@ -112,43 +113,43 @@ but see below.</p>
          <span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</span><span class="p">]</span> <span class="p">[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2 [3 4 25 6] 7] z-down&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2 [3 4 25 6] 7] z-down&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">2</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [] [[3 4 25 6] 7] 2 z-right&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [] [[3 4 25 6] 7] 2 z-right&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</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">7</span><span class="p">]</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [3 4 25 6] z-down&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [3 4 25 6] z-down&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</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">7</span><span class="p">]</span> <span class="p">[]</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">3</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [] [4 25 6] 3 z-right&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [] [4 25 6] 3 z-right&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</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">7</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">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">4</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [3] [25 6] 4 z-right&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [3] [25 6] 4 z-right&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</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">7</span><span class="p">]</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">3</span><span class="p">]</span> <span class="p">[</span><span class="mi">6</span><span class="p">]</span> <span class="mi">25</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [4 3] [6] 25 sqr&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [4 3] [6] 25 sqr&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</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">7</span><span class="p">]</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">3</span><span class="p">]</span> <span class="p">[</span><span class="mi">6</span><span class="p">]</span> <span class="mi">625</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [4 3] [6] 625 z-up&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [4 3] [6] 625 z-up&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                              <span class="o">.</span> <span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</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">7</span><span class="p">]</span> <span class="p">[</span><span class="mi">4</span> <span class="mi">3</span><span class="p">]</span> <span class="p">[</span><span class="mi">6</span><span class="p">]</span> <span class="mi">625</span> <span class="n">z</span><span class="o">-</span><span class="n">up</span>
@@ -167,24 +168,24 @@ but see below.</p>
   <span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</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">7</span><span class="p">]</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">625</span> <span class="mi">6</span><span class="p">]</span> <span class="o">.</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [3 4 625 6] z-up&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2] [7] [3 4 625 6] z-up&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">8</span><span class="p">]</span> <span class="p">[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">625</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span>
 </pre></div>
 </div>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2 [3 4 625 6] 7] z-up&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1] [8] [2 [3 4 625 6] 7] z-up&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">625</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">8</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="dip-and-infra">
+</section>
+<section id="dip-and-infra">
 <h2><code class="docutils literal notranslate"><span class="pre">dip</span></code> and <code class="docutils literal notranslate"><span class="pre">infra</span></code><a class="headerlink" href="#dip-and-infra" title="Permalink to this headline">¶</a></h2>
 <p>In Joy we have the <code class="docutils literal notranslate"><span class="pre">dip</span></code> and <code class="docutils literal notranslate"><span class="pre">infra</span></code> combinators which can “target”
 or “address” any particular item in a Joy tree structure.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8] [[[[[[sqr] dipd] infra] dip] infra] dip] infra&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8] [[[[[[sqr] dipd] infra] dip] infra] dip] infra&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                                                                <span class="o">.</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="mi">4</span> <span class="mi">25</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">8</span><span class="p">]</span> <span class="p">[[[[[[</span><span class="n">sqr</span><span class="p">]</span> <span class="n">dipd</span><span class="p">]</span> <span class="n">infra</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span> <span class="n">infra</span><span class="p">]</span> <span class="n">dip</span><span class="p">]</span> <span class="n">infra</span>
@@ -222,8 +223,8 @@ the subject datastructure. Instead of maintaining temporary results on
 the stack they are pushed into the pending expression (continuation).
 When <code class="docutils literal notranslate"><span class="pre">sqr</span></code> has run the rest of the pending expression rebuilds the
 datastructure.</p>
-</div>
-<div class="section" id="z">
+</section>
+<section id="z">
 <h2><code class="docutils literal notranslate"><span class="pre">Z</span></code><a class="headerlink" href="#z" title="Permalink to this headline">¶</a></h2>
 <p>Imagine a function <code class="docutils literal notranslate"><span class="pre">Z</span></code> that accepts a sequence of <code class="docutils literal notranslate"><span class="pre">dip</span></code> and
 <code class="docutils literal notranslate"><span class="pre">infra</span></code> combinators, a quoted program <code class="docutils literal notranslate"><span class="pre">[Q]</span></code>, and a datastructure to
@@ -235,11 +236,11 @@ been embedded in a nested series of quoted programs, e.g.:</p>
 </pre></div>
 </div>
 <p>The <code class="docutils literal notranslate"><span class="pre">Z</span></code> function isn’t hard to make.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Z == [[] cons cons] step i&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">define</span><span class="p">(</span><span class="s1">&#39;Z == [[] cons cons] step i&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>Here it is in action in a simplified scenario.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 [2 3 4] Z&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">V</span><span class="p">(</span><span class="s1">&#39;1 [2 3 4] Z&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>                             <span class="o">.</span> <span class="mi">1</span> <span class="p">[</span><span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span><span class="p">]</span> <span class="n">Z</span>
@@ -272,14 +273,14 @@ been embedded in a nested series of quoted programs, e.g.:</p>
 </pre></div>
 </div>
 <p>And here it is doing the main thing.</p>
-<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8] [sqr] [dip dip infra dip infra dip infra] Z&#39;</span><span class="p">)</span>
+<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">J</span><span class="p">(</span><span class="s1">&#39;[1 [2 [3 4 25 6] 7] 8] [sqr] [dip dip infra dip infra dip infra] Z&#39;</span><span class="p">)</span>
 </pre></div>
 </div>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span> <span class="p">[</span><span class="mi">2</span> <span class="p">[</span><span class="mi">3</span> <span class="mi">4</span> <span class="mi">625</span> <span class="mi">6</span><span class="p">]</span> <span class="mi">7</span><span class="p">]</span> <span class="mi">8</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="addressing">
+</section>
+<section id="addressing">
 <h2>Addressing<a class="headerlink" href="#addressing" title="Permalink to this headline">¶</a></h2>
 <p>Because we are only using two combinators we could replace the list with
 a string made from only two characters.</p>
@@ -290,8 +291,8 @@ a string made from only two characters.</p>
 </div>
 <p>The string can be considered a name or address for an item in the
 subject datastructure.</p>
-</div>
-<div class="section" id="determining-the-right-path-for-an-item-in-a-tree">
+</section>
+<section id="determining-the-right-path-for-an-item-in-a-tree">
 <h2>Determining the right “path” for an item in a tree.<a class="headerlink" href="#determining-the-right-path-for-an-item-in-a-tree" title="Permalink to this headline">¶</a></h2>
 <p>It’s easy to read off (in reverse) the right sequence of “d” and “i”
 from the subject datastructure:</p>
@@ -299,27 +300,55 @@ from the subject datastructure:</p>
 i d i d i d d Bingo!
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Traversing Datastructures with Zippers</a><ul>
-<li><a class="reference internal" href="#trees">Trees</a></li>
-<li><a class="reference internal" href="#zipper-in-joy">Zipper in Joy</a></li>
-<li><a class="reference internal" href="#dip-and-infra"><code class="docutils literal notranslate"><span class="pre">dip</span></code> and <code class="docutils literal notranslate"><span class="pre">infra</span></code></a></li>
-<li><a class="reference internal" href="#z"><code class="docutils literal notranslate"><span class="pre">Z</span></code></a></li>
-<li><a class="reference internal" href="#addressing">Addressing</a></li>
-<li><a class="reference internal" href="#determining-the-right-path-for-an-item-in-a-tree">Determining the right “path” for an item in a tree.</a></li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -331,25 +360,24 @@ i d i d i d d Bingo!
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/Zipper.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -360,7 +388,7 @@ i d i d i d d Bingo!
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index c8887e7..6ab069e 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Essays about Programming in Joy &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
     <link rel="next" title="Developing a Program in Joy" href="Developing.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="essays-about-programming-in-joy">
+  <section id="essays-about-programming-in-joy">
 <h1>Essays about Programming in Joy<a class="headerlink" href="#essays-about-programming-in-joy" title="Permalink to this headline">¶</a></h1>
 <p>These essays are adapted from Jupyter notebooks.  I hope to have those hosted somewhere where people can view them “live” and interact with them, possibly on MS Azure.  For now, Sphinx does such a great job rendering the HTML that I am copying over some notebooks in ReST format and hand-editing them into these documents.</p>
 <div class="toctree-wrapper compound">
 </li>
 </ul>
 </div>
-</div>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Essays about Programming in Joy</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2"><a class="reference internal" href="The_Four_Operations.html">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
+</ul>
+</li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../index.html">Documentation overview</a><ul>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/index.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index b536469..b356b95 100644 (file)
Binary files a/docs/sphinx_docs/_build/html/objects.inv and b/docs/sphinx_docs/_build/html/objects.inv differ
index 8d3d8e1..99c6be7 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Parsing Text into Joy Expressions &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Tracing Joy Execution" href="pretty.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="parsing-text-into-joy-expressions">
+  <section id="parsing-text-into-joy-expressions">
 <h1>Parsing Text into Joy Expressions<a class="headerlink" href="#parsing-text-into-joy-expressions" title="Permalink to this headline">¶</a></h1>
 <p>TODO: example…</p>
-<div class="section" id="module-joy.parser">
+<section id="module-joy.parser">
 <span id="joy-parser"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.parser</span></code><a class="headerlink" href="#module-joy.parser" title="Permalink to this headline">¶</a></h2>
 <p>This module exports a single function for converting text to a joy
 expression as well as a single Symbol class and a single Exception type.</p>
@@ -51,60 +52,78 @@ literal value (integer, float, string, or Joy expression) or a function
 symbol.  Function symbols are unquoted strings and cannot contain square
 brackets.   Terms must be separated by blanks, which can be omitted
 around square brackets.</p>
-<dl class="exception">
-<dt id="joy.parser.ParseError">
-<em class="property">exception </em><code class="descclassname">joy.parser.</code><code class="descname">ParseError</code><a class="reference internal" href="_modules/joy/parser.html#ParseError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.parser.ParseError" title="Permalink to this definition">¶</a></dt>
+<dl class="py exception">
+<dt class="sig sig-object py" id="joy.parser.ParseError">
+<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">joy.parser.</span></span><span class="sig-name descname"><span class="pre">ParseError</span></span><a class="reference internal" href="_modules/joy/parser.html#ParseError"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.parser.ParseError" title="Permalink to this definition">¶</a></dt>
 <dd><p>Raised when there is a error while parsing text.</p>
 </dd></dl>
 
-<dl class="class">
-<dt id="joy.parser.Symbol">
-<em class="property">class </em><code class="descclassname">joy.parser.</code><code class="descname">Symbol</code><a class="reference internal" href="_modules/joy/parser.html#Symbol"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.parser.Symbol" title="Permalink to this definition">¶</a></dt>
+<dl class="py class">
+<dt class="sig sig-object py" id="joy.parser.Symbol">
+<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">joy.parser.</span></span><span class="sig-name descname"><span class="pre">Symbol</span></span><a class="reference internal" href="_modules/joy/parser.html#Symbol"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.parser.Symbol" title="Permalink to this definition">¶</a></dt>
 <dd><p>A string class that represents Joy function names.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.parser.text_to_expression">
-<code class="descclassname">joy.parser.</code><code class="descname">text_to_expression</code><span class="sig-paren">(</span><em>text</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/parser.html#text_to_expression"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.parser.text_to_expression" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.parser.text_to_expression">
+<span class="sig-prename descclassname"><span class="pre">joy.parser.</span></span><span class="sig-name descname"><span class="pre">text_to_expression</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/parser.html#text_to_expression"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.parser.text_to_expression" title="Permalink to this definition">¶</a></dt>
 <dd><p>Convert a string to a Joy expression.</p>
 <p>When supplied with a string this function returns a Python datastructure
 that represents the Joy datastructure described by the text expression.
 Any unbalanced square brackets will raise a ParseError.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>text</strong> (<em>str</em>) – Text to convert.</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">stack</td>
-</tr>
-<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><a class="reference internal" href="#joy.parser.ParseError" title="joy.parser.ParseError"><strong>ParseError</strong></a> – if the parse fails.</td>
-</tr>
-</tbody>
-</table>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to convert.</p>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>stack</p>
+</dd>
+<dt class="field-odd">Raises</dt>
+<dd class="field-odd"><p><a class="reference internal" href="#joy.parser.ParseError" title="joy.parser.ParseError"><strong>ParseError</strong></a> – if the parse fails.</p>
+</dd>
+</dl>
 </dd></dl>
 
-</div>
-<div class="section" id="parser-internals">
+</section>
+<section id="parser-internals">
 <h2>Parser Internals<a class="headerlink" href="#parser-internals" title="Permalink to this headline">¶</a></h2>
 <p>TODO: Document things like the regular expressions used for tokenizing, and the re.Scanner, etc…</p>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Parsing Text into Joy Expressions</a><ul>
-<li><a class="reference internal" href="#module-joy.parser"><code class="docutils literal notranslate"><span class="pre">joy.parser</span></code></a></li>
-<li><a class="reference internal" href="#parser-internals">Parser Internals</a></li>
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Parsing Text into Joy Expressions</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#module-joy.parser"><code class="docutils literal notranslate"><span class="pre">joy.parser</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="#parser-internals">Parser Internals</a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -114,25 +133,24 @@ Any unbalanced square brackets will raise a ParseError.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/parser.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -143,7 +161,7 @@ Any unbalanced square brackets will raise a ParseError.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index f393797..9ac1af8 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Tracing Joy Execution &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Function Reference" href="library.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="tracing-joy-execution">
+  <section id="tracing-joy-execution">
 <h1>Tracing Joy Execution<a class="headerlink" href="#tracing-joy-execution" title="Permalink to this headline">¶</a></h1>
-<div class="section" id="module-joy.utils.pretty_print">
+<section id="module-joy.utils.pretty_print">
 <span id="joy-utils-pretty-print"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.utils.pretty_print</span></code><a class="headerlink" href="#module-joy.utils.pretty_print" title="Permalink to this headline">¶</a></h2>
 <p>Pretty printing support, e.g.:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Joy? [23 18 * 99 +] trace
@@ -53,89 +54,97 @@ joy?
 <p>On each line the stack is printed with the top to the left, then a
 bullet symbol,``•<a href="#id1"><span class="problematic" id="id2">``</span></a>, to represent the current locus of processing, then
 the pending expression to the right.</p>
-<dl class="class">
-<dt id="joy.utils.pretty_print.TracePrinter">
-<em class="property">class </em><code class="descclassname">joy.utils.pretty_print.</code><code class="descname">TracePrinter</code><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter" title="Permalink to this definition">¶</a></dt>
+<dl class="py class">
+<dt class="sig sig-object py" id="joy.utils.pretty_print.TracePrinter">
+<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">joy.utils.pretty_print.</span></span><span class="sig-name descname"><span class="pre">TracePrinter</span></span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter" title="Permalink to this definition">¶</a></dt>
 <dd><p>This is what does the formatting.  You instantiate it and pass the <code class="docutils literal notranslate"><span class="pre">viewer()</span></code>
 method to the <a class="reference internal" href="joy.html#joy.joy.joy" title="joy.joy.joy"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.joy.joy()</span></code></a> function, then print it to see the
 trace.</p>
-<dl class="method">
-<dt id="joy.utils.pretty_print.TracePrinter.go">
-<code class="descname">go</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter.go"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.go" title="Permalink to this definition">¶</a></dt>
+<dl class="py method">
+<dt class="sig sig-object py" id="joy.utils.pretty_print.TracePrinter.go">
+<span class="sig-name descname"><span class="pre">go</span></span><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"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.go" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return a list of strings, one for each entry in the history, prefixed
 with enough spaces to align all the interpreter dots.</p>
 <p>This method is called internally by the <code class="docutils literal notranslate"><span class="pre">__str__()</span></code> method.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list(str)</td>
-</tr>
-</tbody>
-</table>
+<dl class="field-list simple">
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p>list(str)</p>
+</dd>
+</dl>
 </dd></dl>
 
-<dl class="method">
-<dt id="joy.utils.pretty_print.TracePrinter.viewer">
-<code class="descname">viewer</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter.viewer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.viewer" title="Permalink to this definition">¶</a></dt>
+<dl class="py method">
+<dt class="sig sig-object py" id="joy.utils.pretty_print.TracePrinter.viewer">
+<span class="sig-name descname"><span class="pre">viewer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter.viewer"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.viewer" title="Permalink to this definition">¶</a></dt>
 <dd><p>Record the current stack and expression in the TracePrinter’s history.
 Pass this method as the <code class="docutils literal notranslate"><span class="pre">viewer</span></code> argument to the <a class="reference internal" href="joy.html#joy.joy.joy" title="joy.joy.joy"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.joy.joy()</span></code></a> function.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
-<li><strong>quote</strong> (<em>stack</em>) – A stack.</li>
-<li><strong>expression</strong> (<em>stack</em>) – A stack.</li>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>quote</strong> (<em>stack</em>) – A stack.</p></li>
+<li><p><strong>expression</strong> (<em>stack</em>) – A stack.</p></li>
 </ul>
-</td>
-</tr>
-</tbody>
-</table>
+</dd>
+</dl>
 </dd></dl>
 
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.pretty_print.trace">
-<code class="descclassname">joy.utils.pretty_print.</code><code class="descname">trace</code><span class="sig-paren">(</span><em>stack</em>, <em>expression</em>, <em>dictionary</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#trace"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.pretty_print.trace" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.pretty_print.trace">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.pretty_print.</span></span><span class="sig-name descname"><span class="pre">trace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#trace"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.trace" title="Permalink to this definition">¶</a></dt>
 <dd><p>Evaluate a Joy expression on a stack and print a trace.</p>
 <p>This function is just like the <cite>i</cite> combinator but it also prints a
 trace of the evaluation</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
-<li><strong>stack</strong> (<em>stack</em>) – The stack.</li>
-<li><strong>expression</strong> (<em>stack</em>) – The expression to evaluate.</li>
-<li><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</li>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>stack</strong> (<em>stack</em>) – The stack.</p></li>
+<li><p><strong>expression</strong> (<em>stack</em>) – The expression to evaluate.</p></li>
+<li><p><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</p></li>
 </ul>
-</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(stack, (), dictionary)</p>
-</td>
-</tr>
-</tbody>
-</table>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>(stack, (), dictionary)</p>
+</dd>
+</dl>
 </dd></dl>
 
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Tracing Joy Execution</a><ul>
-<li><a class="reference internal" href="#module-joy.utils.pretty_print"><code class="docutils literal notranslate"><span class="pre">joy.utils.pretty_print</span></code></a></li>
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Tracing Joy Execution</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#module-joy.utils.pretty_print"><code class="docutils literal notranslate"><span class="pre">joy.utils.pretty_print</span></code></a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -145,25 +154,24 @@ trace of the evaluation</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/pretty.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -174,7 +182,7 @@ trace of the evaluation</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 569ddf3..7c96010 100644 (file)
@@ -1,19 +1,17 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Python Module Index &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
 
@@ -31,6 +29,8 @@
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
 
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="index.html">Documentation overview</a><ul>
 </ul>
 </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index 0505c47..cb9bd5d 100644 (file)
@@ -1,27 +1,23 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Search &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-    <script type="text/javascript" src="_static/searchtools.js"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
+    <script src="_static/searchtools.js"></script>
+    <script src="_static/language_data.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="#" />
-  <script type="text/javascript">
-    jQuery(function() { Search.loadIndex("searchindex.js"); });
-  </script>
-  
-  <script type="text/javascript" id="searchindexloader"></script>
+  <script src="searchindex.js" defer></script>
   
    
   <link rel="stylesheet" href="_static/custom.css" type="text/css" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
   <h1 id="search-documentation">Search</h1>
-  <div id="fallback" class="admonition warning">
-  <script type="text/javascript">$('#fallback').hide();</script>
+  
+  <noscript>
+  <div class="admonition warning">
   <p>
     Please activate JavaScript to enable the search
     functionality.
   </p>
   </div>
+  </noscript>
+  
+  
   <p>
-    From here you can search these documents. Enter your search
-    words into the box below and click "search". Note that the search
-    function will automatically search for all of the words. Pages
-    containing fewer words won't appear in the result list.
+    Searching for multiple words only shows matches that contain
+    all words.
   </p>
+  
+  
   <form action="" method="get">
-    <input type="text" name="q" value="" />
+    <input type="text" name="q" aria-labelledby="search-documentation" value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
     <input type="submit" value="search" />
     <span id="search-progress" style="padding-left: 10px"></span>
   </form>
   
+  
+  
   <div id="search-results">
   
   </div>
+  
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
-        <div class="sphinxsidebarwrapper"><div class="relations">
+        <div class="sphinxsidebarwrapper">
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
+</ul>
+
+<div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="index.html">Documentation overview</a><ul>
   </ul></li>
 </ul>
 </div>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index efc8f75..713fb77 100644 (file)
@@ -1 +1 @@
-Search.setIndex({docnames:["index","joy","lib","library","notebooks/Categorical","notebooks/Derivatives_of_Regular_Expressions","notebooks/Developing","notebooks/Generator_Programs","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Recursion_Combinators","notebooks/Replacing","notebooks/The_Four_Operations","notebooks/Treestep","notebooks/TypeChecking","notebooks/Types","notebooks/Zipper","notebooks/index","parser","pretty","stack","types"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Categorical.rst","notebooks/Derivatives_of_Regular_Expressions.rst","notebooks/Developing.rst","notebooks/Generator_Programs.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Recursion_Combinators.rst","notebooks/Replacing.rst","notebooks/The_Four_Operations.rst","notebooks/Treestep.rst","notebooks/TypeChecking.rst","notebooks/Types.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst","types.rst"],objects:{"joy.joy":{joy:[1,1,1,""],repl:[1,1,1,""],run:[1,1,1,""]},"joy.library":{"void":[3,1,1,""],BinaryBuiltinWrapper:[3,1,1,""],DefinitionWrapper:[3,2,1,""],FunctionWrapper:[3,1,1,""],SimpleFunctionWrapper:[3,1,1,""],UnaryBuiltinWrapper:[3,1,1,""],add_aliases:[3,1,1,""],app1:[3,1,1,""],app2:[3,1,1,""],app3:[3,1,1,""],b:[3,1,1,""],branch:[3,1,1,""],choice:[3,1,1,""],clear:[3,1,1,""],cmp_:[3,1,1,""],concat_:[3,1,1,""],cond:[3,1,1,""],dip:[3,1,1,""],dipd:[3,1,1,""],dipdd:[3,1,1,""],disenstacken:[3,1,1,""],divmod_:[3,1,1,""],drop:[3,1,1,""],dupdip:[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,""],infra:[3,1,1,""],initialize:[3,1,1,""],inscribe:[3,1,1,""],inscribe_:[3,1,1,""],loop:[3,1,1,""],map_:[3,1,1,""],max_:[3,1,1,""],min_:[3,1,1,""],parse:[3,1,1,""],pm:[3,1,1,""],pred:[3,1,1,""],primrec:[3,1,1,""],remove:[3,1,1,""],reverse:[3,1,1,""],select:[3,1,1,""],sharing:[3,1,1,""],shunt:[3,1,1,""],sort_:[3,1,1,""],sqrt:[3,1,1,""],step:[3,1,1,""],succ:[3,1,1,""],sum_:[3,1,1,""],take:[3,1,1,""],times:[3,1,1,""],unique:[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:[21,4,1,""],Symbol:[21,2,1,""],text_to_expression:[21,1,1,""]},"joy.utils":{generated_library:[3,0,0,"-"],pretty_print:[22,0,0,"-"],stack:[23,0,0,"-"]},"joy.utils.generated_library":{ccons:[3,1,1,""],cons:[3,1,1,""],dup:[3,1,1,""],dupd:[3,1,1,""],dupdd:[3,1,1,""],first:[3,1,1,""],first_two:[3,1,1,""],fourth:[3,1,1,""],over:[3,1,1,""],pop:[3,1,1,""],popd:[3,1,1,""],popdd:[3,1,1,""],popop:[3,1,1,""],popopd:[3,1,1,""],popopdd:[3,1,1,""],rest:[3,1,1,""],rolldown:[3,1,1,""],rollup:[3,1,1,""],rrest:[3,1,1,""],second:[3,1,1,""],stack:[3,1,1,""],stuncons:[3,1,1,""],stununcons:[3,1,1,""],swaack:[3,1,1,""],swap:[3,1,1,""],swons:[3,1,1,""],third:[3,1,1,""],tuck:[3,1,1,""],uncons:[3,1,1,""],unit:[3,1,1,""],unswons:[3,1,1,""]},"joy.utils.pretty_print":{TracePrinter:[22,2,1,""],trace:[22,1,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[22,5,1,""],viewer:[22,5,1,""]},"joy.utils.stack":{concat:[23,1,1,""],expression_to_string:[23,1,1,""],iter_stack:[23,1,1,""],list_to_stack:[23,1,1,""],pick:[23,1,1,""],stack_to_string:[23,1,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[21,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:{"05s":5,"0b11100111011011":6,"23rd":18,"5bkei":11,"9a9d60354c35":18,"\u03b4":5,"\u03b5":9,"abstract":[8,11],"boolean":[2,3,8,11,15],"break":[5,8,18],"byte":[5,6],"case":[2,3,13,15,16,18,23],"char":5,"class":[3,5,8,18,21,22,23],"default":[3,7,11,23],"export":[3,21],"final":[2,11,13],"float":[3,8,18,19,21],"function":[0,1,4,6,7,10,12,17,19,20,21,22,23,24],"g\u00e9rard":19,"goto":5,"import":[2,5,6,7,9,11,12,13,14,16,17,18,19],"int":[5,7,8,13,18,19,21,23],"long":[11,18,20],"new":[2,3,5,7,8,10,13,14,18],"p\u00f6ial":20,"p\u00f6ial06typingtool":18,"public":10,"return":[1,3,5,6,8,11,13,14,15,16,18,21,22,23],"static":[2,10],"super":18,"switch":[2,18],"throw":[11,24],"true":[2,3,5,6,13,15,18],"try":[7,9,12,13,16,17,18,20],"void":[0,3],"while":[3,5,8,11,18,21,23],AND:[5,18],Adding:[8,14,20],And:[5,6,7,9,11,13,15,18,19,23],But:[0,4,6,7,8,11,14,18],CPS:8,For:[2,3,11,13,14,18,20,23],Its:3,NOT:5,Not:18,One:[2,8,15,18,20],REs:5,TOS:[2,3],That:[6,11],The:[0,1,2,3,4,5,7,9,10,12,19,20,21,22,23,24],Then:[2,3,11,12,13,18],There:[5,12,13,15,16,18,23],These:[15,18,20,23],Use:[3,9,13],Used:15,Using:[0,9,11,20],With:[9,13,18,20,24],_1000:18,__add__:18,__builtin__:[],__call__:5,__class__:18,__eq__:18,__ge__:18,__hash__:18,__init__:[5,18],__main__:18,__radd__:18,__repr__:18,__str__:22,_and:5,_compaction_rul:5,_con:5,_dictionari:18,_ge:18,_infer:18,_interpret:18,_log:18,_log_it:18,_names_for:18,_or:5,_templat:5,_to_str:18,_tree_add_:11,_tree_add_e:[11,24],_tree_add_p:11,_tree_add_r:11,_tree_add_t:11,_tree_delete_:11,_tree_delete_clear_stuff:[11,24],_tree_delete_del:11,_tree_delete_r0:[11,24],_tree_delete_r1:11,_tree_delete_rightmost:11,_tree_delete_w:11,_tree_get_:[11,24],_tree_get_p:11,_tree_get_r:11,_tree_get_t:11,_tree_iter_order_curr:11,_tree_iter_order_left:11,_tree_iter_order_r:11,_tree_iter_order_right:11,_tree_t:11,_treestep_0:16,_treestep_1:16,_uniqu:18,_within_b:9,_within_p:9,_within_r:9,a10001:18,a10002:18,a10003:18,a10004:18,abbrevi:16,abl:[5,15,18,24],about:[0,8,11,15,18,19,23],abov:[0,5,6,9,11,13,15,18],abs:9,absolut:8,accept:[1,2,3,5,6,7,8,11,12,14,15,16,18,19],accord:5,accordingli:[11,15],accumul:6,act:[5,24],action:[0,8,14,18,19,20],actual:[2,6,8,11,15,18],adapt:20,add:[3,5,6,7,8,14,18,22,24],add_alias:3,add_def:3,add_definit:[3,11,16],added:[4,11],adding:[10,18],addit:[0,2,3,6,8,13,14,16],address:20,adjust:11,advantag:18,affect:[3,15],after:[5,6,7,8,13,15,18,24],afterward:8,again:[2,3,6,8,11,13,18],against:18,aggreg:19,ahead:18,aka:[5,8,19,24],albrecht:0,algorithm:[5,8,18],alia:3,alias:[3,8],align:[8,22],all:[3,5,6,7,8,11,13,14,15,16,18,22],alloc:18,allow:[10,11,15],almost:11,along:[5,8,13,18],alphabet:[3,20],alreadi:[5,9,14,18,19],also:[0,5,6,8,11,15,18,22,23],alter:[5,18],altern:[4,18],although:[4,11],altogeth:7,alwai:[6,10,13,15],amend:15,among:18,amort:11,analysi:[4,20],anamorph:[8,20],ani:[4,5,6,8,10,11,15,18,19,21],annual:8,anonym:11,anoth:[5,11,15,18,23,24],anyhow:[15,18],anyjoytyp:18,anymor:18,anystarjoytyp:18,anyth:[2,3,5,8,18,24],apart:18,api:10,app1:3,app2:[3,8,12,13,14,15],app3:[3,15],app:8,appear:[2,4,5,6,11],append:18,appendix:20,appli:[2,3,6,7,11,13,18],applic:7,approach:6,appropri:5,approxim:20,archiv:0,aren:19,arg:[2,3],argument:[2,3,8,9,12,13,20,22,23],arithmet:2,ariti:[2,15],around:[6,18,21,23],arrang:16,arriv:[7,16],arrow:5,articl:[0,4,7,13],ascii:5,ascii_lowercas:5,ask:[4,7,18],aspect:0,assembl:5,assert:[5,18],assign:[15,23],associ:11,assum:9,asterisk:16,asterix:[18,24],asyncron:15,attack:8,attempt:[0,1,18],attribut:3,attributeerror:18,author:18,auto:[0,18,24],automat:[4,15,18],auxiliari:[5,16],avail:[0,18,24],averag:[8,14],avoid:11,awai:[11,18],awar:2,awkward:[11,13,18],azur:20,back:[3,11,18],backtrack:24,backward:[10,11,12,16],bad:18,bag:8,banana:13,bar:15,barb:13,base:[0,2,3,10,13,16,18],basestr:[],basic:[2,3,8,11],basicconfig:[17,18],becaas:5,becaus:[2,3,5,8,11,15,16,18,19,23],becom:[11,16,23],becuas:18,been:[5,9,10,11,18,19],befor:[5,7,8,11],begin:[11,16],behavior:[10,16,24],behaviour:[0,1,18],behind:15,being:[0,15],below:[2,3,5,6,7,11,18,19],bespok:8,best:0,better:[6,11,13,18],between:[0,6],beyond:7,biannual:8,bin:5,binari:[0,7,8,20],binary_search_tre:11,binarybuiltinwrapp:3,bind:8,bingo:19,bit:[5,6,7,11,18],blank:21,bliss:[0,20],block:6,bodi:[2,3,5,8,11,15],body_text:3,booktitl:18,bool:[13,18,24],booleanjoytyp:[],borrow:[8,18],both:[2,6,8,12,13,14,15,18,23],bottom:7,bounce_to:5,bracket:[8,18,21],branch:[3,5,6,7,13,18,20,24],branch_fals:18,branch_tru:18,breakpoint:8,bring:[6,8,18],bruijn:18,brutal:15,brzozowski:[18,20],brzozowskian:5,btree:[11,16],buck:11,bug:[0,8],build:[7,8,12,13,19,23],built:[12,18],bullet:22,bundl:[2,3,13],burgeon:8,calculu:4,call:[1,2,5,8,10,11,13,15,18,22,23],caller:[11,18],can:[0,2,3,4,5,6,7,8,9,10,12,13,14,15,16,18,19,20,21,23,24],cancel:15,cannot:[17,18,21],captur:8,card:8,care:[6,23],carefulli:19,carri:[7,11],cartesian:4,catamorph:20,categor:[0,20],categori:[4,15],ccc:4,ccon:[3,11,17,18,24],cell:[13,18],certain:[8,23],certainli:11,chain:[3,15],chang:[2,10,11,18,19],charact:[5,19],chat:8,chatter:[0,18],check:[0,7,9,18,20],child:16,choic:[3,13],choos:10,chop:12,chose:5,cinf:11,circl:5,circuit:4,cite_not:11,classmethod:3,claus:[3,18],clean:18,clear:[3,6,8],clear_stuff:11,cleav:[8,12,14],close:[0,1,4],clunki:[6,18],clv:15,cmp:[3,16,20],cmp_:3,code:[0,1,4,5,12,13,15,18,20,24],codireco:[7,9],collaps:13,collect:[4,5,7,8,18],collis:[],combin:[0,3,6,7,8,9,12,15,16,19,20,22,24],combinatorjoytyp:18,come:[8,11,18],command:[8,11,18],comment:15,common:[2,6,15],compar:[3,4,5,18],comparison:[0,11],compat:15,compel:4,compil:[2,4,5,8,11,14,15,20,24],compile_:[],complement:5,complet:4,complex:[3,15,18,19,24],complic:18,compos:[5,24],composit:18,compostit:18,compound:11,comput:[2,4,5,6,8,12,15,18,24],con:[3,5,6,7,8,9,11,12,13,15,16,19,23,24],conal:[4,15],concat:[3,7,8,15,16,18,23],concat_:3,concaten:[0,5],concatin:[0,3,5,23],concern:15,conclus:20,concurr:2,cond:[3,11],condit:[3,8],confer:18,conflict:[11,18],consecut:20,consid:[5,6,7,11,13,16,18,19],consist:[2,7,8,15,16],constant:11,constitu:13,construct:[15,18],consum:[15,18],contain:[0,2,3,5,7,8,13,18,21],content:18,context:2,conting:11,continu:[0,5,13,18,19],control:8,conveni:[4,15,18],convent:15,convers:18,convert:[13,14,16,18,21,23],cool:11,copi:[2,3,6,11,13,15,16,17,20],copyright:8,correspond:[4,15],could:[2,4,5,6,8,10,11,15,18,19],couldn:15,count:[3,18],counter:[6,18],coupl:16,cours:[6,11,18],cover:18,cpu:15,crack:11,crash:11,creat:[0,2,3,6,9,11,15,18],creativ:18,crude:[11,18,21],cruft:18,curent:24,current:[2,3,8,13,15,16,18,19,22,24],curri:5,custom:10,cycl:[6,7],cython:8,d010101:5,d0101:5,d01:5,d10:5,d_compact:5,dai:8,data:[2,3,5,13],datastructur:[0,2,13,18,20,21,23],datatyp:23,ddididi:19,deal:[0,5,11,15],dealt:18,debugg:18,decid:11,declar:18,decor:3,decoupl:13,decrement:3,deduc:[6,18],deeper:0,deepli:4,def:[3,5,8,13,14,18,23],defaultdict:[5,18],defi:3,defin:[2,3,4,5,6,7,8,9,10,12,13,14,15,18,19,20],definit:[0,2,3,6,7,8,10,11,13,16,18,20,24],definitionwrapp:[3,11,13,16],defint:15,del:17,delabel:[],deleg:8,delet:20,deliber:18,demo:18,demonstr:4,depend:[3,11,13,15],deposit:16,depth:[18,24],dequot:13,der:11,deriv:[2,3,6,8,9,11,18,20],derv:5,describ:[3,4,5,11,13,15,16,18,21],descript:[6,8],descriptor:18,design:[2,3,11,15,20],desir:[8,16],destin:5,destruct:11,detail:[8,11,18],detect:[5,7,11,13,18],determin:20,develop:[0,7,8,18,20],diagram:6,dialect:1,dict:[1,3,5,18,22],dictionari:[0,1,3,8,18,20,22],did:18,differ:[0,4,6,9,11,12,13,15,23],differenti:4,difficult:18,difficulti:15,dig:[11,19],digit:6,digraph:5,dinfrirst:[8,18,24],dip:[3,6,7,8,9,11,12,13,14,15,16,18,20,24],dipd:[3,7,8,11,12,13,15,18,19,24],dipdd:[3,11],direco:20,direct:8,directli:[6,15,16,18,23],disappear:[2,5,18],discard:[3,7,9,11,13],disciplin:11,disctionari:1,disenstacken:[3,8],disk:8,displac:2,displai:18,distiguish:18,distribut:15,ditch:11,div:[3,8,18,24],dive:16,divis:[11,18],divmod:[3,24],divmod_:[3,18],doc:[2,3,8,18],doc_from_stack_effect:17,docstr:18,document:[18,20,21,23],doe:[0,1,3,4,5,7,8,14,15,18,20,22,24],doesn:[6,10,11,15,16,18,23],doing:[4,6,8,15,18,19],domain:[4,18],don:[5,6,8,11,18],done:[2,6,8,10,18],dooooc:18,door:8,dot:[5,22],doubl:[3,5,6,8,18],doublecircl:5,down:[2,5,9,13,19,24],down_to_zero:8,dozen:8,draft:[4,10],dream:8,drive:[7,9],driven:6,driver:[5,7],drop:[3,11],dudipd:8,due:18,dup:[3,6,7,8,9,11,12,13,15,17,19,23,24],dupd:[3,18,24],dupdd:[3,24],dupdip:[3,6,11,12,13],duplic:[3,11,13],durat:2,dure:[2,13],each:[2,3,4,5,6,8,13,14,15,16,18,22,24],easi:[0,11,16,18,19],easier:[3,11,15],easili:4,eat:5,edit:20,effect:[2,3,5,8,15,19,20,24],effici:[7,14,19],efg:18,either:[1,2,3,5,11,13,18],elabor:18,eleg:[0,5,8,11,15,20],element:[2,3],elif:18,elimin:[5,18],elliott:[4,15],els:[2,3,5,13,15,18],else_:18,embed:[4,11,19],emit:18,empti:[3,5,8,16,18,23,24],encapsul:8,enclos:8,encod:7,encount:18,end:[5,6,11,13,16,18,23],endless:7,enforc:[2,8],engend:8,enough:[5,8,13,22,24],enstacken:[7,8,18],enter:[3,8],enter_guard:18,entir:23,entri:[3,19,22],enumer:18,epsilon:9,equal:[3,6,16,23],equat:[8,9],equival:15,ergo:[5,11],err:[11,17],error:[8,18,21],essai:0,establish:18,etc:[3,16,18,19,21],euler:20,euro:18,eval:[0,18],evalu:[1,2,3,8,9,11,12,13,14,15,16,18,22],event:15,eventu:[15,18],ever:18,everi:[1,7,15],everybodi:15,everyth:[3,5,11,12,15,18],evolv:10,examin:13,exampl:[0,3,5,6,18,20,21,23,24],exce:7,except:[5,8,11,17,18,21],execut:[0,1,2,3,8,13,14,15,16,18,19,23,24],exend:18,exercis:[5,11],exist:[4,11,18],expand:11,expect:[2,3,15,16,18,23],experi:[8,16],explain:18,explan:8,explor:[8,18],express:[0,1,2,3,4,11,13,14,18,19,20,22,23],expression_to_str:[18,23],extend:18,extra:[6,7],extract:[11,12,20],extrem:8,extrememli:8,f_g:18,f_in:18,f_out:18,f_python:18,facet:0,facil:8,fact:21,factor:[2,6,8,11,18],factori:[3,20],fail:[2,3,11,20,21],fail_fail:3,fairli:18,fake:5,fall:18,fals:[2,3,5,6,13,15,18],falsei:18,far:[9,11,13,18,24],fascin:0,favorit:15,fear:[11,18],few:[6,8,9,12,15,18],fewer:[3,8],fg_in:18,fg_out:18,fib:7,fib_gen:7,fibonacci:20,figur:[2,3,11,13,18],filter:11,fin:6,find:[2,3,5,6,7,15,16,18,20,24],finder:9,fine:[0,5,6,11,18,24],finite_state_machin:5,first:[3,5,7,8,9,11,12,13,14,16,19,20,24],first_two:[3,11,24],fit:[6,8],five:[6,8,20],fix:[2,3,5,13,18],fixm:[5,18],flag:[15,18],flatten:[8,16,18],flesh:5,flexibl:20,floatjoytyp:18,floatstarjoytyp:18,floor:3,floordiv:[6,24],flow:8,follow:[0,2,3,5,8,10,13,15,16,18,19],foo:[8,10,11,15,18],foo_ii:10,fork:15,form:[2,3,4,5,6,7,13,16,18,23],forman:8,format:[17,18,20,22],formula:[0,6,20],forth:[8,18],forum:0,forward:18,found:8,four:[0,2,3,6,7,8,11,20],fourteen:6,fourth:[2,3,11,13,24],fractal:8,fraction0:8,fraction:[2,8],frame:13,framework:8,free:[4,8,11],freeli:2,from:[0,1,2,3,5,6,7,8,9,11,12,14,15,16,17,18,19,20,23],from_:5,front:[2,3,13],frozenset:5,fulin:15,full:6,fun:[5,20],func:18,functionjoytyp:18,functionwrapp:3,functool:5,fundament:[0,20],funtion:11,further:[9,18,20],futur:15,g_in:18,g_out:18,garbag:8,gari:11,gcd:8,gener:[0,2,4,15,18,20,23,24],generated_librari:3,genrec:[3,8,11,13,15,16,18],geometr:6,get:[2,4,5,6,7,8,12,13,18,20],getch:5,getitem:3,getrecursionlimit:23,getsourc:8,ghc:4,give:[4,6,11,13,16,18,23],given:[2,3,6,7,9,11,15,18,19,20],global:[17,18],glue:8,goe:24,going:[5,11,12,15,16,18,19],good:[6,11,18],grab:18,grammar:21,grand:8,graph:15,graphic:5,graphviz:5,great:[0,8,18,20],greater:23,grind:18,group:0,grow:5,gsra:9,guard:[11,18],had:[5,6,19],haiku:8,half:[6,18,19],hallmark:15,hand:[5,8,14,18,20],handi:[9,18],handl:[11,18,23,24],happen:[8,18],happi:5,hard:[5,18,19],hardwar:4,has:[0,2,3,5,7,8,9,10,11,13,15,18,19,23],hasattr:18,hash:18,haskel:4,have:[2,3,5,6,7,8,9,10,13,14,15,18,19,20,23,24],haven:[],head:23,heh:18,help:[8,11,13,18],help_:3,helper:[3,5],herd:8,here:[5,6,7,11,16,18,19,24],hide:11,hierarchi:18,higher:[5,8,11,18],highli:8,hij:5,histori:[18,22],hit:5,hmm:[5,11],hoist:3,hold:[6,18],hood:11,hope:[0,6,8,20],hopefulli:13,host:20,how:[0,4,5,9,11,13,18,19,20],howev:[13,14,15,18],html:[2,3,7,12,13,20],http:[11,24],huet:19,huge:11,hugh:[9,16],human:8,hybrid:24,hylomorph:20,hypothet:2,id_:3,idea:[4,6,8,18],ident:[3,5,13,18,24],if_not_empti:11,ift:[3,11,13,16,18,24],ignor:[1,3,11,18],iii:20,illustr:[5,13],imagin:[5,15,19],imap:18,imit:[5,16],immedi:[5,13],immut:[5,8,11],imper:13,implement:[0,1,2,3,4,8,10,11,13,14,15,20,24],implementaion:15,implicit:8,improv:18,includ:[4,11,15,16,18,24],inclus:6,incom:23,incompat:10,incorpor:12,increas:6,increment:[3,4,6,10,15],indetermin:[],index:[0,8,18,23],indexerror:23,indic:[15,16,18,24],ineffici:18,infer:[0,17],infer_:[],inferenc:24,info:[17,18],inform:[3,5,18,24],infra:[3,7,8,11,12,14,15,16,18,20,24],infrastructur:3,initi:[2,3,5,8,9,11,18],inlin:11,inner:18,inproceed:18,input:[1,9,15,17,18],input_:5,inscrib:3,inscribe_:3,insert:18,insight:13,inspect:8,inspect_stack:18,instal:0,instanc:18,instanti:[4,22],instead:[5,6,7,11,13,18,19,23,24],instruct:5,integ:[2,3,8,16,18,21],integr:3,intend:[0,8],interact:[8,20],interest:[0,6,11,18,20],interfer:15,interlud:20,intermedi:13,intern:[0,18,22,23],interpret:[0,4,10,14,21,22,24],interrupt:8,intersect:5,interspers:15,interv:[4,6],intjoytyp:18,introduc:10,introduct:0,intstarjoytyp:18,intuit:18,invalid:[],invari:3,invent:18,involv:18,ipf:8,ipython:18,isinst:[5,18],isn:[5,11,19],issubclass:18,item:[2,3,8,11,13,15,16,18,20,23],iter:[1,3,5,8,13,15,16,18,20,23],iter_stack:[14,23],iteritem:[5,18],itertool:[5,18],its:[0,1,2,3,4,6,8,11,13,15,16,18,23],itself:[0,2,8,11,15,18],j05cmp:[2,3,13],jaanu:18,jmp:5,job:[15,20],john:[9,16],joi:[2,4,10,11,12,14,15,17],join:[5,18],joypi:[19,24],joytypeerror:17,jump:5,jump_from:5,junk:18,jupyt:20,just:[0,2,3,5,7,8,10,11,13,15,16,18,19,22],juxtaposit:15,keep:[5,11,12,15,18,19],kei:[5,16,20],kevin:0,key_n:11,keyerror:[5,11,18],kind:[2,4,8,11,13,16,18,24],kinda:18,kleen:[16,18],kleenestar:18,kleffner:18,know:[6,11,18],knowledg:18,known:[4,15],kstar:5,l_kei:11,l_left:11,l_right:11,l_valu:11,label:[5,18],lambda:[4,5,18],languag:[3,4,5,8,10,11,14,18],larg:[5,18],larger:[20,23],largest:3,last:[6,11,13,18],lastli:7,later:[5,8,16,18],law:2,lazi:18,lazili:9,lcm:6,lead:[5,8,18],leaf:11,lean:8,learn:0,least:[2,6,13,18,23],least_fract:8,leav:[3,6,15],left:[5,8,12,13,15,16,18,19,22,23],leftov:13,legend:5,len:[5,18],length:[3,6,23],lens:13,less:[6,7,8,13,18,23],let:[7,9,11,12,13,16,18,19,20],letter:18,level:[4,5,11,17,18],librari:[0,5,14],like:[2,3,5,6,8,15,16,18,20,21,22,24],limit:[18,24],line:[3,8,11,12,18,22,24],linear:23,link:[0,5,18],linux:0,list:[0,3,5,6,8,9,11,15,16,18,19,22],list_to_stack:[18,23],liter:[1,11,16,18,19,21],literatur:18,littl:[5,7,11,15,18,20],live:20,lkei:16,load:[6,8],local:18,locat:2,locu:22,log:[17,18],log_2:11,logic:[0,6,20],longer:[11,18],look:[1,5,7,8,9,11,12,15,18],lookup:8,loop:[0,1,3,5,6,18,20,24],lose:18,lot:[5,8,11,18,19],love:6,low:[4,5],lower:6,lowercas:[5,18],lowest:11,lshift:24,machin:[0,20],machineri:[11,18],macro:8,made:[0,8,15,18,19],magic:18,mai:[2,13,15,24],mail:0,main:[0,3,8,12,15,18,19],mainloop:10,maintain:19,major:10,make:[2,3,4,6,8,11,13,14,15,16,18,19,20],make_gener:9,make_graph:5,manfr:[0,2,3,4,13],mani:[0,5,8,18],manipul:18,manner:12,map:[1,3,5,6,8,10,13,16,18,22],map_:3,marker:8,mask:[6,7],match:[0,1,18,20],materi:0,math:[0,8,9,11,12,18],mathemat:8,matter:[6,9,11,16],max_:3,maximum:3,mayb:[11,18],mean:[4,6,8,9,11,13,16,18,23],meant:[8,11,13,16],mem:5,member:[2,3,13],memo:5,mental:8,mention:2,mercuri:0,mess:18,messag:[17,18],meta:[8,11,14],meta_compos:18,method:[0,3,8,18,20,22],midpoint:6,might:[4,5,7,11,18],mike:11,million:7,min_:3,mind:18,minimum:3,minor:11,minu:3,mirror:0,miscellan:0,mismatch:18,mix:[8,18],mod:3,mode:18,model:[4,8],modern:0,modif:[7,18],modifi:[8,11,19],modul:[0,1,3,8,18,21],modulo:18,modulu:[8,24],moment:18,month:8,more:[0,3,4,5,6,7,8,9,13,14,15,16,18,21,23,24],most:[5,18,24],mostli:0,move:[5,11],movement:2,much:[5,6,7,11,13,18],muck:11,mul:[3,8,12,17,19,22,24],multi:3,multipl:[20,24],multipli:3,must:[2,3,6,10,13,15,16,18,21],myself:18,n10001:18,n10002:18,n10003:18,n1001:18,n1002:18,n1003:18,name:[1,3,5,8,10,11,13,18,19,20,21,22,23,24],narr:18,natur:[5,6,7,11,18],navig:19,nearli:18,neat:11,neato:18,necessarili:18,need:[2,3,6,7,9,10,11,13,15,18],neg:[3,12,24],neither:[15,18],ness:5,nest:[3,8,11,19],net:24,network:8,never:[5,10,13],new_def:18,new_f:18,new_fo:18,new_kei:11,new_valu:11,newton:[0,20],next:[5,6,15,16,18,24],nice:[0,5,13,23],niether:2,node:[5,16,20],node_kei:11,node_valu:11,non:[5,16,18],none:[1,3,18],nope:16,nor:5,normal:15,notat:[8,11],note:[2,5,6,9,11,13,15,18,23],notebook:[6,7,8,18,19,20],notebook_preambl:[2,6,7,9,11,12,13,14,16,18,19],noth:[2,11,15],notic:6,now:[3,5,6,7,8,13,14,16,18,20],nth:[3,23],nullari:[8,11,15,18,24],number:[1,2,3,6,7,9,15,23,24],numberjoytyp:18,numberstarjoytyp:18,numer:18,object:[5,18,21],observ:6,obviou:7,obvious:18,occur:11,odd:[6,7],off:[2,3,6,7,12,18,19],often:[5,15],old:[2,14],old_k:11,old_kei:11,old_valu:11,omg:5,omit:[13,18,21],onc:[3,5,10,11],one:[2,3,5,6,7,11,13,15,16,18,22,23,24],ones:[5,7,18],onli:[2,3,5,6,11,13,15,18,19,23],onto:[1,2,3,8,13,23],open:[8,18],oper:[0,3,5,8,11,13,20,23],oppos:18,optim:11,option:[1,8,11,18,23],orchestr:15,order:[0,2,3,8,13,15,17,18,20,23],org:[0,11],origin:[0,1,2,3,11,19],osdn:24,other:[0,2,3,4,5,8,11,13,16,18,23],otherwis:[3,5,6,7,11,16,18],our:[5,6,7,8,9,13,16,18],out:[2,3,4,6,7,8,9,11,12,13,15,18,19,20],outcom:16,outlin:5,output:[5,9,13,15,17,18,24],outsid:4,over:[3,4,6,7,8,9,11,12,15,16,18,20,24],overhaul:18,overview:[3,18],own:[11,18],pack:23,packag:[0,8],page:[0,11,18,23],pair:[2,3,6,7,11,18],palidrom:6,palindrom:6,pam:8,paper:[4,8,13,15,19],paradigm:20,parallel:[2,20],paramet:[1,2,3,13,14,21,22,23],parameter:20,paramorph:13,parenthes:[11,23],pariti:7,pars:[0,3,5,8],parse_definit:3,parseerror:21,parser:[0,17,18],part:[2,3,9,13,16,20],partial:[5,18],particular:19,pass:[0,5,11,18,22],patch:5,path:[5,18,20],pattern:[5,6,15,16,20],pe1:[6,7],pe2:7,pearl:19,pend:[3,8,13,18,19,22],peopl:20,per:[8,16],perfectli:15,perform:[5,15,18],perhap:7,period:8,permit:[15,18,23],permut:18,persist:[3,11],phase:2,phi:5,pick:[6,7,15,23],pickl:8,pictur:11,piec:13,pip:0,place:[3,6,8,18],plai:0,plu:3,plug:[7,13,16],point:[4,5,8,11,13,15],pointless:2,poly_compos:[],pool:15,pop:[3,5,6,7,8,11,13,14,16,17,23,24],popd:[3,8,9,11,14,15,18,24],popdd:[3,7,12,18,24],popop:[3,6,7,8,9,11,16,18,24],popopd:[3,24],popopdd:[3,24],posit:[3,6,8,13],possibilit:11,possibl:[11,16,18,20],post:8,poswrd:18,potenti:15,pow:24,power:[8,18],pprint:5,pragmat:6,preambl:9,preceed:15,precis:[0,1],pred:[3,18,24],predecessor:3,predic:[2,3,5,7,13,15],prefix:[18,22],preliminari:5,present:18,preserv:[4,16],pretti:[9,11,12,15,16,18,22,23],pretty_print:0,previou:[8,15],prime:9,primit:[2,3,18,20],primrec:[3,7,8,13],print:[0,1,2,3,5,17,18,22,23],probabl:[7,8,11,18],problem:[8,18,20],proc_curr:11,proc_left:11,proc_right:11,proce:[6,24],process:[5,8,16,18,22],produc:[3,6,11,13,16,18],product:[5,7,8,17,18],program:[0,2,3,7,8,9,11,13,15,18,19],programm:[15,18],progress:15,project:[20,24],prolog:18,promis:15,prompt:8,proper:[2,3,13,15,24],properti:0,provid:[0,3,4,8,15,18,24],pun:[0,8],punctuat:18,pure:[0,5],puriti:8,purpos:8,push:[2,3,8,13,19,23],put:[1,2,7,8,15,18,20,23],pypi:0,python3:8,python:[0,2,3,5,11,13,15,19,20,21,23,24],quadrat:[0,20],queri:[11,16],query_kei:16,queu:13,quit:[0,16],quot:[0,3,7,8,11,12,13,15,16,18,19,22],quotat:[2,3,13],quotient:3,r_kei:11,r_left:11,r_right:11,r_valu:11,rais:[5,11,18,21,23],rang:[5,8,18],range_revers:13,range_to_zero:8,ranger:13,ranger_revers:13,rankdir:5,raphson:9,rather:[6,8,13,16],ratio:8,reach:[5,6,7,13],read:[0,1,6,7,11,18,19],readabl:14,reader:[5,11],readi:18,real:11,realiz:[4,11],rearrang:[2,11,18],reason:[6,8,15,18],rebuild:[16,19],rec1:[2,3,13],rec2:[2,3,13],recent:18,recogn:21,recombin:15,record:[8,22],recur:[3,13,18],recurs:[0,2,3,5,7,8,9,15,18,20,23],recus:8,redefin:20,redistribut:[3,8],redo:5,reduc:[2,18],redund:23,refactor:[8,10],refer:[0,2],referenti:15,reflect:15,regard:15,regist:2,regular:[18,20,21],reifi:17,reimplement:[15,20],relabel:[],relat:[5,18],releas:10,remain:[2,8,10,18],remaind:[3,9],rememb:5,remind:18,remov:[3,11,18,23,24],render:20,repeat:6,repeatedli:6,repetit:5,repl:[0,1],replac:[0,2,3,7,12,13,15,16,18,19,20,23],repositori:0,repr:[5,18],repres:[2,8,11,15,21,22],represent:23,reprod:7,repurpos:18,requir:[15,18,23],res:18,research:18,resembl:8,resolut:15,resourc:[3,15],respect:[5,6,15],rest:[3,6,7,8,11,13,19,20,23,24],rest_two:11,restart:3,restor:2,result:[1,2,3,5,6,11,12,13,15,16,18,19],resum:8,retir:2,retri:8,reus:[11,18],revers:[3,6,7,13,18,19,20,23],revisit:18,rewrit:[3,8,18],rewritten:8,rid:11,right:[7,8,12,16,18,20,22,23],rightest:11,rightmost:6,rigor:15,risk:18,rkei:16,rob:18,roll:[3,9,11,16],roll_dn:18,rolldown:[3,17,18,24],rollup:[3,18,24],root:[3,9,12],round:18,row:5,rrest:[3,17,18,24],rshift:24,rule:[15,20],run:[0,1,3,6,8,9,11,12,13,15,16,18,19],runtim:15,runtimeerror:23,sai:[5,7,11,12,16,18],same:[2,4,6,11,15,18,23],sandwich:[2,3,13],save:[2,5,6,8],scan:3,scanner:[8,21],scenario:19,scm:24,scope:[7,11],search:[0,11],sec:18,second:[3,8,11,13,16,23,24],section:13,see:[0,5,7,8,9,10,12,13,14,18,19,22],seem:[0,6,8,16,18,24],seen:[18,19],select:3,self:[5,15,18],semant:[2,3,8,10,11,15,18],semi:8,send:8,sens:[0,2,6,18,19],separ:[8,15,18,21],seq:18,sequenc:[0,1,2,3,6,8,11,13,14,19,20,21,24],sequence_to_stack:18,seri:[6,7,11,19],ses:18,set:[2,3,5,13,18,20],seven:[6,7],sever:[0,4,8,13],shape:[5,15],share:[3,8],shelf:2,shew:5,shift:[6,7],shorter:20,shorthand:11,should:[2,3,5,6,11,13,15,18],shouldn:8,show:[4,15,18,19],shunt:[3,19],side:[5,11,17,18,24],sign:3,signatur:24,signifi:[8,11],similar:[11,16,18],simon:8,simpl:[5,8,13,23,24],simplefunctionwrapp:[3,14,18],simpler:16,simplest:[18,20],simpli:4,simplifi:[6,11,19],sinc:[2,6,11,18],singl:[3,7,8,14,15,18,21,24],singleton:5,situ:11,situat:11,six:[6,7,8],sixti:[6,7],size:[5,8,20],skeptic:8,skip:18,slight:9,slightli:[11,13,18],smallest:3,smart:11,softwar:8,solei:2,solut:[6,7],solvabl:8,some:[2,3,5,7,8,11,13,15,16,18,20,23,24],somehow:[11,18],someth:[2,10,11,18],sometim:11,somewher:[11,20],sort:[3,5,11,15,18],sort_:3,sourc:[0,1,3,18,20,21,22,23],space:[6,22],span:6,spawn:18,special:[7,11,20],specif:[0,4],specifi:[11,15],speed:14,spell:[5,16],sphinx:[20,23],spirit:[0,1,16],split:[5,18],sqr:[3,8,9,12,19],sqrt:[3,9,18,24],squar:[3,9,18,21],stack:[0,1,3,6,7,9,11,12,13,14,15,16,17,19,20,21,22,24],stack_effect:18,stack_effect_com:18,stack_to_str:[17,23],stacki:18,stackjoytyp:18,stackstarjoytyp:18,stage:16,stai:[0,1],stand:[4,5],standard:[8,11],star:[16,18],stare:11,start:[5,6,7,8,9,11,13,16,18,24],state:[8,20],state_nam:5,statement:[3,5],stdout:[17,18],step:[3,6,8,11,14,18,19,20],still:[5,11,18],stop:11,stopiter:5,storag:[6,11],store:[6,13,18],stori:13,str:[1,5,18,21,22,23],straightforward:[5,7,9,18,20],stream:[6,17,18],stretch:11,string:[1,2,3,8,18,19,20,21,22,23],stringi:5,structur:[8,15,16,18,19,20,23],stuck:5,studi:5,stuff:[11,18],stuncon:[3,24],stununcon:[3,24],style:[0,4,18],sub:[10,15,24],subclass:8,subject:[15,19],subsequ:15,subset:[18,24],substitut:[5,11,18],subtract:6,subtyp:20,succ:[3,18,24],succe:18,success:9,suck:18,suffic:18,suffici:11,suffix:18,suggest:[4,5,11],suitabl:[3,4,6],sum:[3,7,8,12,13,14,16],sum_:[3,18],summand:6,sumtre:16,suppli:[11,21],support:[8,18,22,23],sure:15,suspect:2,svg:5,swaack:[3,12,14,18,19,24],swap:[3,6,7,8,9,11,13,14,15,16,17,19,24],swon:[3,7,8,13,16,18,19,24],swoncat:[7,8,9,13,16],swuncon:13,sym:5,symbol:[1,2,3,5,15,18,19,20,21,22],symboljoytyp:18,symmetr:[6,11],symmetri:5,syntact:8,syntax:[8,23],sys:[17,18,23],system:[8,11,15],tabl:[5,18],tag:[5,18,24],tail:[9,11,18,20,23],tailrec:[3,9],take:[3,5,6,8,9,11,13,15,18,23],talk:[8,11,18,23],target:19,tast:4,tbd:8,tear:13,technic:2,techniqu:[4,19],technolog:2,temporari:19,ten:6,term:[1,2,5,8,9,13,15,18,20,21,23,24],termin:[2,3,5,13],ternari:8,test:[2,3,13],text:[0,1,3,18],text_to_express:[8,17,21],textjoytyp:[],textual:8,than:[0,3,5,6,7,8,9,13,15,16,18,23,24],thei:[2,5,6,7,8,11,13,15,18,19,21,23],them:[2,3,5,6,7,11,13,15,18,19,20,24],themselv:[15,18],theori:[2,3,13,15],therefor:7,thi:[0,1,2,3,4,5,6,7,8,9,12,13,15,16,18,19,20,21,22,23,24],thing:[2,7,11,13,15,18,19,21,23,24],think:[2,6,8,11,13,15,16,18],third:[3,7,8,11,24],thirti:6,those:[2,3,5,11,13,18,20,24],though:[6,15],thought:[8,15],thousand:6,thread:[2,15],three:[2,3,5,6,8,11,12,16,18,20],through:[1,6,8,16,18,19,23,24],thun:[2,3,4,10,13,15],thunder:8,thunk:15,time:[3,5,6,8,9,11,13,15,18,19],titl:18,to_check:5,to_set:11,todai:8,todo:[8,21],togeth:[7,8,15,18,20],token:21,toler:20,too:[5,13,18],tool:[8,18],tooo:18,top:[2,3,8,13,18,22,23],total:6,tower:18,trace:[0,8,12,13,19,20,23],traceback:18,traceprint:22,track:[12,18,19],tracker:0,transform:4,transit:5,translat:[4,12,18],trap:5,travers:[0,20],treasur:0,treat:[0,2,3,13,18,20],treatment:7,tree:[0,8,20],treegrind:20,treestep:[0,20],tri:6,triangl:15,triangular_numb:13,trick:[6,18],tricki:18,trinari:[],trobe:0,trove:0,truediv:24,truthi:[3,8,15,18],tuck:[3,8,18,24],tupl:[3,5,8,18,23],turn:[2,3,5,18],twice:[11,13],two:[2,3,6,8,9,11,12,13,15,16,17,18,19,20,23,24],txt:3,type:[0,1,4,8,11,13,15,20,21,22,23],type_check:[],typeerror:18,typeless:18,typic:[2,3,12,13],unari:8,unarybuiltinwrapp:3,unbalanc:[11,21],unbound:24,unchang:11,uncompil:18,uncon:[3,7,8,11,13,16,19,24],under:[2,3,8,11],underli:[5,15,18],underscor:18,understand:[0,11],undistinguish:11,undocu:8,unfinish:5,unfortun:23,uni_unifi:[],unicod:18,unif:[18,20],unifi:17,union:5,uniqu:[3,5,11,18],unit:[3,8,13,15,24],univers:[0,8,15,18],unlik:15,unnecessari:20,unnecesssari:18,unpack:[2,3,11,23],unpair:6,unquot:[8,16,21],unrol:5,unstack:18,unswon:[3,24],untangl:13,until:[5,7,15],unus:6,unusu:11,unwrap:5,updat:[0,17,20,24],uppercas:5,upward:15,usag:8,use:[0,2,3,4,5,6,7,8,9,10,11,12,13,14,16,19,20,23],used:[3,4,8,11,13,15,18,19,21,23],useful:[0,15,18],user:16,uses:[2,3,5,6,13],using:[7,11,12,13,16,19,24],usual:[0,2,13],util:[0,3,14,17,18],valid:18,valu:[0,1,2,3,6,8,9,12,13,14,15,16,18,20,21,23,24],value_n:11,valueerror:[5,18,23],variabl:[18,20],variant:11,variat:[13,15,20],varieti:[4,8],variou:0,vener:23,verbos:4,veri:[0,1,4,5,8,11,23],versa:[2,18],version:[0,1,2,5,7,10,16,19,20],via:8,vice:[2,18],view:[11,20],viewer:[1,8,10,22],vii:20,visibl:18,von:[0,2,3,4,13],waaaai:5,wai:[0,2,3,4,5,6,8,13,14,15,18],wait:15,want:[2,3,6,7,9,11,13,18],warranti:[3,8],wash:8,wast:8,web:23,websit:[0,6],welcom:8,well:[0,4,8,9,11,18,21],went:18,were:[8,18,19],what:[2,3,4,5,8,11,13,15,16,18,22],whatev:[2,3,13,16,23],when:[6,7,8,11,13,15,18,19,21,23,24],where:[2,3,5,8,11,13,18,20,23],whether:[3,13],which:[0,1,3,5,6,8,9,11,15,16,18,19,21,23,24],whole:[2,3,6,13,16,18],whose:7,why:[9,15,16],wiki:11,wikipedia:[0,11,19],wildli:8,wind:8,wire:13,within:[8,11,14,20],without:[2,8,11,12,15,18],won:[11,18,23],word:[0,3,6,8,13,19],work:[0,3,5,6,7,8,9,11,12,13,15,16,19,20,23,24],worker:15,worri:15,worth:6,would:[2,6,7,8,9,11,13,15,18,19,23],wrap:[3,8],wrapper:18,write:[4,5,9,11,13,15,16,18,19,20,23],written:[0,1,9,11,14,18,23],wrong:2,wrote:18,xrang:18,yang:18,yeah:15,year:[8,18],yet:[11,15,18,19],yield:[2,3,13,18,23],yin:20,yin_funct:[],you:[0,2,3,5,6,7,8,10,11,12,13,14,15,16,18,19,22,23,24],your:[2,3,8,13,18],yourself:[5,8,11],zero:[3,5,11,13,15,16,18,21,23],zerodivisionerror:18,zip:[5,6,18],zip_:3,zipper:[0,20],zstr:19},titles:["Thun 0.4.1 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Categorical Programming","\u2202RE","Developing a Program in Joy","Using <code class=\"docutils literal notranslate\"><span class=\"pre\">x</span></code> to Generate Values","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Recursion Combinators","Replacing Functions in the Dictionary","The Four Fundamental Operations of Definite Action","Treating Trees II: <code class=\"docutils literal notranslate\"><span class=\"pre\">treestep</span></code>","Type Checking","The Blissful Elegance of Typing Joy","Traversing Datastructures with Zippers","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026","Type Inference of Joy Expressions"],titleterms:{"\u03bb":5,"\u03d5":5,"case":[9,11],"function":[2,3,5,8,9,11,13,14,15,16,18],"long":14,"new":11,"p\u00f6ial":18,"try":5,"void":2,"while":[2,15],Adding:11,One:[7,11],The:[6,8,11,13,15,16,18],There:8,Using:7,With:[5,16],about:20,action:15,add:[2,11],adding:11,address:19,alphabet:5,altern:16,ana:13,analysi:6,anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[11,13,18],appli:15,approxim:9,argument:18,auto:3,averag:2,base:[9,11],binari:[2,11,16],bliss:18,both:11,branch:[2,11,15],brzozowski:5,can:11,cata:13,catamorph:13,categor:4,chatter:2,check:17,child:11,choic:2,clear:2,cleav:[2,15],cmp:11,code:[8,11],combin:[2,11,13,18],comment:18,compact:5,compar:11,comparison:2,compil:[7,18],compile_:18,compos:18,comput:9,con:[2,18],concat:2,conclus:[13,18],consecut:9,continu:8,current:11,datastructur:[5,8,11,19],deal:18,defin:[11,16],definit:[12,15],delabel:18,delet:11,deriv:[5,12,13,16],design:13,determin:19,develop:6,diagram:5,dialect:0,dictionari:14,dip:[2,19],dipd:2,dipdd:2,direco:7,disenstacken:2,distinguish:18,div:2,doc_from_stack_effect:18,document:0,doe:11,down_to_zero:2,drive:5,drop:2,dup:[2,18],dupd:2,dupdip:2,effect:18,eleg:18,els:11,empti:11,enstacken:2,equal:11,essai:20,euler:[6,7],eval:8,even:7,exampl:[2,8,11,13,16,17],execut:22,explor:5,express:[5,8,21,24],extract:16,factori:13,fail:17,fibonacci:7,filter:6,find:[9,11,13],finish:15,finit:5,first:[2,6,15,18],five:7,flatten:2,flexibl:16,floordiv:2,formula:12,found:11,four:[13,15],from:13,fsm:5,fulmin:15,fun:13,fundament:15,further:6,gcd:2,gener:[3,5,6,7,9,13],genrec:2,get:[11,16],getitem:2,given:[13,16],greater:11,group:2,handl:15,have:[11,16],help:2,highest:11,host:0,how:[6,7],hybrid:18,hylo:13,hylomorph:13,identifi:18,ift:[2,15],iii:18,implement:[5,18],indic:0,infer:[18,24],inferenc:18,inform:0,infra:[2,19],integ:[6,13],interest:7,interlud:11,intern:21,interpret:[1,8,18],item:19,iter:[6,11],joi:[0,1,3,6,8,13,18,19,20,21,22,23,24],join:15,just:6,kei:11,kind:15,languag:0,larger:5,least_fract:2,left:11,less:11,let:[5,6],letter:5,librari:[3,8,18],like:11,list:[2,13,23],literari:8,littl:6,logic:[2,18],loop:[2,8,15],lower:11,lshift:2,machin:5,make:[7,9],mani:6,map:[2,15],match:5,math:2,memoiz:5,method:9,min:2,miscellan:2,mod:2,modifi:18,modulu:2,more:11,most:11,mul:[2,18],multipl:[6,7,18],must:11,name:12,neg:2,newton:9,next:9,node:11,non:11,now:11,nullari:2,nulli:5,number:[13,18],one:8,onli:8,oper:15,order:[11,16],osdn:0,other:15,our:11,out:5,over:2,pack:6,pam:[2,15],para:13,paradigm:18,parallel:15,parameter:[11,16],pars:[2,21],parser:[8,21],part:18,pass:8,path:19,pattern:13,per:11,pop:[2,18],popd:2,popop:2,pow:2,power:7,pred:2,predic:[6,9,11,16],pretty_print:22,primit:13,primrec:2,print:8,problem:[6,7],process:11,product:2,program:[4,6,12,16,20],progress:18,project:[0,6,7],pure:8,put:[11,12,16],python:[8,14,18],quadrat:12,quick:0,quot:[2,23],rang:[2,6,13],range_to_zero:2,read:8,recur:[9,11],recurs:[11,13,16],redefin:[11,16],refactor:[6,11],refer:3,regular:[5,8],reimplement:16,relabel:18,rem:2,remaind:2,remov:2,render:6,repl:8,replac:[11,14],repres:[5,18],represent:5,reset:7,rest:[2,18],revers:[2,5,17],right:[11,19],rightmost:11,roll:[2,18],rolldown:2,rollup:2,rshift:2,rule:[5,18],run:[2,7],second:[2,18],select:2,sequenc:[7,15,18,23],set:[9,11],shorter:14,should:8,shunt:2,simpl:18,simplest:6,size:[2,14],sourc:11,special:[13,18],sqr:[2,18],sqrt:[2,12],stack:[2,8,18,23],start:0,state:5,step:[2,13,16],straightforward:12,stream:5,string:5,structur:11,style:8,sub:[2,11],subtyp:18,succ:2,sum:[2,6],swaack:2,swap:[2,18],swon:2,swoncat:2,symbol:[8,13],tabl:0,tail:13,take:2,term:[6,7,16],ternari:2,text:21,than:11,them:12,thi:11,third:[2,18],three:7,thun:[0,8],time:[2,7],togeth:[11,12,16],token:8,toler:9,trace:[14,22],traceprint:8,trampolin:5,travers:[11,16,19],treat:[11,16],tree:[11,16,19],treegrind:16,treestep:16,triangular:13,truediv:2,truthi:2,tuck:2,two:[5,7],type:[17,18,24],unari:2,unbound:18,uncon:[2,18],unif:17,unifi:18,unit:2,unnecessari:6,unquot:2,unstack:2,updat:[10,18],use:18,util:[22,23,24],valu:[7,11],variabl:12,variat:7,version:[6,11,14,18],view:8,vii:18,which:13,within:9,word:2,work:[17,18],write:12,xor:2,yin:18,zero:7,zip:2,zipper:19}})
\ No newline at end of file
+Search.setIndex({docnames:["index","joy","lib","library","notebooks/Categorical","notebooks/Derivatives_of_Regular_Expressions","notebooks/Developing","notebooks/Generator_Programs","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Recursion_Combinators","notebooks/Replacing","notebooks/The_Four_Operations","notebooks/Treestep","notebooks/TypeChecking","notebooks/Types","notebooks/Zipper","notebooks/index","parser","pretty","stack","types"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Categorical.rst","notebooks/Derivatives_of_Regular_Expressions.rst","notebooks/Developing.rst","notebooks/Generator_Programs.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Recursion_Combinators.rst","notebooks/Replacing.rst","notebooks/The_Four_Operations.rst","notebooks/Treestep.rst","notebooks/TypeChecking.rst","notebooks/Types.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst","types.rst"],objects:{"joy.joy":[[1,1,1,"","UnknownSymbolError"],[1,2,1,"","interp"],[1,2,1,"","joy"],[1,2,1,"","repl"],[1,2,1,"","run"]],"joy.library":[[3,2,1,"","BinaryBuiltinWrapper"],[3,3,1,"","DefinitionWrapper"],[3,2,1,"","FunctionWrapper"],[3,2,1,"","SimpleFunctionWrapper"],[3,2,1,"","UnaryBuiltinWrapper"],[3,2,1,"","add_aliases"],[3,2,1,"","app1"],[3,2,1,"","app2"],[3,2,1,"","app3"],[3,2,1,"","b"],[3,2,1,"","branch"],[3,2,1,"","choice"],[3,2,1,"","clear"],[3,2,1,"","cmp_"],[3,2,1,"","concat_"],[3,2,1,"","cond"],[3,2,1,"","dip"],[3,2,1,"","dipd"],[3,2,1,"","dipdd"],[3,2,1,"","disenstacken"],[3,2,1,"","divmod_"],[3,2,1,"","drop"],[3,2,1,"","dupdip"],[3,2,1,"","floor"],[3,2,1,"","genrec"],[3,2,1,"","getitem"],[3,2,1,"","help_"],[3,2,1,"","i"],[3,2,1,"","id_"],[3,2,1,"","infra"],[3,2,1,"","initialize"],[3,2,1,"","inscribe"],[3,2,1,"","inscribe_"],[3,2,1,"","loop"],[3,2,1,"","map_"],[3,2,1,"","max_"],[3,2,1,"","min_"],[3,2,1,"","parse"],[3,2,1,"","pm"],[3,2,1,"","pred"],[3,2,1,"","primrec"],[3,2,1,"","remove"],[3,2,1,"","reverse"],[3,2,1,"","select"],[3,2,1,"","sharing"],[3,2,1,"","shunt"],[3,2,1,"","sort_"],[3,2,1,"","sqrt"],[3,2,1,"","step"],[3,2,1,"","succ"],[3,2,1,"","sum_"],[3,2,1,"","take"],[3,2,1,"","times"],[3,2,1,"","unique"],[3,2,1,"","void"],[3,2,1,"","warranty"],[3,2,1,"","words"],[3,2,1,"","x"],[3,2,1,"","zip_"]],"joy.library.DefinitionWrapper":[[3,4,1,"","add_def"],[3,4,1,"","add_definitions"],[3,4,1,"","parse_definition"]],"joy.parser":[[21,1,1,"","ParseError"],[21,3,1,"","Symbol"],[21,2,1,"","text_to_expression"]],"joy.utils":[[3,0,0,"-","generated_library"],[22,0,0,"-","pretty_print"],[23,0,0,"-","stack"]],"joy.utils.generated_library":[[3,2,1,"","ccons"],[3,2,1,"","cons"],[3,2,1,"","dup"],[3,2,1,"","dupd"],[3,2,1,"","dupdd"],[3,2,1,"","first"],[3,2,1,"","first_two"],[3,2,1,"","fourth"],[3,2,1,"","over"],[3,2,1,"","pop"],[3,2,1,"","popd"],[3,2,1,"","popdd"],[3,2,1,"","popop"],[3,2,1,"","popopd"],[3,2,1,"","popopdd"],[3,2,1,"","rest"],[3,2,1,"","rolldown"],[3,2,1,"","rollup"],[3,2,1,"","rrest"],[3,2,1,"","second"],[3,2,1,"","stack"],[3,2,1,"","stuncons"],[3,2,1,"","stununcons"],[3,2,1,"","swaack"],[3,2,1,"","swap"],[3,2,1,"","swons"],[3,2,1,"","third"],[3,2,1,"","tuck"],[3,2,1,"","uncons"],[3,2,1,"","unit"],[3,2,1,"","unswons"]],"joy.utils.pretty_print":[[22,3,1,"","TracePrinter"],[22,2,1,"","trace"]],"joy.utils.pretty_print.TracePrinter":[[22,4,1,"","go"],[22,4,1,"","viewer"]],"joy.utils.stack":[[23,2,1,"","concat"],[23,2,1,"","dnd"],[23,2,1,"","expression_to_string"],[23,2,1,"","iter_stack"],[23,2,1,"","list_to_stack"],[23,2,1,"","pick"],[23,2,1,"","stack_to_string"]],joy:[[1,0,0,"-","joy"],[3,0,0,"-","library"],[21,0,0,"-","parser"]]},objnames:{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"],"3":["py","class","Python class"],"4":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:exception","2":"py:function","3":"py:class","4":"py:method"},terms:{"0":[2,3,5,6,7,8,9,10,11,12,13,14,16,17,18,24],"0000000001585":9,"000000001":9,"01":[6,7],"03":18,"05":5,"0a":18,"0b":[6,7],"0b11100111011011":6,"1":[2,3,5,6,7,8,9,10,11,12,13,14,16,17,18,19,23,24],"10":[2,5,6,7,13,18,24],"100":[5,16,18],"1000":[5,6,7,18],"10000":[5,18],"10001":5,"1001":[5,18],"10010":5,"10011":5,"1002":18,"101":5,"1010":5,"10100":5,"10101":5,"1011":5,"10110":5,"10111":5,"102":16,"1024":2,"103":16,"104":16,"105":16,"106":16,"107":16,"108":16,"109":16,"10946":7,"11":[2,6,7,18,24],"110":[5,6],"1100":5,"11000":5,"11001":5,"1101":5,"11010":5,"11011":5,"1110":5,"11100":5,"11101":5,"1111":5,"11110":5,"11111":5,"12":[2,6,16],"120":13,"122":5,"123":8,"128":7,"13":[2,7,16,24],"1346269":7,"14":[2,6,16],"144":7,"14811":[6,7],"15":[2,6,13,16,18,24],"16":[2,7,12,16,24],"160":2,"17":[11,16],"18":[6,8,14,16,22],"19":[16,18,24],"196418":7,"1a":18,"1b":18,"2":[2,3,5,6,8,9,10,11,13,14,16,17,19,23,24],"20":[2,6,14,18,24],"2006":18,"2017":[8,18],"2020":24,"207":2,"21":[6,7],"22":[9,18,24],"23":[2,6,7,8,9,11,14,16,18,22],"230":7,"231":[6,7],"232":7,"233":7,"233168":[6,7],"234":7,"23rd":18,"24":[2,6,7],"25":[6,7,12,16,17,19,24],"256":7,"2584":7,"26":[2,5,7,18,24],"27":[6,7],"273":10,"28":[7,17,24],"29":[18,24],"2a":18,"2b":18,"3":[2,3,7,8,10,11,12,13,16,17,19,20,23,24],"30":[2,6,18,24],"31":17,"32":[2,7,16],"33":6,"34":[7,17,18,24],"36":9,"37":[17,18,24],"3702":[6,7],"38":[18,24],"3819660112501051":12,"3b":18,"3i":18,"4":[2,6,7,8,9,11,13,16,17,19,23,24],"40":[2,17,18],"4000000":7,"41":[14,18,24],"414":22,"44":[11,16,18,24],"45":[2,6],"46":18,"4613732":7,"46368":7,"466":6,"47":[18,24],"48":[18,24],"49":[16,18,24],"4ac":12,"4m":7,"5":[2,3,5,7,8,11,12,13,14,16,18,20,24],"50":2,"513":22,"529":[2,8],"53":[18,24],"547":8,"55":[6,7],"552":2,"5555555555555554":2,"56":[18,24],"57":[6,7],"5bkei":11,"5d":11,"6":[2,6,9,11,13,16,18,19],"60":6,"610":7,"618033988749895":12,"625":19,"64":7,"66":[6,7],"6945":6,"7":[2,6,7,11,16,18,19,24],"75":2,"795831523312719":[2,9],"8":[2,5,6,7,11,12,16,18,19,24],"80":6,"832040":7,"88":11,"8888":8,"89":7,"9":[2,6,11,12,16,18,24],"90":2,"92":5,"925":6,"978":6,"980":6,"981":6,"984":6,"985":6,"987":6,"99":22,"990":6,"991":6,"992":6,"993":6,"995":6,"996":6,"999":[6,7],"999999999999996":9,"9a9d60354c35":18,"\u03b4":5,"\u03b5":9,"abstract":[8,11],"boolean":[2,3,8,11,15],"break":[5,8,18],"byte":[5,6],"case":[2,3,13,15,16,18,23],"char":5,"class":[3,5,8,18,21,22,23],"default":[3,7,11,23],"do":[2,3,4,5,6,7,8,11,13,14,15,18,19,20],"export":[3,21],"final":[2,11,13],"float":[8,18,19,21],"function":[0,1,4,6,7,10,12,17,19,20,21,22,23,24],"g\u00e9rard":19,"goto":5,"import":[2,5,6,7,9,11,12,13,14,16,17,18,19],"int":[5,7,8,13,18,19,21,23],"long":[11,18,20],"new":[2,3,5,7,8,10,13,14,18],"p\u00f6ial":20,"p\u00f6ial06typingtool":18,"public":10,"return":[1,3,5,6,8,11,13,14,15,16,18,21,22,23],"static":[2,10],"super":18,"switch":[2,18],"throw":[11,24],"true":[2,3,5,6,13,15,18],"try":[7,9,12,13,16,17,18,20],"void":[0,3],"while":[3,5,8,11,18,21,23],A:[1,3,4,8,13,15,18,20,21,22,23],AND:[5,18],And:[5,6,7,9,11,13,15,18,19,23],As:[4,6,11,18],At:[6,13,18],Be:2,But:[0,4,6,7,8,11,14,18],By:[7,11,18],For:[2,3,11,13,14,18,20,23],If:[2,3,5,6,7,8,9,10,12,13,16,18,19],In:[2,3,4,6,7,8,13,15,18,19,20,23],It:[0,2,3,4,5,6,7,8,10,11,13,18,19,23,24],Its:3,NO:8,NOT:5,No:[0,16,20],Not:18,OR:[5,18],Of:6,On:[3,22],One:[2,8,15,18,20],Or:[5,10,11,16,18],TOS:[2,3],That:[6,11],The:[0,1,2,3,4,5,7,9,10,12,19,20,21,22,23,24],Then:[2,3,11,12,13,18],There:[5,12,13,15,16,18,23],These:[15,18,20,23],To:[0,5,6,7,9,11,13,16,18],With:[9,13,18,20,24],_0:5,_1000:18,_1:5,_:[8,14,18],__:11,__add__:18,__call__:5,__class__:18,__eq__:18,__ge__:18,__hash__:18,__init__:[5,18],__main__:18,__radd__:18,__repr__:18,__str__:22,_and:5,_compaction_rul:5,_con:5,_dictionari:18,_f:18,_ge:18,_infer:18,_interpret:18,_log:18,_log_it:18,_names_for:18,_or:5,_r:18,_templat:5,_to_str:18,_tree_add_:11,_tree_add_e:[11,24],_tree_add_p:11,_tree_add_r:11,_tree_add_t:11,_tree_delete_:11,_tree_delete_clear_stuff:[11,24],_tree_delete_del:11,_tree_delete_r0:[11,24],_tree_delete_r1:11,_tree_delete_rightmost:11,_tree_delete_w:11,_tree_get_:[11,24],_tree_get_p:11,_tree_get_r:11,_tree_get_t:11,_tree_iter_order_curr:11,_tree_iter_order_left:11,_tree_iter_order_r:11,_tree_iter_order_right:11,_tree_t:11,_treestep_0:16,_treestep_1:16,_uniqu:18,_within_b:9,_within_p:9,_within_r:9,a0:18,a10001:18,a10002:18,a10003:18,a10004:18,a1:[3,17,18,24],a2:[3,17,18,24],a3:[3,17,18,24],a4:[3,17,18,24],a5:[17,18,24],a_:9,a_i:9,aa:13,ab:[5,9],abbrevi:16,abl:[5,15,18,24],about:[0,8,11,15,18,19,23],abov:[0,5,6,9,11,13,15,18],absolut:8,ac:5,accept:[1,2,3,5,6,7,8,11,12,14,15,16,18,19],accord:5,accordingli:[11,15],accumul:6,act:[5,24],action:[0,8,14,18,19,20],actual:[2,6,8,11,15,18],ad:[4,5,8,10,14,18,20],adapt:20,add:[3,5,6,7,8,14,18,22,24],add_alias:3,add_def:3,add_definit:[3,11,16],addit:[0,2,3,6,8,13,14,16],address:20,adjust:11,advantag:18,affect:[3,15],after:[5,6,7,8,13,15,18,23,24],afterward:8,again:[2,3,6,8,11,13,18],against:18,aggreg:19,ahead:18,aka:[5,8,19,24],al:[15,18],albrecht:0,algorithm:[5,8,18],alia:3,alias:[3,8],align:[8,22],all:[3,5,6,7,8,11,13,14,15,16,18,22,23],alloc:18,allow:[10,11,15],almost:11,along:[5,8,13,18],alphabet:[3,20],alreadi:[5,9,14,18,19],also:[0,5,6,8,11,15,18,22,23],alter:[5,18],altern:[4,18],although:[4,11],altogeth:7,alwai:[6,10,13,15],am:[15,20],amend:15,among:18,amort:11,an:[0,1,2,3,4,5,9,13,14,16,20,23,24],analysi:[4,20],anamorph:[8,20],ani:[4,5,6,8,10,11,15,18,19,21],annual:8,anonym:11,anoth:[5,11,15,18,23,24],anyhow:[15,18],anyjoytyp:18,anymor:18,anystarjoytyp:18,anyth:[2,3,5,8,18,24],apart:18,api:10,app1:3,app2:[3,8,12,13,14,15],app3:[3,15],app:8,appear:[2,4,5,6,11],append:18,appendix:20,appli:[2,3,6,7,11,13,18],applic:7,approach:6,appropri:5,approxim:20,ar:[1,2,3,5,6,7,8,10,12,13,15,16,18,19,20,21,23,24],archiv:0,aren:19,arg:[2,3],argument:[2,3,8,9,12,13,20,22,23],arithmet:2,ariti:[2,15],around:[6,18,21,23],arrang:16,arriv:[7,16],arrow:5,articl:[0,4,7,13],ascii:5,ascii_lowercas:5,ask:[4,7,18],aspect:0,assembl:5,assert:[5,18],assign:[15,23],associ:11,assum:9,asterisk:16,asterix:[18,24],asyncron:15,attack:8,attempt:[0,1,18],attribut:3,attributeerror:18,author:18,auto:[0,18,24],automat:[4,15,18],auxiliari:[5,16],avail:[0,18,24],averag:[8,14],avoid:11,awai:[11,18],awar:2,awkward:[11,13,18],azur:20,b0:3,b1:[3,18,24],b2:24,b3:24,b:[3,5,7,8,9,11,13,15,16,18],back:[3,11,18],backtrack:24,backward:[10,11,12,16],bad:18,bag:8,banana:13,bar:15,barb:13,base:[0,2,3,10,13,16,18],basic:[2,3,8,11],basicconfig:[17,18],bc:5,bd:5,becaas:5,becaus:[2,3,5,8,11,15,16,18,19,23],becom:[11,16,23],becuas:18,been:[5,9,10,11,18,19],befor:[5,7,8,11],begin:[11,16],behavior:[10,16,24],behaviour:[0,1,18],behind:15,being:[0,15],below:[2,3,5,6,7,11,18,19],bespok:8,best:0,better:[6,11,13,18],between:[0,6],beyond:7,biannual:8,bin:5,binari:[0,7,8,20],binary_search_tre:11,binarybuiltinwrapp:3,bind:8,bingo:19,bit:[5,6,7,11,18],blank:21,bliss:[0,20],block:6,bodi:[2,3,5,8,11,15],body_text:3,booktitl:18,bool:[13,18,24],borrow:[8,18],both:[2,6,8,12,13,14,15,18,23],bottom:7,bounce_to:5,bracket:[8,18,21],branch:[3,5,6,7,13,18,20,24],branch_fals:18,branch_tru:18,breakpoint:8,bring:[6,8,18],bruijn:18,brutal:15,brzozowski:[18,20],brzozowskian:5,btree:[11,16],buck:11,bug:[0,8],build:[7,8,12,13,19,23],built:[12,18],bullet:22,bundl:[2,3,13],burgeon:8,c:[0,1,2,3,5,7,9,11,13,15,16],calculu:4,call:[1,2,5,8,10,11,13,15,18,22,23],caller:[11,18],can:[0,2,3,4,5,6,7,8,9,10,12,13,14,15,16,18,19,20,21,23,24],cancel:15,cannot:[17,18,21],captur:8,card:8,care:[6,23],carefulli:19,carri:[7,11],cartesian:4,catamorph:20,categor:[0,20],categori:[4,15],ccc:4,ccon:[3,11,17,18,24],cell:[13,18],certain:[8,23],certainli:11,cf:[7,9,12,13],chain:[3,15],chang:[2,10,11,18,19],charact:[5,19],chat:8,chatter:[0,18],check:[0,7,9,18,20],child:16,choic:[3,13],choos:10,chop:12,chose:5,cinf:11,circl:5,circuit:4,cite_not:11,classmethod:3,claus:[3,18],clean:18,clear:[3,6,8],clear_stuff:11,cleav:[8,12,14],client:23,close:[0,1,4],clunki:[6,18],clv:15,cmp:[3,16,20],cmp_:3,code:[0,1,4,5,12,13,15,18,20,24],codireco:[7,9],collaps:13,collect:[4,5,7,8,18],combin:[0,3,6,7,8,9,12,15,16,19,20,22,24],combinatorjoytyp:18,come:[8,11,18],command:[8,11,18],comment:15,common:[2,6,15],compar:[3,4,5,18],comparison:[0,11],compat:15,compel:4,compil:[2,4,5,8,11,14,15,20,24],complement:5,complet:4,complex:[3,15,18,19,24],complic:18,compos:[5,24],composit:18,compostit:18,compound:11,comput:[2,4,5,6,8,12,15,18,24],con:[3,5,6,7,8,9,11,12,13,15,16,19,23,24],conal:[4,15],concat:[3,7,8,15,16,18,23],concat_:3,concaten:[0,5],concatin:[0,3,5,23],concern:15,conclus:20,concurr:2,cond:[3,11],condit:[3,8],confer:18,conflict:[11,18],consecut:20,consid:[5,6,7,11,13,16,18,19],consist:[2,7,8,15,16],constant:11,constitu:13,construct:[15,18],consum:[15,18],contain:[0,2,3,5,7,8,13,18,21],content:18,context:2,conting:11,continu:[0,5,13,18,19],control:8,conveni:[4,15,18],convent:15,convers:18,convert:[13,14,16,18,21,23],cool:11,copi:[2,3,6,11,13,15,16,17,20],copyright:8,correspond:[4,15],could:[2,4,5,6,8,10,11,15,18,19],couldn:15,count:[3,18],counter:[6,18],coupl:16,cours:[6,11,18],cover:18,cp:8,cpu:15,crack:11,crash:11,creat:[0,2,3,6,9,11,15,18],creativ:18,crude:[11,18,21],cruft:18,curent:24,current:[2,3,8,13,15,16,18,19,22,24],curri:5,custom:10,cycl:[6,7],cython:8,d010101:5,d0101:5,d01:5,d0:5,d10:5,d1:5,d:[2,3,5,11,13,14,15,16,17,18,19],d_compact:5,dai:8,data:[2,3,5,13],datastructur:[0,2,13,18,20,21,23],datatyp:23,ddididi:19,de:[18,19],deal:[0,5,11,15],dealt:18,debugg:18,decid:11,declar:18,decor:3,decoupl:13,decrement:3,deduc:[6,18],deeper:0,deepli:4,def:[3,5,8,13,14,18,23],defaultdict:[5,18],defi:3,defin:[2,3,4,5,6,7,8,9,10,12,13,14,15,18,19,20],definit:[0,2,3,6,7,8,10,11,13,16,18,20,24],definitionwrapp:[3,11,13,16],defint:15,del:17,deleg:8,delet:20,deliber:18,demo:18,demonstr:4,depend:[3,11,13,15],deposit:16,depth:[18,24],dequot:13,der:11,deriv:[2,3,6,8,9,11,18,20],derv:5,describ:[3,4,5,11,13,15,16,18,21],descript:[6,8],descriptor:18,design:[2,3,11,15,20],desir:[8,16],destin:5,destruct:11,detail:[8,11,18],detect:[5,7,11,13,18],determin:20,develop:[0,7,8,18,20],diagram:6,dialect:1,dict:[1,3,5,18,22],dictionari:[0,1,3,8,18,20,22],did:18,differ:[0,4,6,9,11,12,13,15,23],differenti:4,difficult:18,difficulti:15,dig:[11,19],digit:6,digraph:5,dinfrirst:[8,18,24],dip:[3,6,7,8,9,11,12,13,14,15,16,18,20,24],dipd:[3,7,8,11,12,13,15,18,19,24],dipdd:[3,11],direco:20,direct:8,directli:[6,15,16,18,23],disappear:[2,5,18],discard:[3,7,9,11,13],disciplin:11,disenstacken:[3,8],disk:8,displac:2,displai:18,distiguish:18,distribut:15,ditch:11,div:[3,8,18,24],dive:16,divis:[11,18],divmod:[3,24],divmod_:[3,18],dnd:23,doc:[2,3,8,18],doc_from_stack_effect:17,docstr:18,document:[18,20,21,23],doe:[0,1,3,4,5,7,8,14,15,18,20,22,24],doesn:[6,10,11,15,16,18,23],domain:[4,18],don:[5,6,8,11,18],done:[2,6,8,10,18],dooooc:18,door:8,dot:[5,22],doubl:[3,5,6,8,18],doublecircl:5,down:[2,5,9,13,19,24],down_to_zero:8,dozen:8,dr:5,draft:[4,10],drag:23,dream:8,drive:[7,9],driven:6,driver:[5,7],drop:[3,11,23],ds:5,dudipd:8,due:18,dup:[3,6,7,8,9,11,12,13,15,17,19,23,24],dupd:[3,18,24],dupdd:[3,24],dupdip:[3,6,11,12,13],duplic:[3,11,13],durat:2,dure:[2,13],e:[2,3,5,7,8,10,11,14,15,17,18,19,22,23],each:[2,3,4,5,6,8,13,14,15,16,18,22,24],easi:[0,11,16,18,19],easier:[3,11,15],easili:4,eat:5,edit:20,ee:[11,18],effect:[2,3,5,8,15,19,20,24],effici:[7,14,19],efg:18,eh:18,either:[1,2,3,5,11,13,18],el:23,elabor:18,eleg:[0,5,8,11,15,20],element:[2,3],elif:18,elimin:[5,18],elliott:[4,15],els:[2,3,5,13,15,18],else_:18,embed:[4,11,19],emit:18,empti:[3,5,8,16,18,23,24],en:11,encapsul:8,enclos:8,encod:7,encount:18,end:[5,6,11,13,16,18,23],endless:7,enforc:[2,8],engend:8,enough:[5,8,13,22,24],enstacken:[7,8,18],enter:[3,8],enter_guard:18,entir:23,entri:[3,19,22],enumer:18,epsilon:9,eq:[2,24],equal:[3,6,16,23],equat:[8,9],equival:15,er:[0,8],ergo:[5,11],err:[11,17],error:[8,18,21],essai:0,establish:18,et:[15,18],etc:[3,16,18,19,21],euler:20,euro:18,eval:[0,18],evalu:[1,2,3,8,9,11,12,13,14,15,16,18,22],event:15,eventu:[15,18],ever:18,everi:[1,7,15],everybodi:15,everyth:[3,5,11,12,15,18],evolv:10,examin:13,exampl:[0,3,5,6,18,20,21,23,24],exce:7,except:[1,5,8,11,17,18,21],execut:[0,1,2,3,8,13,14,15,16,18,19,23,24],exend:18,exercis:[5,11],exist:[4,11,18],expand:11,expect:[2,3,15,16,18,23],experi:[8,16],explain:18,explan:8,explor:[8,18],express:[0,1,2,3,4,11,13,14,18,19,20,22,23],expression_to_str:[18,23],extend:18,extra:[1,6,7],extract:[11,12,20],extrem:8,extrememli:8,f0:18,f1:[17,18,24],f2:[17,18,24],f3:[18,24],f:[2,3,5,6,7,9,13,15,18],f_g:18,f_in:18,f_out:18,f_python:18,facet:0,facil:8,fact:21,factor:[2,6,8,11,18],factori:[3,20],fail:[2,3,11,20,21],fail_fail:3,fairli:18,fake:5,fall:18,fals:[2,3,5,6,13,15,18],falsei:18,far:[9,11,13,18,24],fascin:0,favorit:15,fear:[11,18],few:[6,8,9,12,15,18],fewer:[3,8],fg:18,fg_in:18,fg_out:18,fi:[17,18],fib:7,fib_gen:7,fibonacci:20,figur:[2,3,11,13,18],filter:11,fin:6,find:[2,3,5,6,7,15,16,18,20,24],finder:9,fine:[0,5,6,11,18,24],finite_state_machin:5,first:[3,5,7,8,9,11,12,13,14,16,19,20,23,24],first_two:[3,11,24],fit:[6,8],five:[6,8,20],fix:[2,3,5,13,18],fixm:[5,18],flag:[15,18],flatten:[8,16,18],flesh:5,flexibl:20,floatjoytyp:18,floatstarjoytyp:18,floor:3,floordiv:[6,24],flow:8,fn:18,fo:[17,18],follow:[0,2,3,5,8,10,13,15,16,18,19],foo:[8,10,11,15,18],foo_ii:10,fork:15,form:[2,3,4,5,6,7,13,16,18,23],forman:8,format:[17,18,20,22],formula:[0,6,20],forth:[8,18],forum:0,forward:18,found:8,four:[0,2,3,6,7,8,11,20],fourteen:6,fourth:[2,3,11,13,24],fr:5,frac:[9,12],fractal:8,fraction0:8,fraction:[2,8],frame:13,framework:8,free:[4,8,11],freeli:2,from:[0,1,2,3,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,23],from_:5,from_index:23,front:[2,3,13],frozenset:5,fulin:15,full:6,fun:[5,20],func:18,functionjoytyp:18,functionwrapp:3,functool:5,fundament:[0,20],funtion:11,further:[9,18,20],futur:15,g:[2,3,5,7,8,9,10,11,13,14,15,17,18,19,22,23],g_in:18,g_out:18,garbag:8,gari:11,gcd:8,ge:[2,24],gener:[0,2,4,13,15,18,20,23,24],generated_librari:3,genrec:[3,8,11,13,15,16,18],geometr:6,get:[2,4,5,6,7,8,12,13,18,20],getch:5,getitem:3,getrecursionlimit:23,getsourc:8,ghc:4,gi:18,give:[4,6,11,13,16,18,23],given:[2,3,6,7,9,11,13,15,18,19,20,23],global:[17,18],glue:8,go:[5,6,11,12,13,15,16,18,19,22],goe:24,good:[6,11,18],grab:18,grammar:21,grand:8,graph:[5,15],graphic:5,graphviz:5,great:[0,8,18,20],greater:23,grind:18,group:0,grow:5,gsra:9,gt:[2,24],guard:[11,18],h:[5,13,18],ha:[0,2,3,5,7,8,9,10,11,13,15,18,19,23],had:[5,6,19],haiku:8,half:[6,18,19],hallmark:15,hand:[5,8,14,18,20],handi:[9,18],handl:[11,18,23,24],happen:[8,18],happi:5,hard:[5,18,19],hardwar:4,hasattr:18,hash:18,haskel:4,have:[2,3,5,6,7,8,9,10,13,14,15,18,19,20,23,24],he:[4,9],head:23,heh:18,help:[8,11,13,18],help_:3,helper:[3,5],herd:8,here:[5,6,7,11,16,18,19,24],hg:24,hide:11,hierarchi:18,higher:[5,8,11,18],highli:8,hij:5,histori:[18,22],hit:5,hmm:[5,11],hoist:3,hold:[6,18],hood:11,hope:[0,6,8,20],hopefulli:13,host:20,how:[0,4,5,9,11,13,18,19,20],howev:[13,14,15,18],html:[2,3,7,12,13,20],http:[11,24],huet:19,huge:11,hugh:[9,16],human:8,hybrid:24,hylomorph:20,hypothet:2,i0:18,i1:[17,18,24],i2:[17,18,24],i3:[18,24],i:[0,3,6,7,8,9,13,14,15,16,19,20,22,24],id:18,id_:3,idea:[4,6,8,18],ident:[3,5,13,18,24],if_not_empti:11,ift:[3,11,13,16,18,24],ignor:[1,3,11,18],ii:[0,20],iii:20,illustr:[5,13],imagin:[5,15,19],imap:18,imit:[5,16],immedi:[5,13],immut:[5,8,11],imper:13,implement:[0,1,2,3,4,8,10,11,13,14,15,20,24],implementaion:15,implicit:8,improv:18,includ:[4,11,15,16,18,24],inclus:6,incom:23,incompat:10,incorpor:12,increas:6,increment:[3,4,6,10,15],index:[0,8,18,23],indexerror:23,indic:[15,16,18,23,24],ineffici:18,infer:[0,17],inferenc:24,info:[17,18],inform:[3,5,18,24],infra:[3,7,8,11,12,14,15,16,18,20,24],infrastructur:3,initi:[2,3,5,8,9,11,18],inlin:11,inner:18,inproceed:18,input:[1,9,15,17,18],input_:5,inscrib:3,inscribe_:3,insert:[18,23],insight:13,inspect:8,inspect_stack:18,instal:0,instanc:18,instanti:[4,22],instead:[5,6,7,11,13,18,19,23,24],instruct:5,integ:[2,3,8,13,16,18,21],integr:3,intend:[0,8],interact:[8,20],interest:[0,6,11,18,20],interfer:15,interlud:20,intermedi:13,intern:[0,18,22,23],interp:1,interpret:[0,4,10,14,21,22,24],interrupt:8,intersect:5,interspers:15,interv:[4,6],intjoytyp:18,introduc:10,introduct:0,intstarjoytyp:18,intuit:18,invari:3,invent:18,involv:18,ipf:8,ipython:18,isinst:[5,18],isn:[5,11,19],issubclass:18,item:[2,3,8,11,13,15,16,18,20,23],iter:[1,3,5,8,13,15,16,18,20,23],iter_stack:[14,23],iteritem:[5,18],itertool:[5,18],its:[0,1,2,3,4,6,8,11,13,15,16,18,23],itself:[0,2,8,11,15,18],iv:20,j05cmp:[2,3,13],j:[2,5,6,7,9,11,12,13,14,16,18,19],jaanu:18,jmp:5,job:[15,20],john:[9,16],joi:[2,4,10,11,12,14,15,17],join:[5,18],joypi:[19,24],joytypeerror:17,jp:[7,12],js:8,jump:5,jump_from:5,junk:18,jupyt:20,just:[0,2,3,5,7,8,10,11,13,15,16,18,19,22],juxtaposit:15,k:[6,11,16,18],keep:[5,11,12,15,18,19],kei:[5,16,20],kevin:0,key_n:11,keyerror:[5,11,18],kind:[2,4,8,11,13,16,18,24],kinda:18,kleen:[16,18],kleenestar:18,kleffner:18,know:[6,11,18],knowledg:18,known:[4,15],kstar:5,l:[3,5,11,18],l_kei:11,l_left:11,l_right:11,l_valu:11,la:0,label:[5,18],lambda:[4,5,18],languag:[3,4,5,8,10,11,14,18],larg:[5,18],larger:[20,23],largest:3,last:[6,11,13,18],lastli:7,later:[5,8,16,18],law:2,lazi:18,lazili:9,lcm:6,le:[2,24],lead:[5,8,18],leaf:11,lean:8,learn:0,least:[2,6,13,18,23],least_fract:8,leav:[3,6,15],left:[5,8,12,13,15,16,18,19,22,23],leftov:13,legend:5,len:[5,18],length:[3,6,23],lens:13,less:[6,7,8,13,18,23],let:[7,9,11,12,13,16,18,19,20],letter:18,level:[4,5,11,17,18],librari:[0,5,14],like:[2,3,5,6,8,15,16,18,20,21,22,24],limit:[18,24],line:[3,8,11,12,18,22,24],linear:23,link:[0,5,18],linux:0,list:[0,3,5,6,8,9,11,13,15,16,18,19,22],list_to_stack:[18,23],liter:[1,11,16,18,19,21],literatur:18,littl:[5,7,11,15,18,20],live:20,lk:16,lkei:16,ll:[5,6,7,8,13,16,18,19],load:[6,8],local:18,locat:2,locu:22,log:[17,18],log_2:11,logic:[0,6,20],longer:[11,18],look:[1,5,7,8,9,11,12,15,18],lookup:8,loop:[0,1,3,5,6,18,20,24],lose:18,lot:[5,8,11,18,19],love:6,low:[4,5],lower:6,lowercas:[5,18],lowest:11,lr:5,lshift:24,lt:[2,24],m:[0,5,6,8,11,15,16,18],machin:[0,20],machineri:[11,18],macro:8,made:[0,8,15,18,19],magic:18,mai:[2,13,15,24],mail:0,main:[0,3,8,12,15,18,19],mainloop:10,maintain:19,major:10,make:[2,3,4,6,8,11,13,14,15,16,18,19,20],make_gener:9,make_graph:5,manfr:[0,2,3,4,13],mani:[0,5,8,18],manipul:18,manner:12,map:[1,3,5,6,8,10,13,16,18,22],map_:3,marker:8,mask:[6,7],match:[0,1,18,20],materi:0,math:[0,8,9,11,12,18],mathemat:8,matter:[6,9,11,16],max_:3,maximum:3,mayb:[11,18],mc:18,me:[8,16,18],mean:[4,6,8,9,11,13,16,18,23],meant:[8,11,13,16,23],mem:5,member:[2,3,13],memo:5,mental:8,mention:2,mercuri:0,mess:18,messag:[17,18],meta:[8,11,14],meta_compos:18,method:[0,3,8,18,20,22],midpoint:6,might:[4,5,7,11,18],mike:11,million:7,min_:3,mind:18,minimum:3,minor:11,minu:3,mirror:0,miscellan:0,mismatch:18,mix:[8,18],mod:3,mode:18,model:[4,8],modern:0,modif:[7,18],modifi:[8,11,19],modul:[0,1,3,8,18,21],modulo:18,modulu:[8,24],moment:18,month:8,more:[0,3,4,5,6,7,8,9,13,14,15,16,18,21,23,24],most:[5,18,24],mostli:0,move:[5,11],movement:2,ms:20,much:[5,6,7,11,13,18,23],muck:11,mul:[3,8,12,17,19,22,24],multi:3,multipl:[20,24],multipli:3,must:[2,3,6,10,13,15,16,18,21],my:[0,6,8,15],myself:18,n0:18,n10001:18,n10002:18,n10003:18,n1001:18,n1002:18,n1003:18,n1:[18,24],n2:[18,24],n3:[18,24],n4:[18,24],n:[2,3,5,6,8,9,11,13,14,16,18,19,23],name:[1,3,5,8,10,11,13,18,19,20,21,22,23,24],narr:18,natur:[5,6,7,11,18],navig:19,ne:24,nearli:18,neat:11,neato:18,necessarili:18,need:[2,3,6,7,9,10,11,13,15,18],neg:[3,12,24],neither:[15,18],ness:5,nest:[3,8,11,19],net:24,network:8,never:[5,10,13],new_def:18,new_f:18,new_fo:18,new_kei:11,new_valu:11,newton:[0,20],next:[5,6,15,16,18,24],nice:[0,5,13,23],niether:2,nk:6,nm:5,node:[5,16,20],node_kei:11,node_valu:11,non:[5,16,18],none:[1,3,18],nope:16,nor:5,normal:15,notat:[8,11],note:[2,5,6,9,11,13,15,18,23],notebook:[6,7,8,18,19,20],notebook_preambl:[2,6,7,9,11,12,13,14,16,18,19],noth:[2,11,15],notic:6,now:[3,5,6,7,8,13,14,16,18,20],ns:18,nth:[3,23],nullari:[8,11,15,18,24],number:[1,2,3,6,7,9,15,23,24],numberjoytyp:18,numberstarjoytyp:18,numer:18,o:[5,7,11,18],object:[5,18,21],observ:6,obviou:7,obvious:18,occur:11,odd:[6,7],off:[2,3,6,7,12,18,19],often:[5,15],oh:11,ok:18,old:[2,14],old_k:11,old_kei:11,old_valu:11,omg:[],omit:[13,18,21],onc:[3,5,10,11],one:[2,3,5,6,7,11,13,15,16,18,22,23,24],ones:[5,7,18],onli:[2,3,5,6,11,13,15,18,19,23],onto:[1,2,3,8,13,23],open:[8,18],oper:[0,3,5,8,11,13,20,23],oppos:18,optim:11,option:[1,8,11,18,23],orchestr:15,order:[0,2,3,8,13,15,17,18,20,23],org:[0,11],origin:[0,1,2,3,11,19],osdn:24,other:[0,2,3,4,5,8,11,13,16,18,23],otherwis:[3,5,6,7,11,16,18],our:[5,6,7,8,9,13,16,18],out:[2,3,4,6,7,8,9,11,12,13,15,18,19,20],outcom:16,outlin:5,output:[1,5,9,13,15,17,18,24],outsid:4,over:[3,4,6,7,8,9,11,12,15,16,18,20,24],overhaul:18,overview:[3,18],own:[11,18],p:[2,3,6,11,13,15],pack:23,packag:[0,8],page:[0,11,18,23],pair:[2,3,6,7,11,18],palidrom:6,palindrom:6,pam:8,paper:[4,8,13,15,19],paradigm:20,parallel:[2,20],param:1,paramet:[1,2,3,13,14,21,22,23],parameter:20,paramorph:13,parenthes:[11,23],pariti:7,pars:[0,3,5,8],parse_definit:3,parseerror:21,parser:[0,17,18],part:[2,3,9,13,16,20],partial:[5,18],particular:19,pass:[0,5,11,18,22],patch:5,path:[5,18,20],pattern:[5,6,15,16,20],pe1:[6,7],pe2:7,pearl:19,pend:[3,8,13,18,19,22],peopl:20,per:[8,16],perfectli:15,perform:[5,15,18],perhap:7,period:8,permit:[15,18,23],permut:18,persist:[3,11],phase:2,phi:5,pick:[6,7,15,23],pickl:8,pictur:11,piec:13,pip:0,place:[3,6,8,18],plai:0,plu:3,plug:[7,13,16],pm:[3,12,18,24],point:[4,5,8,11,13,15],pointless:2,pool:15,pop:[3,5,6,7,8,11,13,14,16,17,23,24],popd:[3,8,9,11,14,15,18,24],popdd:[3,7,12,18,24],popop:[3,6,7,8,9,11,16,18,24],popopd:[3,24],popopdd:[3,24],posit:[3,6,8,13],possibilit:11,possibl:[11,16,18,20],post:8,poswrd:18,potenti:15,pow:24,power:[8,18],pprint:5,pragmat:6,preambl:9,preceed:15,precis:[0,1],pred:[3,18,24],predecessor:3,predic:[2,3,5,7,13,15],prefix:[18,22],preliminari:5,present:18,preserv:[4,16],pretti:[9,11,12,15,16,18,22,23],pretty_print:0,previou:[8,15],prime:9,primit:[2,3,18,20],primrec:[3,7,8,13],print:[0,1,2,3,5,17,18,22,23],probabl:[7,8,11,18],problem:[8,18,20],proc_curr:11,proc_left:11,proc_right:11,proce:[6,24],process:[5,8,16,18,22],produc:[3,6,11,13,16,18],product:[5,7,8,17,18],program:[0,2,3,7,8,9,11,13,15,18,19],programm:[15,18],progress:15,project:[20,24],prolog:18,promis:15,prompt:8,proper:[2,3,13,15,24],properti:0,provid:[0,3,4,8,15,18,24],pun:[0,8],punctuat:18,pure:[0,5],puriti:8,purpos:8,push:[2,3,8,13,19,23],put:[1,2,7,8,15,18,20,23],pypi:0,python3:8,python:[0,2,3,5,11,13,15,19,20,21,23,24],q:[2,3,11,13,15,18,19],quadrat:[0,20],queri:[11,16],query_kei:16,queu:13,quit:[0,16],quot:[0,3,7,8,11,12,13,15,16,18,19,22],quotat:[2,3,13],quotient:3,r0:[9,11,16],r1:[2,3,9,11,13,16],r2:[2,3,13],r:[2,3,5,11,13,18],r_kei:11,r_left:11,r_right:11,r_valu:11,rais:[5,11,18,21,23],rang:[5,8,18],range_revers:13,range_to_zero:8,ranger:13,ranger_revers:13,rankdir:5,raphson:9,rather:[6,8,13,16],ratio:8,re:[0,6,7,8,9,14,18,20,21],reach:[5,6,7,13],read:[0,1,6,7,11,18,19],readabl:14,reader:[5,11],readi:18,real:11,realiz:[4,11],rearrang:[2,11,18,23],reason:[6,8,15,18],rebuild:[16,19],rec1:[2,3,13],rec2:[2,3,13],recent:18,recogn:21,recombin:15,record:[8,22],recur:[3,13,18],recurs:[0,2,3,5,7,8,9,15,18,20,23],recus:8,redefin:20,redistribut:[3,8],redo:5,reduc:[2,18],redund:23,refactor:[8,10],refer:[0,2],referenti:15,reflect:15,regard:15,regist:2,regular:[18,20,21],reifi:17,reimplement:[15,20],rel:23,relat:[5,18],releas:10,remain:[2,8,10,18],remaind:[3,9],rememb:5,remind:18,remot:23,remov:[3,11,18,23,24],render:20,repeat:6,repeatedli:6,repetit:5,repl:[0,1],replac:[0,2,3,7,12,13,15,16,18,19,20,23],repositori:0,repr:[5,18],repres:[2,8,11,15,21,22],represent:23,reprod:7,repurpos:18,requir:[15,18,23],research:18,resembl:8,resolut:15,resourc:[3,15],respect:[5,6,15],rest:[3,6,7,8,11,13,19,20,23,24],rest_two:11,restart:3,restor:2,result:[1,2,3,5,6,11,12,13,15,16,18,19],resum:8,retir:2,retri:8,reus:[11,18,23],revers:[3,6,7,13,18,19,20,23],revisit:18,rewrit:[3,8,18],rewritten:8,rid:11,right:[7,8,12,16,18,20,22,23],rightest:11,rightmost:6,rigor:15,risk:18,rk:16,rkei:16,rob:18,roll:[3,9,11,16],roll_dn:18,rolldown:[3,17,18,24],rollup:[3,18,24],root:[3,9,12],round:18,row:5,rrest:[3,17,18,24],rshift:24,rtype:1,rule:[15,20],run:[0,1,3,6,8,9,11,12,13,15,16,18,19],runtim:15,runtimeerror:23,s0:18,s1:[17,18,24],s2:[17,18],s3:18,s4:18,s5:18,s:[0,1,2,3,4,7,8,10,12,13,14,15,16,17,19,20,22,23,24],sai:[5,7,11,12,16,18],same:[2,4,6,11,15,18,23],sandwich:[2,3,13],save:[2,5,6,8],scan:3,scanner:[8,21],scenario:19,scm:24,scope:[7,11],script:1,se:18,search:[0,11],sec:18,second:[3,8,11,13,16,23,24],section:13,see:[0,5,7,8,9,10,12,13,14,18,19,22],seem:[0,6,8,16,18,24],seen:[18,19],select:3,self:[5,15,18],semant:[2,3,8,10,11,15,18],semi:8,send:8,sens:[0,2,6,18,19],separ:[8,15,18,21],seq:18,sequenc:[0,1,2,3,6,8,11,13,14,19,20,21,24],sequence_to_stack:18,seri:[6,7,11,19],set:[2,3,5,13,18,20],seven:[6,7],sever:[0,4,8,13],shape:[5,15],share:[3,8],shelf:2,shew:5,shift:[6,7],shorter:20,shorthand:11,should:[2,3,5,6,11,13,15,18],shouldn:8,show:[4,15,18,19],shunt:[3,19],side:[5,11,17,18,24],sign:3,signatur:24,signifi:[8,11],similar:[11,16,18],simon:8,simpl:[1,5,8,13,23,24],simplefunctionwrapp:[3,14,18],simpler:16,simplest:[18,20],simpli:4,simplifi:[6,11,19],sinc:[2,6,11,18],singl:[3,7,8,14,15,18,21,24],singleton:5,situ:11,situat:11,six:[6,7,8],sixti:[6,7],size:[5,8,20],skeptic:8,skip:18,slight:9,slightli:[11,13,18],smallest:3,smart:11,sn:18,so:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,24],softwar:8,solei:2,solut:[6,7],solvabl:8,some:[2,3,5,7,8,11,13,15,16,18,20,23,24],somehow:[11,18],someth:[2,10,11,18],sometim:11,somewher:[11,20],sort:[3,5,11,15,18],sort_:3,sourc:[0,1,3,18,20,21,22,23],space:[6,22],span:6,spawn:18,special:[7,11,20],specif:[0,4],specifi:[11,15],speed:14,spell:[5,16],sphinx:[20,23],spirit:[0,1,16],split:[5,18],sqr:[3,8,9,12,19],sqrt:[3,9,18,24],squar:[3,9,18,21],ss:18,stack:[0,1,3,6,7,9,11,12,13,14,15,16,17,19,20,21,22,24],stack_effect:18,stack_effect_com:18,stack_to_str:[17,23],stacki:18,stackjoytyp:18,stacklistbox:23,stackstarjoytyp:18,stage:16,stai:[0,1],stand:[4,5],standard:[8,11],star:[16,18],stare:11,start:[5,6,7,8,9,11,13,16,18,24],state:[8,20],state_nam:5,statement:[3,5],stdout:[17,18],step:[3,6,8,11,14,18,19,20],still:[5,11,18],stop:11,stopiter:5,storag:[6,11],store:[6,13,18],stori:13,str:[1,5,18,21,22,23],straightforward:[5,7,9,18,20],stream:[6,17,18],stretch:11,string:[1,2,3,8,18,19,20,21,22,23],stringi:5,structur:[8,15,16,18,19,20,23],stuck:5,studi:5,stuff:[11,18],stuncon:[3,24],stununcon:[3,24],style:[0,4,18],sub:[10,15,24],subclass:8,subject:[15,19],subsequ:15,subset:[18,24],substitut:[5,11,18],subtract:6,subtyp:20,succ:[3,18,24],succe:18,success:9,suck:18,suffic:18,suffici:11,suffix:18,suggest:[4,5,11],suitabl:[1,3,4,6],sum:[3,7,8,12,13,14,16],sum_:[3,18],summand:6,sumtre:16,suppli:[11,21],support:[8,18,22,23],sure:15,suspect:2,svg:[],swaack:[3,12,14,18,19,24],swap:[3,6,7,8,9,11,13,14,15,16,17,19,24],swon:[3,7,8,13,16,18,19,24],swoncat:[7,8,9,13,16],swuncon:13,sy:[17,18,23],sym:5,symbol:[1,2,3,5,15,18,19,20,21,22],symboljoytyp:18,symmetr:[6,11],symmetri:5,syntact:8,syntax:[8,23],system:[8,11,15],t0:3,t1:3,t:[2,3,5,6,8,10,11,13,15,18,19,23],tabl:[5,18],tag:[5,18,24],tail:[9,11,18,20,23],tailrec:[3,9],take:[3,5,6,8,9,11,13,15,18,23],talk:[8,11,18,23],target:19,tast:4,tbd:8,te:11,tear:13,technic:2,techniqu:[4,19],technolog:2,temporari:19,ten:6,term:[1,2,5,8,9,13,15,18,20,21,23,24],termin:[2,3,5,13],ternari:8,test:[2,3,13],text:[0,1,3,18],text_to_express:[8,17,21],textual:8,than:[0,3,5,6,7,8,9,13,15,16,18,23,24],thei:[2,5,6,7,8,11,13,15,18,19,21,23],them:[2,3,5,6,7,11,13,15,18,19,20,24],themselv:[15,18],theori:[2,3,13,15],therefor:7,thi:[0,1,2,3,4,5,6,7,8,9,12,13,15,16,18,19,20,21,22,23,24],thing:[2,7,11,13,15,18,19,21,23,24],think:[2,6,8,11,13,15,16,18],third:[3,7,8,11,24],thirti:6,those:[2,3,5,11,13,18,20,24],though:[6,15],thought:[8,15],thousand:6,thread:[2,15],three:[2,3,5,6,8,11,12,16,18,20],through:[1,6,8,16,18,19,23,24],thun:[2,3,4,10,13,15],thunder:8,thunk:15,time:[3,5,6,8,9,11,13,15,18,19],titl:18,to_check:5,to_index:23,to_set:11,todai:8,todo:[8,21],togeth:[7,8,15,18,20],token:21,toler:20,too:[5,13,18],tool:[8,18],tooo:18,top:[2,3,8,13,18,22,23],total:6,tower:18,trace:[0,8,12,13,19,20,23],traceback:18,traceprint:22,track:[12,18,19],tracker:0,transform:4,transit:5,translat:[4,12,18],trap:5,travers:[0,20],treasur:0,treat:[0,2,3,13,18,20],treatment:7,tree:[0,8,20],treegrind:20,treestep:[0,20],tri:6,triangl:15,triangular_numb:13,trick:[6,18],tricki:18,trobe:0,trove:0,truediv:24,truthi:[3,8,15,18],ts:16,tuck:[3,8,18,24],tupl:[3,5,8,18,23],turn:[2,3,5,18],twice:[11,13],two:[2,3,6,8,9,11,12,13,15,16,17,18,19,20,23,24],txt:3,type:[0,1,4,8,11,13,15,20,21,22,23],typeerror:18,typeless:18,typic:[2,3,12,13],u:[17,18],uh:18,ui:8,unari:8,unarybuiltinwrapp:3,unbalanc:[11,21],unbound:24,unchang:11,uncompil:18,uncon:[3,7,8,11,13,16,19,24],under:[2,3,8,11],underli:[5,15,18],underscor:18,understand:[0,11],undistinguish:11,undocu:8,unfinish:5,unfortun:23,unicod:18,unif:[18,20],unifi:17,union:5,uniqu:[3,5,11,18],unit:[3,8,13,15,24],univers:[0,8,15,18],unknownsymbolerror:1,unlik:15,unnecessari:20,unnecesssari:18,unpack:[2,3,11,23],unpair:6,unquot:[8,16,21],unrol:5,unstack:18,unswon:[3,24],untangl:13,until:[5,7,15],unus:6,unusu:11,unwrap:5,up:[1,2,3,6,7,8,11,13,14,15,18,19,23],updat:[0,17,20,24],uppercas:5,upward:15,us:[0,1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,19,20,21,23,24],usag:8,user:16,usual:[0,2,13],util:[0,3,14,17,18],uu:18,v0:24,v:[2,6,7,9,11,12,13,14,16,19,20],valid:18,valu:[0,1,2,3,6,8,9,12,13,14,15,16,18,20,21,23,24],value_n:11,valueerror:[5,18,23],variabl:[18,20],variant:11,variat:[13,15,20],varieti:[4,8],variou:0,ve:[11,18],vener:23,verbos:4,veri:[0,1,4,5,8,11,23],versa:[2,18],version:[0,1,2,5,7,10,16,19,20],vi:20,via:8,vice:[2,18],view:[11,20],viewer:[1,8,10,22],vii:20,visibl:18,von:[0,2,3,4,13],vs:18,vv:18,w:[3,11,13,16,18],wa:[2,6,8,11,15,18,23],waaaai:5,wai:[0,2,3,4,5,6,8,13,14,15,18],wait:15,want:[2,3,6,7,9,11,13,18],warranti:[3,8],wash:8,wast:8,we:[2,5,6,7,8,9,10,12,13,14,15,18,19,20,23],web:23,websit:[0,6],welcom:8,well:[0,4,8,9,11,18,21],went:18,were:[8,18,19],what:[2,3,4,5,8,11,13,15,16,18,22],whatev:[2,3,13,16,23],when:[6,7,8,11,13,15,18,19,21,23,24],where:[2,3,5,8,11,13,18,20,23],whether:[3,13],which:[0,1,3,5,6,8,9,11,13,15,16,18,19,21,23,24],whole:[2,3,6,13,16,18],whose:7,why:[9,15,16],wiki:11,wikipedia:[0,11,19],wildli:8,wind:8,wire:13,within:[8,11,14,20],without:[2,8,11,12,15,18],won:[11,18,23],word:[0,3,6,8,13,19],work:[0,3,5,6,7,8,9,11,12,13,15,16,19,20,23,24],worker:15,worri:15,worth:6,would:[2,6,7,8,9,11,13,15,18,19,23],wrap:[3,8],wrapper:18,write:[4,5,9,11,13,15,16,18,19,20,23],written:[0,1,9,11,14,18,23],wrong:2,wrote:18,x:[0,3,5,6,8,9,15,19,20],xrang:18,y:[2,3,5,15],yang:18,yeah:15,year:[8,18],yet:[11,15,18,19],yield:[2,3,13,18,23],yin:20,you:[0,2,3,5,6,7,8,10,11,12,13,14,15,16,18,19,22,23,24],your:[2,3,8,13,18],yourself:[5,8,11],z:[3,5,15,18,20],zero:[3,5,11,13,15,16,18,21,23],zerodivisionerror:18,zip:[5,6,18],zip_:3,zipper:[0,20],zstr:19},titles:["Thun 0.4.1 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Categorical Programming","\u2202RE","Developing a Program in Joy","Using <code class=\"docutils literal notranslate\"><span class=\"pre\">x</span></code> to Generate Values","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Recursion Combinators","Replacing Functions in the Dictionary","The Four Fundamental Operations of Definite Action","Treating Trees II: <code class=\"docutils literal notranslate\"><span class=\"pre\">treestep</span></code>","Type Checking","The Blissful Elegance of Typing Joy","Traversing Datastructures with Zippers","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026","Type Inference of Joy Expressions"],titleterms:{"0":0,"01":5,"1":0,"11":5,"111":5,"2":[7,12,18],"2a":12,"3":[6,18],"4":[0,12,18],"466":7,"5":6,"\u03bb":5,"\u03d5":5,"case":[9,11],"do":16,"function":[2,3,5,8,9,11,13,14,15,16,18],"long":14,"new":11,"p\u00f6ial":18,"try":5,"void":2,"while":[2,15],A:[5,6,7,9,11,14],If:11,In:[11,16],No:[5,10],One:[7,11],The:[6,8,11,13,15,16,18],There:8,With:[5,16],about:20,action:15,ad:11,add:[2,11],address:19,al:13,alphabet:5,altern:16,an:[6,7,8,11,17,18,19],ana:13,analysi:6,anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[11,13,18],appli:15,approxim:9,ar:11,argument:18,auto:3,averag:2,b:[2,12],base:[9,11],binari:[2,11,16],bliss:18,both:11,branch:[2,11,15],brzozowski:5,c:[12,18],can:11,cata:13,catamorph:13,categor:4,chatter:2,check:17,child:11,choic:2,clear:2,cleav:[2,15],cmp:11,code:[8,11],combin:[2,11,13,18],comment:18,compact:5,compar:11,comparison:2,compil:[7,18],compile_:18,compos:18,comput:9,con:[2,18],concat:2,conclus:[13,18],consecut:9,continu:8,current:11,datastructur:[5,8,11,19],deal:18,defin:[11,16],definit:[12,15],delabel:18,delet:11,deriv:[5,12,13,16],design:13,determin:19,develop:6,diagram:5,dialect:0,dictionari:14,dip:[2,19],dipd:2,dipdd:2,direco:7,disenstacken:2,distinguish:18,div:2,doc_from_stack_effect:18,document:0,doe:11,down_to_zero:2,drive:5,drop:2,dup:[2,18],dupd:2,dupdip:2,e:16,effect:18,eleg:18,els:11,empti:11,enstacken:2,equal:11,er:2,essai:20,et:13,euler:[6,7],eval:8,even:7,exampl:[2,8,11,13,16,17],execut:22,explor:5,express:[5,8,21,24],extract:16,f:11,factori:13,fail:17,fibonacci:7,filter:6,find:[9,11,13],finish:15,finit:5,first:[2,6,15,18],five:7,flatten:2,flexibl:16,floordiv:2,formula:12,found:11,four:[13,15],from:[],fsm:5,fulmin:15,fun:13,fundament:15,further:6,gcd:2,gener:[3,5,6,7,9],genrec:2,get:[11,16],getitem:2,given:16,greater:11,group:2,h1:13,h2:13,h3:13,h4:13,handl:15,have:[11,16],help:2,highest:11,host:0,how:[6,7],hybrid:18,hylo:13,hylomorph:13,i:[2,5,11,18],identifi:18,ift:[2,15],ii:[16,18],iii:18,implement:[5,18],indic:0,infer:[18,24],inferenc:18,inform:0,infra:[2,19],integ:6,interest:7,interlud:11,intern:21,interpret:[1,8,18],item:19,iter:[6,11],iv:18,joi:[0,1,3,6,8,13,18,19,20,21,22,23,24],join:15,just:6,kei:11,kind:15,languag:0,larger:5,least_fract:2,left:11,less:11,let:[5,6],letter:5,librari:[3,8,18],like:11,list:[2,23],literari:8,littl:6,logic:[2,18],loop:[2,8,15],lower:11,lshift:2,machin:5,make:[7,9],mani:6,map:[2,15],match:5,math:2,memoiz:5,method:9,min:2,miscellan:2,mod:2,modifi:18,modulu:2,more:11,most:11,mul:[2,18],multipl:[6,7,18],must:11,n:[],name:12,ne:2,neg:2,newton:9,next:9,node:11,non:11,now:11,nullari:2,nulli:5,number:[13,18],one:8,onli:8,oper:15,order:[11,16],osdn:0,other:15,our:11,out:5,over:2,p:16,pack:6,pam:[2,15],para:13,paradigm:18,parallel:15,parameter:[11,16],pars:[2,21],parser:[8,21],part:18,pass:8,path:19,pattern:13,per:11,pop:[2,18],popd:2,popop:2,pow:2,power:7,pred:2,predic:[6,9,11,16],pretty_print:22,primit:13,primrec:2,print:8,problem:[6,7],process:11,product:2,program:[4,6,12,16,20],progress:18,project:[0,6,7],pure:8,put:[11,12,16],python:[8,14,18],quadrat:12,quick:0,quot:[2,23],rang:[2,6,13],range_to_zero:2,re:[5,11],read:8,recur:[9,11],recurs:[11,13,16],redefin:[11,16],refactor:[6,11],refer:3,regular:[5,8],reimplement:16,relabel:18,rem:2,remaind:2,remov:2,render:6,repl:8,replac:[11,14],repres:[5,18],represent:5,reset:7,rest:[2,18],revers:[2,5,17],right:[11,19],rightmost:11,roll:[2,18],rolldown:2,rollup:2,rshift:2,rule:[5,18],run:[2,7],s:[5,6,9,11,18],second:[2,18],select:2,sequenc:[7,15,18,23],set:[9,11],shorter:14,should:8,shunt:2,simpl:18,simplest:6,size:[2,14],sourc:11,special:[13,18],sqr:[2,18],sqrt:[2,12],stack:[2,8,18,23],start:0,state:5,step:[2,13,16],straightforward:12,stream:5,string:5,structur:11,style:8,sub:[2,11],subtyp:18,succ:2,sum:[2,6],swaack:2,swap:[2,18],swon:2,swoncat:2,symbol:[8,13],t:16,tabl:0,tail:13,take:2,term:[6,7,16],ternari:2,text:21,than:11,them:12,thi:11,third:[2,18],three:7,thun:[0,8],time:[2,7],togeth:[11,12,16],token:8,toler:9,trace:[14,22],traceprint:8,trampolin:5,travers:[11,16,19],treat:[11,16],tree:[11,16,19],treegrind:16,treestep:16,triangular:13,truediv:2,truthi:2,tuck:2,two:[5,7],type:[17,18,24],unari:2,unbound:18,uncon:[2,18],unif:17,unifi:18,unit:2,unnecessari:6,unquot:2,unstack:2,up:9,updat:[10,18],us:[7,18],util:[22,23,24],v:18,valu:[7,11],variabl:12,variat:7,version:[6,11,14,18],vi:18,view:8,vii:18,we:[11,16],which:[],within:9,word:2,work:[17,18],write:12,x:[2,7],xor:2,yin:18,z:19,zero:7,zip:2,zipper:19}})
\ No newline at end of file
index 693f249..ab153d5 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Stack or Quote or Sequence or List… &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Parsing Text into Joy Expressions" href="parser.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="stack-or-quote-or-sequence-or-list">
+  <section id="stack-or-quote-or-sequence-or-list">
 <h1>Stack or Quote or Sequence or List…<a class="headerlink" href="#stack-or-quote-or-sequence-or-list" title="Permalink to this headline">¶</a></h1>
-<div class="section" id="module-joy.utils.stack">
+<section id="module-joy.utils.stack">
 <span id="joy-utils-stack"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.utils.stack</span></code><a class="headerlink" href="#module-joy.utils.stack" title="Permalink to this headline">¶</a></h2>
 <p>When talking about Joy we use the terms “stack”, “quote”, “sequence”,
 “list”, and others to mean the same thing: a simple linear datatype that
@@ -44,7 +45,7 @@ values from (at least) one end.</p>
 venerable two-tuple recursive sequence datastructure, where the
 empty tuple <code class="docutils literal notranslate"><span class="pre">()</span></code> is the empty stack and <code class="docutils literal notranslate"><span class="pre">(head,</span> <span class="pre">rest)</span></code> gives the
 recursive form of a stack with one or more items on it:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">stack</span> <span class="p">:</span><span class="o">=</span> <span class="p">()</span> <span class="o">|</span> <span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">stack</span><span class="p">)</span>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">stack</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>
 </pre></div>
 </div>
 <p>Putting some numbers onto a stack:</p>
@@ -59,7 +60,7 @@ recursive form of a stack with one or more items on it:</p>
 means we can directly “unpack” the expected arguments to a Joy function.</p>
 <p>For example:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">dup</span><span class="p">((</span><span class="n">head</span><span class="p">,</span> <span class="n">tail</span><span class="p">)):</span>
-        <span class="k">return</span> <span class="n">head</span><span class="p">,</span> <span class="p">(</span><span class="n">head</span><span class="p">,</span> <span class="n">tail</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">head</span><span class="p">,</span> <span class="p">(</span><span class="n">head</span><span class="p">,</span> <span class="n">tail</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>We replace the argument “stack” by the expected structure of the stack,
@@ -71,8 +72,8 @@ where they would be redundant.)</p>
 web page, doesn’t handle tuples in the function parameters.  And in Python 3, this
 syntax was removed entirely.  Instead you would have to write:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">dup</span><span class="p">(</span><span class="n">stack</span><span class="p">):</span>
-        <span class="n">head</span><span class="p">,</span> <span class="n">tail</span> <span class="o">=</span> <span class="n">stack</span>
-        <span class="k">return</span> <span class="n">head</span><span class="p">,</span> <span class="p">(</span><span class="n">head</span><span class="p">,</span> <span class="n">tail</span><span class="p">)</span>
+    <span class="n">head</span><span class="p">,</span> <span class="n">tail</span> <span class="o">=</span> <span class="n">stack</span>
+    <span class="k">return</span> <span class="n">head</span><span class="p">,</span> <span class="p">(</span><span class="n">head</span><span class="p">,</span> <span class="n">tail</span><span class="p">)</span>
 </pre></div>
 </div>
 <p>We have two very simple functions, one to build up a stack from a Python
@@ -80,155 +81,168 @@ iterable and another to iterate through a stack and yield its items
 one-by-one in order.  There are also two functions to generate string representations
 of stacks.  They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left.  In both functions <em>internal stacks</em> are
 printed left-to-right.  These functions are written to support <a class="reference internal" href="pretty.html"><span class="doc">Tracing Joy Execution</span></a>.</p>
-<dl class="function">
-<dt id="joy.utils.stack.concat">
-<code class="descclassname">joy.utils.stack.</code><code class="descname">concat</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#concat"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.concat" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.stack.concat">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.stack.</span></span><span class="sig-name descname"><span class="pre">concat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">quote</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#concat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.stack.concat" title="Permalink to this definition">¶</a></dt>
 <dd><p>Concatinate quote onto expression.</p>
 <p>In joy [1 2] [3 4] would become [1 2 3 4].</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
-<li><strong>quote</strong> (<em>stack</em>) – A stack.</li>
-<li><strong>expression</strong> (<em>stack</em>) – A stack.</li>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>quote</strong> (<em>stack</em>) – A stack.</p></li>
+<li><p><strong>expression</strong> (<em>stack</em>) – A stack.</p></li>
 </ul>
-</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><strong>RuntimeError</strong> – if quote is larger than sys.getrecursionlimit().</p>
-</td>
-</tr>
-<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
-</td>
-</tr>
-</tbody>
-</table>
+</dd>
+<dt class="field-even">Raises</dt>
+<dd class="field-even"><p><strong>RuntimeError</strong> – if quote is larger than sys.getrecursionlimit().</p>
+</dd>
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p>stack</p>
+</dd>
+</dl>
+</dd></dl>
+
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.stack.dnd">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.stack.</span></span><span class="sig-name descname"><span class="pre">dnd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">from_index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">to_index</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#dnd"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.stack.dnd" title="Permalink to this definition">¶</a></dt>
+<dd><p>Given a stack and two indices return a rearranged stack.
+First remove the item at from_index and then insert it at to_index,
+the second index is relative to the stack after removal of the item
+at from_index.</p>
+<p>This function reuses all of the items and as much of the stack as it
+can.  It’s meant to be used by remote clients to support drag-n-drop
+rearranging of the stack from e.g. the StackListbox.</p>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.stack.expression_to_string">
-<code class="descclassname">joy.utils.stack.</code><code class="descname">expression_to_string</code><span class="sig-paren">(</span><em>expression</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#expression_to_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.expression_to_string" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.stack.expression_to_string">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.stack.</span></span><span class="sig-name descname"><span class="pre">expression_to_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#expression_to_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.stack.expression_to_string" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return a “pretty print” string for a expression.</p>
 <p>The items are written left-to-right:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">top</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="o">...</span><span class="p">))</span> <span class="o">-&gt;</span> <span class="s1">&#39;top second ...&#39;</span>
 </pre></div>
 </div>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>expression</strong> (<em>stack</em>) – A stack.</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
-</tr>
-</tbody>
-</table>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><p><strong>expression</strong> (<em>stack</em>) – A stack.</p>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>str</p>
+</dd>
+</dl>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.stack.iter_stack">
-<code class="descclassname">joy.utils.stack.</code><code class="descname">iter_stack</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#iter_stack"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.iter_stack" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.stack.iter_stack">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.stack.</span></span><span class="sig-name descname"><span class="pre">iter_stack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#iter_stack"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.stack.iter_stack" title="Permalink to this definition">¶</a></dt>
 <dd><p>Iterate through the items on the stack.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stack</strong> (<em>stack</em>) – A stack.</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">iterator</td>
-</tr>
-</tbody>
-</table>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><p><strong>stack</strong> (<em>stack</em>) – A stack.</p>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>iterator</p>
+</dd>
+</dl>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.stack.list_to_stack">
-<code class="descclassname">joy.utils.stack.</code><code class="descname">list_to_stack</code><span class="sig-paren">(</span><em>el</em>, <em>stack=()</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#list_to_stack"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.list_to_stack" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.stack.list_to_stack">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.stack.</span></span><span class="sig-name descname"><span class="pre">list_to_stack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">el</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stack</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#list_to_stack"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.stack.list_to_stack" title="Permalink to this definition">¶</a></dt>
 <dd><p>Convert a Python list (or other sequence) to a Joy stack:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="p">())))</span>
 </pre></div>
 </div>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
-<li><strong>el</strong> (<em>list</em>) – A Python list or other sequence (iterators and generators
-won’t work because <code class="docutils literal notranslate"><span class="pre">reverse()</span></code> is called on <code class="docutils literal notranslate"><span class="pre">el</span></code>.)</li>
-<li><strong>stack</strong> (<em>stack</em>) – A stack, optional, defaults to the empty stack.</li>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>el</strong> (<em>list</em>) – A Python list or other sequence (iterators and generators
+won’t work because <code class="docutils literal notranslate"><span class="pre">reverse()</span></code> is called on <code class="docutils literal notranslate"><span class="pre">el</span></code>.)</p></li>
+<li><p><strong>stack</strong> (<em>stack</em>) – A stack, optional, defaults to the empty stack.</p></li>
 </ul>
-</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stack</p>
-</td>
-</tr>
-</tbody>
-</table>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>stack</p>
+</dd>
+</dl>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.stack.pick">
-<code class="descclassname">joy.utils.stack.</code><code class="descname">pick</code><span class="sig-paren">(</span><em>stack</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>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.stack.pick">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.stack.</span></span><span class="sig-name descname"><span class="pre">pick</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#pick"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.stack.pick" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return the nth item on the stack.</p>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
-<li><strong>stack</strong> (<em>stack</em>) – A stack.</li>
-<li><strong>n</strong> (<em>int</em>) – An index into the stack.</li>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><ul class="simple">
+<li><p><strong>stack</strong> (<em>stack</em>) – A stack.</p></li>
+<li><p><strong>n</strong> (<em>int</em>) – An index into the stack.</p></li>
 </ul>
-</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first simple">
-<li><strong>ValueError</strong> – if <code class="docutils literal notranslate"><span class="pre">n</span></code> is less than zero.</li>
-<li><strong>IndexError</strong> – if <code class="docutils literal notranslate"><span class="pre">n</span></code> is equal to or greater than the length of <code class="docutils literal notranslate"><span class="pre">stack</span></code>.</li>
+</dd>
+<dt class="field-even">Raises</dt>
+<dd class="field-even"><ul class="simple">
+<li><p><strong>ValueError</strong> – if <code class="docutils literal notranslate"><span class="pre">n</span></code> is less than zero.</p></li>
+<li><p><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">stack</span></code>.</p></li>
 </ul>
-</td>
-</tr>
-<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">whatever</p>
-</td>
-</tr>
-</tbody>
-</table>
+</dd>
+<dt class="field-odd">Return type</dt>
+<dd class="field-odd"><p>whatever</p>
+</dd>
+</dl>
 </dd></dl>
 
-<dl class="function">
-<dt id="joy.utils.stack.stack_to_string">
-<code class="descclassname">joy.utils.stack.</code><code class="descname">stack_to_string</code><span class="sig-paren">(</span><em>stack</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#stack_to_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.utils.stack.stack_to_string" title="Permalink to this definition">¶</a></dt>
+<dl class="py function">
+<dt class="sig sig-object py" id="joy.utils.stack.stack_to_string">
+<span class="sig-prename descclassname"><span class="pre">joy.utils.stack.</span></span><span class="sig-name descname"><span class="pre">stack_to_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/stack.html#stack_to_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.stack.stack_to_string" title="Permalink to this definition">¶</a></dt>
 <dd><p>Return a “pretty print” string for a stack.</p>
 <p>The items are written right-to-left:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">top</span><span class="p">,</span> <span class="p">(</span><span class="n">second</span><span class="p">,</span> <span class="o">...</span><span class="p">))</span> <span class="o">-&gt;</span> <span class="s1">&#39;... second top&#39;</span>
 </pre></div>
 </div>
-<table class="docutils field-list" frame="void" rules="none">
-<col class="field-name" />
-<col class="field-body" />
-<tbody valign="top">
-<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stack</strong> (<em>stack</em>) – A stack.</td>
-</tr>
-<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
-</tr>
-</tbody>
-</table>
+<dl class="field-list simple">
+<dt class="field-odd">Parameters</dt>
+<dd class="field-odd"><p><strong>stack</strong> (<em>stack</em>) – A stack.</p>
+</dd>
+<dt class="field-even">Return type</dt>
+<dd class="field-even"><p>str</p>
+</dd>
+</dl>
 </dd></dl>
 
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Stack or Quote or Sequence or List…</a><ul>
-<li><a class="reference internal" href="#module-joy.utils.stack"><code class="docutils literal notranslate"><span class="pre">joy.utils.stack</span></code></a></li>
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Stack or Quote or Sequence or List…</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#module-joy.utils.stack"><code class="docutils literal notranslate"><span class="pre">joy.utils.stack</span></code></a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -238,25 +252,24 @@ won’t work because <code class="docutils literal notranslate"><span class="pre
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/stack.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -267,7 +280,7 @@ won’t work because <code class="docutils literal notranslate"><span class="pre
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index d8a9e0d..a7e9539 100644 (file)
@@ -1,19 +1,18 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
     <title>Type Inference of Joy Expressions &#8212; Thun 0.4.1 documentation</title>
-    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="_static/documentation_options.js"></script>
-    <script type="text/javascript" src="_static/jquery.js"></script>
-    <script type="text/javascript" src="_static/underscore.js"></script>
-    <script type="text/javascript" src="_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
     <link rel="index" title="Index" href="genindex.html" />
     <link rel="search" title="Search" href="search.html" />
     <link rel="next" title="Essays about Programming in Joy" href="notebooks/index.html" />
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="type-inference-of-joy-expressions">
+  <section id="type-inference-of-joy-expressions">
 <h1>Type Inference of Joy Expressions<a class="headerlink" href="#type-inference-of-joy-expressions" title="Permalink to this headline">¶</a></h1>
 <p>UPDATE: May 2020 - I removed the type inference code in <cite>joy.utils.types</cite>
 but you can find it in the <cite>v0.4.0</cite> tag here:
@@ -44,7 +45,7 @@ functions, and a more complex inferencer/interpreter hybrid that can
 infer the stack effects of most Joy expressions, including multiple stack
 effects, unbounded sequences of values, and combinators (if enough
 information is available.)</p>
-<div class="section" id="joy-utils-types">
+<section id="joy-utils-types">
 <h2><code class="docutils literal notranslate"><span class="pre">joy.utils.types</span></code><a class="headerlink" href="#joy-utils-types" title="Permalink to this headline">¶</a></h2>
 <p>Curently (asterix after name indicates a function that can be
 auto-compiled to Python):</p>
@@ -173,22 +174,41 @@ far.</p>
 (i2 i1 -- i3)
 </pre></div>
 </div>
-</div>
-</div>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">Type Inference of Joy Expressions</a><ul>
-<li><a class="reference internal" href="#joy-utils-types"><code class="docutils literal notranslate"><span class="pre">joy.utils.types</span></code></a></li>
+<h1 class="logo"><a href="index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1 current"><a class="current reference internal" href="#">Type Inference of Joy Expressions</a><ul>
+<li class="toctree-l2"><a class="reference internal" href="#joy-utils-types"><code class="docutils literal notranslate"><span class="pre">joy.utils.types</span></code></a></li>
 </ul>
 </li>
+<li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
@@ -198,25 +218,24 @@ far.</p>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="_sources/types.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -227,7 +246,7 @@ far.</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>
index b765192..2b93e4f 100644 (file)
@@ -2,7 +2,7 @@
 Functions Grouped by, er, Function with Examples
 ------------------------------------------------
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import J, V
 
@@ -19,7 +19,7 @@ it's "off the shelf" technology.)
 ``clear``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 clear')
 
@@ -32,7 +32,7 @@ it's "off the shelf" technology.)
 ``dup`` ``dupd``
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 dup')
 
@@ -42,7 +42,7 @@ it's "off the shelf" technology.)
     1 2 3 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 dupd')
 
@@ -58,7 +58,7 @@ it's "off the shelf" technology.)
 (I may have these paired up wrong. I.e. ``disenstacken`` should be
 ``unstack`` and vice versa.)
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 enstacken') # Replace the stack with a quote of itself.
 
@@ -68,7 +68,7 @@ it's "off the shelf" technology.)
     [3 2 1]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('4 5 6 [3 2 1] disenstacken')  # Unpack a list onto the stack.
 
@@ -78,7 +78,7 @@ it's "off the shelf" technology.)
     4 5 6 3 2 1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 stack')  # Get the stack on the stack.
 
@@ -88,7 +88,7 @@ it's "off the shelf" technology.)
     1 2 3 [3 2 1]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 [4 5 6] unstack')  # Replace the stack with the list on top.
                                 # The items appear reversed but they are not,
@@ -103,7 +103,7 @@ it's "off the shelf" technology.)
 ``pop`` ``popd`` ``popop``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 pop')
 
@@ -113,7 +113,7 @@ it's "off the shelf" technology.)
     1 2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 popd')
 
@@ -123,7 +123,7 @@ it's "off the shelf" technology.)
     1 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 popop')
 
@@ -139,7 +139,7 @@ it's "off the shelf" technology.)
 The "down" and "up" refer to the movement of two of the top three items
 (displacing the third.)
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 roll<')
 
@@ -149,7 +149,7 @@ The "down" and "up" refer to the movement of two of the top three items
     2 3 1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 roll>')
 
@@ -162,7 +162,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``swap``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 swap')
 
@@ -175,7 +175,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``tuck`` ``over``
 ~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 tuck')
 
@@ -185,7 +185,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 3 2 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 over')
 
@@ -198,7 +198,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``unit`` ``quoted`` ``unquoted``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 unit')
 
@@ -208,7 +208,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 2 [3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 quoted')
 
@@ -218,7 +218,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 [2] 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 [2] 3 unquoted')
 
@@ -228,7 +228,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 2 3
 
 
-.. code:: ipython2
+.. code:: python
 
     V('1 [dup] 3 unquoted')  # Unquoting evaluates.  Be aware.
 
@@ -253,7 +253,7 @@ List words
 ``concat`` ``swoncat`` ``shunt``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [4 5 6] concat')
 
@@ -263,7 +263,7 @@ List words
     [1 2 3 4 5 6]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [4 5 6] swoncat')
 
@@ -273,7 +273,7 @@ List words
     [4 5 6 1 2 3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [4 5 6] shunt')
 
@@ -286,7 +286,7 @@ List words
 ``cons`` ``swons`` ``uncons``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 [2 3] cons')
 
@@ -296,7 +296,7 @@ List words
     [1 2 3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[2 3] 1 swons')
 
@@ -306,7 +306,7 @@ List words
     [1 2 3]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] uncons')
 
@@ -319,7 +319,7 @@ List words
 ``first`` ``second`` ``third`` ``rest``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] first')
 
@@ -329,7 +329,7 @@ List words
     1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] second')
 
@@ -339,7 +339,7 @@ List words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] third')
 
@@ -349,7 +349,7 @@ List words
     3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] rest')
 
@@ -362,7 +362,7 @@ List words
 ``flatten``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[[1] [2 [3] 4] [5 6]] flatten')
 
@@ -377,7 +377,7 @@ List words
 
 ``at`` and ``getitem`` are the same function. ``of == swap at``
 
-.. code:: ipython2
+.. code:: python
 
     J('[10 11 12 13 14] 2 getitem')
 
@@ -387,7 +387,7 @@ List words
     12
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] 0 at')
 
@@ -397,7 +397,7 @@ List words
     1
 
 
-.. code:: ipython2
+.. code:: python
 
     J('2 [1 2 3 4] of')
 
@@ -407,7 +407,7 @@ List words
     3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] 2 drop')
 
@@ -417,7 +417,7 @@ List words
     [3 4]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] 2 take')  # reverses the order
 
@@ -432,7 +432,7 @@ List words
 ``remove``
 ~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 1 4] 1 remove')
 
@@ -445,7 +445,7 @@ List words
 ``reverse``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 4] reverse')
 
@@ -458,7 +458,7 @@ List words
 ``size``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 1 1 1] size')
 
@@ -475,7 +475,7 @@ List words
 put the old stack on top of the new one. Think of it as a context
 switch. Niether of the lists/stacks change their order.
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 [4 5 6] swaack')
 
@@ -488,7 +488,7 @@ switch. Niether of the lists/stacks change their order.
 ``choice`` ``select``
 ~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 1 choice')
 
@@ -498,7 +498,7 @@ switch. Niether of the lists/stacks change their order.
     9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 0 choice')
 
@@ -508,7 +508,7 @@ switch. Niether of the lists/stacks change their order.
     23
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 9 7] 1 select')  # select is basically getitem, should retire it?
 
@@ -518,7 +518,7 @@ switch. Niether of the lists/stacks change their order.
     9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 9 7] 0 select')
 
@@ -531,7 +531,7 @@ switch. Niether of the lists/stacks change their order.
 ``zip``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [6 5 4] zip')
 
@@ -541,7 +541,7 @@ switch. Niether of the lists/stacks change their order.
     [[6 1] [5 2] [4 3]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] [6 5 4] zip [sum] map')
 
@@ -557,7 +557,7 @@ Math words
 ``+`` ``add``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 +')
 
@@ -570,7 +570,7 @@ Math words
 ``-`` ``sub``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 -')
 
@@ -583,7 +583,7 @@ Math words
 ``*`` ``mul``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 *')
 
@@ -596,7 +596,7 @@ Math words
 ``/`` ``div`` ``floordiv`` ``truediv``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 /')
 
@@ -606,7 +606,7 @@ Math words
     2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 -9 truediv')
 
@@ -616,7 +616,7 @@ Math words
     -2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 div')
 
@@ -626,7 +626,7 @@ Math words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 floordiv')
 
@@ -636,7 +636,7 @@ Math words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 -9 div')
 
@@ -646,7 +646,7 @@ Math words
     -3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 -9 floordiv')
 
@@ -659,7 +659,7 @@ Math words
 ``%`` ``mod`` ``modulus`` ``rem`` ``remainder``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 %')
 
@@ -672,7 +672,7 @@ Math words
 ``neg``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 neg -5 neg')
 
@@ -685,7 +685,7 @@ Math words
 ``pow``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('2 10 pow')
 
@@ -698,7 +698,7 @@ Math words
 ``sqr`` ``sqrt``
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 sqr')
 
@@ -708,7 +708,7 @@ Math words
     529
 
 
-.. code:: ipython2
+.. code:: python
 
     J('23 sqrt')
 
@@ -721,7 +721,7 @@ Math words
 ``++`` ``succ`` ``--`` ``pred``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 ++')
 
@@ -731,7 +731,7 @@ Math words
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 --')
 
@@ -744,7 +744,7 @@ Math words
 ``<<`` ``lshift`` ``>>`` ``rshift``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('8 1 <<')
 
@@ -754,7 +754,7 @@ Math words
     16
 
 
-.. code:: ipython2
+.. code:: python
 
     J('8 1 >>')
 
@@ -767,7 +767,7 @@ Math words
 ``average``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] average')
 
@@ -780,7 +780,7 @@ Math words
 ``range`` ``range_to_zero`` ``down_to_zero``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('5 range')
 
@@ -790,7 +790,7 @@ Math words
     [4 3 2 1 0]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('5 range_to_zero')
 
@@ -800,7 +800,7 @@ Math words
     [0 1 2 3 4 5]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('5 down_to_zero')
 
@@ -813,7 +813,7 @@ Math words
 ``product``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] product')
 
@@ -826,7 +826,7 @@ Math words
 ``sum``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] sum')
 
@@ -839,7 +839,7 @@ Math words
 ``min``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3 5] min')
 
@@ -852,7 +852,7 @@ Math words
 ``gcd``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('45 30 gcd')
 
@@ -868,7 +868,7 @@ Math words
 If we represent fractions as a quoted pair of integers [q d] this word
 reduces them to their ... least common factors or whatever.
 
-.. code:: ipython2
+.. code:: python
 
     J('[45 30] least_fraction')
 
@@ -878,7 +878,7 @@ reduces them to their ... least common factors or whatever.
     [3 2]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 12] least_fraction')
 
@@ -896,7 +896,7 @@ Logic and Comparison
 
 Get the Boolean value of the item on the top of the stack.
 
-.. code:: ipython2
+.. code:: python
 
     J('23 truthy')
 
@@ -906,7 +906,7 @@ Get the Boolean value of the item on the top of the stack.
     True
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[] truthy')  # Python semantics.
 
@@ -916,7 +916,7 @@ Get the Boolean value of the item on the top of the stack.
     False
 
 
-.. code:: ipython2
+.. code:: python
 
     J('0 truthy')
 
@@ -930,7 +930,7 @@ Get the Boolean value of the item on the top of the stack.
 
     ? == dup truthy
 
-.. code:: ipython2
+.. code:: python
 
     V('23 ?')
 
@@ -944,7 +944,7 @@ Get the Boolean value of the item on the top of the stack.
     23 True . 
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[] ?')
 
@@ -954,7 +954,7 @@ Get the Boolean value of the item on the top of the stack.
     [] False
 
 
-.. code:: ipython2
+.. code:: python
 
     J('0 ?')
 
@@ -967,7 +967,7 @@ Get the Boolean value of the item on the top of the stack.
 ``&`` ``and``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 &')
 
@@ -980,7 +980,7 @@ Get the Boolean value of the item on the top of the stack.
 ``!=`` ``<>`` ``ne``
 ~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('23 9 !=')
 
@@ -996,7 +996,7 @@ Get the Boolean value of the item on the top of the stack.
 ``^`` ``xor``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 1 ^')
 
@@ -1006,7 +1006,7 @@ Get the Boolean value of the item on the top of the stack.
     0
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 0 ^')
 
@@ -1022,7 +1022,7 @@ Miscellaneous
 ``help``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[help] help')
 
@@ -1036,7 +1036,7 @@ Miscellaneous
 ``parse``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[parse] help')
 
@@ -1047,7 +1047,7 @@ Miscellaneous
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 "2 [3] dup" parse')
 
@@ -1062,7 +1062,7 @@ Miscellaneous
 
 Evaluate a quoted Joy sequence.
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 dup + +] run')
 
@@ -1078,7 +1078,7 @@ Combinators
 ``app1`` ``app2`` ``app3``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[app1] help')
 
@@ -1095,7 +1095,7 @@ Combinators
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 4 [sqr *] app1')
 
@@ -1105,7 +1105,7 @@ Combinators
     10 160
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 3 4 [sqr *] app2')
 
@@ -1115,7 +1115,7 @@ Combinators
     10 90 160
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[app2] help')
 
@@ -1131,7 +1131,7 @@ Combinators
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 2 3 4 [sqr *] app3')
 
@@ -1159,7 +1159,7 @@ Example, ``range``:
 
     range == [0 <=] [1 - dup] anamorphism
 
-.. code:: ipython2
+.. code:: python
 
     J('3 [0 <=] [1 - dup] anamorphism')
 
@@ -1172,7 +1172,7 @@ Example, ``range``:
 ``branch``
 ~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('3 4 1 [+] [*] branch')
 
@@ -1182,7 +1182,7 @@ Example, ``range``:
     12
 
 
-.. code:: ipython2
+.. code:: python
 
     J('3 4 0 [+] [*] branch')
 
@@ -1217,7 +1217,7 @@ in terms of ``app2``:
 
     cleave == [i] app2 [popd] dip
 
-.. code:: ipython2
+.. code:: python
 
     J('10 2 [+] [-] cleave')
 
@@ -1230,7 +1230,7 @@ in terms of ``app2``:
 ``dip`` ``dipd`` ``dipdd``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] dip')
 
@@ -1240,7 +1240,7 @@ in terms of ``app2``:
     1 2 7 5
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] dipd')
 
@@ -1250,7 +1250,7 @@ in terms of ``app2``:
     1 5 4 5
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] dipdd')
 
@@ -1270,7 +1270,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 
     n [Q] dupdip == n Q n
 
-.. code:: ipython2
+.. code:: python
 
     V('23 [++] dupdip *')  # N(N + 1)
 
@@ -1289,7 +1289,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``genrec`` ``primrec``
 ~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[genrec] help')
 
@@ -1343,7 +1343,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('3 [1 <=] [] [dup --] [i *] genrec')
 
@@ -1356,7 +1356,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``i``
 ~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     V('1 2 3 [+ +] i')
 
@@ -1380,7 +1380,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 
     [predicate] [then] [else] ifte
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 [1] [+] [*] ifte')
 
@@ -1390,7 +1390,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 [0] [+] [*] ifte')
 
@@ -1403,7 +1403,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``infra``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     V('1 2 3 [4 5 6] [* +] infra')
 
@@ -1426,7 +1426,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``loop``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[loop] help')
 
@@ -1445,7 +1445,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('3 dup [1 - dup] loop')
 
@@ -1477,7 +1477,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``map`` ``pam``
 ~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('10 [1 2 3] [*] map')
 
@@ -1487,7 +1487,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     10 [10 20 30]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('10 5 [[*][/][+][-]] pam')
 
@@ -1503,7 +1503,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 Run a quoted program enforcing
 `arity <https://en.wikipedia.org/wiki/Arity>`__.
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] nullary')
 
@@ -1513,7 +1513,7 @@ Run a quoted program enforcing
     1 2 3 4 5 9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] unary')
 
@@ -1523,7 +1523,7 @@ Run a quoted program enforcing
     1 2 3 4 9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] binary')  # + has arity 2 so this is technically pointless...
 
@@ -1533,7 +1533,7 @@ Run a quoted program enforcing
     1 2 3 9
 
 
-.. code:: ipython2
+.. code:: python
 
     J('1 2 3 4 5 [+] ternary')
 
@@ -1546,7 +1546,7 @@ Run a quoted program enforcing
 ``step``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[step] help')
 
@@ -1574,7 +1574,7 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('0 [1 2 3] [+] step')
 
@@ -1603,7 +1603,7 @@ Run a quoted program enforcing
 ``times``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     V('3 2 1 2 [+] times')
 
@@ -1627,7 +1627,7 @@ Run a quoted program enforcing
 ``b``
 ~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[b] help')
 
@@ -1641,7 +1641,7 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('1 2 [3] [4] b')
 
@@ -1665,7 +1665,7 @@ Run a quoted program enforcing
 
     [predicate] [body] while
 
-.. code:: ipython2
+.. code:: python
 
     J('3 [0 >] [dup --] while')
 
@@ -1678,7 +1678,7 @@ Run a quoted program enforcing
 ``x``
 ~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[x] help')
 
@@ -1693,7 +1693,7 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: python
 
     V('1 [2] [i 3] x')  # Kind of a pointless example.
 
@@ -1720,7 +1720,7 @@ Implements `**Laws of Form**
 over quote-only datastructures (that is, datastructures that consist
 soley of containers, without strings or numbers or anything else.)
 
-.. code:: ipython2
+.. code:: python
 
     J('[] void')
 
@@ -1730,7 +1730,7 @@ soley of containers, without strings or numbers or anything else.)
     False
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[[]] void')
 
@@ -1740,7 +1740,7 @@ soley of containers, without strings or numbers or anything else.)
     True
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[[][[]]] void')
 
@@ -1750,7 +1750,7 @@ soley of containers, without strings or numbers or anything else.)
     True
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[[[]][[][]]] void')
 
index 29dc9fb..be09155 100644 (file)
@@ -76,7 +76,7 @@ E.g.:
 Implementation
 --------------
 
-.. code:: ipython2
+.. code:: python
 
     from functools import partial as curry
     from itertools import product
@@ -86,7 +86,7 @@ Implementation
 
 The empty set and the set of just the empty string.
 
-.. code:: ipython2
+.. code:: python
 
     phi = frozenset()   # ϕ
     y = frozenset({''}) # λ
@@ -101,7 +101,7 @@ alphabet with two symbols (if you had to.)
 I chose the names ``O`` and ``l`` (uppercase “o” and lowercase “L”) to
 look like ``0`` and ``1`` (zero and one) respectively.
 
-.. code:: ipython2
+.. code:: python
 
     syms = O, l = frozenset({'0'}), frozenset({'1'})
 
@@ -123,7 +123,7 @@ expression* is one of:
 
 Where ``R`` and ``S`` stand for *regular expressions*.
 
-.. code:: ipython2
+.. code:: python
 
     AND, CONS, KSTAR, NOT, OR = 'and cons * not or'.split()  # Tags are just strings.
 
@@ -133,7 +133,7 @@ only, these datastructures are immutable.
 String Representation of RE Datastructures
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def stringy(re):
         '''
@@ -175,11 +175,11 @@ Match anything. Often spelled “.”
 
    I = (0|1)*
 
-.. code:: ipython2
+.. code:: python
 
     I = (KSTAR, (OR, O, l))
 
-.. code:: ipython2
+.. code:: python
 
     print stringy(I)
 
@@ -201,14 +201,14 @@ The example expression from Brzozowski:
 
 Note that it contains one of everything.
 
-.. code:: ipython2
+.. code:: python
 
     a = (CONS, I, (CONS, l, (CONS, l, (CONS, l, I))))
     b = (CONS, I, (CONS, O, l))
     c = (CONS, l, (KSTAR, l))
     it = (AND, a, (NOT, (OR, b, c)))
 
-.. code:: ipython2
+.. code:: python
 
     print stringy(it)
 
@@ -223,7 +223,7 @@ Note that it contains one of everything.
 
 Let’s get that auxiliary predicate function ``δ`` out of the way.
 
-.. code:: ipython2
+.. code:: python
 
     def nully(R):
         '''
@@ -263,7 +263,7 @@ This is the straightforward version with no “compaction”. It works fine,
 but does waaaay too much work because the expressions grow each
 derivation.
 
-.. code:: ipython2
+.. code:: python
 
     def D(symbol):
     
@@ -308,7 +308,7 @@ derivation.
 Compaction Rules
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def _compaction_rule(relation, one, zero, a, b):
         return (
@@ -320,7 +320,7 @@ Compaction Rules
 
 An elegant symmetry.
 
-.. code:: ipython2
+.. code:: python
 
     # R ∧ I = I ∧ R = R
     # R ∧ ϕ = ϕ ∧ R = ϕ
@@ -341,7 +341,7 @@ We can save re-processing by remembering results we have already
 computed. RE datastructures are immutable and the ``derv()`` functions
 are *pure* so this is fine.
 
-.. code:: ipython2
+.. code:: python
 
     class Memo(object):
     
@@ -365,7 +365,7 @@ With “Compaction”
 This version uses the rules above to perform compaction. It keeps the
 expressions from growing too large.
 
-.. code:: ipython2
+.. code:: python
 
     def D_compaction(symbol):
     
@@ -414,7 +414,7 @@ Let’s try it out…
 
 (FIXME: redo.)
 
-.. code:: ipython2
+.. code:: python
 
     o, z = D_compaction('0'), D_compaction('1')
     REs = set()
@@ -533,10 +533,10 @@ machine transition table.
 
 Says, “Three or more 1’s and not ending in 01 nor composed of all 1’s.”
 
-.. figure:: attachment:omg.svg
-   :alt: omg.svg
+.. figure:: omg.svg
+   :alt: State Machine Graph
 
-   omg.svg
+   State Machine Graph
 
 Start at ``a`` and follow the transition arrows according to their
 labels. Accepting states have a double outline. (Graphic generated with
@@ -605,20 +605,20 @@ You can see the one-way nature of the ``g`` state and the ``hij`` “trap”
 in the way that the ``.111.`` on the left-hand side of the ``&``
 disappears once it has been matched.
 
-.. code:: ipython2
+.. code:: python
 
     from collections import defaultdict
     from pprint import pprint
     from string import ascii_lowercase
 
-.. code:: ipython2
+.. code:: python
 
     d0, d1 = D_compaction('0'), D_compaction('1')
 
 ``explore()``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def explore(re):
     
@@ -645,7 +645,7 @@ disappears once it has been matched.
     
         return table, accepting
 
-.. code:: ipython2
+.. code:: python
 
     table, accepting = explore(it)
     table
@@ -678,7 +678,7 @@ disappears once it has been matched.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     accepting
 
@@ -697,7 +697,7 @@ Generate Diagram
 Once we have the FSM table and the set of accepting states we can
 generate the diagram above.
 
-.. code:: ipython2
+.. code:: python
 
     _template = '''\
     digraph finite_state_machine {
@@ -722,7 +722,7 @@ generate the diagram above.
               )
             )
 
-.. code:: ipython2
+.. code:: python
 
     print make_graph(table, accepting)
 
@@ -776,7 +776,7 @@ Trampoline Function
 Python has no GOTO statement but we can fake it with a “trampoline”
 function.
 
-.. code:: ipython2
+.. code:: python
 
     def trampoline(input_, jump_from, accepting):
         I = iter(input_)
@@ -793,7 +793,7 @@ Stream Functions
 Little helpers to process the iterator of our data (a “stream” of “1”
 and “0” characters, not bits.)
 
-.. code:: ipython2
+.. code:: python
 
     getch = lambda I: int(next(I))
     
@@ -816,7 +816,7 @@ code. (You have to imagine that these are GOTO statements in C or
 branches in assembly and that the state names are branch destination
 labels.)
 
-.. code:: ipython2
+.. code:: python
 
     a = lambda I: c if getch(I) else b
     b = lambda I: _0(I) or d
@@ -833,12 +833,12 @@ Note that the implementations of ``h`` and ``g`` are identical ergo
 ``h = g`` and we could eliminate one in the code but ``h`` is an
 accepting state and ``g`` isn’t.
 
-.. code:: ipython2
+.. code:: python
 
     def acceptable(input_):
         return trampoline(input_, a, {h, i})
 
-.. code:: ipython2
+.. code:: python
 
     for n in range(2**5):
         s = bin(n)[2:]
index 5b9314b..556225a 100644 (file)
@@ -12,7 +12,7 @@ As an example of developing a program in Joy let's take the first problem from t
 
     Find the sum of all the multiples of 3 or 5 below 1000.
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import J, V, define
 
@@ -22,11 +22,11 @@ Sum a range filtered by a predicate
 Let's create a predicate that returns ``True`` if a number is a multiple
 of 3 or 5 and ``False`` otherwise.
 
-.. code:: ipython2
+.. code:: python
 
     define('P == [3 % not] dupdip 5 % not or')
 
-.. code:: ipython2
+.. code:: python
 
     V('80 P')
 
@@ -108,11 +108,11 @@ the counter to the running sum. This function will do that:
 
     PE1.1 == + [+] dupdip
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1.1 == + [+] dupdip')
 
-.. code:: ipython2
+.. code:: python
 
     V('0 0 3 PE1.1')
 
@@ -131,7 +131,7 @@ the counter to the running sum. This function will do that:
         3 3 . 
 
 
-.. code:: ipython2
+.. code:: python
 
     V('0 0 [3 2 1 3 1 2 3] [PE1.1] step')
 
@@ -219,7 +219,7 @@ total to 60.
 How many multiples to sum?
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-.. code:: ipython2
+.. code:: python
 
     1000 / 15
 
@@ -232,7 +232,7 @@ How many multiples to sum?
 
 
 
-.. code:: ipython2
+.. code:: python
 
     66 * 15
 
@@ -245,7 +245,7 @@ How many multiples to sum?
 
 
 
-.. code:: ipython2
+.. code:: python
 
     1000 - 990
 
@@ -260,7 +260,7 @@ How many multiples to sum?
 
 We only want the terms *less than* 1000.
 
-.. code:: ipython2
+.. code:: python
 
     999 - 990
 
@@ -276,11 +276,11 @@ We only want the terms *less than* 1000.
 That means we want to run the full list of numbers sixty-six times to
 get to 990 and then the first four numbers 3 2 1 3 to get to 999.
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop')
 
-.. code:: ipython2
+.. code:: python
 
     J('PE1')
 
@@ -305,7 +305,7 @@ integer terms from the list.
         3  2  1  3  1  2  3
     0b 11 10 01 11 01 10 11 == 14811
 
-.. code:: ipython2
+.. code:: python
 
     0b11100111011011
 
@@ -318,11 +318,11 @@ integer terms from the list.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1.2 == [3 & PE1.1] dupdip 2 >>')
 
-.. code:: ipython2
+.. code:: python
 
     V('0 0 14811 PE1.2')
 
@@ -349,7 +349,7 @@ integer terms from the list.
                  3 3 3702 . 
 
 
-.. code:: ipython2
+.. code:: python
 
     V('3 3 3702 PE1.2')
 
@@ -376,7 +376,7 @@ integer terms from the list.
                  8 5 925 . 
 
 
-.. code:: ipython2
+.. code:: python
 
     V('0 0 14811 7 [PE1.2] times pop')
 
@@ -518,11 +518,11 @@ integer terms from the list.
 
 And so we have at last:
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop')
 
-.. code:: ipython2
+.. code:: python
 
     J('PE1')
 
@@ -542,17 +542,17 @@ Let's refactor
       14811 n [PE1.2] times pop
     n 14811 swap [PE1.2] times pop
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1.3 == 14811 swap [PE1.2] times pop')
 
 Now we can simplify the definition above:
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop')
 
-.. code:: ipython2
+.. code:: python
 
     J('PE1')
 
@@ -581,11 +581,11 @@ then four more. In the *Generator Programs* notebook we derive a
 generator that can be repeatedly driven by the ``x`` combinator to
 produce a stream of the seven numbers repeating over and over again.
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]')
 
-.. code:: ipython2
+.. code:: python
 
     J('PE1.terms 21 [x] times')
 
@@ -598,7 +598,7 @@ produce a stream of the seven numbers repeating over and over again.
 We know from above that we need sixty-six times seven then four more
 terms to reach up to but not over one thousand.
 
-.. code:: ipython2
+.. code:: python
 
     J('7 66 * 4 +')
 
@@ -611,7 +611,7 @@ terms to reach up to but not over one thousand.
 Here they are...
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('PE1.terms 466 [x] times pop')
 
@@ -624,7 +624,7 @@ Here they are...
 ...and they do sum to 999.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[PE1.terms 466 [x] times pop] run sum')
 
@@ -638,7 +638,7 @@ Now we can use ``PE1.1`` to accumulate the terms as we go, and then
 ``pop`` the generator and the counter from the stack when we're done,
 leaving just the sum.
 
-.. code:: ipython2
+.. code:: python
 
     J('0 0 PE1.terms 466 [x [PE1.1] dip] times popop')
 
@@ -654,7 +654,7 @@ A little further analysis renders iteration unnecessary.
 Consider finding the sum of the positive integers less than or equal to
 ten.
 
-.. code:: ipython2
+.. code:: python
 
     J('[10 9 8 7 6 5 4 3 2 1] sum')
 
@@ -686,11 +686,11 @@ positive integers is:
 (The formula also works for odd values of N, I'll leave that to you if
 you want to work it out or you can take my word for it.)
 
-.. code:: ipython2
+.. code:: python
 
     define('F == dup ++ * 2 floordiv')
 
-.. code:: ipython2
+.. code:: python
 
     V('10 F')
 
@@ -727,7 +727,7 @@ And ending with:
 
 If we reverse one of these two blocks and sum pairs...
 
-.. code:: ipython2
+.. code:: python
 
     J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip')
 
@@ -737,7 +737,7 @@ If we reverse one of these two blocks and sum pairs...
     [[978 15] [980 12] [981 10] [984 9] [985 6] [987 5] [990 3]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map')
 
@@ -750,7 +750,7 @@ If we reverse one of these two blocks and sum pairs...
 (Interesting that the sequence of seven numbers appears again in the
 rightmost digit of each term.)
 
-.. code:: ipython2
+.. code:: python
 
     J('[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum')
 
@@ -771,7 +771,7 @@ additional unpaired terms between 990 and 1000:
 So we can give the "sum of all the multiples of 3 or 5 below 1000" like
 so:
 
-.. code:: ipython2
+.. code:: python
 
     J('6945 33 * [993 995 996 999] cons sum')
 
index 55e1679..a59df18 100644 (file)
@@ -3,7 +3,7 @@ Using ``x`` to Generate Values
 
 Cf. jp-reprod.html
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import J, V, define
 
@@ -57,7 +57,7 @@ We can make a generator for the Natural numbers (0, 1, 2, …) by using
 
 Let’s try it:
 
-.. code:: ipython2
+.. code:: python
 
     V('[0 swap [dup ++] dip rest cons] x')
 
@@ -81,7 +81,7 @@ Let’s try it:
 After one application of ``x`` the quoted program contains ``1`` and
 ``0`` is below it on the stack.
 
-.. code:: ipython2
+.. code:: python
 
     J('[0 swap [dup ++] dip rest cons] x x x x x pop')
 
@@ -94,11 +94,11 @@ After one application of ``x`` the quoted program contains ``1`` and
 ``direco``
 ----------
 
-.. code:: ipython2
+.. code:: python
 
     define('direco == dip rest cons')
 
-.. code:: ipython2
+.. code:: python
 
     V('[0 swap [dup ++] direco] x')
 
@@ -149,13 +149,13 @@ Reading from the bottom up:
    G == [direco] cons [swap] swap concat cons
    G == [direco] cons [swap] swoncat cons
 
-.. code:: ipython2
+.. code:: python
 
     define('G == [direco] cons [swap] swoncat cons')
 
 Let’s try it out:
 
-.. code:: ipython2
+.. code:: python
 
     J('0 [dup ++] G')
 
@@ -165,7 +165,7 @@ Let’s try it out:
     [0 swap [dup ++] direco]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('0 [dup ++] G x x x pop')
 
@@ -178,7 +178,7 @@ Let’s try it out:
 Powers of 2
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('1 [dup 1 <<] G x x x x x x x x x pop')
 
@@ -194,7 +194,7 @@ Powers of 2
 If we have one of these quoted programs we can drive it using ``times``
 with the ``x`` combinator.
 
-.. code:: ipython2
+.. code:: python
 
     J('23 [dup ++] G 5 [x] times')
 
@@ -226,11 +226,11 @@ int:
 And pick them off by masking with 3 (binary 11) and then shifting the
 int right two bits.
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1.1 == dup [3 &] dip 2 >>')
 
-.. code:: ipython2
+.. code:: python
 
     V('14811 PE1.1')
 
@@ -252,7 +252,7 @@ int right two bits.
 
 If we plug ``14811`` and ``[PE1.1]`` into our generator form…
 
-.. code:: ipython2
+.. code:: python
 
     J('14811 [PE1.1] G')
 
@@ -264,7 +264,7 @@ If we plug ``14811`` and ``[PE1.1]`` into our generator form…
 
 …we get a generator that works for seven cycles before it reaches zero:
 
-.. code:: ipython2
+.. code:: python
 
     J('[14811 swap [PE1.1] direco] 7 [x] times')
 
@@ -280,11 +280,11 @@ Reset at Zero
 We need a function that checks if the int has reached zero and resets it
 if so.
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1.1.check == dup [pop 14811] [] branch')
 
-.. code:: ipython2
+.. code:: python
 
     J('14811 [PE1.1.check PE1.1] G')
 
@@ -294,7 +294,7 @@ if so.
     [14811 swap [PE1.1.check PE1.1] direco]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times')
 
@@ -316,7 +316,7 @@ In the PE1 problem we are asked to sum all the multiples of three and
 five less than 1000. It’s worked out that we need to use all seven
 numbers sixty-six times and then four more.
 
-.. code:: ipython2
+.. code:: python
 
     J('7 66 * 4 +')
 
@@ -328,7 +328,7 @@ numbers sixty-six times and then four more.
 
 If we drive our generator 466 times and sum the stack we get 999.
 
-.. code:: ipython2
+.. code:: python
 
     J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times')
 
@@ -338,7 +338,7 @@ If we drive our generator 466 times and sum the stack we get 999.
     3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 [57 swap [PE1.1.check PE1.1] direco]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum')
 
@@ -351,13 +351,13 @@ If we drive our generator 466 times and sum the stack we get 999.
 Project Euler Problem One
 -------------------------
 
-.. code:: ipython2
+.. code:: python
 
     define('PE1.2 == + dup [+] dip')
 
 Now we can add ``PE1.2`` to the quoted program given to ``G``.
 
-.. code:: ipython2
+.. code:: python
 
     J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop')
 
@@ -445,15 +445,15 @@ Putting it all together:
    F == + [popdd over] cons infra uncons
    fib_gen == [1 1 F]
 
-.. code:: ipython2
+.. code:: python
 
     define('fib == + [popdd over] cons infra uncons')
 
-.. code:: ipython2
+.. code:: python
 
     define('fib_gen == [1 1 fib]')
 
-.. code:: ipython2
+.. code:: python
 
     J('fib_gen 10 [x] times')
 
@@ -473,14 +473,14 @@ Now that we have a generator for the Fibonacci sequence, we need a
 function that adds a term in the sequence to a sum if it is even, and
 ``pop``\ s it otherwise.
 
-.. code:: ipython2
+.. code:: python
 
     define('PE2.1 == dup 2 % [+] [pop] branch')
 
 And a predicate function that detects when the terms in the series
 “exceed four million”.
 
-.. code:: ipython2
+.. code:: python
 
     define('>4M == 4000000 >')
 
@@ -488,11 +488,11 @@ Now it’s straightforward to define ``PE2`` as a recursive function that
 generates terms in the Fibonacci sequence until they exceed four million
 and sums the even ones.
 
-.. code:: ipython2
+.. code:: python
 
     define('PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec')
 
-.. code:: ipython2
+.. code:: python
 
     J('PE2')
 
@@ -535,7 +535,7 @@ So the Fibonacci sequence considered in terms of just parity would be:
 
 Every third term is even.
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 0 fib] x x x')  # To start the sequence with 1 1 2 3 instead of 1 2 3.
 
@@ -547,7 +547,7 @@ Every third term is even.
 
 Drive the generator three times and ``popop`` the two odd terms.
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 0 fib] x x x [popop] dipd')
 
@@ -557,11 +557,11 @@ Drive the generator three times and ``popop`` the two odd terms.
     2 [3 2 fib]
 
 
-.. code:: ipython2
+.. code:: python
 
     define('PE2.2 == x x x [popop] dipd')
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 0 fib] 10 [PE2.2] times')
 
@@ -574,7 +574,7 @@ Drive the generator three times and ``popop`` the two odd terms.
 Replace ``x`` with our new driver function ``PE2.2`` and start our
 ``fib`` generator at ``1 0``.
 
-.. code:: ipython2
+.. code:: python
 
     J('0 [1 0 fib] PE2.2 [pop >4M] [popop] [[PE2.1] dip PE2.2] primrec')
 
@@ -593,11 +593,11 @@ modifications to the default ``x``?
 An Interesting Variation
 ------------------------
 
-.. code:: ipython2
+.. code:: python
 
     define('codireco == cons dip rest cons')
 
-.. code:: ipython2
+.. code:: python
 
     V('[0 [dup ++] codireco] x')
 
@@ -620,11 +620,11 @@ An Interesting Variation
              0 [1 [dup ++] codireco] . 
 
 
-.. code:: ipython2
+.. code:: python
 
     define('G == [codireco] cons cons')
 
-.. code:: ipython2
+.. code:: python
 
     J('230 [dup ++] G 5 [x] times pop')
 
index b832048..73704cf 100644 (file)
@@ -150,7 +150,7 @@ TBD (look in the :module: joy.parser  module.)
 Examples
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     joy.parser.text_to_expression('1 2 3 4 5')  # A simple sequence.
 
@@ -160,7 +160,7 @@ Examples
     (1, (2, (3, (4, (5, ())))))
 
 
-.. code:: ipython2
+.. code:: python
 
     joy.parser.text_to_expression('[1 2 3] 4 5')  # Three items, the first is a list with three items
 
@@ -170,7 +170,7 @@ Examples
     ((1, (2, (3, ()))), (4, (5, ())))
 
 
-.. code:: ipython2
+.. code:: python
 
     joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888')  # A mixed bag. cons is
                                                                      # a Symbol, no lookup at
@@ -184,7 +184,7 @@ Examples
 
 
 
-.. code:: ipython2
+.. code:: python
 
     joy.parser.text_to_expression('[][][][][]')  # Five empty lists.
 
@@ -197,7 +197,7 @@ Examples
 
 
 
-.. code:: ipython2
+.. code:: python
 
     joy.parser.text_to_expression('[[[[[]]]]]')  # Five nested lists.
 
@@ -221,7 +221,7 @@ provide control-flow and higher-order operations.
 
 Many of the functions are defined in Python, like ``dip``:
 
-.. code:: ipython2
+.. code:: python
 
     print inspect.getsource(joy.library.dip)
 
@@ -239,7 +239,7 @@ When the interpreter executes a definition function that function just
 pushes its body expression onto the pending expression (the
 continuation) and returns control to the interpreter.
 
-.. code:: ipython2
+.. code:: python
 
     print joy.library.definitions
 
index cb3f759..b580502 100644 (file)
@@ -7,7 +7,7 @@ to write a function that can compute the square root of a number.
 Cf. `"Why Functional Programming Matters" by John
 Hughes <https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf>`__
 
-.. code:: ipython3
+.. code:: python
 
     from notebook_preamble import J, V, define
 
@@ -75,11 +75,11 @@ The generator can be written as:
     1       [23 over / + 2 /]      [dup] swoncat make_generator
     1   [dup 23 over / + 2 /]                    make_generator
 
-.. code:: ipython3
+.. code:: python
 
     define('gsra 1 swap [over / + 2 /] cons [dup] swoncat make_generator')
 
-.. code:: ipython3
+.. code:: python
 
     J('23 gsra')
 
@@ -92,7 +92,7 @@ The generator can be written as:
 Let's drive the generator a few time (with the ``x`` combinator) and
 square the approximation to see how well it works...
 
-.. code:: ipython3
+.. code:: python
 
     J('23 gsra 6 [x popd] times first sqr')
 
@@ -142,7 +142,7 @@ Predicate
     abs(a-b)            ε                   <=
     (abs(a-b)<=ε)
 
-.. code:: ipython3
+.. code:: python
 
     define('_within_P [first - abs] dip <=')
 
@@ -156,7 +156,7 @@ Base-Case
       [b G]               first
        b
 
-.. code:: ipython3
+.. code:: python
 
     define('_within_B roll< popop first')
 
@@ -184,7 +184,7 @@ Pretty straightforward:
 
     b [c G] ε within
 
-.. code:: ipython3
+.. code:: python
 
     define('_within_R [popd x] dip')
 
@@ -199,14 +199,14 @@ The recursive function we have defined so far needs a slight preamble:
     [a G] x ε ...
     a [b G] ε ...
 
-.. code:: ipython3
+.. code:: python
 
     define('within x 0.000000001 [_within_P] [_within_B] [_within_R] tailrec')
     define('sqrt gsra within')
 
 Try it out...
 
-.. code:: ipython3
+.. code:: python
 
     J('36 sqrt')
 
@@ -216,7 +216,7 @@ Try it out...
     6.0
 
 
-.. code:: ipython3
+.. code:: python
 
     J('23 sqrt')
 
@@ -228,7 +228,7 @@ Try it out...
 
 Check it.
 
-.. code:: ipython3
+.. code:: python
 
     4.795831523312719**2
 
@@ -241,7 +241,7 @@ Check it.
 
 
 
-.. code:: ipython3
+.. code:: python
 
     from math import sqrt
     
index 569d665..a625ac3 100644 (file)
@@ -36,7 +36,7 @@ implementation under the hood. (Where does the “type” come from? It has
 a contingent existence predicated on the disciplined use of these
 functions on otherwise undistinguished Joy datastructures.)
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import D, J, V, define, DefinitionWrapper
 
@@ -87,11 +87,11 @@ Definition:
 
    Tree-new == swap [[] []] cons cons
 
-.. code:: ipython2
+.. code:: python
 
     define('Tree-new == swap [[] []] cons cons')
 
-.. code:: ipython2
+.. code:: python
 
     J('"v" "k" Tree-new')
 
@@ -163,11 +163,11 @@ comparison operator:
    P < == pop roll> pop first <
    P   == pop roll> pop first
 
-.. code:: ipython2
+.. code:: python
 
     define('P == pop roll> pop first')
 
-.. code:: ipython2
+.. code:: python
 
     J('["old_key" 23 [] []] 17 "new_key" ["..."] P')
 
@@ -242,11 +242,11 @@ And so ``T`` is just:
 
    T == cons cons [dipdd] cons infra
 
-.. code:: ipython2
+.. code:: python
 
     define('T == cons cons [dipdd] cons infra')
 
-.. code:: ipython2
+.. code:: python
 
     J('["old_k" "old_value" "left" "right"] "new_value" "new_key" ["Tree-add"] T')
 
@@ -266,7 +266,7 @@ This is very very similar to the above:
    [key_n value_n left right] value key [Tree-add] E
    [key_n value_n left right] value key [Tree-add] [P <] [Te] [Ee] ifte
 
-.. code:: ipython2
+.. code:: python
 
     define('E == [P <] [Te] [Ee] ifte')
 
@@ -278,11 +278,11 @@ instead of the right, so the only difference is that it must use
 
    Te == cons cons [dipd] cons infra
 
-.. code:: ipython2
+.. code:: python
 
     define('Te == cons cons [dipd] cons infra')
 
-.. code:: ipython2
+.. code:: python
 
     J('["old_k" "old_value" "left" "right"] "new_value" "new_key" ["Tree-add"] Te')
 
@@ -320,11 +320,11 @@ Example:
    key new_value [              left right]                                     cons cons
                  [key new_value left right]
 
-.. code:: ipython2
+.. code:: python
 
     define('Ee == pop swap roll< rest rest cons cons')
 
-.. code:: ipython2
+.. code:: python
 
     J('["k" "old_value" "left" "right"] "new_value" "k" ["Tree-add"] Ee')
 
@@ -355,14 +355,14 @@ Putting it all together:
 
    Tree-add == [popop not] [[pop] dipd Tree-new] [] [R] genrec
 
-.. code:: ipython2
+.. code:: python
 
     define('Tree-add == [popop not] [[pop] dipd Tree-new] [] [[P >] [T] [E] ifte] genrec')
 
 Examples
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[] 23 "b" Tree-add')  # Initial
 
@@ -372,7 +372,7 @@ Examples
     ['b' 23 [] []]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('["b" 23 [] []] 88 "c" Tree-add')  # Greater than
 
@@ -382,7 +382,7 @@ Examples
     ['b' 23 [] ['c' 88 [] []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('["b" 23 [] []] 88 "a" Tree-add')  # Less than
 
@@ -392,7 +392,7 @@ Examples
     ['b' 23 ['a' 88 [] []] []]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('["b" 23 [] []] 88 "b" Tree-add')  # Equal to
 
@@ -402,7 +402,7 @@ Examples
     ['b' 88 [] []]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[] 23 "b" Tree-add 88 "a" Tree-add 44 "c" Tree-add')  # Series.
 
@@ -412,7 +412,7 @@ Examples
     ['b' 23 ['a' 88 [] []] ['c' 44 [] []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[] [[23 "b"] [88 "a"] [44 "c"]] [i Tree-add] step')
 
@@ -444,7 +444,7 @@ values:
    ------------------------- a < b
                    L
 
-.. code:: ipython2
+.. code:: python
 
     J("1 0 ['G'] ['E'] ['L'] cmp")
 
@@ -454,7 +454,7 @@ values:
     'G'
 
 
-.. code:: ipython2
+.. code:: python
 
     J("1 1 ['G'] ['E'] ['L'] cmp")
 
@@ -464,7 +464,7 @@ values:
     'E'
 
 
-.. code:: ipython2
+.. code:: python
 
     J("0 1 ['G'] ['E'] ['L'] cmp")
 
@@ -514,7 +514,7 @@ Or just:
 
    P == over [popop popop first] nullary
 
-.. code:: ipython2
+.. code:: python
 
     define('P == over [popop popop first] nullary')
 
@@ -541,11 +541,11 @@ to understand:
 
    Tree-add == [popop not] [[pop] dipd Tree-new] [] [P [T] [Ee] [Te] cmp] genrec
 
-.. code:: ipython2
+.. code:: python
 
     define('Tree-add == [popop not] [[pop] dipd Tree-new] [] [P [T] [Ee] [Te] cmp] genrec')
 
-.. code:: ipython2
+.. code:: python
 
     J('[] 23 "b" Tree-add 88 "a" Tree-add 44 "c" Tree-add')  # Still works.
 
@@ -685,14 +685,14 @@ Working backward:
 
    Tree-iter == [not] [pop] roll< [dupdip rest rest] cons [step] genrec
 
-.. code:: ipython2
+.. code:: python
 
     define('Tree-iter == [not] [pop] roll< [dupdip rest rest] cons [step] genrec')
 
 Examples
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     J('[] [foo] Tree-iter')  #  It doesn't matter what F is as it won't be used.
 
@@ -702,7 +702,7 @@ Examples
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J("['b' 23 ['a' 88 [] []] ['c' 44 [] []]] [first] Tree-iter")
 
@@ -712,7 +712,7 @@ Examples
     'b' 'a' 'c'
 
 
-.. code:: ipython2
+.. code:: python
 
     J("['b' 23 ['a' 88 [] []] ['c' 44 [] []]] [second] Tree-iter")
 
@@ -731,7 +731,7 @@ to it will only occur once within it, and we can query it in
 `:math:`O(\log_2 N)` <https://en.wikipedia.org/wiki/Binary_search_tree#cite_note-2>`__
 time.
 
-.. code:: ipython2
+.. code:: python
 
     J('[] [3 9 5 2 8 6 7 8 4] [0 swap Tree-add] step')
 
@@ -741,11 +741,11 @@ time.
     [3 0 [2 0 [] []] [9 0 [5 0 [4 0 [] []] [8 0 [6 0 [] [7 0 [] []]] []]] []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     define('to_set == [] swap [0 swap Tree-add] step')
 
-.. code:: ipython2
+.. code:: python
 
     J('[3 9 5 2 8 6 7 8 4] to_set')
 
@@ -758,11 +758,11 @@ time.
 And with that we can write a little program ``unique`` to remove
 duplicate items from a list.
 
-.. code:: ipython2
+.. code:: python
 
     define('unique == [to_set [first] Tree-iter] cons run')
 
-.. code:: ipython2
+.. code:: python
 
     J('[3 9 3 5 2 9 8 8 8 6 2 7 8 4 3] unique')  # Filter duplicate items.
 
@@ -872,7 +872,7 @@ Let’s do a little semantic factoring:
 
 Now we can sort sequences.
 
-.. code:: ipython2
+.. code:: python
 
     #define('Tree-iter-order == [not] [pop] [dup third] [[cons dip] dupdip [[first] dupdip] dip [rest rest rest first] dip i] genrec')
     
@@ -892,7 +892,7 @@ Now we can sort sequences.
     
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[3 9 5 2 8 6 7 8 4] to_set Tree-iter-order')
 
@@ -1070,7 +1070,7 @@ So:
 
    Tree-get == [pop not] swap [] [P [T>] [E] [T<] cmp] genrec
 
-.. code:: ipython2
+.. code:: python
 
     # I don't want to deal with name conflicts with the above so I'm inlining everything here.
     # The original Joy system has "hide" which is a meta-command which allows you to use named
@@ -1088,7 +1088,7 @@ So:
       ] genrec
     ''')
 
-.. code:: ipython2
+.. code:: python
 
     J('["gary" 23 [] []] "mike" [popd " not in tree" +] Tree-get')
 
@@ -1098,7 +1098,7 @@ So:
     'mike not in tree'
 
 
-.. code:: ipython2
+.. code:: python
 
     J('["gary" 23 [] []] "gary" [popop "err"] Tree-get')
 
@@ -1108,7 +1108,7 @@ So:
     23
 
 
-.. code:: ipython2
+.. code:: python
 
     J('''
     
@@ -1124,7 +1124,7 @@ So:
     2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('''
     
@@ -1500,7 +1500,7 @@ Refactoring
 By the standards of the code I’ve written so far, this is a *huge* Joy
 program.
 
-.. code:: ipython2
+.. code:: python
 
     DefinitionWrapper.add_definitions('''
     first_two == uncons uncons pop
@@ -1519,7 +1519,7 @@ program.
     Tree-Delete == [pop not] [pop] [R0] [R1] genrec
     ''', D)
 
-.. code:: ipython2
+.. code:: python
 
     J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'c' Tree-Delete ")
 
@@ -1529,7 +1529,7 @@ program.
     ['a' 23 [] ['b' 88 [] []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'b' Tree-Delete ")
 
@@ -1539,7 +1539,7 @@ program.
     ['a' 23 [] ['c' 44 [] []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'a' Tree-Delete ")
 
@@ -1549,7 +1549,7 @@ program.
     ['b' 88 [] ['c' 44 [] []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J("['a' 23 [] ['b' 88 [] ['c' 44 [] []]]] 'der' Tree-Delete ")
 
@@ -1559,7 +1559,7 @@ program.
     ['a' 23 [] ['b' 88 [] ['c' 44 [] []]]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[] [4 2 3 1 6 7 5 ] [0 swap Tree-add] step')
 
@@ -1569,7 +1569,7 @@ program.
     [4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J("[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 3 Tree-Delete ")
 
@@ -1579,7 +1579,7 @@ program.
     [4 0 [2 0 [1 0 [] []] []] [6 0 [5 0 [] []] [7 0 [] []]]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J("[4 0 [2 0 [1 0 [] []] [3 0 [] []]] [6 0 [5 0 [] []] [7 0 [] []]]] 4 Tree-Delete ")
 
index 3262e84..5afb8e2 100644 (file)
@@ -1,4 +1,4 @@
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import J, V, define
 
@@ -81,13 +81,13 @@ the variables:
 The three arguments are to the left, so we can “chop off” everything to
 the right and say it’s the definition of the ``quadratic`` function:
 
-.. code:: ipython2
+.. code:: python
 
     define('quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2')
 
 Let’s try it out:
 
-.. code:: ipython2
+.. code:: python
 
     J('3 1 1 quadratic')
 
@@ -102,7 +102,7 @@ lines are the ``dip`` and ``dipd`` combinators building the main program
 by incorporating the values on the stack. Then that program runs and you
 get the results. This is pretty typical of Joy code.
 
-.. code:: ipython2
+.. code:: python
 
     V('-5 1 4 quadratic')
 
index 9159882..2298cfd 100644 (file)
@@ -1,4 +1,4 @@
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import D, DefinitionWrapper, J, V, define
 
@@ -80,7 +80,7 @@ is a recursive function ``H :: A -> C`` that converts a value of type
 It may be helpful to see this function implemented in imperative Python
 code.
 
-.. code:: ipython2
+.. code:: python
 
     def hylomorphism(c, F, P, G):
         '''Return a hylomorphism function H.'''
@@ -185,7 +185,7 @@ the left so we have a definition for ``hylomorphism``:
 
    hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec
 
-.. code:: ipython2
+.. code:: python
 
     define('hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec')
 
@@ -203,13 +203,13 @@ To sum a range of integers from 0 to *n* - 1:
 -  ``[G]`` is ``[-- dup]``
 -  ``[F]`` is ``[+]``
 
-.. code:: ipython2
+.. code:: python
 
     define('triangular_number == [1 <=] 0 [-- dup] [+] hylomorphism')
 
 Let’s try it:
 
-.. code:: ipython2
+.. code:: python
 
     J('5 triangular_number')
 
@@ -219,7 +219,7 @@ Let’s try it:
     10
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[0 1 2 3 4 5 6] [triangular_number] map')
 
@@ -391,8 +391,10 @@ values.
 
    A == [P] [] [G] [swons] hylomorphism
 
-``range`` et. al. An example of an anamorphism is the ``range`` function which generates the list of integers from 0 to *n* - 1 given *n*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``range`` et. al.
+~~~~~~~~~~~~~~~~~
+
+An example of an anamorphism is the ``range`` function which generates the list of integers from 0 to *n* - 1 given *n*.
 
 Each of the above variations can be used to make four slightly different
 ``range`` functions.
@@ -405,11 +407,11 @@ Each of the above variations can be used to make four slightly different
    H1 == [P]    [pop c]  [G]      [dip F]     genrec
       == [0 <=] [pop []] [-- dup] [dip swons] genrec
 
-.. code:: ipython2
+.. code:: python
 
     define('range == [0 <=] [] [-- dup] [swons] hylomorphism')
 
-.. code:: ipython2
+.. code:: python
 
     J('5 range')
 
@@ -427,11 +429,11 @@ Each of the above variations can be used to make four slightly different
    H2 == c  swap [P]    [pop] [G      [F]     dip] primrec
       == [] swap [0 <=] [pop] [-- dup [swons] dip] primrec
 
-.. code:: ipython2
+.. code:: python
 
     define('range_reverse == [] swap [0 <=] [pop] [-- dup [swons] dip] primrec')
 
-.. code:: ipython2
+.. code:: python
 
     J('5 range_reverse')
 
@@ -449,11 +451,11 @@ Each of the above variations can be used to make four slightly different
    H3 == [P]    [pop c]  [[G]  dupdip] [dip F]     genrec
       == [0 <=] [pop []] [[--] dupdip] [dip swons] genrec
 
-.. code:: ipython2
+.. code:: python
 
     define('ranger == [0 <=] [pop []] [[--] dupdip] [dip swons] genrec')
 
-.. code:: ipython2
+.. code:: python
 
     J('5 ranger')
 
@@ -471,11 +473,11 @@ Each of the above variations can be used to make four slightly different
    H4 == c  swap [P]    [pop] [[F]     dupdip G ] primrec
       == [] swap [0 <=] [pop] [[swons] dupdip --] primrec
 
-.. code:: ipython2
+.. code:: python
 
     define('ranger_reverse == [] swap [0 <=] [pop] [[swons] dupdip --] primrec')
 
-.. code:: ipython2
+.. code:: python
 
     J('5 ranger_reverse')
 
@@ -501,7 +503,7 @@ and makes some new value.
 
    C == [not] c [uncons swap] [F] hylomorphism
 
-.. code:: ipython2
+.. code:: python
 
     define('swuncons == uncons swap')  # Awkward name.
 
@@ -511,11 +513,11 @@ An example of a catamorphism is the sum function.
 
    sum == [not] 0 [swuncons] [+] hylomorphism
 
-.. code:: ipython2
+.. code:: python
 
     define('sum == [not] 0 [swuncons] [+] hylomorphism')
 
-.. code:: ipython2
+.. code:: python
 
     J('[5 4 3 2 1] sum')
 
@@ -531,7 +533,7 @@ The ``step`` combinator
 The ``step`` combinator will usually be better to use than
 ``catamorphism``.
 
-.. code:: ipython2
+.. code:: python
 
     J('[step] help')
 
@@ -560,11 +562,11 @@ The ``step`` combinator will usually be better to use than
     
 
 
-.. code:: ipython2
+.. code:: python
 
     define('sum == 0 swap [+] step')
 
-.. code:: ipython2
+.. code:: python
 
     J('[5 4 3 2 1] sum')
 
@@ -592,11 +594,11 @@ With:
    G == --
    P == 1 <=
 
-.. code:: ipython2
+.. code:: python
 
     define('factorial == 1 swap [1 <=] [pop] [[*] dupdip --] primrec')
 
-.. code:: ipython2
+.. code:: python
 
     J('5 factorial')
 
@@ -635,11 +637,11 @@ We would use:
    G == rest dup
    P == not
 
-.. code:: ipython2
+.. code:: python
 
     define('tails == [] swap [not] [pop] [rest dup [swons] dip] primrec')
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 2 3] tails')
 
index 0f90445..02ecb3b 100644 (file)
@@ -9,14 +9,14 @@ dictionary. However, there’s no function that does that. Adding a new
 function to the dictionary is a meta-interpreter action, you have to do
 it in Python, not Joy.
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import D, J, V
 
 A long trace
 ------------
 
-.. code:: ipython2
+.. code:: python
 
     V('[23 18] average')
 
@@ -81,7 +81,7 @@ An efficient ``sum`` function is already in the library. But for
 ``size`` we can use a “compiled” version hand-written in Python to speed
 up evaluation and make the trace more readable.
 
-.. code:: ipython2
+.. code:: python
 
     from joy.library import SimpleFunctionWrapper
     from joy.utils.stack import iter_stack
@@ -99,7 +99,7 @@ up evaluation and make the trace more readable.
 Now we replace the old version in the dictionary with the new version,
 and re-evaluate the expression.
 
-.. code:: ipython2
+.. code:: python
 
     D['size'] = size
 
@@ -108,7 +108,7 @@ A shorter trace
 
 You can see that ``size`` now executes in a single step.
 
-.. code:: ipython2
+.. code:: python
 
     V('[23 18] average')
 
index 6b9081f..7f273d8 100644 (file)
@@ -148,11 +148,11 @@ Working backwards:
 Define ``treestep``
 -------------------
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import D, J, V, define, DefinitionWrapper
 
-.. code:: ipython2
+.. code:: python
 
     DefinitionWrapper.add_definitions('''
     
@@ -173,7 +173,7 @@ all nodes in a tree with this function:
 
    sumtree == [pop 0] [] [sum +] treestep
 
-.. code:: ipython2
+.. code:: python
 
     define('sumtree == [pop 0] [] [sum +] treestep')
 
@@ -185,7 +185,7 @@ Running this function on an empty tree value gives zero:
    ------------------------------------
               0
 
-.. code:: ipython2
+.. code:: python
 
     J('[] sumtree')  # Empty tree.
 
@@ -205,7 +205,7 @@ Running it on a non-empty node:
    n m                                             +
    n+m
 
-.. code:: ipython2
+.. code:: python
 
     J('[23] sumtree')  # No child trees.
 
@@ -215,7 +215,7 @@ Running it on a non-empty node:
     23
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 []] sumtree')  # Child tree, empty.
 
@@ -225,7 +225,7 @@ Running it on a non-empty node:
     23
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 [2 [4]] [3]] sumtree')  # Non-empty child trees.
 
@@ -235,7 +235,7 @@ Running it on a non-empty node:
     32
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 [2 [8] [9]] [3] [4 []]] sumtree')  # Etc...
 
@@ -245,7 +245,7 @@ Running it on a non-empty node:
     49
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 [2 [8] [9]] [3] [4 []]] [pop 0] [] [cons sum] treestep')  # Alternate "spelling".
 
@@ -255,7 +255,7 @@ Running it on a non-empty node:
     49
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 [2 [8] [9]] [3] [4 []]] [] [pop 23] [cons] treestep')  # Replace each node.
 
@@ -265,7 +265,7 @@ Running it on a non-empty node:
     [23 [23 [23] [23]] [23] [23 []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep')
 
@@ -275,7 +275,7 @@ Running it on a non-empty node:
     [1 [1 [1] [1]] [1] [1 []]]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 [2 [8] [9]] [3] [4 []]] [] [pop 1] [cons] treestep sumtree')
 
@@ -285,7 +285,7 @@ Running it on a non-empty node:
     6
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[23 [2 [8] [9]] [3] [4 []]] [pop 0] [pop 1] [sum +] treestep')  # Combine replace and sum into one function.
 
@@ -295,7 +295,7 @@ Running it on a non-empty node:
     6
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[4 [3 [] [7]]] [pop 0] [pop 1] [sum +] treestep')  # Combine replace and sum into one function.
 
@@ -339,7 +339,7 @@ Traversal
 
 This doesn’t quite work:
 
-.. code:: ipython2
+.. code:: python
 
     J('[[3 0] [[2 0] [][]] [[9 0] [[5 0] [[4 0] [][]] [[8 0] [[6 0] [] [[7 0] [][]]][]]][]]] ["B"] [first] [i] treestep')
 
@@ -369,7 +369,7 @@ So:
 
    [] [first] [flatten cons] treestep
 
-.. code:: ipython2
+.. code:: python
 
     J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [first] [flatten cons] treestep')
 
@@ -401,7 +401,7 @@ So:
 
    [] [i roll< swons concat] [first] treestep
 
-.. code:: ipython2
+.. code:: python
 
     J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [uncons pop] [i roll< swons concat] treestep')
 
@@ -429,7 +429,7 @@ Plugging in our BTree structure:
 
    [key value] N [left right] [K] C
 
-.. code:: ipython2
+.. code:: python
 
     J('[["key" "value"] ["left"] ["right"] ] ["B"] ["N"] ["C"] treegrind')
 
@@ -444,7 +444,7 @@ Plugging in our BTree structure:
 
 Iteration through the nodes
 
-.. code:: ipython2
+.. code:: python
 
     J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] ["N"] [step] treegrind')
 
@@ -456,7 +456,7 @@ Iteration through the nodes
 
 Sum the nodes’ keys.
 
-.. code:: ipython2
+.. code:: python
 
     J('0 [[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [pop] [first +] [step] treegrind')
 
@@ -468,7 +468,7 @@ Sum the nodes’ keys.
 
 Rebuild the tree using ``map`` (imitating ``treestep``.)
 
-.. code:: ipython2
+.. code:: python
 
     J('[[3 0] [[2 0] [] []] [[9 0] [[5 0] [[4 0] [] []] [[8 0] [[6 0] [] [[7 0] [] []]] []]] []]]   [] [[100 +] infra] [map cons] treegrind')
 
@@ -574,7 +574,7 @@ Putting it together
 
 To me, that seems simpler than the ``genrec`` version.
 
-.. code:: ipython2
+.. code:: python
 
     DefinitionWrapper.add_definitions('''
     
@@ -587,7 +587,7 @@ To me, that seems simpler than the ``genrec`` version.
     
     ''', D)
 
-.. code:: ipython2
+.. code:: python
 
     J('''\
     
@@ -603,7 +603,7 @@ To me, that seems simpler than the ``genrec`` version.
     15
 
 
-.. code:: ipython2
+.. code:: python
 
     J('''\
     
index cd85c67..4e70a1a 100644 (file)
@@ -1,7 +1,7 @@
 Type Checking
 =============
 
-.. code:: ipython2
+.. code:: python
 
     import logging, sys
     
@@ -11,7 +11,7 @@ Type Checking
       level=logging.INFO,
       )
 
-.. code:: ipython2
+.. code:: python
 
     from joy.utils.types import (
         doc_from_stack_effect, 
@@ -22,7 +22,7 @@ Type Checking
         JoyTypeError,
     )
 
-.. code:: ipython2
+.. code:: python
 
     D = FUNCTIONS.copy()
     del D['product']
@@ -31,7 +31,7 @@ Type Checking
 An Example
 ----------
 
-.. code:: ipython2
+.. code:: python
 
     fi, fo = infer(pop, swap, rolldown, rrest, ccons)[0]
 
@@ -46,7 +46,7 @@ An Example
      40 ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1]) ∘ 
 
 
-.. code:: ipython2
+.. code:: python
 
     print doc_from_stack_effect(fi, fo)
 
@@ -56,13 +56,13 @@ An Example
     ([a4 a5 ...1] a3 a2 a1 -- [a2 a3 ...1])
 
 
-.. code:: ipython2
+.. code:: python
 
     from joy.parser import text_to_expression
     from joy.utils.stack import stack_to_string
 
 
-.. code:: ipython2
+.. code:: python
 
     e = text_to_expression('0 1 2 [3 4]')  # reverse order
     print stack_to_string(e)
@@ -73,7 +73,7 @@ An Example
     [3 4] 2 1 0
 
 
-.. code:: ipython2
+.. code:: python
 
     u = unify(e, fi)[0]
     u
@@ -87,7 +87,7 @@ An Example
 
 
 
-.. code:: ipython2
+.. code:: python
 
     g = reify(u, (fi, fo))
     print doc_from_stack_effect(*g)
@@ -101,11 +101,11 @@ An Example
 Unification Works “in Reverse”
 ------------------------------
 
-.. code:: ipython2
+.. code:: python
 
     e = text_to_expression('[2 3]')
 
-.. code:: ipython2
+.. code:: python
 
     u = unify(e, fo)[0]  # output side, not input side
     u
@@ -119,7 +119,7 @@ Unification Works “in Reverse”
 
 
 
-.. code:: ipython2
+.. code:: python
 
     g = reify(u, (fi, fo))
     print doc_from_stack_effect(*g)
@@ -133,7 +133,7 @@ Unification Works “in Reverse”
 Failing a Check
 ---------------
 
-.. code:: ipython2
+.. code:: python
 
     fi, fo = infer(dup, mul)[0]
 
@@ -146,7 +146,7 @@ Failing a Check
      31 (i1 -- i2) ∘ 
 
 
-.. code:: ipython2
+.. code:: python
 
     e = text_to_expression('"two"')
     print stack_to_string(e)
@@ -157,7 +157,7 @@ Failing a Check
     'two'
 
 
-.. code:: ipython2
+.. code:: python
 
     try:
         unify(e, fi)
index 4c91600..8ca737d 100644 (file)
@@ -184,7 +184,7 @@ Compiling ``pop∘swap∘roll<``
 
 The simplest way to “compile” this function would be something like:
 
-.. code:: ipython2
+.. code:: python
 
     def poswrd(s, e, d):
         return rolldown(*swap(*pop(s, e, d)))
@@ -200,7 +200,7 @@ Looking ahead for a moment, from the stack effect comment:
 
 We should be able to directly write out a Python function like:
 
-.. code:: ipython2
+.. code:: python
 
     def poswrd(stack):
         (_, (a, (b, (c, stack)))) = stack
@@ -393,7 +393,7 @@ And there you have it, the stack effect for
 From this stack effect comment it should be possible to construct the
 following Python code:
 
-.. code:: ipython2
+.. code:: python
 
     def F(stack):
         (_, (d, (c, ((a, (b, S0)), stack)))) = stack
@@ -408,7 +408,7 @@ Representing Stack Effect Comments in Python
 I’m going to use pairs of tuples of type descriptors, which will be
 integers or tuples of type descriptors:
 
-.. code:: ipython2
+.. code:: python
 
     roll_dn = (1, 2, 3), (2, 3, 1)
     
@@ -419,7 +419,7 @@ integers or tuples of type descriptors:
 ``compose()``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def compose(f, g):
     
@@ -465,7 +465,7 @@ integers or tuples of type descriptors:
 ``unify()``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def unify(u, v, s=None):
         if s is None:
@@ -483,7 +483,7 @@ integers or tuples of type descriptors:
 ``update()``
 ~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def update(s, term):
         if not isinstance(term, tuple):
@@ -493,7 +493,7 @@ integers or tuples of type descriptors:
 ``relabel()``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def relabel(left, right):
         return left, _1000(right)
@@ -517,7 +517,7 @@ integers or tuples of type descriptors:
 ``delabel()``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     def delabel(f):
         s = {u: i for i, u in enumerate(sorted(_unique(f)))}
@@ -551,7 +551,7 @@ At last we put it all together in a function ``C()`` that accepts two
 stack effect comments and returns their composition (or raises and
 exception if they can’t be composed due to type conflicts.)
 
-.. code:: ipython2
+.. code:: python
 
     def C(f, g):
         f, g = relabel(f, g)
@@ -560,7 +560,7 @@ exception if they can’t be composed due to type conflicts.)
 
 Let’s try it out.
 
-.. code:: ipython2
+.. code:: python
 
     C(pop, swap)
 
@@ -573,7 +573,7 @@ Let’s try it out.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     C(C(pop, swap), roll_dn)
 
@@ -586,7 +586,7 @@ Let’s try it out.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     C(swap, roll_dn)
 
@@ -599,7 +599,7 @@ Let’s try it out.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     C(pop, C(swap, roll_dn))
 
@@ -612,7 +612,7 @@ Let’s try it out.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     poswrd = reduce(C, (pop, swap, roll_dn))
     poswrd
@@ -633,13 +633,13 @@ Here’s that trick to represent functions like ``rest`` and ``cons`` that
 manipulate stacks. We use a cons-list of tuples and give the tails their
 own numbers. Then everything above already works.
 
-.. code:: ipython2
+.. code:: python
 
     rest = ((1, 2),), (2,)
     
     cons = (1, 2), ((1, 2),)
 
-.. code:: ipython2
+.. code:: python
 
     C(poswrd, rest)
 
@@ -671,7 +671,7 @@ The translation table, if you will, would be:
    0: 0,
    }
 
-.. code:: ipython2
+.. code:: python
 
     F = reduce(C, (pop, swap, roll_dn, rest, rest, cons, cons))
     
@@ -699,11 +699,11 @@ Dealing with ``cons`` and ``uncons``
 However, if we try to compose e.g. ``cons`` and ``uncons`` it won’t
 work:
 
-.. code:: ipython2
+.. code:: python
 
     uncons = ((1, 2),), (1, 2)
 
-.. code:: ipython2
+.. code:: python
 
     try:
         C(cons, uncons)
@@ -723,7 +723,7 @@ The problem is that the ``unify()`` function as written doesn’t handle
 the case when both terms are tuples. We just have to add a clause to
 deal with this recursively:
 
-.. code:: ipython2
+.. code:: python
 
     def unify(u, v, s=None):
         if s is None:
@@ -753,7 +753,7 @@ deal with this recursively:
     
         return s
 
-.. code:: ipython2
+.. code:: python
 
     C(cons, uncons)
 
@@ -771,7 +771,7 @@ Part III: Compiling Yin Functions
 
 Now consider the Python function we would like to derive:
 
-.. code:: ipython2
+.. code:: python
 
     def F_python(stack):
         (_, (d, (c, ((a, (b, S0)), stack)))) = stack
@@ -779,7 +779,7 @@ Now consider the Python function we would like to derive:
 
 And compare it to the input stack effect comment tuple we just computed:
 
-.. code:: ipython2
+.. code:: python
 
     F[0]
 
@@ -816,7 +816,7 @@ Eh?
 
 And the return tuple
 
-.. code:: ipython2
+.. code:: python
 
     F[1]
 
@@ -848,7 +848,7 @@ Python Identifiers
 We want to substitute Python identifiers for the integers. I’m going to
 repurpose ``joy.parser.Symbol`` class for this:
 
-.. code:: ipython2
+.. code:: python
 
     from collections import defaultdict
     from joy.parser import Symbol
@@ -874,7 +874,7 @@ effect comment tuples to reasonable text format. There are some details
 in how this code works that related to stuff later in the notebook, so
 you should skip it for now and read it later if you’re interested.
 
-.. code:: ipython2
+.. code:: python
 
     def doc_from_stack_effect(inputs, outputs):
         return '(%s--%s)' % (
@@ -914,7 +914,7 @@ Now we can write a compiler function to emit Python source code. (The
 underscore suffix distiguishes it from the built-in ``compile()``
 function.)
 
-.. code:: ipython2
+.. code:: python
 
     def compile_(name, f, doc=None):
         if doc is None:
@@ -932,7 +932,7 @@ function.)
 
 Here it is in action:
 
-.. code:: ipython2
+.. code:: python
 
     source = compile_('F', F)
     
@@ -949,7 +949,7 @@ Here it is in action:
 
 Compare:
 
-.. code:: ipython2
+.. code:: python
 
     def F_python(stack):
         (_, (d, (c, ((a, (b, S0)), stack)))) = stack
@@ -957,7 +957,7 @@ Compare:
 
 Next steps:
 
-.. code:: ipython2
+.. code:: python
 
     L = {}
     
@@ -976,16 +976,16 @@ Next steps:
 
 Let’s try it out:
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import D, J, V
     from joy.library import SimpleFunctionWrapper
 
-.. code:: ipython2
+.. code:: python
 
     D['F'] = SimpleFunctionWrapper(L['F'])
 
-.. code:: ipython2
+.. code:: python
 
     J('[4 5 ...] 2 3 1 F')
 
@@ -1012,7 +1012,7 @@ Compiling Library Functions
 We can use ``compile_()`` to generate many primitives in the library
 from their stack effect comments:
 
-.. code:: ipython2
+.. code:: python
 
     def defs():
     
@@ -1036,7 +1036,7 @@ from their stack effect comments:
     
         return locals()
 
-.. code:: ipython2
+.. code:: python
 
     for name, stack_effect_comment in sorted(defs().items()):
         print
@@ -1205,7 +1205,7 @@ Python class hierarchy of Joy types and use the ``issubclass()`` method
 to establish domain ordering, as well as other handy behaviour that will
 make it fairly easy to reuse most of the code above.
 
-.. code:: ipython2
+.. code:: python
 
     class AnyJoyType(object):
     
@@ -1251,14 +1251,14 @@ make it fairly easy to reuse most of the code above.
 
 Mess with it a little:
 
-.. code:: ipython2
+.. code:: python
 
     from itertools import permutations
 
 “Any” types can be specialized to numbers and stacks, but not vice
 versa:
 
-.. code:: ipython2
+.. code:: python
 
     for a, b in permutations((A[0], N[0], S[0]), 2):
         print a, '>=', b, '->', a >= b
@@ -1278,7 +1278,7 @@ Our crude `Numerical
 Tower <https://en.wikipedia.org/wiki/Numerical_tower>`__ of *numbers* >
 *floats* > *integers* works as well (but we’re not going to use it yet):
 
-.. code:: ipython2
+.. code:: python
 
     for a, b in permutations((A[0], N[0], FloatJoyType(0), IntJoyType(0)), 2):
         print a, '>=', b, '->', a >= b
@@ -1303,13 +1303,13 @@ Tower <https://en.wikipedia.org/wiki/Numerical_tower>`__ of *numbers* >
 Typing ``sqr``
 ~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: python
 
     dup = (A[1],), (A[1], A[1])
     
     mul = (N[1], N[2]), (N[3],)
 
-.. code:: ipython2
+.. code:: python
 
     dup
 
@@ -1322,7 +1322,7 @@ Typing ``sqr``
 
 
 
-.. code:: ipython2
+.. code:: python
 
     mul
 
@@ -1340,7 +1340,7 @@ Modifying the Inferencer
 
 Re-labeling still works fine:
 
-.. code:: ipython2
+.. code:: python
 
     foo = relabel(dup, mul)
     
@@ -1361,7 +1361,7 @@ Re-labeling still works fine:
 The ``delabel()`` function needs an overhaul. It now has to keep track
 of how many labels of each domain it has “seen”.
 
-.. code:: ipython2
+.. code:: python
 
     from collections import Counter
     
@@ -1383,7 +1383,7 @@ of how many labels of each domain it has “seen”.
     
         return tuple(delabel(inner, seen, c) for inner in f)
 
-.. code:: ipython2
+.. code:: python
 
     delabel(foo)
 
@@ -1399,7 +1399,7 @@ of how many labels of each domain it has “seen”.
 ``unify()`` version 3
 ^^^^^^^^^^^^^^^^^^^^^
 
-.. code:: ipython2
+.. code:: python
 
     def unify(u, v, s=None):
         if s is None:
@@ -1449,7 +1449,7 @@ of how many labels of each domain it has “seen”.
 
 Rewrite the stack effect comments:
 
-.. code:: ipython2
+.. code:: python
 
     def defs():
     
@@ -1503,11 +1503,11 @@ Rewrite the stack effect comments:
     
         return locals()
 
-.. code:: ipython2
+.. code:: python
 
     DEFS = defs()
 
-.. code:: ipython2
+.. code:: python
 
     for name, stack_effect_comment in sorted(DEFS.items()):
         print name, '=', doc_from_stack_effect(*stack_effect_comment)
@@ -1543,14 +1543,14 @@ Rewrite the stack effect comments:
     uncons = ([a1 .1.] -- a1 [.1.])
 
 
-.. code:: ipython2
+.. code:: python
 
     globals().update(DEFS)
 
 Compose ``dup`` and ``mul``
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-.. code:: ipython2
+.. code:: python
 
     C(dup, mul)
 
@@ -1565,7 +1565,7 @@ Compose ``dup`` and ``mul``
 
 Revisit the ``F`` function, works fine.
 
-.. code:: ipython2
+.. code:: python
 
     F = reduce(C, (pop, swap, rolldown, rest, rest, cons, cons))
     F
@@ -1579,7 +1579,7 @@ Revisit the ``F`` function, works fine.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     print doc_from_stack_effect(*F)
 
@@ -1592,12 +1592,12 @@ Revisit the ``F`` function, works fine.
 Some otherwise inefficient functions are no longer to be feared. We can
 also get the effect of combinators in some limited cases.
 
-.. code:: ipython2
+.. code:: python
 
     def neato(*funcs):
         print doc_from_stack_effect(*reduce(C, funcs))
 
-.. code:: ipython2
+.. code:: python
 
     # e.g. [swap] dip
     neato(rollup, swap, rolldown)
@@ -1608,7 +1608,7 @@ also get the effect of combinators in some limited cases.
     (a1 a2 a3 -- a2 a1 a3)
 
 
-.. code:: ipython2
+.. code:: python
 
     # e.g. [popop] dipd
     neato(popdd, rolldown, pop)
@@ -1619,7 +1619,7 @@ also get the effect of combinators in some limited cases.
     (a1 a2 a3 a4 -- a3 a4)
 
 
-.. code:: ipython2
+.. code:: python
 
     # Reverse the order of the top three items.
     neato(rollup, swap)
@@ -1636,7 +1636,7 @@ also get the effect of combinators in some limited cases.
 Because the type labels represent themselves as valid Python identifiers
 the ``compile_()`` function doesn’t need to generate them anymore:
 
-.. code:: ipython2
+.. code:: python
 
     def compile_(name, f, doc=None):
         inputs, outputs = f
@@ -1652,7 +1652,7 @@ the ``compile_()`` function doesn’t need to generate them anymore:
         %s = stack
         return %s''' % (name, doc, i, o)
 
-.. code:: ipython2
+.. code:: python
 
     print compile_('F', F)
 
@@ -1668,7 +1668,7 @@ the ``compile_()`` function doesn’t need to generate them anymore:
 But it cannot magically create new functions that involve e.g. math and
 such. Note that this is *not* a ``sqr`` function implementation:
 
-.. code:: ipython2
+.. code:: python
 
     print compile_('sqr', C(dup, mul))
 
@@ -1696,7 +1696,7 @@ The functions that *can* be compiled are the ones that have only
 ``AnyJoyType`` and ``StackJoyType`` labels in their stack effect
 comments. We can write a function to check that:
 
-.. code:: ipython2
+.. code:: python
 
     from itertools import imap
     
@@ -1704,7 +1704,7 @@ comments. We can write a function to check that:
     def compilable(f):
         return isinstance(f, tuple) and all(imap(compilable, f)) or stacky(f)
 
-.. code:: ipython2
+.. code:: python
 
     for name, stack_effect_comment in sorted(defs().items()):
         if compilable(stack_effect_comment):
@@ -1828,7 +1828,7 @@ the “truthiness” of ``StackJoyType`` to false to let e.g.
 ``joy.utils.stack.concat`` work with our stack effect comment cons-list
 tuples.)
 
-.. code:: ipython2
+.. code:: python
 
     def compose(f, g):
         (f_in, f_out), (g_in, g_out) = f, g
@@ -1840,7 +1840,7 @@ tuples.)
 I don’t want to rewrite all the defs myself, so I’ll write a little
 conversion function instead. This is programmer’s laziness.
 
-.. code:: ipython2
+.. code:: python
 
     def sequence_to_stack(seq, stack=StackJoyType(23)):
         for item in seq: stack = item, stack
@@ -1854,7 +1854,7 @@ conversion function instead. This is programmer’s laziness.
     NEW_DEFS['swaack'] = (S[1], S[0]), (S[0], S[1])
     globals().update(NEW_DEFS)
 
-.. code:: ipython2
+.. code:: python
 
     C(stack, uncons)
 
@@ -1867,7 +1867,7 @@ conversion function instead. This is programmer’s laziness.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     reduce(C, (stack, uncons, uncons))
 
@@ -1887,7 +1887,7 @@ The display function should be changed too.
 
 Clunky junk, but it will suffice for now.
 
-.. code:: ipython2
+.. code:: python
 
     def doc_from_stack_effect(inputs, outputs):
         switch = [False]  # Do we need to display the '...' for the rest of the main stack?
@@ -1935,7 +1935,7 @@ Clunky junk, but it will suffice for now.
         a.append(end)
         return '[%s]' % ' '.join(a)
 
-.. code:: ipython2
+.. code:: python
 
     for name, stack_effect_comment in sorted(NEW_DEFS.items()):
         print name, '=', doc_from_stack_effect(*stack_effect_comment)
@@ -1973,7 +1973,7 @@ Clunky junk, but it will suffice for now.
     uncons = ([a1 .1.] -- a1 [.1.])
 
 
-.. code:: ipython2
+.. code:: python
 
     print ; print doc_from_stack_effect(*stack)
     print ; print doc_from_stack_effect(*C(stack, uncons))
@@ -1993,7 +1993,7 @@ Clunky junk, but it will suffice for now.
     (... a1 -- ... a1 [a1 ...])
 
 
-.. code:: ipython2
+.. code:: python
 
     print doc_from_stack_effect(*C(ccons, stack))
 
@@ -2003,7 +2003,7 @@ Clunky junk, but it will suffice for now.
     (... a2 a1 [.1.] -- ... [a2 a1 .1.] [[a2 a1 .1.] ...])
 
 
-.. code:: ipython2
+.. code:: python
 
     Q = C(ccons, stack)
     
@@ -2024,7 +2024,7 @@ Clunky junk, but it will suffice for now.
 This makes the ``compile_()`` function pretty simple as the stack effect
 comments are now already in the form needed for the Python code:
 
-.. code:: ipython2
+.. code:: python
 
     def compile_(name, f, doc=None):
         i, o = f
@@ -2035,7 +2035,7 @@ comments are now already in the form needed for the Python code:
         %s = stack
         return %s''' % (name, doc, i, o)
 
-.. code:: ipython2
+.. code:: python
 
     print compile_('Q', Q)
 
@@ -2053,12 +2053,12 @@ comments are now already in the form needed for the Python code:
 
 
 
-.. code:: ipython2
+.. code:: python
 
     unstack = (S[1], S[0]), S[1]
     enstacken = S[0], (S[0], S[1])
 
-.. code:: ipython2
+.. code:: python
 
     print doc_from_stack_effect(*unstack)
 
@@ -2068,7 +2068,7 @@ comments are now already in the form needed for the Python code:
     ([.1.] --)
 
 
-.. code:: ipython2
+.. code:: python
 
     print doc_from_stack_effect(*enstacken)
 
@@ -2078,7 +2078,7 @@ comments are now already in the form needed for the Python code:
     (-- [.0.])
 
 
-.. code:: ipython2
+.. code:: python
 
     print doc_from_stack_effect(*C(cons, unstack))
 
@@ -2088,7 +2088,7 @@ comments are now already in the form needed for the Python code:
     (a1 [.1.] -- a1)
 
 
-.. code:: ipython2
+.. code:: python
 
     print doc_from_stack_effect(*C(cons, enstacken))
 
@@ -2098,7 +2098,7 @@ comments are now already in the form needed for the Python code:
     (a1 [.1.] -- [[a1 .1.] .2.])
 
 
-.. code:: ipython2
+.. code:: python
 
     C(cons, unstack)
 
@@ -2117,7 +2117,7 @@ Part VI: Multiple Stack Effects
 
 …
 
-.. code:: ipython2
+.. code:: python
 
     class IntJoyType(NumberJoyType): prefix = 'i'
     
@@ -2125,7 +2125,7 @@ Part VI: Multiple Stack Effects
     F = map(FloatJoyType, _R)
     I = map(IntJoyType, _R)
 
-.. code:: ipython2
+.. code:: python
 
     muls = [
          ((I[2], (I[1], S[0])), (I[3], S[0])),
@@ -2134,7 +2134,7 @@ Part VI: Multiple Stack Effects
          ((F[2], (F[1], S[0])), (F[3], S[0])),
     ]
 
-.. code:: ipython2
+.. code:: python
 
     for f in muls:
         print doc_from_stack_effect(*f)
@@ -2148,7 +2148,7 @@ Part VI: Multiple Stack Effects
     (f1 f2 -- f3)
 
 
-.. code:: ipython2
+.. code:: python
 
     for f in muls:
         try:
@@ -2164,7 +2164,7 @@ Part VI: Multiple Stack Effects
     (a1 -- a1 a1) (f1 f2 -- f3) (f1 -- f2)
 
 
-.. code:: ipython2
+.. code:: python
 
     from itertools import product
     
@@ -2180,7 +2180,7 @@ Part VI: Multiple Stack Effects
     def MC(F, G):
         return sorted(set(meta_compose(F, G)))
 
-.. code:: ipython2
+.. code:: python
 
     for f in MC([dup], [mul]):
         print doc_from_stack_effect(*f)
@@ -2191,7 +2191,7 @@ Part VI: Multiple Stack Effects
     (n1 -- n2)
 
 
-.. code:: ipython2
+.. code:: python
 
     for f in MC([dup], muls):
         print doc_from_stack_effect(*f)
@@ -2264,7 +2264,7 @@ Giving us two unifiers:
    {c: a,  d: b,  .1.:      .0.}
    {c: a,  d: e,  .1.: A* b .0.}
 
-.. code:: ipython2
+.. code:: python
 
     class KleeneStar(object):
     
@@ -2314,7 +2314,7 @@ Giving us two unifiers:
 
 Can now return multiple results…
 
-.. code:: ipython2
+.. code:: python
 
     def unify(u, v, s=None):
         if s is None:
@@ -2386,7 +2386,7 @@ Can now return multiple results…
     def stacky(thing):
         return thing.__class__ in {AnyJoyType, StackJoyType}
 
-.. code:: ipython2
+.. code:: python
 
     a = (As[1], S[1])
     a
@@ -2400,7 +2400,7 @@ Can now return multiple results…
 
 
 
-.. code:: ipython2
+.. code:: python
 
     b = (A[1], S[2])
     b
@@ -2414,7 +2414,7 @@ Can now return multiple results…
 
 
 
-.. code:: ipython2
+.. code:: python
 
     for result in unify(b, a):
         print result, '->', update(result, a), update(result, b)
@@ -2426,7 +2426,7 @@ Can now return multiple results…
     {a1: a10001, s2: (a1*, s1)} -> (a1*, s1) (a10001, (a1*, s1))
 
 
-.. code:: ipython2
+.. code:: python
 
     for result in unify(a, b):
         print result, '->', update(result, a), update(result, b)
@@ -2446,7 +2446,7 @@ Can now return multiple results…
 
    (a1*, s1)       [a1*]       (a2, (a1*, s1)) [a2 a1*]
 
-.. code:: ipython2
+.. code:: python
 
     sum_ = ((Ns[1], S[1]), S[0]), (N[0], S[0])
     
@@ -2458,7 +2458,7 @@ Can now return multiple results…
     ([n1* .1.] -- n0)
 
 
-.. code:: ipython2
+.. code:: python
 
     f = (N[1], (N[2], (N[3], S[1]))), S[0]
     
@@ -2470,7 +2470,7 @@ Can now return multiple results…
     (-- [n1 n2 n3 .1.])
 
 
-.. code:: ipython2
+.. code:: python
 
     for result in unify(sum_[0], f):
         print result, '->', update(result, sum_[1])
@@ -2489,7 +2489,7 @@ Can now return multiple results…
 
 This function has to be modified to yield multiple results.
 
-.. code:: ipython2
+.. code:: python
 
     def compose(f, g):
         (f_in, f_out), (g_in, g_out) = f, g
@@ -2501,7 +2501,7 @@ This function has to be modified to yield multiple results.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     def meta_compose(F, G):
         for f, g in product(F, G):
@@ -2517,7 +2517,7 @@ This function has to be modified to yield multiple results.
         for fg in compose(f, g):
             yield delabel(fg)
 
-.. code:: ipython2
+.. code:: python
 
     for f in MC([dup], muls):
         print doc_from_stack_effect(*f)
@@ -2529,7 +2529,7 @@ This function has to be modified to yield multiple results.
     (i1 -- i2)
 
 
-.. code:: ipython2
+.. code:: python
 
     
     
@@ -2542,7 +2542,7 @@ This function has to be modified to yield multiple results.
     ([n1* .1.] -- [n1* .1.] n1)
 
 
-.. code:: ipython2
+.. code:: python
 
     
     
@@ -2556,7 +2556,7 @@ This function has to be modified to yield multiple results.
     (n1 [n1* .1.] -- n2)
 
 
-.. code:: ipython2
+.. code:: python
 
     sum_ = (((N[1], (Ns[1], S[1])), S[0]), (N[0], S[0]))
     print doc_from_stack_effect(*cons),
@@ -2571,7 +2571,7 @@ This function has to be modified to yield multiple results.
     (a1 [.1.] -- [a1 .1.]) ([n1 n1* .1.] -- n0) (n1 [n1* .1.] -- n2)
 
 
-.. code:: ipython2
+.. code:: python
 
     a = (A[4], (As[1], (A[3], S[1])))
     a
@@ -2585,7 +2585,7 @@ This function has to be modified to yield multiple results.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     b = (A[1], (A[2], S[2]))
     b
@@ -2599,7 +2599,7 @@ This function has to be modified to yield multiple results.
 
 
 
-.. code:: ipython2
+.. code:: python
 
     for result in unify(b, a):
         print result
@@ -2611,7 +2611,7 @@ This function has to be modified to yield multiple results.
     {a1: a4, s2: (a1*, (a3, s1)), a2: a10003}
 
 
-.. code:: ipython2
+.. code:: python
 
     for result in unify(a, b):
         print result
@@ -2681,7 +2681,7 @@ We need a type variable for Joy functions that can go in our expressions
 and be used by the hybrid inferencer/interpreter. They have to store a
 name and a list of stack effects.
 
-.. code:: ipython2
+.. code:: python
 
     class FunctionJoyType(AnyJoyType):
     
@@ -2703,14 +2703,14 @@ Specialized for Simple Functions and Combinators
 For non-combinator functions the stack effects list contains stack
 effect comments (represented by pairs of cons-lists as described above.)
 
-.. code:: ipython2
+.. code:: python
 
     class SymbolJoyType(FunctionJoyType):
         prefix = 'F'
 
 For combinators the list contains Python functions.
 
-.. code:: ipython2
+.. code:: python
 
     class CombinatorJoyType(FunctionJoyType):
     
@@ -2731,7 +2731,7 @@ For combinators the list contains Python functions.
 For simple combinators that have only one effect (like ``dip``) you only
 need one function and it can be the combinator itself.
 
-.. code:: ipython2
+.. code:: python
 
     import joy.library
     
@@ -2741,7 +2741,7 @@ For combinators that can have more than one effect (like ``branch``) you
 have to write functions that each implement the action of one of the
 effects.
 
-.. code:: ipython2
+.. code:: python
 
     def branch_true(stack, expression, dictionary):
         (then, (else_, (flag, stack))) = stack
@@ -2771,7 +2771,7 @@ updated along with the stack effects after doing unification or we risk
 losing useful information. This was a straightforward, if awkward,
 modification to the call structure of ``meta_compose()`` et. al.
 
-.. code:: ipython2
+.. code:: python
 
     ID = S[0], S[0]  # Identity function.
     
@@ -2833,7 +2833,7 @@ cruft to convert the definitions in ``DEFS`` to the new
 ``SymbolJoyType`` objects, and some combinators. Here is an example of
 output from the current code :
 
-.. code:: ipython2
+.. code:: python
 
     1/0  # (Don't try to run this cell!  It's not going to work.  This is "read only" code heh..)
     
@@ -2956,7 +2956,7 @@ module. But if you’re interested in all that you should just use Prolog!
 
 Anyhow, type *checking* is a few easy steps away.
 
-.. code:: ipython2
+.. code:: python
 
     def _ge(self, other):
         return (issubclass(other.__class__, self.__class__)
index dc4f996..c44343a 100644 (file)
@@ -10,7 +10,7 @@ Huet <https://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/huet-
 Given a datastructure on the stack we can navigate through it, modify
 it, and rebuild it using the “zipper” technique.
 
-.. code:: ipython2
+.. code:: python
 
     from notebook_preamble import J, V, define
 
@@ -23,7 +23,7 @@ strings, Symbols (strings that are names of functions) and sequences
 `trees <https://en.wikipedia.org/wiki/Tree_%28data_structure%29>`__ out
 of sequences.
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 [2 [3 4 25 6] 7] 8]')
 
@@ -54,14 +54,14 @@ show the trace so you can see how it works. If we were going to use
 these a lot it would make sense to write Python versions for efficiency,
 but see below.
 
-.. code:: ipython2
+.. code:: python
 
     define('z-down == [] swap uncons swap')
     define('z-up == swons swap shunt')
     define('z-right == [swons] cons dip uncons swap')
     define('z-left == swons [uncons swap] dip swap')
 
-.. code:: ipython2
+.. code:: python
 
     V('[1 [2 [3 4 25 6] 7] 8] z-down')
 
@@ -77,7 +77,7 @@ but see below.
     [] [[2 [3 4 25 6] 7] 8] 1 . 
 
 
-.. code:: ipython2
+.. code:: python
 
     V('[] [[2 [3 4 25 6] 7] 8] 1 z-right')
 
@@ -101,7 +101,7 @@ but see below.
              [1] [8] [2 [3 4 25 6] 7] . 
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [2 [3 4 25 6] 7] z-down')
 
@@ -111,7 +111,7 @@ but see below.
     [1] [8] [] [[3 4 25 6] 7] 2
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [] [[3 4 25 6] 7] 2 z-right')
 
@@ -121,7 +121,7 @@ but see below.
     [1] [8] [2] [7] [3 4 25 6]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [2] [7] [3 4 25 6] z-down')
 
@@ -131,7 +131,7 @@ but see below.
     [1] [8] [2] [7] [] [4 25 6] 3
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [2] [7] [] [4 25 6] 3 z-right')
 
@@ -141,7 +141,7 @@ but see below.
     [1] [8] [2] [7] [3] [25 6] 4
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [2] [7] [3] [25 6] 4 z-right')
 
@@ -151,7 +151,7 @@ but see below.
     [1] [8] [2] [7] [4 3] [6] 25
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [2] [7] [4 3] [6] 25 sqr')
 
@@ -161,7 +161,7 @@ but see below.
     [1] [8] [2] [7] [4 3] [6] 625
 
 
-.. code:: ipython2
+.. code:: python
 
     V('[1] [8] [2] [7] [4 3] [6] 625 z-up')
 
@@ -184,7 +184,7 @@ but see below.
       [1] [8] [2] [7] [3 4 625 6] . 
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [2] [7] [3 4 625 6] z-up')
 
@@ -194,7 +194,7 @@ but see below.
     [1] [8] [2 [3 4 625 6] 7]
 
 
-.. code:: ipython2
+.. code:: python
 
     J('[1] [8] [2 [3 4 625 6] 7] z-up')
 
@@ -210,7 +210,7 @@ but see below.
 In Joy we have the ``dip`` and ``infra`` combinators which can “target”
 or “address” any particular item in a Joy tree structure.
 
-.. code:: ipython2
+.. code:: python
 
     V('[1 [2 [3 4 25 6] 7] 8] [[[[[[sqr] dipd] infra] dip] infra] dip] infra')
 
@@ -270,13 +270,13 @@ been embedded in a nested series of quoted programs, e.g.:
 
 The ``Z`` function isn’t hard to make.
 
-.. code:: ipython2
+.. code:: python
 
     define('Z == [[] cons cons] step i')
 
 Here it is in action in a simplified scenario.
 
-.. code:: ipython2
+.. code:: python
 
     V('1 [2 3 4] Z')
 
@@ -314,7 +314,7 @@ Here it is in action in a simplified scenario.
 
 And here it is doing the main thing.
 
-.. code:: ipython2
+.. code:: python
 
     J('[1 [2 [3 4 25 6] 7] 8] [sqr] [dip dip infra dip infra dip infra] Z')
 
index 005473b..e1f7b80 100644 (file)
 #    You should have received a copy of the GNU General Public License
 #    along with Thun.  If not see <http://www.gnu.org/licenses/>.
 #
+import sys
 from .library import initialize, inscribe
-from .joy import repl
+from .joy import repl, interp
 from .utils.pretty_print import trace
 
 
 inscribe(trace)
-print('''\
+
+if '-q' in sys.argv:
+    j = interp
+else:
+    j = repl
+    print('''\
 Thun - Copyright © 2017 Simon Forman
 This program comes with ABSOLUTELY NO WARRANTY; for details type "warranty".
 This is free software, and you are welcome to redistribute it
@@ -31,4 +37,4 @@ under certain conditions; type "sharing" for details.
 Type "words" to see a list of all words, and "[<name>] help" to print the
 docs for a word.
 ''')
-stack = repl(dictionary=initialize())
+stack = j(dictionary=initialize())
index 0e755da..ad597a7 100644 (file)
@@ -27,83 +27,124 @@ from builtins import input
 from traceback import print_exc
 from .parser import text_to_expression, ParseError, Symbol
 from .utils.stack import stack_to_string
+from .utils.errors import (
+    NotAListError,
+    NotAnIntError,
+    StackUnderflowError,
+    )
+
+
+class UnknownSymbolError(KeyError): pass
 
 
 def joy(stack, expression, dictionary, viewer=None):
-       '''Evaluate a Joy expression on a stack.
+    '''Evaluate a Joy expression on a stack.
 
   This function iterates through a sequence of terms which are either
   literals (strings, numbers, sequences of terms) or function symbols.
   Literals are put onto the stack and functions are looked up in the
   dictionary and executed.
 
-       The viewer is a function that is called with the stack and expression
-       on every iteration, its return value is ignored.
+    The viewer is a function that is called with the stack and expression
+    on every iteration, its return value is ignored.
 
-       :param stack stack: The stack.
-       :param stack expression: The expression to evaluate.
-       :param dict dictionary: A ``dict`` mapping names to Joy functions.
-       :param function viewer: Optional viewer function.
-       :rtype: (stack, (), dictionary)
+    :param stack stack: The stack.
+    :param stack expression: The expression to evaluate.
+    :param dict dictionary: A ``dict`` mapping names to Joy functions.
+    :param function viewer: Optional viewer function.
+    :rtype: (stack, (), dictionary)
 
-       '''
-       while expression:
+    '''
+    while expression:
 
-               if viewer: viewer(stack, expression)
+        if viewer: viewer(stack, expression)
 
-               term, expression = expression
-               if isinstance(term, Symbol):
-                       term = dictionary[term]
-                       stack, expression, dictionary = term(stack, expression, dictionary)
-               else:
-                       stack = term, stack
+        term, expression = expression
+        if isinstance(term, Symbol):
+            try:
+                term = dictionary[term]
+            except KeyError:
+                raise UnknownSymbolError(term)
+            stack, expression, dictionary = term(stack, expression, dictionary)
+        else:
+            stack = term, stack
 
-       if viewer: viewer(stack, expression)
-       return stack, expression, dictionary
+    if viewer: viewer(stack, expression)
+    return stack, expression, dictionary
 
 
 def run(text, stack, dictionary, viewer=None):
-       '''
-       Return the stack resulting from running the Joy code text on the stack.
+    '''
+    Return the stack resulting from running the Joy code text on the stack.
 
-       :param str text: Joy code.
-       :param stack stack: The stack.
-       :param dict dictionary: A ``dict`` mapping names to Joy functions.
-       :param function viewer: Optional viewer function.
-       :rtype: (stack, (), dictionary)
+    :param str text: Joy code.
+    :param stack stack: The stack.
+    :param dict dictionary: A ``dict`` mapping names to Joy functions.
+    :param function viewer: Optional viewer function.
+    :rtype: (stack, (), dictionary)
 
-       '''
-       expression = text_to_expression(text)
-       return joy(stack, expression, dictionary, viewer)
+    '''
+    expression = text_to_expression(text)
+    return joy(stack, expression, dictionary, viewer)
 
 
 def repl(stack=(), dictionary=None):
-       '''
-       Read-Evaluate-Print Loop
-
-       Accept input and run it on the stack, loop.
-
-       :param stack stack: The stack.
-       :param dict dictionary: A ``dict`` mapping names to Joy functions.
-       :rtype: stack
-
-       '''
-       if dictionary is None:
-               dictionary = {}
-       try:
-               while True:
-                       print()
-                       print(stack_to_string(stack), '<-top')
-                       print()
-                       try:
-                               text = input('joy? ')
-                       except (EOFError, KeyboardInterrupt):
-                               break
-                       try:
-                               stack, _, dictionary = run(text, stack, dictionary)
-                       except:
-                               print_exc()
-       except:
-               print_exc()
-       print()
-       return stack
+    '''
+    Read-Evaluate-Print Loop
+
+    Accept input and run it on the stack, loop.
+
+    :param stack stack: The stack.
+    :param dict dictionary: A ``dict`` mapping names to Joy functions.
+    :rtype: stack
+
+    '''
+    if dictionary is None:
+        dictionary = {}
+    try:
+        while True:
+            print()
+            print(stack_to_string(stack), '<-top')
+            print()
+            try:
+                text = input('joy? ')
+            except (EOFError, KeyboardInterrupt):
+                break
+            try:
+                stack, _, dictionary = run(text, stack, dictionary)
+            except:
+                print_exc()
+    except:
+        print_exc()
+    print()
+    return stack
+
+
+def interp(stack=(), dictionary=None):
+    '''
+    Simple REPL with no extra output, suitable for use in scripts.
+    '''
+    if dictionary is None:
+        dictionary = {}
+    try:
+        while True:
+            try:
+                text = input()
+            except (EOFError, KeyboardInterrupt):
+                break
+            try:
+                stack, _, dictionary = run(text, stack, dictionary)
+            except UnknownSymbolError as sym:
+                print('Unknown:', sym)
+            except StackUnderflowError as e:
+                print(e)  # 'Not enough values on stack.'
+            except NotAnIntError:
+                print('Not an integer.')
+            except NotAListError as e:
+                print(e)  # 'Not a list.'
+            except:
+                print_exc()
+            print(stack_to_string(stack))
+    except:
+        print_exc()
+    return stack
index 8ad7948..5faf22f 100644 (file)
@@ -30,13 +30,18 @@ import operator, math
 
 from .parser import text_to_expression, Symbol
 from .utils import generated_library as genlib
+from .utils.errors import (
+    NotAListError,
+    NotAnIntError,
+    StackUnderflowError,
+    )
 from .utils.stack import (
-       concat,
-       expression_to_string,
-       iter_stack,
-       list_to_stack,
-       pick,
-       )
+    concat,
+    expression_to_string,
+    iter_stack,
+    list_to_stack,
+    pick,
+    )
 
 
 HELP_TEMPLATE = '''\
@@ -54,57 +59,56 @@ _dictionary = {}
 
 
 def inscribe(function):
-       '''A decorator to inscribe functions into the default dictionary.'''
-       _dictionary[function.name] = function
-       return function
+    '''A decorator to inscribe functions into the default dictionary.'''
+    _dictionary[function.name] = function
+    return function
 
 
 def initialize():
-       '''Return a dictionary of Joy functions for use with joy().'''
-       return _dictionary.copy()
+    '''Return a dictionary of Joy functions for use with joy().'''
+    return _dictionary.copy()
 
 
 ALIASES = (
-       ('add', ['+']),
-       ('and', ['&']),
-       ('bool', ['truthy']),
-       ('mul', ['*']),
-       ('floordiv', ['/floor', '//']),
-       ('truediv', ['/', 'div']),
-       ('mod', ['%', 'rem', 'remainder', 'modulus']),
-       ('eq', ['=']),
-       ('ge', ['>=']),
-       ('getitem', ['pick', 'at']),
-       ('gt', ['>']),
-       ('le', ['<=']),
-       ('lshift', ['<<']),
-       ('lt', ['<']),
-       ('ne', ['<>', '!=']),
-       ('rshift', ['>>']),
-       ('sub', ['-']),
-       ('xor', ['^']),
-       ('succ', ['++']),
-       ('pred', ['--']),
-       ('rolldown', ['roll<']),
-       ('rollup', ['roll>']),
-       ('eh', ['?']),
-       ('id', [u'•']),
-       )
+    ('add', ['+']),
+    ('and', ['&']),
+    ('bool', ['truthy']),
+    ('mul', ['*']),
+    ('floordiv', ['/floor', '//', '/', 'div']),
+    ('mod', ['%', 'rem', 'remainder', 'modulus']),
+    ('eq', ['=']),
+    ('ge', ['>=']),
+    ('getitem', ['pick', 'at']),
+    ('gt', ['>']),
+    ('le', ['<=']),
+    ('lshift', ['<<']),
+    ('lt', ['<']),
+    ('ne', ['<>', '!=']),
+    ('rshift', ['>>']),
+    ('sub', ['-']),
+    ('xor', ['^']),
+    ('succ', ['++']),
+    ('pred', ['--']),
+    ('rolldown', ['roll<']),
+    ('rollup', ['roll>']),
+    ('eh', ['?']),
+    ('id', [u'•']),
+    )
 
 
 def add_aliases(D, A):
-       '''
-       Given a dict and a iterable of (name, [alias, ...]) pairs, create
-       additional entries in the dict mapping each alias to the named function
-       if it's in the dict.  Aliases for functions not in the dict are ignored.
-       '''
-       for name, aliases in A:
-               try:
-                       F = D[name]
-               except KeyError:
-                       continue
-               for alias in aliases:
-                       D[alias] = F
+    '''
+    Given a dict and a iterable of (name, [alias, ...]) pairs, create
+    additional entries in the dict mapping each alias to the named function
+    if it's in the dict.  Aliases for functions not in the dict are ignored.
+    '''
+    for name, aliases in A:
+        try:
+            F = D[name]
+        except KeyError:
+            continue
+        for alias in aliases:
+            D[alias] = F
 
 
 definitions = ('''\
@@ -190,121 +194,130 @@ while == swap [nullary] cons dup dipd concat loop
 
 
 def FunctionWrapper(f):
-       '''Set name attribute.'''
-       if not f.__doc__:
-               raise ValueError('Function %s must have doc string.' % f.__name__)
-       f.name = f.__name__.rstrip('_')  # Don't shadow builtins.
-       return f
+    '''Set name attribute.'''
+    if not f.__doc__:
+        raise ValueError('Function %s must have doc string.' % f.__name__)
+    f.name = f.__name__.rstrip('_')  # Don't shadow builtins.
+    return f
 
 
 def SimpleFunctionWrapper(f):
-       '''
-       Wrap functions that take and return just a stack.
-       '''
-       @FunctionWrapper
-       @wraps(f)
-       def inner(stack, expression, dictionary):
-               return f(stack), expression, dictionary
-       return inner
+    '''
+    Wrap functions that take and return just a stack.
+    '''
+    @FunctionWrapper
+    @wraps(f)
+    def inner(stack, expression, dictionary):
+        return f(stack), expression, dictionary
+    return inner
 
 
 def BinaryBuiltinWrapper(f):
-       '''
-       Wrap functions that take two arguments and return a single result.
-       '''
-       @FunctionWrapper
-       @wraps(f)
-       def inner(stack, expression, dictionary):
-               (a, (b, stack)) = stack
-               result = f(b, a)
-               return (result, stack), expression, dictionary
-       return inner
+    '''
+    Wrap functions that take two arguments and return a single result.
+    '''
+    @FunctionWrapper
+    @wraps(f)
+    def inner(stack, expression, dictionary):
+        try:
+            (a, (b, stack)) = stack
+        except ValueError:
+            raise StackUnderflowError('Not enough values on stack.')
+        if (   not isinstance(a, int)
+            or not isinstance(b, int)
+            or isinstance(a, bool)  # Because bools are ints in Python.
+            or isinstance(b, bool)
+            ):
+            raise NotAnIntError
+        result = f(b, a)
+        return (result, stack), expression, dictionary
+    return inner
 
 
 def UnaryBuiltinWrapper(f):
-       '''
-       Wrap functions that take one argument and return a single result.
-       '''
-       @FunctionWrapper
-       @wraps(f)
-       def inner(stack, expression, dictionary):
-               (a, stack) = stack
-               result = f(a)
-               return (result, stack), expression, dictionary
-       return inner
+    '''
+    Wrap functions that take one argument and return a single result.
+    '''
+    @FunctionWrapper
+    @wraps(f)
+    def inner(stack, expression, dictionary):
+        (a, stack) = stack
+        result = f(a)
+        return (result, stack), expression, dictionary
+    return inner
 
 
 class DefinitionWrapper(object):
-       '''
-       Provide implementation of defined functions, and some helper methods.
-       '''
-
-       def __init__(self, name, body_text, doc=None):
-               self.name = self.__name__ = name
-               self.body = text_to_expression(body_text)
-               self._body = tuple(iter_stack(self.body))
-               self.__doc__ = doc or body_text
-               self._compiled = None
-
-       def __call__(self, stack, expression, dictionary):
-               if self._compiled:
-                       return self._compiled(stack, expression, dictionary)  # pylint: disable=E1102
-               expression = list_to_stack(self._body, expression)
-               return stack, expression, dictionary
-
-       @classmethod
-       def parse_definition(class_, defi):
-               '''
-               Given some text describing a Joy function definition parse it and
-               return a DefinitionWrapper.
-               '''
-               # At some point I decided that the definitions file should NOT
-               # use '==' to separate the name from the body.  But somehow the
-               # xerblin\gui\default_joy_home\definitions.txt file didn't get
-               # the memo.  Nor did the load_definitions() method.
-               # So I think the simplest way forward at the moment will be to
-               # edit this function to expect '=='.
-
-               name, part, body = defi.partition('==')
-               if part:
-                       return class_(name.strip(), body.strip())
-               raise ValueError("No '==' in definition text %r" % (defi,))
-
-               # return class_(*(n.strip() for n in defi.split(None, 1)))
-
-       @classmethod
-       def add_definitions(class_, defs, dictionary):
-               '''
-               Scan multi-line string defs for definitions and add them to the
-               dictionary.
-               '''
-               for definition in _text_to_defs(defs):
-                       class_.add_def(definition, dictionary)
-
-       @classmethod
-       def add_def(class_, definition, dictionary, fail_fails=False):
-               '''
-               Add the definition to the dictionary.
-               '''
-               F = class_.parse_definition(definition)
-               dictionary[F.name] = F
-
-       @classmethod
-       def load_definitions(class_, filename, dictionary):
-               with open(filename) as f:
-                       lines = [line for line in f if '==' in line]
-               for line in lines:
-                       class_.add_def(line, dictionary)
+    '''
+    Provide implementation of defined functions, and some helper methods.
+    '''
+
+    def __init__(self, name, body_text, doc=None):
+        self.name = self.__name__ = name
+        self.body = text_to_expression(body_text)
+        self._body = tuple(iter_stack(self.body))
+        self.__doc__ = doc or body_text
+        self._compiled = None
+
+    def __call__(self, stack, expression, dictionary):
+        if self._compiled:
+            return self._compiled(stack, expression, dictionary)  # pylint: disable=E1102
+        expression = list_to_stack(self._body, expression)
+        return stack, expression, dictionary
+
+    @classmethod
+    def parse_definition(class_, defi):
+        '''
+        Given some text describing a Joy function definition parse it and
+        return a DefinitionWrapper.
+        '''
+        # At some point I decided that the definitions file should NOT
+        # use '==' to separate the name from the body.  But somehow the
+        # xerblin\gui\default_joy_home\definitions.txt file didn't get
+        # the memo.  Nor did the load_definitions() method.
+        # So I think the simplest way forward at the moment will be to
+        # edit this function to expect '=='.
+
+        name, part, body = defi.partition('==')
+        if part:
+            return class_(name.strip(), body.strip())
+        raise ValueError("No '==' in definition text %r" % (defi,))
+
+        # return class_(*(n.strip() for n in defi.split(None, 1)))
+
+    @classmethod
+    def add_definitions(class_, defs, dictionary):
+        '''
+        Scan multi-line string defs for definitions and add them to the
+        dictionary.
+        '''
+        for definition in _text_to_defs(defs):
+            class_.add_def(definition, dictionary)
+
+    @classmethod
+    def add_def(class_, definition, dictionary, fail_fails=False):
+        '''
+        Add the definition to the dictionary.
+        '''
+        F = class_.parse_definition(definition)
+        dictionary[F.name] = F
+
+    @classmethod
+    def load_definitions(class_, filename, dictionary):
+        with open(filename) as f:
+            lines = [line for line in f if '==' in line]
+        for line in lines:
+            class_.add_def(line, dictionary)
 
 
 def _text_to_defs(text):
-       return (
-               line.strip()
-               for line in text.splitlines()
-               if line
-                  and not line.startswith('#')
-                  and '==' in line
-               )
+    return (
+        line.strip()
+        for line in text.splitlines()
+        if line
+           and not line.startswith('#')
+           and '==' in line
+        )
 
 
 #
@@ -315,112 +328,112 @@ def _text_to_defs(text):
 @inscribe
 @FunctionWrapper
 def inscribe_(stack, expression, dictionary):
-       '''
-       Create a new Joy function definition in the Joy dictionary.  A
-       definition is given as a string with a name followed by a double
-       equal sign then one or more Joy functions, the body. for example:
+    '''
+    Create a new Joy function definition in the Joy dictionary.  A
+    definition is given as a string with a name followed by a double
+    equal sign then one or more Joy functions, the body. for example:
 
-               sqr == dup mul
+        sqr == dup mul
 
-       If you want the definition to persist over restarts, enter it into
-       the definitions.txt resource.
-       '''
-       definition, stack = stack
-       DefinitionWrapper.add_def(definition, dictionary, fail_fails=True)
-       return stack, expression, dictionary
+    If you want the definition to persist over restarts, enter it into
+    the definitions.txt resource.
+    '''
+    definition, stack = stack
+    DefinitionWrapper.add_def(definition, dictionary, fail_fails=True)
+    return stack, expression, dictionary
 
 
 @inscribe
 @SimpleFunctionWrapper
 def parse(stack):
-       '''Parse the string on the stack to a Joy expression.'''
-       text, stack = stack
-       expression = text_to_expression(text)
-       return expression, stack
+    '''Parse the string on the stack to a Joy expression.'''
+    text, stack = stack
+    expression = text_to_expression(text)
+    return expression, stack
 
 
 # @inscribe
 # @SimpleFunctionWrapper
 # def infer_(stack):
-#      '''Attempt to infer the stack effect of a Joy expression.'''
-#      E, stack = stack
-#      effects = infer_expression(E)
-#      e = list_to_stack([(fi, (fo, ())) for fi, fo in effects])
-#      return e, stack
+#     '''Attempt to infer the stack effect of a Joy expression.'''
+#     E, stack = stack
+#     effects = infer_expression(E)
+#     e = list_to_stack([(fi, (fo, ())) for fi, fo in effects])
+#     return e, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def getitem(stack):
-       '''
-       ::
+    '''
+    ::
 
-               getitem == drop first
+        getitem == drop first
 
-       Expects an integer and a quote on the stack and returns the item at the
-       nth position in the quote counting from 0.
-       ::
+    Expects an integer and a quote on the stack and returns the item at the
+    nth position in the quote counting from 0.
+    ::
 
-                  [a b c d] 0 getitem
-               -------------------------
-                   a
+           [a b c d] 0 getitem
+        -------------------------
+            a
 
-       '''
-       n, (Q, stack) = stack
-       return pick(Q, n), stack
+    '''
+    n, (Q, stack) = stack
+    return pick(Q, n), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def drop(stack):
-       '''
-       ::
+    '''
+    ::
 
-               drop == [rest] times
+        drop == [rest] times
 
-       Expects an integer and a quote on the stack and returns the quote with
-       n items removed off the top.
-       ::
+    Expects an integer and a quote on the stack and returns the quote with
+    n items removed off the top.
+    ::
 
-                  [a b c d] 2 drop
-               ----------------------
-                      [c d]
+           [a b c d] 2 drop
+        ----------------------
+               [c d]
 
-       '''
-       n, (Q, stack) = stack
-       while n > 0:
-               try:
-                       _, Q = Q
-               except ValueError:
-                       raise IndexError
-               n -= 1
-       return Q, stack
+    '''
+    n, (Q, stack) = stack
+    while n > 0:
+        try:
+            _, Q = Q
+        except ValueError:
+            raise IndexError
+        n -= 1
+    return Q, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def take(stack):
-       '''
-       Expects an integer and a quote on the stack and returns the quote with
-       just the top n items in reverse order (because that's easier and you can
-       use reverse if needed.)
-       ::
-
-                  [a b c d] 2 take
-               ----------------------
-                      [b a]
-
-       '''
-       n, (Q, stack) = stack
-       x = ()
-       while n > 0:
-               try:
-                       item, Q = Q
-               except ValueError:
-                       raise IndexError
-               x = item, x
-               n -= 1
-       return x, stack
+    '''
+    Expects an integer and a quote on the stack and returns the quote with
+    just the top n items in reverse order (because that's easier and you can
+    use reverse if needed.)
+    ::
+
+           [a b c d] 2 take
+        ----------------------
+               [b a]
+
+    '''
+    n, (Q, stack) = stack
+    x = ()
+    while n > 0:
+        try:
+            item, Q = Q
+        except ValueError:
+            raise IndexError
+        x = item, x
+        n -= 1
+    return x, stack
 
 
 @inscribe
@@ -439,245 +452,245 @@ def gcd2(stack, expression, dictionary):
 @inscribe
 @SimpleFunctionWrapper
 def choice(stack):
-       '''
-       Use a Boolean value to select one of two items.
-       ::
+    '''
+    Use a Boolean value to select one of two items.
+    ::
 
-                  A B False choice
-               ----------------------
-                  A
+           A B False choice
+        ----------------------
+           A
 
 
-                  A B True choice
-               ---------------------
-                    B
+           A B True choice
+        ---------------------
+             B
 
-       Currently Python semantics are used to evaluate the "truthiness" of the
-       Boolean value (so empty string, zero, etc. are counted as false, etc.)
-       '''
-       (if_, (then, (else_, stack))) = stack
-       return then if if_ else else_, stack
+    Currently Python semantics are used to evaluate the "truthiness" of the
+    Boolean value (so empty string, zero, etc. are counted as false, etc.)
+    '''
+    (if_, (then, (else_, stack))) = stack
+    return then if if_ else else_, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def select(stack):
-       '''
-       Use a Boolean value to select one of two items from a sequence.
-       ::
+    '''
+    Use a Boolean value to select one of two items from a sequence.
+    ::
 
-                  [A B] False select
-               ------------------------
-                   A
+           [A B] False select
+        ------------------------
+            A
 
 
-                  [A B] True select
-               -----------------------
-                     B
+           [A B] True select
+        -----------------------
+              B
 
-       The sequence can contain more than two items but not fewer.
-       Currently Python semantics are used to evaluate the "truthiness" of the
-       Boolean value (so empty string, zero, etc. are counted as false, etc.)
-       '''
-       (flag, (choices, stack)) = stack
-       (else_, (then, _)) = choices
-       return then if flag else else_, stack
+    The sequence can contain more than two items but not fewer.
+    Currently Python semantics are used to evaluate the "truthiness" of the
+    Boolean value (so empty string, zero, etc. are counted as false, etc.)
+    '''
+    (flag, (choices, stack)) = stack
+    (else_, (then, _)) = choices
+    return then if flag else else_, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def max_(S):
-       '''Given a list find the maximum.'''
-       tos, stack = S
-       return max(iter_stack(tos)), stack
+    '''Given a list find the maximum.'''
+    tos, stack = S
+    return max(iter_stack(tos)), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def min_(S):
-       '''Given a list find the minimum.'''
-       tos, stack = S
-       return min(iter_stack(tos)), stack
+    '''Given a list find the minimum.'''
+    tos, stack = S
+    return min(iter_stack(tos)), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def sum_(S):
-       '''
-       Given a quoted sequence of numbers return the sum.
-       ::
+    '''
+    Given a quoted sequence of numbers return the sum.
+    ::
 
-               sum == 0 swap [+] step
+        sum == 0 swap [+] step
 
-       '''
-       tos, stack = S
-       return sum(iter_stack(tos)), stack
+    '''
+    tos, stack = S
+    return sum(iter_stack(tos)), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def remove(S):
-       '''
-       Expects an item on the stack and a quote under it and removes that item
-       from the the quote.  The item is only removed once.
-       ::
+    '''
+    Expects an item on the stack and a quote under it and removes that item
+    from the the quote.  The item is only removed once.
+    ::
 
-                  [1 2 3 1] 1 remove
-               ------------------------
-                    [2 3 1]
+           [1 2 3 1] 1 remove
+        ------------------------
+             [2 3 1]
 
-       '''
-       (tos, (second, stack)) = S
-       l = list(iter_stack(second))
-       l.remove(tos)
-       return list_to_stack(l), stack
+    '''
+    (tos, (second, stack)) = S
+    l = list(iter_stack(second))
+    l.remove(tos)
+    return list_to_stack(l), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def unique(S):
-       '''Given a list remove duplicate items.'''
-       tos, stack = S
-       I = list(iter_stack(tos))
-       return list_to_stack(sorted(set(I), key=I.index)), stack
+    '''Given a list remove duplicate items.'''
+    tos, stack = S
+    I = list(iter_stack(tos))
+    return list_to_stack(sorted(set(I), key=I.index)), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def sort_(S):
-       '''Given a list return it sorted.'''
-       tos, stack = S
-       return list_to_stack(sorted(iter_stack(tos))), stack
+    '''Given a list return it sorted.'''
+    tos, stack = S
+    return list_to_stack(sorted(iter_stack(tos))), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def clear(stack):
-       '''Clear everything from the stack.
-       ::
+    '''Clear everything from the stack.
+    ::
 
-               clear == stack [pop stack] loop
+        clear == stack [pop stack] loop
 
-                  ... clear
-               ---------------
+           ... clear
+        ---------------
 
-       '''
-       return ()
+    '''
+    return ()
 
 
 @inscribe
 @SimpleFunctionWrapper
 def disenstacken(stack):
-       '''
-       The disenstacken operator expects a list on top of the stack and makes that
-       the stack discarding the rest of the stack.
-       '''
-       return stack[0]
+    '''
+    The disenstacken operator expects a list on top of the stack and makes that
+    the stack discarding the rest of the stack.
+    '''
+    return stack[0]
 
 
 @inscribe
 @SimpleFunctionWrapper
 def reverse(S):
-       '''
-       Reverse the list on the top of the stack.
-       ::
+    '''
+    Reverse the list on the top of the stack.
+    ::
 
-               reverse == [] swap shunt
-       '''
-       (tos, stack) = S
-       res = ()
-       for term in iter_stack(tos):
-               res = term, res
-       return res, stack
+        reverse == [] swap shunt
+    '''
+    (tos, stack) = S
+    res = ()
+    for term in iter_stack(tos):
+        res = term, res
+    return res, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def concat_(S):
-       '''
-       Concatinate the two lists on the top of the stack.
-       ::
+    '''
+    Concatinate the two lists on the top of the stack.
+    ::
 
-                  [a b c] [d e f] concat
-               ----------------------------
-                      [a b c d e f]
+           [a b c] [d e f] concat
+        ----------------------------
+               [a b c d e f]
 
-       '''
-       (tos, (second, stack)) = S
-       return concat(second, tos), stack
+    '''
+    (tos, (second, stack)) = S
+    return concat(second, tos), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def shunt(stack):
-       '''
-       Like concat but reverses the top list into the second.
-       ::
+    '''
+    Like concat but reverses the top list into the second.
+    ::
 
-               shunt == [swons] step == reverse swap concat
+        shunt == [swons] step == reverse swap concat
 
-                  [a b c] [d e f] shunt
-               ---------------------------
-                      [f e d a b c] 
+           [a b c] [d e f] shunt
+        ---------------------------
+               [f e d a b c] 
 
-       '''
-       (tos, (second, stack)) = stack
-       while tos:
-               term, tos = tos
-               second = term, second
-       return second, stack
+    '''
+    (tos, (second, stack)) = stack
+    while tos:
+        term, tos = tos
+        second = term, second
+    return second, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def zip_(S):
-       '''
-       Replace the two lists on the top of the stack with a list of the pairs
-       from each list.  The smallest list sets the length of the result list.
-       '''
-       (tos, (second, stack)) = S
-       accumulator = [
-               (a, (b, ()))
-               for a, b in zip(iter_stack(tos), iter_stack(second))
-               ]
-       return list_to_stack(accumulator), stack
+    '''
+    Replace the two lists on the top of the stack with a list of the pairs
+    from each list.  The smallest list sets the length of the result list.
+    '''
+    (tos, (second, stack)) = S
+    accumulator = [
+        (a, (b, ()))
+        for a, b in zip(iter_stack(tos), iter_stack(second))
+        ]
+    return list_to_stack(accumulator), stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def succ(S):
-       '''Increment TOS.'''
-       (tos, stack) = S
-       return tos + 1, stack
+    '''Increment TOS.'''
+    (tos, stack) = S
+    return tos + 1, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def pred(S):
-       '''Decrement TOS.'''
-       (tos, stack) = S
-       return tos - 1, stack
+    '''Decrement TOS.'''
+    (tos, stack) = S
+    return tos - 1, stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def pm(stack):
-       '''
-       Plus or minus
-       ::
+    '''
+    Plus or minus
+    ::
 
-                  a b pm
-               -------------
-                  a+b a-b
+           a b pm
+        -------------
+           a+b a-b
 
-       '''
-       a, (b, stack) = stack
-       p, m, = b + a, b - a
-       return m, (p, stack)
+    '''
+    a, (b, stack) = stack
+    p, m, = b + a, b - a
+    return m, (p, stack)
 
 
 def floor(n):
-       return int(math.floor(n))
+    return int(math.floor(n))
 
 floor.__doc__ = math.floor.__doc__
 
@@ -685,27 +698,27 @@ floor.__doc__ = math.floor.__doc__
 @inscribe
 @SimpleFunctionWrapper
 def divmod_(S):
-       '''
-       divmod(x, y) -> (quotient, remainder)
+    '''
+    divmod(x, y) -> (quotient, remainder)
 
-       Return the tuple (x//y, x%y).  Invariant: div*y + mod == x.
-       '''
-       a, (b, stack) = S
-       d, m = divmod(a, b)
-       return d, (m, stack)
+    Return the tuple (x//y, x%y).  Invariant: q * y + r == x.
+    '''
+    a, (b, stack) = S
+    d, m = divmod(a, b)
+    return d, (m, stack)
 
 
 def sqrt(a):
-       '''
-       Return the square root of the number a.
-       Negative numbers return complex roots.
-       '''
-       try:
-               r = math.sqrt(a)
-       except ValueError:
-               assert a < 0, repr(a)
-               r = math.sqrt(-a) * 1j
-       return r
+    '''
+    Return the square root of the number a.
+    Negative numbers return complex roots.
+    '''
+    try:
+        r = math.sqrt(a)
+    except ValueError:
+        assert a < 0, repr(a)
+        r = math.sqrt(-a) * 1j
+    return r
 
 
 #def execute(S):
@@ -718,20 +731,20 @@ def sqrt(a):
 @inscribe
 @SimpleFunctionWrapper
 def id_(stack):
-       '''The identity function.'''
-       return stack
+    '''The identity function.'''
+    return stack
 
 
 @inscribe
 @SimpleFunctionWrapper
 def void(stack):
-       '''True if the form on TOS is void otherwise False.'''
-       form, stack = stack
-       return _void(form), stack
+    '''True if the form on TOS is void otherwise False.'''
+    form, stack = stack
+    return _void(form), stack
 
 
 def _void(form):
-       return any(not _void(i) for i in iter_stack(form))
+    return any(not _void(i) for i in iter_stack(form))
 
 
 
@@ -743,42 +756,42 @@ def _void(form):
 @inscribe
 @FunctionWrapper
 def words(stack, expression, dictionary):
-       '''Print all the words in alphabetical order.'''
-       print(' '.join(sorted(dictionary)))
-       return stack, expression, dictionary
+    '''Print all the words in alphabetical order.'''
+    print(' '.join(sorted(dictionary)))
+    return stack, expression, dictionary
 
 
 @inscribe
 @FunctionWrapper
 def sharing(stack, expression, dictionary):
-       '''Print redistribution information.'''
-       print("You may convey verbatim copies of the Program's source code as"
-       ' you receive it, in any medium, provided that you conspicuously'
-       ' and appropriately publish on each copy an appropriate copyright'
-       ' notice; keep intact all notices stating that this License and'
-       ' any non-permissive terms added in accord with section 7 apply'
-       ' to the code; keep intact all notices of the absence of any'
-       ' warranty; and give all recipients a copy of this License along'
-       ' with the Program.'
-       ' You should have received a copy of the GNU General Public License'
-       ' along with Thun.  If not see <http://www.gnu.org/licenses/>.')
-       return stack, expression, dictionary
+    '''Print redistribution information.'''
+    print("You may convey verbatim copies of the Program's source code as"
+    ' you receive it, in any medium, provided that you conspicuously'
+    ' and appropriately publish on each copy an appropriate copyright'
+    ' notice; keep intact all notices stating that this License and'
+    ' any non-permissive terms added in accord with section 7 apply'
+    ' to the code; keep intact all notices of the absence of any'
+    ' warranty; and give all recipients a copy of this License along'
+    ' with the Program.'
+    ' You should have received a copy of the GNU General Public License'
+    ' along with Thun.  If not see <http://www.gnu.org/licenses/>.')
+    return stack, expression, dictionary
 
 
 @inscribe
 @FunctionWrapper
 def warranty(stack, expression, dictionary):
-       '''Print warranty information.'''
-       print('THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY'
-       ' APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE'
-       ' COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM'
-       ' "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR'
-       ' IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES'
-       ' OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE'
-       ' ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS'
-       ' WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE'
-       ' COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.')
-       return stack, expression, dictionary
+    '''Print warranty information.'''
+    print('THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY'
+    ' APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE'
+    ' COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM'
+    ' "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR'
+    ' IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES'
+    ' OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE'
+    ' ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS'
+    ' WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE'
+    ' COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.')
+    return stack, expression, dictionary
 
 
 # def simple_manual(stack):
@@ -803,11 +816,11 @@ def warranty(stack, expression, dictionary):
 @inscribe
 @FunctionWrapper
 def help_(S, expression, dictionary):
-       '''Accepts a quoted symbol on the top of the stack and prints its docs.'''
-       ((symbol, _), stack) = S
-       word = dictionary[symbol]
-       print(HELP_TEMPLATE % (symbol, getdoc(word), symbol))
-       return stack, expression, dictionary
+    '''Accepts a quoted symbol on the top of the stack and prints its docs.'''
+    ((symbol, _), stack) = S
+    word = dictionary[symbol]
+    print(HELP_TEMPLATE % (symbol, getdoc(word), symbol))
+    return stack, expression, dictionary
 
 
 #
@@ -836,215 +849,218 @@ S_times = Symbol('times')
 @inscribe
 @FunctionWrapper
 def i(stack, expression, dictionary):
-       '''
-       The i combinator expects a quoted program on the stack and unpacks it
-       onto the pending expression for evaluation.
-       ::
+    '''
+    The i combinator expects a quoted program on the stack and unpacks it
+    onto the pending expression for evaluation.
+    ::
 
-                  [Q] i
-               -----------
-                   Q
+           [Q] i
+        -----------
+            Q
 
-       '''
-       quote, stack = stack
-       return stack, concat(quote, expression), dictionary
+    '''
+    try:
+        quote, stack = stack
+    except ValueError:
+        raise StackUnderflowError('Not enough values on stack.')
+    return stack, concat(quote, expression), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def x(stack, expression, dictionary):
-       '''
-       ::
+    '''
+    ::
 
-               x == dup i
+        x == dup i
 
-               ... [Q] x = ... [Q] dup i
-               ... [Q] x = ... [Q] [Q] i
-               ... [Q] x = ... [Q]  Q
+        ... [Q] x = ... [Q] dup i
+        ... [Q] x = ... [Q] [Q] i
+        ... [Q] x = ... [Q]  Q
 
-       '''
-       quote, _ = stack
-       return stack, concat(quote, expression), dictionary
+    '''
+    quote, _ = stack
+    return stack, concat(quote, expression), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def b(stack, expression, dictionary):
-       '''
-       ::
+    '''
+    ::
 
-               b == [i] dip i
+        b == [i] dip i
 
-               ... [P] [Q] b == ... [P] i [Q] i
-               ... [P] [Q] b == ... P Q
+        ... [P] [Q] b == ... [P] i [Q] i
+        ... [P] [Q] b == ... P Q
 
-       '''
-       q, (p, (stack)) = stack
-       return stack, concat(p, concat(q, expression)), dictionary
+    '''
+    q, (p, (stack)) = stack
+    return stack, concat(p, concat(q, expression)), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def dupdip(stack, expression, dictionary):
-       '''
-       ::
+    '''
+    ::
 
-               [F] dupdip == dup [F] dip
+        [F] dupdip == dup [F] dip
 
-               ... a [F] dupdip
-               ... a dup [F] dip
-               ... a a   [F] dip
-               ... a F a
+        ... a [F] dupdip
+        ... a dup [F] dip
+        ... a a   [F] dip
+        ... a F a
 
-       '''
-       F, stack = stack
-       a = stack[0]
-       return stack, concat(F, (a,  expression)), dictionary
+    '''
+    F, stack = stack
+    a = stack[0]
+    return stack, concat(F, (a,  expression)), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def infra(stack, expression, dictionary):
-       '''
-       Accept a quoted program and a list on the stack and run the program
-       with the list as its stack.  Does not affect the rest of the stack.
-       ::
+    '''
+    Accept a quoted program and a list on the stack and run the program
+    with the list as its stack.  Does not affect the rest of the stack.
+    ::
 
-                  ... [a b c] [Q] . infra
-               -----------------------------
-                   c b a . Q [...] swaack
+           ... [a b c] [Q] . infra
+        -----------------------------
+            c b a . Q [...] swaack
 
-       '''
-       (quote, (aggregate, stack)) = stack
-       return aggregate, concat(quote, (stack, (S_swaack, expression))), dictionary
+    '''
+    (quote, (aggregate, stack)) = stack
+    return aggregate, concat(quote, (stack, (S_swaack, expression))), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def genrec(stack, expression, dictionary):
-       '''
-       General Recursion Combinator.
-       ::
+    '''
+    General Recursion Combinator.
+    ::
 
-                                 [if] [then] [rec1] [rec2] genrec
-           ---------------------------------------------------------------------
-              [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
+                  [if] [then] [rec1] [rec2] genrec
+        ---------------------------------------------------------------------
+           [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
 
-       From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun:
-       "The genrec combinator takes four program parameters in addition to
-       whatever data parameters it needs. Fourth from the top is an if-part,
-       followed by a then-part. If the if-part yields true, then the then-part
-       is executed and the combinator terminates. The other two parameters are
-       the rec1-part and the rec2-part. If the if-part yields false, the
-       rec1-part is executed. Following that the four program parameters and
-       the combinator are again pushed onto the stack bundled up in a quoted
-       form. Then the rec2-part is executed, where it will find the bundled
-       form. Typically it will then execute the bundled form, either with i or
-       with app2, or some other combinator."
+    From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun:
+    "The genrec combinator takes four program parameters in addition to
+    whatever data parameters it needs. Fourth from the top is an if-part,
+    followed by a then-part. If the if-part yields true, then the then-part
+    is executed and the combinator terminates. The other two parameters are
+    the rec1-part and the rec2-part. If the if-part yields false, the
+    rec1-part is executed. Following that the four program parameters and
+    the combinator are again pushed onto the stack bundled up in a quoted
+    form. Then the rec2-part is executed, where it will find the bundled
+    form. Typically it will then execute the bundled form, either with i or
+    with app2, or some other combinator."
 
-       The way to design one of these is to fix your base case [then] and the
-       test [if], and then treat rec1 and rec2 as an else-part "sandwiching"
-       a quotation of the whole function.
+    The way to design one of these is to fix your base case [then] and the
+    test [if], and then treat rec1 and rec2 as an else-part "sandwiching"
+    a quotation of the whole function.
 
-       For example, given a (general recursive) function 'F':
-       ::
+    For example, given a (general recursive) function 'F':
+    ::
 
-               F == [I] [T] [R1] [R2] genrec
+        F == [I] [T] [R1] [R2] genrec
 
-       If the [I] if-part fails you must derive R1 and R2 from:
-       ::
+    If the [I] if-part fails you must derive R1 and R2 from:
+    ::
 
-               ... R1 [F] R2
+        ... R1 [F] R2
 
-       Just set the stack arguments in front, and figure out what R1 and R2
-       have to do to apply the quoted [F] in the proper way.  In effect, the
-       genrec combinator turns into an ifte combinator with a quoted copy of
-       the original definition in the else-part:
-       ::
+    Just set the stack arguments in front, and figure out what R1 and R2
+    have to do to apply the quoted [F] in the proper way.  In effect, the
+    genrec combinator turns into an ifte combinator with a quoted copy of
+    the original definition in the else-part:
+    ::
 
-               F == [I] [T] [R1]   [R2] genrec
-                 == [I] [T] [R1 [F] R2] ifte
+        F == [I] [T] [R1]   [R2] genrec
+          == [I] [T] [R1 [F] R2] ifte
 
-       Primitive recursive functions are those where R2 == i.
-       ::
+    Primitive recursive functions are those where R2 == i.
+    ::
 
-               P == [I] [T] [R] tailrec
-                 == [I] [T] [R [P] i] ifte
-                 == [I] [T] [R P] ifte
+        P == [I] [T] [R] tailrec
+          == [I] [T] [R [P] i] ifte
+          == [I] [T] [R P] ifte
 
-       '''
-       (rec2, (rec1, stack)) = stack
-       (then, (if_, _)) = stack
-       F = (if_, (then, (rec1, (rec2, (S_genrec, ())))))
-       else_ = concat(rec1, (F, rec2))
-       return (else_, stack), (S_ifte, expression), dictionary
+    '''
+    (rec2, (rec1, stack)) = stack
+    (then, (if_, _)) = stack
+    F = (if_, (then, (rec1, (rec2, (S_genrec, ())))))
+    else_ = concat(rec1, (F, rec2))
+    return (else_, stack), (S_ifte, expression), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def map_(S, expression, dictionary):
-       '''
-       Run the quoted program on TOS on the items in the list under it, push a
-       new list with the results in place of the program and original list.
-       '''
-       # (quote, (aggregate, stack)) = S
-       # results = list_to_stack([
-       # joy((term, stack), quote, dictionary)[0][0]
-       # for term in iter_stack(aggregate)
-       # ])
-       # return (results, stack), expression, dictionary
-       (quote, (aggregate, stack)) = S
-       if not aggregate:
-               return (aggregate, stack), expression, dictionary
-       batch = ()
-       for term in iter_stack(aggregate):
-               s = term, stack
-               batch = (s, (quote, (S_infra, (S_first, batch))))
-       stack = (batch, ((), stack))
-       return stack, (S_infra, expression), dictionary
+    '''
+    Run the quoted program on TOS on the items in the list under it, push a
+    new list with the results in place of the program and original list.
+    '''
+    # (quote, (aggregate, stack)) = S
+    # results = list_to_stack([
+    # joy((term, stack), quote, dictionary)[0][0]
+    # for term in iter_stack(aggregate)
+    # ])
+    # return (results, stack), expression, dictionary
+    (quote, (aggregate, stack)) = S
+    if not aggregate:
+        return (aggregate, stack), expression, dictionary
+    batch = ()
+    for term in iter_stack(aggregate):
+        s = term, stack
+        batch = (s, (quote, (S_infra, (S_first, batch))))
+    stack = (batch, ((), stack))
+    return stack, (S_infra, expression), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def primrec(stack, expression, dictionary):
-       '''
-       From the "Overview of the language JOY":
-
-       > The primrec combinator expects two quoted programs in addition to a
-       data parameter. For an integer data parameter it works like this: If
-       the data parameter is zero, then the first quotation has to produce
-       the value to be returned. If the data parameter is positive then the
-       second has to combine the data parameter with the result of applying
-       the function to its predecessor.::
-
-               5  [1]  [*]  primrec
-
-       > Then primrec tests whether the top element on the stack (initially
-       the 5) is equal to zero. If it is, it pops it off and executes one of
-       the quotations, the [1] which leaves 1 on the stack as the result.
-       Otherwise it pushes a decremented copy of the top element and
-       recurses. On the way back from the recursion it uses the other
-       quotation, [*], to multiply what is now a factorial on top of the
-       stack by the second element on the stack.::
-
-               n [Base] [Recur] primrec
-
-                  0 [Base] [Recur] primrec
-               ------------------------------
-                     Base
-
-                        n [Base] [Recur] primrec
-               ------------------------------------------ n > 0
-                  n (n-1) [Base] [Recur] primrec Recur
-
-       '''
-       recur, (base, (n, stack)) = stack
-       if n <= 0:
-               expression = concat(base, expression)
-       else:
-               expression = S_primrec, concat(recur, expression)
-               stack = recur, (base, (n - 1, (n, stack)))
-       return stack, expression, dictionary
+    '''
+    From the "Overview of the language JOY":
+
+    > The primrec combinator expects two quoted programs in addition to a
+    data parameter. For an integer data parameter it works like this: If
+    the data parameter is zero, then the first quotation has to produce
+    the value to be returned. If the data parameter is positive then the
+    second has to combine the data parameter with the result of applying
+    the function to its predecessor.::
+
+        5  [1]  [*]  primrec
+
+    > Then primrec tests whether the top element on the stack (initially
+    the 5) is equal to zero. If it is, it pops it off and executes one of
+    the quotations, the [1] which leaves 1 on the stack as the result.
+    Otherwise it pushes a decremented copy of the top element and
+    recurses. On the way back from the recursion it uses the other
+    quotation, [*], to multiply what is now a factorial on top of the
+    stack by the second element on the stack.::
+
+        n [Base] [Recur] primrec
+
+           0 [Base] [Recur] primrec
+        ------------------------------
+              Base
+
+             n [Base] [Recur] primrec
+        ------------------------------------------ n > 0
+           n (n-1) [Base] [Recur] primrec Recur
+
+    '''
+    recur, (base, (n, stack)) = stack
+    if n <= 0:
+        expression = concat(base, expression)
+    else:
+        expression = S_primrec, concat(recur, expression)
+        stack = recur, (base, (n - 1, (n, stack)))
+    return stack, expression, dictionary
 
 
 #def cleave(S, expression, dictionary):
@@ -1064,26 +1080,26 @@ def primrec(stack, expression, dictionary):
 @inscribe
 @FunctionWrapper
 def branch(stack, expression, dictionary):
-       '''
-       Use a Boolean value to select one of two quoted programs to run.
+    '''
+    Use a Boolean value to select one of two quoted programs to run.
 
-       ::
+    ::
 
-               branch == roll< choice i
+        branch == roll< choice i
 
-       ::
+    ::
 
-                  False [F] [T] branch
-               --------------------------
-                         F
+           False [F] [T] branch
+        --------------------------
+              F
 
-                  True [F] [T] branch
-               -------------------------
-                            T
+           True [F] [T] branch
+        -------------------------
+                 T
 
-       '''
-       (then, (else_, (flag, stack))) = stack
-       return stack, concat(then if flag else else_, expression), dictionary
+    '''
+    (then, (else_, (flag, stack))) = stack
+    return stack, concat(then if flag else else_, expression), dictionary
 
 
 ##@inscribe
@@ -1117,224 +1133,227 @@ def branch(stack, expression, dictionary):
 @inscribe
 @FunctionWrapper
 def cond(stack, expression, dictionary):
-       '''
-       This combinator works like a case statement.  It expects a single quote
-       on the stack that must contain zero or more condition quotes and a 
-       default quote.  Each condition clause should contain a quoted predicate
-       followed by the function expression to run if that predicate returns
-       true.  If no predicates return true the default function runs.
-
-       It works by rewriting into a chain of nested `ifte` expressions, e.g.::
-
-                     [[[B0] T0] [[B1] T1] [D]] cond
-               -----------------------------------------
-                  [B0] [T0] [[B1] [T1] [D] ifte] ifte
-
-       '''
-       conditions, stack = stack
-       if conditions:
-               expression = _cond(conditions, expression)
-               try:
-                       # Attempt to preload the args to first ifte.
-                       (P, (T, (E, expression))) = expression
-               except ValueError:
-                       # If, for any reason, the argument to cond should happen to contain
-                       # only the default clause then this optimization will fail.
-                       pass
-               else:
-                       stack = (E, (T, (P, stack)))
-       return stack, expression, dictionary
+    '''
+    This combinator works like a case statement.  It expects a single quote
+    on the stack that must contain zero or more condition quotes and a 
+    default quote.  Each condition clause should contain a quoted predicate
+    followed by the function expression to run if that predicate returns
+    true.  If no predicates return true the default function runs.
+
+    It works by rewriting into a chain of nested `ifte` expressions, e.g.::
+
+              [[[B0] T0] [[B1] T1] [D]] cond
+        -----------------------------------------
+           [B0] [T0] [[B1] [T1] [D] ifte] ifte
+
+    '''
+    conditions, stack = stack
+    if conditions:
+        expression = _cond(conditions, expression)
+        try:
+            # Attempt to preload the args to first ifte.
+            (P, (T, (E, expression))) = expression
+        except ValueError:
+            # If, for any reason, the argument to cond should happen to contain
+            # only the default clause then this optimization will fail.
+            pass
+        else:
+            stack = (E, (T, (P, stack)))
+    return stack, expression, dictionary
 
 
 def _cond(conditions, expression):
-       (clause, rest) = conditions
-       if not rest:  # clause is [D]
-               return clause
-       P, T = clause
-       return (P, (T, (_cond(rest, ()), (S_ifte, expression))))
+    (clause, rest) = conditions
+    if not rest:  # clause is [D]
+        return clause
+    P, T = clause
+    return (P, (T, (_cond(rest, ()), (S_ifte, expression))))
 
 
 @inscribe
 @FunctionWrapper
 def dip(stack, expression, dictionary):
-       '''
-       The dip combinator expects a quoted program on the stack and below it
-       some item, it hoists the item into the expression and runs the program
-       on the rest of the stack.
-       ::
+    '''
+    The dip combinator expects a quoted program on the stack and below it
+    some item, it hoists the item into the expression and runs the program
+    on the rest of the stack.
+    ::
 
-                  ... x [Q] dip
-               -------------------
-                    ... Q x
+           ... x [Q] dip
+        -------------------
+             ... Q x
 
-       '''
-       (quote, (x, stack)) = stack
-       expression = (x, expression)
-       return stack, concat(quote, expression), dictionary
+    '''
+    try:
+        (quote, (x, stack)) = stack
+    except ValueError:
+        raise StackUnderflowError('Not enough values on stack.')
+    expression = (x, expression)
+    return stack, concat(quote, expression), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def dipd(S, expression, dictionary):
-       '''
-       Like dip but expects two items.
-       ::
+    '''
+    Like dip but expects two items.
+    ::
 
-                  ... y x [Q] dip
-               ---------------------
-                    ... Q y x
+           ... y x [Q] dip
+        ---------------------
+             ... Q y x
 
-       '''
-       (quote, (x, (y, stack))) = S
-       expression = (y, (x, expression))
-       return stack, concat(quote, expression), dictionary
+    '''
+    (quote, (x, (y, stack))) = S
+    expression = (y, (x, expression))
+    return stack, concat(quote, expression), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def dipdd(S, expression, dictionary):
-       '''
-       Like dip but expects three items.
-       ::
+    '''
+    Like dip but expects three items.
+    ::
 
-                  ... z y x [Q] dip
-               -----------------------
-                    ... Q z y x
+           ... z y x [Q] dip
+        -----------------------
+             ... Q z y x
 
-       '''
-       (quote, (x, (y, (z, stack)))) = S
-       expression = (z, (y, (x, expression)))
-       return stack, concat(quote, expression), dictionary
+    '''
+    (quote, (x, (y, (z, stack)))) = S
+    expression = (z, (y, (x, expression)))
+    return stack, concat(quote, expression), dictionary
 
 
 @inscribe
 @FunctionWrapper
 def app1(S, expression, dictionary):
-       '''
-       Given a quoted program on TOS and anything as the second stack item run
-       the program and replace the two args with the first result of the
-       program.
-       ::
+    '''
+    Given a quoted program on TOS and anything as the second stack item run
+    the program and replace the two args with the first result of the
+    program.
+    ::
 
-                        ... x [Q] . app1
-               -----------------------------------
-                  ... [x ...] [Q] . infra first
+             ... x [Q] . app1
+        -----------------------------------
+           ... [x ...] [Q] . infra first
 
-       '''
-       (quote, (x, stack)) = S
-       stack = (quote, ((x, stack), stack))
-       expression = (S_infra, (S_first, expression))
-       return stack, expression, dictionary
+    '''
+    (quote, (x, stack)) = S
+    stack = (quote, ((x, stack), stack))
+    expression = (S_infra, (S_first, expression))
+    return stack, expression, dictionary
 
 
 @inscribe
 @FunctionWrapper
 def app2(S, expression, dictionary):
-       '''Like app1 with two items.
-       ::
+    '''Like app1 with two items.
+    ::
 
-                      ... y x [Q] . app2
-               -----------------------------------
-                  ... [y ...] [Q] . infra first
-                      [x ...] [Q]   infra first
+               ... y x [Q] . app2
+        -----------------------------------
+           ... [y ...] [Q] . infra first
+               [x ...] [Q]   infra first
 
-       '''
-       (quote, (x, (y, stack))) = S
-       expression = (S_infra, (S_first,
-               ((x, stack), (quote, (S_infra, (S_first,
-                       expression))))))
-       stack = (quote, ((y, stack), stack))
-       return stack, expression, dictionary
+    '''
+    (quote, (x, (y, stack))) = S
+    expression = (S_infra, (S_first,
+        ((x, stack), (quote, (S_infra, (S_first,
+            expression))))))
+    stack = (quote, ((y, stack), stack))
+    return stack, expression, dictionary
 
 
 @inscribe
 @FunctionWrapper
 def app3(S, expression, dictionary):
-       '''Like app1 with three items.
-       ::
+    '''Like app1 with three items.
+    ::
 
-                    ... z y x [Q] . app3
-               -----------------------------------
-                  ... [z ...] [Q] . infra first
-                      [y ...] [Q]   infra first
-                      [x ...] [Q]   infra first
+             ... z y x [Q] . app3
+        -----------------------------------
+           ... [z ...] [Q] . infra first
+               [y ...] [Q]   infra first
+               [x ...] [Q]   infra first
 
-       '''
-       (quote, (x, (y, (z, stack)))) = S
-       expression = (S_infra, (S_first,
-               ((y, stack), (quote, (S_infra, (S_first,
-               ((x, stack), (quote, (S_infra, (S_first,
-                       expression))))))))))
-       stack = (quote, ((z, stack), stack))
-       return stack, expression, dictionary
+    '''
+    (quote, (x, (y, (z, stack)))) = S
+    expression = (S_infra, (S_first,
+        ((y, stack), (quote, (S_infra, (S_first,
+        ((x, stack), (quote, (S_infra, (S_first,
+            expression))))))))))
+    stack = (quote, ((z, stack), stack))
+    return stack, expression, dictionary
 
 
 @inscribe
 @FunctionWrapper
 def step(S, expression, dictionary):
-       '''
-       Run a quoted program on each item in a sequence.
-       ::
+    '''
+    Run a quoted program on each item in a sequence.
+    ::
 
-                  ... [] [Q] . step
-               -----------------------
-                         ... .
+           ... [] [Q] . step
+        -----------------------
+              ... .
 
 
-                  ... [a] [Q] . step
-               ------------------------
-                        ... a . Q
+           ... [a] [Q] . step
+        ------------------------
+             ... a . Q
 
 
-                  ... [a b c] [Q] . step
-               ----------------------------------------
-                            ... a . Q [b c] [Q] step
+           ... [a b c] [Q] . step
+        ----------------------------------------
+                 ... a . Q [b c] [Q] step
 
-       The step combinator executes the quotation on each member of the list
-       on top of the stack.
-       '''
-       (quote, (aggregate, stack)) = S
-       if not aggregate:
-               return stack, expression, dictionary
-       head, tail = aggregate
-       stack = quote, (head, stack)
-       if tail:
-               expression = tail, (quote, (S_step, expression))
-       expression = S_i, expression
-       return stack, expression, dictionary
+    The step combinator executes the quotation on each member of the list
+    on top of the stack.
+    '''
+    (quote, (aggregate, stack)) = S
+    if not aggregate:
+        return stack, expression, dictionary
+    head, tail = aggregate
+    stack = quote, (head, stack)
+    if tail:
+        expression = tail, (quote, (S_step, expression))
+    expression = S_i, expression
+    return stack, expression, dictionary
 
 
 @inscribe
 @FunctionWrapper
 def times(stack, expression, dictionary):
-       '''
-       times == [-- dip] cons [swap] infra [0 >] swap while pop
-       ::
+    '''
+    times == [-- dip] cons [swap] infra [0 >] swap while pop
+    ::
 
-                  ... n [Q] . times
-               ---------------------  w/ n <= 0
-                        ... .
+           ... n [Q] . times
+        ---------------------  w/ n <= 0
+             ... .
 
 
-                  ... 1 [Q] . times
-               -----------------------
-                        ... . Q
+           ... 1 [Q] . times
+        -----------------------
+             ... . Q
 
 
-                  ... n [Q] . times
-               -------------------------------------  w/ n > 1
-                        ... . Q (n - 1) [Q] times
+           ... n [Q] . times
+        -------------------------------------  w/ n > 1
+             ... . Q (n - 1) [Q] times
 
-       '''
-       # times == [-- dip] cons [swap] infra [0 >] swap while pop
-       (quote, (n, stack)) = stack
-       if n <= 0:
-               return stack, expression, dictionary
-       n -= 1
-       if n:
-               expression = n, (quote, (S_times, expression))
-       expression = concat(quote, expression)
-       return stack, expression, dictionary
+    '''
+    # times == [-- dip] cons [swap] infra [0 >] swap while pop
+    (quote, (n, stack)) = stack
+    if n <= 0:
+        return stack, expression, dictionary
+    n -= 1
+    if n:
+        expression = n, (quote, (S_times, expression))
+    expression = concat(quote, expression)
+    return stack, expression, dictionary
 
 
 # The current definition above works like this:
@@ -1356,48 +1375,57 @@ def times(stack, expression, dictionary):
 @inscribe
 @FunctionWrapper
 def loop(stack, expression, dictionary):
-       '''
-       Basic loop combinator.
-       ::
-
-                  ... True [Q] loop
-               -----------------------
-                     ... Q [Q] loop
-
-                  ... False [Q] loop
-               ------------------------
-                         ...
-
-       '''
-       quote, (flag, stack) = stack
-       if flag:
-               expression = concat(quote, (quote, (S_loop, expression)))
-       return stack, expression, dictionary
+    '''
+    Basic loop combinator.
+    ::
+
+           ... True [Q] loop
+        -----------------------
+              ... Q [Q] loop
+
+           ... False [Q] loop
+        ------------------------
+              ...
+
+    '''
+    try:
+        quote, stack = stack
+    except ValueError:
+        raise StackUnderflowError('Not enough values on stack.')
+    if not isinstance(quote, tuple):
+        raise NotAListError('Loop body not a list.')
+    try:
+        (flag, stack) = stack
+    except ValueError:
+        raise StackUnderflowError('Not enough values on stack.')
+    if flag:
+        expression = concat(quote, (quote, (S_loop, expression)))
+    return stack, expression, dictionary
 
 
 @inscribe
 @FunctionWrapper
 def cmp_(stack, expression, dictionary):
-       '''
-       cmp takes two values and three quoted programs on the stack and runs
-       one of the three depending on the results of comparing the two values:
-       ::
+    '''
+    cmp takes two values and three quoted programs on the stack and runs
+    one of the three depending on the results of comparing the two values:
+    ::
 
-                  a b [G] [E] [L] cmp
-               ------------------------- a > b
-                       G
+           a b [G] [E] [L] cmp
+        ------------------------- a > b
+            G
 
-                  a b [G] [E] [L] cmp
-               ------------------------- a = b
-                           E
+           a b [G] [E] [L] cmp
+        ------------------------- a = b
+                E
 
-                  a b [G] [E] [L] cmp
-               ------------------------- a < b
-                               L
-       '''
-       L, (E, (G, (b, (a, stack)))) = stack
-       expression = concat(G if a > b else L if a < b else E, expression)
-       return stack, expression, dictionary
+           a b [G] [E] [L] cmp
+        ------------------------- a < b
+                L
+    '''
+    L, (E, (G, (b, (a, stack)))) = stack
+    expression = concat(G if a > b else L if a < b else E, expression)
+    return stack, expression, dictionary
 
 
 #  FunctionWrapper(cleave),
@@ -1406,46 +1434,46 @@ def cmp_(stack, expression, dictionary):
 
 for F in (
 
-       #divmod_ = pm = __(n2, n1), __(n4, n3)
-
-       BinaryBuiltinWrapper(operator.eq),
-       BinaryBuiltinWrapper(operator.ge),
-       BinaryBuiltinWrapper(operator.gt),
-       BinaryBuiltinWrapper(operator.le),
-       BinaryBuiltinWrapper(operator.lt),
-       BinaryBuiltinWrapper(operator.ne),
-
-       BinaryBuiltinWrapper(operator.xor),
-       BinaryBuiltinWrapper(operator.lshift),
-       BinaryBuiltinWrapper(operator.rshift),
-
-       BinaryBuiltinWrapper(operator.and_),
-       BinaryBuiltinWrapper(operator.or_),
-
-       BinaryBuiltinWrapper(operator.add),
-       BinaryBuiltinWrapper(operator.floordiv),
-       BinaryBuiltinWrapper(operator.mod),
-       BinaryBuiltinWrapper(operator.mul),
-       BinaryBuiltinWrapper(operator.pow),
-       BinaryBuiltinWrapper(operator.sub),
-       BinaryBuiltinWrapper(operator.truediv),
-
-       UnaryBuiltinWrapper(bool),
-       UnaryBuiltinWrapper(operator.not_),
-
-       UnaryBuiltinWrapper(abs),
-       UnaryBuiltinWrapper(operator.neg),
-       UnaryBuiltinWrapper(sqrt),
-
-       UnaryBuiltinWrapper(floor),
-       UnaryBuiltinWrapper(round),
-       ):
-       inscribe(F)
+    #divmod_ = pm = __(n2, n1), __(n4, n3)
+
+    BinaryBuiltinWrapper(operator.eq),
+    BinaryBuiltinWrapper(operator.ge),
+    BinaryBuiltinWrapper(operator.gt),
+    BinaryBuiltinWrapper(operator.le),
+    BinaryBuiltinWrapper(operator.lt),
+    BinaryBuiltinWrapper(operator.ne),
+
+    BinaryBuiltinWrapper(operator.xor),
+    BinaryBuiltinWrapper(operator.lshift),
+    BinaryBuiltinWrapper(operator.rshift),
+
+    BinaryBuiltinWrapper(operator.and_),
+    BinaryBuiltinWrapper(operator.or_),
+
+    BinaryBuiltinWrapper(operator.add),
+    BinaryBuiltinWrapper(operator.floordiv),
+    BinaryBuiltinWrapper(operator.mod),
+    BinaryBuiltinWrapper(operator.mul),
+    BinaryBuiltinWrapper(operator.pow),
+    BinaryBuiltinWrapper(operator.sub),
+##    BinaryBuiltinWrapper(operator.truediv),
+
+    UnaryBuiltinWrapper(bool),
+    UnaryBuiltinWrapper(operator.not_),
+
+    UnaryBuiltinWrapper(abs),
+    UnaryBuiltinWrapper(operator.neg),
+    UnaryBuiltinWrapper(sqrt),
+
+    UnaryBuiltinWrapper(floor),
+    UnaryBuiltinWrapper(round),
+    ):
+    inscribe(F)
 del F  # Otherwise Sphinx autodoc will pick it up.
 
 
 for name, primitive in getmembers(genlib, isfunction):
-       inscribe(SimpleFunctionWrapper(primitive))
+    inscribe(SimpleFunctionWrapper(primitive))
 
 
 add_aliases(_dictionary, ALIASES)
index de8a873..c07573f 100644 (file)
@@ -40,85 +40,83 @@ from re import Scanner
 from .utils.stack import list_to_stack
 
 
-#TODO: explain the details of float lits and strings.
-FLOAT = r'-?\d+\.\d*(e(-|\+)\d+)?'
-INT = r'-?\d+'
-SYMBOL = r'[•\w!@$%^&*()_+<>?|\/;:`~,.=-]+'
 BRACKETS = r'\[|\]'
-STRING_DOUBLE_QUOTED = r'"(?:[^"\\]|\\.)*"'
-STRING_SINGLE_QUOTED = r"'(?:[^'\\]|\\.)*'"
 BLANKS = r'\s+'
+WORDS = r'[^[\]\s]+'
+
+
+token_scanner = Scanner([
+    (BRACKETS, lambda _, token: token),
+    (BLANKS, None),
+    (WORDS, lambda _, token: token),
+    ])
 
 
 class Symbol(str):
-       '''A string class that represents Joy function names.'''
-       __repr__ = str.__str__
+    '''A string class that represents Joy function names.'''
+    __repr__ = str.__str__
 
 
 def text_to_expression(text):
-       '''Convert a string to a Joy expression.
+    '''Convert a string to a Joy expression.
 
-       When supplied with a string this function returns a Python datastructure
-       that represents the Joy datastructure described by the text expression.
-       Any unbalanced square brackets will raise a ParseError.
+    When supplied with a string this function returns a Python datastructure
+    that represents the Joy datastructure described by the text expression.
+    Any unbalanced square brackets will raise a ParseError.
 
-       :param str text: Text to convert.
-       :rtype: stack
-       :raises ParseError: if the parse fails.
-       '''
-       return _parse(_tokenize(text))
+    :param str text: Text to convert.
+    :rtype: stack
+    :raises ParseError: if the parse fails.
+    '''
+    return _parse(_tokenize(text))
 
 
 class ParseError(ValueError):
-       '''Raised when there is a error while parsing text.'''
+    '''Raised when there is a error while parsing text.'''
 
 
 def _tokenize(text):
-       '''Convert a text into a stream of tokens.
+    '''Convert a text into a stream of tokens.
 
-       Converts function names to Symbols.
+    Converts function names to Symbols.
 
-       Raise ParseError (with some of the failing text) if the scan fails.
-       '''
-       tokens, rest = _scanner.scan(text)
-       if rest:
-               raise ParseError(
-                       'Scan failed at position %i, %r'
-                       % (len(text) - len(rest), rest[:10])
-                       )
-       return tokens
+    Raise ParseError (with some of the failing text) if the scan fails.
+    '''
+    tokens, rest = token_scanner.scan(text)
+    if rest:
+        raise ParseError(
+            'Scan failed at position %i, %r'
+            % (len(text) - len(rest), rest[:10])
+            )
+    return tokens
 
 
 def _parse(tokens):
-       '''
-       Return a stack/list expression of the tokens.
-       '''
-       frame = []
-       stack = []
-       for tok in tokens:
-               if tok == '[':
-                       stack.append(frame)
-                       frame = []
-                       stack[-1].append(frame)
-               elif tok == ']':
-                       try:
-                               frame = stack.pop()
-                       except IndexError:
-                               raise ParseError('Extra closing bracket.')
-                       frame[-1] = list_to_stack(frame[-1])
-               else:
-                       frame.append(tok)
-       if stack:
-               raise ParseError('Unclosed bracket.')
-       return list_to_stack(frame)
-
-
-_scanner = Scanner([
-       (FLOAT, lambda _, token: float(token)),
-       (INT, lambda _, token: int(token)),
-       (SYMBOL, lambda _, token: Symbol(token)),
-       (BRACKETS, lambda _, token: token),
-       (STRING_DOUBLE_QUOTED, lambda _, token: token[1:-1].replace('\\"', '"')),
-       (STRING_SINGLE_QUOTED, lambda _, token: token[1:-1].replace("\\'", "'")),
-       (BLANKS, None),
-       ])
+    '''
+    Return a stack/list expression of the tokens.
+    '''
+    frame = []
+    stack = []
+    for tok in tokens:
+        if tok == '[':
+            stack.append(frame)
+            frame = []
+        elif tok == ']':
+            v = frame
+            try: frame = stack.pop()
+            except IndexError:
+                raise ParseError('Extra closing bracket.')
+            frame.append(list_to_stack(v))
+        elif tok == 'true':
+            frame.append(True)
+        elif tok == 'false':
+            frame.append(False)
+        else:
+            try:
+                thing = int(tok)
+            except ValueError:
+                thing = Symbol(tok)
+            frame.append(thing)
+    if stack:
+        raise ParseError('Unclosed bracket.')
+    return list_to_stack(frame)
diff --git a/joy/utils/errors.py b/joy/utils/errors.py
new file mode 100644 (file)
index 0000000..4834ad3
--- /dev/null
@@ -0,0 +1,5 @@
+class NotAListError(Exception): pass
+class NotAnIntError(Exception): pass
+class StackUnderflowError(Exception): pass
+
+
index 8a4acbc..2e51422 100644 (file)
@@ -1,6 +1,7 @@
 # GENERATED FILE. DO NOT EDIT.
 # The code that generated these functions is in the repo history
 # at the v0.4.0 tag.
+from .errors import NotAListError, StackUnderflowError
 
 
 def _Tree_add_Ee(stack):
@@ -65,7 +66,11 @@ def cons(stack):
     (a1 [...0] -- [a1 ...0])
 
   """
-  (s0, (a1, s23)) = stack
+  try: s0, stack = stack
+  except ValueError: raise StackUnderflowError('Not enough values on stack.')
+  if not isinstance(s0, tuple): raise NotAListError('Not a list.')
+  try: a1, s23 = stack
+  except ValueError: raise StackUnderflowError('Not enough values on stack.')
   return ((a1, s0), s23)
 
 
@@ -153,7 +158,10 @@ def pop(stack):
     (a1 --)
 
   """
-  (a1, s23) = stack
+  try:
+    (a1, s23) = stack
+  except ValueError:
+    raise StackUnderflowError('Cannot pop empty stack.')
   return s23
 
 
@@ -219,8 +227,17 @@ def rest(stack):
     ([a1 ...0] -- [...0])
 
   """
-  ((a1, s0), s23) = stack
-  return (s0, s23)
+  try:
+    s0, stack = stack
+  except ValueError:
+    raise StackUnderflowError
+  if not isinstance(s0, tuple):
+    raise NotAListError('Not a list.')
+  try:
+    _, s1 = s0
+  except ValueError:
+    raise StackUnderflowError('Cannot take rest of empty list.')
+  return (s1, stack)
 
 
 def rolldown(stack):
@@ -307,7 +324,12 @@ def swaack(stack):
     ([...1] -- [...0])
 
   """
-  (s1, s0) = stack
+  try:
+    (s1, s0) = stack
+  except ValueError:
+    raise StackUnderflowError('Not enough values on stack.')
+  if not isinstance(s1, tuple):
+    raise NotAListError('Not a list.')
   return (s0, s1)
 
 
@@ -318,7 +340,10 @@ def swap(stack):
     (a1 a2 -- a2 a1)
 
   """
-  (a2, (a1, s23)) = stack
+  try:
+    (a2, (a1, s23)) = stack
+  except ValueError:
+    raise StackUnderflowError('Not enough values on stack.')
   return (a1, (a2, s23))
 
 
index 3c6e8c5..b447591 100644 (file)
@@ -46,79 +46,79 @@ from ..library import FunctionWrapper
 
 @FunctionWrapper
 def trace(stack, expression, dictionary):
-       '''Evaluate a Joy expression on a stack and print a trace.
-
-       This function is just like the `i` combinator but it also prints a
-       trace of the evaluation
-
-       :param stack stack: The stack.
-       :param stack expression: The expression to evaluate.
-       :param dict dictionary: A ``dict`` mapping names to Joy functions.
-       :rtype: (stack, (), dictionary)
-
-       '''
-       tp = TracePrinter()
-       quote, stack = stack
-       try:
-               s, _, d = joy(stack, quote, dictionary, tp.viewer)
-       except:
-               tp.print_()
-               print('-' * 73)
-               raise
-       else:
-               tp.print_()
-       return s, expression, d
+    '''Evaluate a Joy expression on a stack and print a trace.
+
+    This function is just like the `i` combinator but it also prints a
+    trace of the evaluation
+
+    :param stack stack: The stack.
+    :param stack expression: The expression to evaluate.
+    :param dict dictionary: A ``dict`` mapping names to Joy functions.
+    :rtype: (stack, (), dictionary)
+
+    '''
+    tp = TracePrinter()
+    quote, stack = stack
+    try:
+        s, _, d = joy(stack, quote, dictionary, tp.viewer)
+    except:
+        tp.print_()
+        print('-' * 73)
+        raise
+    else:
+        tp.print_()
+    return s, expression, d
 
 
 class TracePrinter(object):
-       '''
-       This is what does the formatting.  You instantiate it and pass the ``viewer()``
-       method to the :py:func:`joy.joy.joy` function, then print it to see the
-       trace.
-       '''
-
-       def __init__(self):
-               self.history = []
-
-       def viewer(self, stack, expression):
-               '''
-               Record the current stack and expression in the TracePrinter's history.
-               Pass this method as the ``viewer`` argument to the :py:func:`joy.joy.joy` function.
-
-               :param stack quote: A stack.
-               :param stack expression: A stack.
-               '''
-               self.history.append((stack, expression))
-
-       def __str__(self):
-               return '\n'.join(self.go())
-
-       def go(self):
-               '''
-               Return a list of strings, one for each entry in the history, prefixed
-               with enough spaces to align all the interpreter dots.
-
-               This method is called internally by the ``__str__()`` method.
-
-               :rtype: list(str)
-               '''
-               max_stack_length = 0
-               lines = []
-               for stack, expression in self.history:
-                       stack = stack_to_string(stack)
-                       expression = expression_to_string(expression)
-                       n = len(stack)
-                       if n > max_stack_length:
-                               max_stack_length = n
-                       lines.append((n, '%s • %s' % (stack, expression)))
-               for i in range(len(lines)):  # Prefix spaces to line up '•'s.
-                       length, line = lines[i]
-                       lines[i] =  (' ' * (max_stack_length - length) + line)
-               return lines
-
-       def print_(self):
-               try:
-                       print(self)
-               except:
-                       print_exc()
-                       print('Exception while printing viewer.')
+    '''
+    This is what does the formatting.  You instantiate it and pass the ``viewer()``
+    method to the :py:func:`joy.joy.joy` function, then print it to see the
+    trace.
+    '''
+
+    def __init__(self):
+        self.history = []
+
+    def viewer(self, stack, expression):
+        '''
+        Record the current stack and expression in the TracePrinter's history.
+        Pass this method as the ``viewer`` argument to the :py:func:`joy.joy.joy` function.
+
+        :param stack quote: A stack.
+        :param stack expression: A stack.
+        '''
+        self.history.append((stack, expression))
+
+    def __str__(self):
+        return '\n'.join(self.go())
+
+    def go(self):
+        '''
+        Return a list of strings, one for each entry in the history, prefixed
+        with enough spaces to align all the interpreter dots.
+
+        This method is called internally by the ``__str__()`` method.
+
+        :rtype: list(str)
+        '''
+        max_stack_length = 0
+        lines = []
+        for stack, expression in self.history:
+            stack = stack_to_string(stack)
+            expression = expression_to_string(expression)
+            n = len(stack)
+            if n > max_stack_length:
+                max_stack_length = n
+            lines.append((n, '%s • %s' % (stack, expression)))
+        for i in range(len(lines)):  # Prefix spaces to line up '•'s.
+            length, line = lines[i]
+            lines[i] =  (' ' * (max_stack_length - length) + line)
+        return lines
+
+    def print_(self):
+        try:
+            print(self)
+        except:
+            print_exc()
+            print('Exception while printing viewer.')
index fc11151..366d8a4 100644 (file)
@@ -43,8 +43,8 @@ means we can directly "unpack" the expected arguments to a Joy function.
 
 For example::
 
-       def dup((head, tail)):
-               return head, (head, tail)
+    def dup((head, tail)):
+        return head, (head, tail)
 
 We replace the argument "stack" by the expected structure of the stack,
 in this case "(head, tail)", and Python takes care of unpacking the
@@ -56,9 +56,9 @@ Unfortunately, the Sphinx documentation generator, which is used to generate thi
 web page, doesn't handle tuples in the function parameters.  And in Python 3, this
 syntax was removed entirely.  Instead you would have to write::
 
-       def dup(stack):
-               head, tail = stack
-               return head, (head, tail)
+    def dup(stack):
+        head, tail = stack
+        return head, (head, tail)
 
 
 We have two very simple functions, one to build up a stack from a Python
@@ -70,172 +70,184 @@ printed left-to-right.  These functions are written to support :doc:`../pretty`.
 .. _cons list: https://en.wikipedia.org/wiki/Cons#Lists
 
 '''
+from .errors import NotAListError
 
 
-from builtins import map
 def list_to_stack(el, stack=()):
-       '''Convert a Python list (or other sequence) to a Joy stack::
+    '''Convert a Python list (or other sequence) to a Joy stack::
 
-       [1, 2, 3] -> (1, (2, (3, ())))
+    [1, 2, 3] -> (1, (2, (3, ())))
 
-       :param list el: A Python list or other sequence (iterators and generators
-                        won't work because ``reverse()`` is called on ``el``.)
-       :param stack stack: A stack, optional, defaults to the empty stack.
-       :rtype: stack
+    :param list el: A Python list or other sequence (iterators and generators
+             won't work because ``reverse()`` is called on ``el``.)
+    :param stack stack: A stack, optional, defaults to the empty stack.
+    :rtype: stack
 
-       '''
-       for item in reversed(el):
-               stack = item, stack
-       return stack
+    '''
+    for item in reversed(el):
+        stack = item, stack
+    return stack
 
 
 def iter_stack(stack):
-       '''Iterate through the items on the stack.
+    '''Iterate through the items on the stack.
 
-       :param stack stack: A stack.
-       :rtype: iterator
-       '''
-       while stack:
-               item, stack = stack
-               yield item
+    :param stack stack: A stack.
+    :rtype: iterator
+    '''
+    while stack:
+        item, stack = stack
+        yield item
 
 
 def stack_to_string(stack):
-       '''
-       Return a "pretty print" string for a stack.
+    '''
+    Return a "pretty print" string for a stack.
 
-       The items are written right-to-left::
+    The items are written right-to-left::
 
-               (top, (second, ...)) -> '... second top'
+        (top, (second, ...)) -> '... second top'
 
-       :param stack stack: A stack.
-       :rtype: str
-       '''
-       f = lambda stack: reversed(list(iter_stack(stack)))
-       return _to_string(stack, f)
+    :param stack stack: A stack.
+    :rtype: str
+    '''
+    f = lambda stack: reversed(list(iter_stack(stack)))
+    return _to_string(stack, f)
 
 
 def expression_to_string(expression):
-       '''
-       Return a "pretty print" string for a expression.
+    '''
+    Return a "pretty print" string for a expression.
 
-       The items are written left-to-right::
+    The items are written left-to-right::
 
-               (top, (second, ...)) -> 'top second ...'
+        (top, (second, ...)) -> 'top second ...'
 
-       :param stack expression: A stack.
-       :rtype: str
-       '''
-       return _to_string(expression, iter_stack)
+    :param stack expression: A stack.
+    :rtype: str
+    '''
+    return _to_string(expression, iter_stack)
+
+
+_JOY_BOOL_LITS = 'false', 'true'
+
+
+def _joy_repr(thing):
+        if isinstance(thing, bool):
+                return _JOY_BOOL_LITS[thing]
+        return repr(thing)
 
 
 def _to_string(stack, f):
-       if not isinstance(stack, tuple): return repr(stack)
-       if not stack: return ''  # shortcut
-       return ' '.join(map(_s, f(stack)))
+    if not isinstance(stack, tuple): return _joy_repr(stack)
+    if not stack: return ''  # shortcut
+    return ' '.join(map(_s, f(stack)))
 
 
 _s = lambda s: (
-       '[%s]' % expression_to_string(s) if isinstance(s, tuple)
-       else repr(s)
-       )
+    '[%s]' % expression_to_string(s)
+        if isinstance(s, tuple)
+    else _joy_repr(s)
+    )
 
 
 def concat(quote, expression):
-       '''Concatinate quote onto expression.
+    '''Concatinate quote onto expression.
 
-       In joy [1 2] [3 4] would become [1 2 3 4].
+    In joy [1 2] [3 4] would become [1 2 3 4].
 
-       :param stack quote: A stack.
-       :param stack expression: A stack.
-       :raises RuntimeError: if quote is larger than sys.getrecursionlimit().
-       :rtype: stack
-       '''
-       # This is the fastest implementation, but will trigger
-       # RuntimeError: maximum recursion depth exceeded
-       # on quotes longer than sys.getrecursionlimit().
+    :param stack quote: A stack.
+    :param stack expression: A stack.
+    :raises RuntimeError: if quote is larger than sys.getrecursionlimit().
+    :rtype: stack
+    '''
+    # This is the fastest implementation, but will trigger
+    # RuntimeError: maximum recursion depth exceeded
+    # on quotes longer than sys.getrecursionlimit().
 
-       return (quote[0], concat(quote[1], expression)) if quote else expression
+##    return (quote[0], concat(quote[1], expression)) if quote else expression
 
-       # Original implementation.
+    # Original implementation.
 
 ##  return list_to_stack(list(iter_stack(quote)), expression)
 
-       # In-lining is slightly faster (and won't break the
-       # recursion limit on long quotes.)
+    # In-lining is slightly faster (and won't break the
+    # recursion limit on long quotes.)
 
-##  temp = []
-##  while quote:
-##    item, quote = quote
-##    temp.append(item)
-##  for item in reversed(temp):
-##    expression = item, expression
-##  return expression
+    temp = []
+    while quote:
+        if not isinstance(quote, tuple):
+            raise NotAListError('Not a list.')
+        item, quote = quote
+        temp.append(item)
+    for item in reversed(temp):
+        expression = item, expression
+    return expression
 
 
 
 def dnd(stack, from_index, to_index):
-       '''
-       Given a stack and two indices return a rearranged stack.
-       First remove the item at from_index and then insert it at to_index,
-       the second index is relative to the stack after removal of the item
-       at from_index.
-
-       This function reuses all of the items and as much of the stack as it
-       can.  It's meant to be used by remote clients to support drag-n-drop
-       rearranging of the stack from e.g. the StackListbox.
-       '''
-       assert 0 <= from_index
-       assert 0 <= to_index
-       if from_index == to_index:
-               return stack
-       head, n = [], from_index
-       while True:
-               item, stack = stack
-               n -= 1
-               if n < 0:
-                       break
-               head.append(item)
-       assert len(head) == from_index
-       # now we have two cases:
-       diff = from_index - to_index
-       if diff < 0:
-               # from < to
-               # so the destination index is still in the stack
-               while diff:
-                       h, stack = stack
-                       head.append(h)
-                       diff += 1
-       else:
-               # from > to
-               # so the destination is in the head list
-               while diff:
-                       stack = head.pop(), stack
-                       diff -= 1
-       stack = item, stack
-       while head:
-               stack = head.pop(), stack
-       return stack
+    '''
+    Given a stack and two indices return a rearranged stack.
+    First remove the item at from_index and then insert it at to_index,
+    the second index is relative to the stack after removal of the item
+    at from_index.
+
+    This function reuses all of the items and as much of the stack as it
+    can.  It's meant to be used by remote clients to support drag-n-drop
+    rearranging of the stack from e.g. the StackListbox.
+    '''
+    assert 0 <= from_index
+    assert 0 <= to_index
+    if from_index == to_index:
+        return stack
+    head, n = [], from_index
+    while True:
+        item, stack = stack
+        n -= 1
+        if n < 0:
+            break
+        head.append(item)
+    assert len(head) == from_index
+    # now we have two cases:
+    diff = from_index - to_index
+    if diff < 0:
+        # from < to
+        # so the destination index is still in the stack
+        while diff:
+            h, stack = stack
+            head.append(h)
+            diff += 1
+    else:
+        # from > to
+        # so the destination is in the head list
+        while diff:
+            stack = head.pop(), stack
+            diff -= 1
+    stack = item, stack
+    while head:
+        stack = head.pop(), stack
+    return stack
 
 
 def pick(stack, n):
-       '''
-       Return the nth item on the stack.
-
-       :param stack stack: A stack.
-       :param int n: An index into the stack.
-       :raises ValueError: if ``n`` is less than zero.
-       :raises IndexError: if ``n`` is equal to or greater than the length of ``stack``.
-       :rtype: whatever
-       '''
-       if n < 0:
-               raise ValueError
-       while True:
-               try:
-                       item, stack = stack
-               except ValueError:
-                       raise IndexError
-               n -= 1
-               if n < 0:
-                       break
-       return item
+    '''
+    Return the nth item on the stack.
+
+    :param stack stack: A stack.
+    :param int n: An index into the stack.
+    :raises ValueError: if ``n`` is less than zero.
+    :raises IndexError: if ``n`` is equal to or greater than the length of ``stack``.
+    :rtype: whatever
+    '''
+    if n < 0:
+        raise ValueError
+    while True:
+        try:
+            item, stack = stack
+        except ValueError:
+            raise IndexError
+        n -= 1
+        if n < 0:
+            break
+    return item
diff --git a/startREPL.bat b/startREPL.bat
deleted file mode 100644 (file)
index 59825cc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-python -m joy
\ No newline at end of file