OSDN Git Service

Bleah.
[joypy/Thun.git] / docs / 2._Library_Examples.rst
index 81030ca..dea1516 100644 (file)
@@ -1,7 +1,7 @@
 Examples (and some documentation) for the Words in the Library
 ==============================================================
 
-.. code:: ipython2
+.. code:: ipython3
 
     from notebook_preamble import J, V
 
@@ -18,7 +18,7 @@ it's "off the shelf" technology.)
 ``clear``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 clear')
 
@@ -31,7 +31,7 @@ it's "off the shelf" technology.)
 ``dup`` ``dupd``
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 dup')
 
@@ -41,7 +41,7 @@ it's "off the shelf" technology.)
     1 2 3 3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 dupd')
 
@@ -56,7 +56,7 @@ it's "off the shelf" technology.)
 
 Replace the stack with a quote of itself.
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 enstacken')
 
@@ -68,7 +68,7 @@ Replace the stack with a quote of itself.
 
 Unpack a list onto the stack.
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('4 5 6 [3 2 1] unstack')
 
@@ -80,7 +80,7 @@ Unpack a list onto the stack.
 
 Get the stack on the stack.
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 stack')
 
@@ -93,7 +93,7 @@ Get the stack on the stack.
 Replace the stack with the list on top. The items appear reversed but
 they are not, is on the top of both the list and the stack.
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 [4 5 6] disenstacken')
 
@@ -106,7 +106,7 @@ they are not, is on the top of both the list and the stack.
 ``pop`` ``popd`` ``popop``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 pop')
 
@@ -116,7 +116,7 @@ they are not, is on the top of both the list and the stack.
     1 2
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 popd')
 
@@ -126,7 +126,7 @@ they are not, is on the top of both the list and the stack.
     1 3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 popop')
 
@@ -142,7 +142,7 @@ they are not, is on the top of both the list and the stack.
 The "down" and "up" refer to the movement of two of the top three items
 (displacing the third.)
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 roll<')
 
@@ -152,7 +152,7 @@ The "down" and "up" refer to the movement of two of the top three items
     2 3 1
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 roll>')
 
@@ -165,7 +165,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``swap``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 swap')
 
@@ -178,7 +178,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``tuck`` ``over``
 ~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 tuck')
 
@@ -188,7 +188,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 3 2 3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 over')
 
@@ -201,7 +201,7 @@ The "down" and "up" refer to the movement of two of the top three items
 ``unit`` ``quoted`` ``unquoted``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 unit')
 
@@ -211,7 +211,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 2 [3]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 quoted')
 
@@ -221,7 +221,7 @@ The "down" and "up" refer to the movement of two of the top three items
     1 [2] 3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 [2] 3 unquoted')
 
@@ -231,23 +231,23 @@ The "down" and "up" refer to the movement of two of the top three items
     1 2 3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('1 [dup] 3 unquoted')  # Unquoting evaluates.  Be aware.
 
 
 .. parsed-literal::
 
-                  . 1 [dup] 3 unquoted
-                1 . [dup] 3 unquoted
-          1 [dup] . 3 unquoted
-        1 [dup] 3 . unquoted
-        1 [dup] 3 . [i] dip
-    1 [dup] 3 [i] . dip
-          1 [dup] . i 3
-                1 . dup 3
-              1 1 . 3
-            1 1 3 . 
+                   1 [dup] 3 unquoted
+                1  [dup] 3 unquoted
+          1 [dup]  3 unquoted
+        1 [dup] 3  unquoted
+        1 [dup] 3  [i] dip
+    1 [dup] 3 [i]  dip
+          1 [dup]  i 3
+                1  dup 3
+              1 1  3
+            1 1 3  
 
 
 List words
@@ -256,7 +256,7 @@ List words
 ``concat`` ``swoncat`` ``shunt``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3] [4 5 6] concat')
 
@@ -266,7 +266,7 @@ List words
     [1 2 3 4 5 6]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3] [4 5 6] swoncat')
 
@@ -276,7 +276,7 @@ List words
     [4 5 6 1 2 3]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3] [4 5 6] shunt')
 
@@ -289,7 +289,7 @@ List words
 ``cons`` ``swons`` ``uncons``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 [2 3] cons')
 
@@ -299,7 +299,7 @@ List words
     [1 2 3]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[2 3] 1 swons')
 
@@ -309,7 +309,7 @@ List words
     [1 2 3]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3] uncons')
 
@@ -322,7 +322,7 @@ List words
 ``first`` ``second`` ``third`` ``rest``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] first')
 
@@ -332,7 +332,7 @@ List words
     1
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] second')
 
@@ -342,7 +342,7 @@ List words
     2
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] third')
 
@@ -352,7 +352,7 @@ List words
     3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] rest')
 
@@ -365,7 +365,7 @@ List words
 ``flatten``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[[1] [2 [3] 4] [5 6]] flatten')
 
@@ -380,7 +380,7 @@ List words
 
 ``at`` and ``getitem`` are the same function. ``of == swap at``
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[10 11 12 13 14] 2 getitem')
 
@@ -390,7 +390,7 @@ List words
     12
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] 0 at')
 
@@ -400,7 +400,7 @@ List words
     1
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('2 [1 2 3 4] of')
 
@@ -410,7 +410,7 @@ List words
     3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] 2 drop')
 
@@ -420,7 +420,7 @@ List words
     [3 4]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] 2 take')  # reverses the order
 
@@ -435,7 +435,7 @@ List words
 ``remove``
 ~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 1 4] 1 remove')
 
@@ -448,7 +448,7 @@ List words
 ``reverse``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 4] reverse')
 
@@ -461,7 +461,7 @@ List words
 ``size``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 1 1 1] size')
 
@@ -478,7 +478,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:: ipython3
 
     J('1 2 3 [4 5 6] swaack')
 
@@ -491,7 +491,7 @@ switch. Niether of the lists/stacks change their order.
 ``choice`` ``select``
 ~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 1 choice')
 
@@ -501,7 +501,7 @@ switch. Niether of the lists/stacks change their order.
     9
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 0 choice')
 
@@ -511,7 +511,7 @@ switch. Niether of the lists/stacks change their order.
     23
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[23 9 7] 1 select')  # select is basically getitem, should retire it?
 
@@ -521,7 +521,7 @@ switch. Niether of the lists/stacks change their order.
     9
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[23 9 7] 0 select')
 
@@ -534,7 +534,7 @@ switch. Niether of the lists/stacks change their order.
 ``zip``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3] [6 5 4] zip')
 
@@ -544,7 +544,7 @@ switch. Niether of the lists/stacks change their order.
     [[6 1] [5 2] [4 3]]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3] [6 5 4] zip [sum] map')
 
@@ -560,7 +560,7 @@ Math words
 ``+`` ``add``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 +')
 
@@ -573,7 +573,7 @@ Math words
 ``-`` ``sub``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 -')
 
@@ -586,7 +586,7 @@ Math words
 ``*`` ``mul``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 *')
 
@@ -599,7 +599,7 @@ Math words
 ``/`` ``div`` ``floordiv`` ``truediv``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 /')
 
@@ -609,7 +609,7 @@ Math words
     2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 -9 truediv')
 
@@ -619,7 +619,7 @@ Math words
     -2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 div')
 
@@ -629,7 +629,7 @@ Math words
     2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 floordiv')
 
@@ -639,7 +639,7 @@ Math words
     2
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 -9 div')
 
@@ -649,7 +649,7 @@ Math words
     -2.5555555555555554
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 -9 floordiv')
 
@@ -662,7 +662,7 @@ Math words
 ``%`` ``mod`` ``modulus`` ``rem`` ``remainder``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 %')
 
@@ -675,7 +675,7 @@ Math words
 ``neg``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 neg -5 neg')
 
@@ -688,7 +688,7 @@ Math words
 pow
 ~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('2 10 pow')
 
@@ -701,7 +701,7 @@ pow
 ``sqr`` ``sqrt``
 ~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 sqr')
 
@@ -711,7 +711,7 @@ pow
     529
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 sqrt')
 
@@ -724,7 +724,7 @@ pow
 ``++`` ``succ`` ``--`` ``pred``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 ++')
 
@@ -734,7 +734,7 @@ pow
     2
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 --')
 
@@ -747,7 +747,7 @@ pow
 ``<<`` ``lshift`` ``>>`` ``rshift``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('8 1 <<')
 
@@ -757,7 +757,7 @@ pow
     16
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('8 1 >>')
 
@@ -770,7 +770,7 @@ pow
 ``average``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 5] average')
 
@@ -783,7 +783,7 @@ pow
 ``range`` ``range_to_zero`` ``down_to_zero``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('5 range')
 
@@ -793,7 +793,7 @@ pow
     [4 3 2 1 0]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('5 range_to_zero')
 
@@ -803,7 +803,7 @@ pow
     [0 1 2 3 4 5]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('5 down_to_zero')
 
@@ -816,7 +816,7 @@ pow
 ``product``
 ~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 5] product')
 
@@ -829,7 +829,7 @@ pow
 ``sum``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 5] sum')
 
@@ -842,7 +842,7 @@ pow
 ``min``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 3 5] min')
 
@@ -855,7 +855,7 @@ pow
 ``gcd``
 ~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('45 30 gcd')
 
@@ -871,7 +871,7 @@ pow
 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:: ipython3
 
     J('[45 30] least_fraction')
 
@@ -881,7 +881,7 @@ reduces them to their ... least common factors or whatever.
     [3.0 2.0]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[23 12] least_fraction')
 
@@ -899,7 +899,7 @@ Logic and Comparison
 
 Get the Boolean value of the item on the top of the stack.
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 truthy')
 
@@ -909,7 +909,7 @@ Get the Boolean value of the item on the top of the stack.
     True
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[] truthy')  # Python semantics.
 
@@ -919,7 +919,7 @@ Get the Boolean value of the item on the top of the stack.
     False
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('0 truthy')
 
@@ -933,21 +933,21 @@ Get the Boolean value of the item on the top of the stack.
 
     ? == dup truthy
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('23 ?')
 
 
 .. parsed-literal::
 
-            . 23 ?
-         23 . ?
-         23 . dup truthy
-      23 23 . truthy
-    23 True . 
+             23 ?
+         23  ?
+         23  dup truthy
+      23 23  truthy
+    23 True  
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[] ?')
 
@@ -957,7 +957,7 @@ Get the Boolean value of the item on the top of the stack.
     [] False
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('0 ?')
 
@@ -970,7 +970,7 @@ Get the Boolean value of the item on the top of the stack.
 ``&`` ``and``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 &')
 
@@ -983,7 +983,7 @@ Get the Boolean value of the item on the top of the stack.
 ``!=`` ``<>`` ``ne``
 ~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('23 9 !=')
 
@@ -999,7 +999,7 @@ Get the Boolean value of the item on the top of the stack.
 ``^`` ``xor``
 ~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 1 ^')
 
@@ -1009,7 +1009,7 @@ Get the Boolean value of the item on the top of the stack.
     0
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 0 ^')
 
@@ -1025,7 +1025,7 @@ Miscellaneous
 ``help``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[help] help')
 
@@ -1045,7 +1045,7 @@ Miscellaneous
 ``parse``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[parse] help')
 
@@ -1062,7 +1062,7 @@ Miscellaneous
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 "2 [3] dup" parse')
 
@@ -1077,7 +1077,7 @@ Miscellaneous
 
 Evaluate a quoted Joy sequence.
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[1 2 dup + +] run')
 
@@ -1093,7 +1093,7 @@ Combinators
 ``app1`` ``app2`` ``app3``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[app1] help')
 
@@ -1108,16 +1108,16 @@ Combinators
     program.
     ::
     
-                                                    ... x [Q] . app1
-             -----------------------------------
-                            ... [x ...] [Q] . infra first
+                     ... x [Q] . app1
+            -----------------------------------
+               ... [x ...] [Q] . infra first
     
     ---- end (app1)
     
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('10 4 [sqr *] app1')
 
@@ -1127,7 +1127,7 @@ Combinators
     10 160
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('10 3 4 [sqr *] app2')
 
@@ -1137,7 +1137,7 @@ Combinators
     10 90 160
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[app2] help')
 
@@ -1150,17 +1150,17 @@ Combinators
     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
     
     ---- end (app2)
     
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('10 2 3 4 [sqr *] app3')
 
@@ -1188,7 +1188,7 @@ Example, ``range``:
 
     range == [0 <=] [1 - dup] anamorphism
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('3 [0 <=] [1 - dup] anamorphism')
 
@@ -1201,7 +1201,7 @@ Example, ``range``:
 ``branch``
 ~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('3 4 1 [+] [*] branch')
 
@@ -1211,7 +1211,7 @@ Example, ``range``:
     12
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('3 4 0 [+] [*] branch')
 
@@ -1246,7 +1246,7 @@ in terms of ``app2``:
 
     cleave == [i] app2 [popd] dip
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('10 2 [+] [-] cleave')
 
@@ -1259,7 +1259,7 @@ in terms of ``app2``:
 ``dip`` ``dipd`` ``dipdd``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 4 5 [+] dip')
 
@@ -1269,7 +1269,7 @@ in terms of ``app2``:
     1 2 7 5
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 4 5 [+] dipd')
 
@@ -1279,7 +1279,7 @@ in terms of ``app2``:
     1 5 4 5
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 4 5 [+] dipdd')
 
@@ -1299,26 +1299,26 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 
     n [Q] dupdip == n Q n
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('23 [++] dupdip *')  # N(N + 1)
 
 
 .. parsed-literal::
 
-            . 23 [++] dupdip *
-         23 . [++] dupdip *
-    23 [++] . dupdip *
-         23 . ++ 23 *
-         24 . 23 *
-      24 23 . *
-        552 . 
+             23 [++] dupdip *
+         23  [++] dupdip *
+    23 [++]  dupdip *
+         23  ++ 23 *
+         24  23 *
+      24 23  *
+        552  
 
 
 ``genrec`` ``primrec``
 ~~~~~~~~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[genrec] help')
 
@@ -1331,9 +1331,9 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     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
@@ -1354,12 +1354,12 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     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:
     ::
     
-                    ... 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
@@ -1367,22 +1367,22 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     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.
     ::
     
-                    P == [I] [T] [R] primrec
-                            == [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
     
     ---- end (genrec)
     
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('3 [1 <=] [] [dup --] [i *] genrec')
 
@@ -1395,21 +1395,21 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``i``
 ~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('1 2 3 [+ +] i')
 
 
 .. parsed-literal::
 
-                . 1 2 3 [+ +] i
-              1 . 2 3 [+ +] i
-            1 2 . 3 [+ +] i
-          1 2 3 . [+ +] i
-    1 2 3 [+ +] . i
-          1 2 3 . + +
-            1 5 . +
-              6 . 
+                 1 2 3 [+ +] i
+              1  2 3 [+ +] i
+            1 2  3 [+ +] i
+          1 2 3  [+ +] i
+    1 2 3 [+ +]  i
+          1 2 3  + +
+            1 5  +
+              6  
 
 
 ``ifte``
@@ -1419,7 +1419,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 
     [predicate] [then] [else] ifte
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 [1] [+] [*] ifte')
 
@@ -1429,7 +1429,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     3
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 [0] [+] [*] ifte')
 
@@ -1442,30 +1442,30 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
 ``infra``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('1 2 3 [4 5 6] [* +] infra')
 
 
 .. parsed-literal::
 
-                        . 1 2 3 [4 5 6] [* +] infra
-                      1 . 2 3 [4 5 6] [* +] infra
-                    1 2 . 3 [4 5 6] [* +] infra
-                  1 2 3 . [4 5 6] [* +] infra
-          1 2 3 [4 5 6] . [* +] infra
-    1 2 3 [4 5 6] [* +] . infra
-                  6 5 4 . * + [3 2 1] swaack
-                   6 20 . + [3 2 1] swaack
-                     26 . [3 2 1] swaack
-             26 [3 2 1] . swaack
-             1 2 3 [26] . 
+                         1 2 3 [4 5 6] [* +] infra
+                      1  2 3 [4 5 6] [* +] infra
+                    1 2  3 [4 5 6] [* +] infra
+                  1 2 3  [4 5 6] [* +] infra
+          1 2 3 [4 5 6]  [* +] infra
+    1 2 3 [4 5 6] [* +]  infra
+                  6 5 4  * + [3 2 1] swaack
+                   6 20  + [3 2 1] swaack
+                     26  [3 2 1] swaack
+             26 [3 2 1]  swaack
+             1 2 3 [26]  
 
 
 ``loop``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[loop] help')
 
@@ -1478,52 +1478,52 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     Basic loop combinator.
     ::
     
-                     ... True [Q] loop
+               ... True [Q] loop
             -----------------------
-                                    ... Q [Q] loop
+                  ... Q [Q] loop
     
-                     ... False [Q] loop
+               ... False [Q] loop
             ------------------------
-                                                    ...
+                      ...
     
     ---- end (loop)
     
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('3 dup [1 - dup] loop')
 
 
 .. parsed-literal::
 
-                  . 3 dup [1 - dup] loop
-                3 . dup [1 - dup] loop
-              3 3 . [1 - dup] loop
-    3 3 [1 - dup] . loop
-                3 . 1 - dup [1 - dup] loop
-              3 1 . - dup [1 - dup] loop
-                2 . dup [1 - dup] loop
-              2 2 . [1 - dup] loop
-    2 2 [1 - dup] . loop
-                2 . 1 - dup [1 - dup] loop
-              2 1 . - dup [1 - dup] loop
-                1 . dup [1 - dup] loop
-              1 1 . [1 - dup] loop
-    1 1 [1 - dup] . loop
-                1 . 1 - dup [1 - dup] loop
-              1 1 . - dup [1 - dup] loop
-                0 . dup [1 - dup] loop
-              0 0 . [1 - dup] loop
-    0 0 [1 - dup] . loop
-                0 . 
+                   3 dup [1 - dup] loop
+                3  dup [1 - dup] loop
+              3 3  [1 - dup] loop
+    3 3 [1 - dup]  loop
+                3  1 - dup [1 - dup] loop
+              3 1  - dup [1 - dup] loop
+                2  dup [1 - dup] loop
+              2 2  [1 - dup] loop
+    2 2 [1 - dup]  loop
+                2  1 - dup [1 - dup] loop
+              2 1  - dup [1 - dup] loop
+                1  dup [1 - dup] loop
+              1 1  [1 - dup] loop
+    1 1 [1 - dup]  loop
+                1  1 - dup [1 - dup] loop
+              1 1  - dup [1 - dup] loop
+                0  dup [1 - dup] loop
+              0 0  [1 - dup] loop
+    0 0 [1 - dup]  loop
+                0  
 
 
 ``map`` ``pam``
 ~~~~~~~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('10 [1 2 3] [*] map')
 
@@ -1533,7 +1533,7 @@ Expects a quoted program ``[Q]`` on the stack and some item under it,
     10 [10 20 30]
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('10 5 [[*][/][+][-]] pam')
 
@@ -1549,7 +1549,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:: ipython3
 
     J('1 2 3 4 5 [+] nullary')
 
@@ -1559,7 +1559,7 @@ Run a quoted program enforcing
     1 2 3 4 5 9
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 4 5 [+] unary')
 
@@ -1569,7 +1569,7 @@ Run a quoted program enforcing
     1 2 3 4 9
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 4 5 [+] binary')  # + has arity 2 so this is technically pointless...
 
@@ -1579,7 +1579,7 @@ Run a quoted program enforcing
     1 2 3 9
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('1 2 3 4 5 [+] ternary')
 
@@ -1592,7 +1592,7 @@ Run a quoted program enforcing
 ``step``
 ~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[step] help')
 
@@ -1605,19 +1605,19 @@ Run a quoted program enforcing
     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 b c] [Q] . step
             ----------------------------------------
-                                                             ... a . Q [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.
@@ -1627,60 +1627,60 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('0 [1 2 3] [+] step')
 
 
 .. parsed-literal::
 
-                  . 0 [1 2 3] [+] step
-                0 . [1 2 3] [+] step
-        0 [1 2 3] . [+] step
-    0 [1 2 3] [+] . step
-          0 1 [+] . i [2 3] [+] step
-              0 1 . + [2 3] [+] step
-                1 . [2 3] [+] step
-          1 [2 3] . [+] step
-      1 [2 3] [+] . step
-          1 2 [+] . i [3] [+] step
-              1 2 . + [3] [+] step
-                3 . [3] [+] step
-            3 [3] . [+] step
-        3 [3] [+] . step
-          3 3 [+] . i
-              3 3 . +
-                6 . 
+                   0 [1 2 3] [+] step
+                0  [1 2 3] [+] step
+        0 [1 2 3]  [+] step
+    0 [1 2 3] [+]  step
+          0 1 [+]  i [2 3] [+] step
+              0 1  + [2 3] [+] step
+                1  [2 3] [+] step
+          1 [2 3]  [+] step
+      1 [2 3] [+]  step
+          1 2 [+]  i [3] [+] step
+              1 2  + [3] [+] step
+                3  [3] [+] step
+            3 [3]  [+] step
+        3 [3] [+]  step
+          3 3 [+]  i
+              3 3  +
+                6  
 
 
 ``times``
 ~~~~~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('3 2 1 2 [+] times')
 
 
 .. parsed-literal::
 
-                . 3 2 1 2 [+] times
-              3 . 2 1 2 [+] times
-            3 2 . 1 2 [+] times
-          3 2 1 . 2 [+] times
-        3 2 1 2 . [+] times
-    3 2 1 2 [+] . times
-          3 2 1 . + 1 [+] times
-            3 3 . 1 [+] times
-          3 3 1 . [+] times
-      3 3 1 [+] . times
-            3 3 . +
-              6 . 
+                 3 2 1 2 [+] times
+              3  2 1 2 [+] times
+            3 2  1 2 [+] times
+          3 2 1  2 [+] times
+        3 2 1 2  [+] times
+    3 2 1 2 [+]  times
+          3 2 1  + 1 [+] times
+            3 3  1 [+] times
+          3 3 1  [+] times
+      3 3 1 [+]  times
+            3 3  +
+              6  
 
 
 ``b``
 ~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[b] help')
 
@@ -1702,21 +1702,21 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('1 2 [3] [4] b')
 
 
 .. parsed-literal::
 
-                . 1 2 [3] [4] b
-              1 . 2 [3] [4] b
-            1 2 . [3] [4] b
-        1 2 [3] . [4] b
-    1 2 [3] [4] . b
-            1 2 . 3 4
-          1 2 3 . 4
-        1 2 3 4 . 
+                 1 2 [3] [4] b
+              1  2 [3] [4] b
+            1 2  [3] [4] b
+        1 2 [3]  [4] b
+    1 2 [3] [4]  b
+            1 2  3 4
+          1 2 3  4
+        1 2 3 4  
 
 
 ``while``
@@ -1726,7 +1726,7 @@ Run a quoted program enforcing
 
     [predicate] [body] while
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('3 [0 >] [dup --] while')
 
@@ -1739,7 +1739,7 @@ Run a quoted program enforcing
 ``x``
 ~~~~~
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[x] help')
 
@@ -1762,23 +1762,23 @@ Run a quoted program enforcing
     
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     V('1 [2] [i 3] x')  # Kind of a pointless example.
 
 
 .. parsed-literal::
 
-                . 1 [2] [i 3] x
-              1 . [2] [i 3] x
-          1 [2] . [i 3] x
-    1 [2] [i 3] . x
-    1 [2] [i 3] . i 3
-          1 [2] . i 3 3
-              1 . 2 3 3
-            1 2 . 3 3
-          1 2 3 . 3
-        1 2 3 3 . 
+                 1 [2] [i 3] x
+              1  [2] [i 3] x
+          1 [2]  [i 3] x
+    1 [2] [i 3]  x
+    1 [2] [i 3]  i 3
+          1 [2]  i 3 3
+              1  2 3 3
+            1 2  3 3
+          1 2 3  3
+        1 2 3 3  
 
 
 ``void``
@@ -1789,7 +1789,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:: ipython3
 
     J('[] void')
 
@@ -1799,7 +1799,7 @@ soley of containers, without strings or numbers or anything else.)
     False
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[[]] void')
 
@@ -1809,7 +1809,7 @@ soley of containers, without strings or numbers or anything else.)
     True
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[[][[]]] void')
 
@@ -1819,7 +1819,7 @@ soley of containers, without strings or numbers or anything else.)
     True
 
 
-.. code:: ipython2
+.. code:: ipython3
 
     J('[[[]][[][]]] void')