diff --git a/docs/Generator Programs.html b/docs/Generator Programs.html index 142e939..aaa6ffe 100644 --- a/docs/Generator Programs.html +++ b/docs/Generator Programs.html @@ -11799,10 +11799,16 @@ div#notebook {

Consider the x combinator:

-
x == dup i
+
x == dup i
-
-

We can apply it to a quoted program consisting of some value a and a function B:

+
+ + +
+
+
+
+

We can apply it to a quoted program consisting of some value a and some function B:

[a B] x
 [a B] a B
@@ -11844,7 +11850,7 @@ b [B] cons
-

Putting it together, this is the definition of B:

+

Altogether, this is the definition of B:

B == swap [C] dip rest cons
@@ -11855,7 +11861,7 @@ b [B] cons
-

We can create a quoted program that generates the Natural numbers (0, 1, 2, ...) by using 0 for a and [dup ++] for [C]:

+

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]
 
@@ -11951,7 +11957,7 @@ b [B]        cons
 
-

direco

+

direco

@@ -12015,7 +12021,7 @@ b [B] cons
-

Making Generators

We want to define a function that accepts a and [C] and builds our quoted program:

+

Making Generators

We want to define a function that accepts a and [C] and builds our quoted program:

         a [C] G
 -------------------------
@@ -12212,7 +12218,7 @@ G == [direco] cons [swap] swoncat cons
-

Generating Multiples of Three and Five

Look at the treatment of the Project Euler Problem One in Developing a Program.ipynb and you'll see that we might be interested in generating an endless cycle of:

+

Generating Multiples of Three and Five

Look at the treatment of the Project Euler Problem One in Developing a Program.ipynb and you'll see that we might be interested in generating an endless cycle of:

3 2 1 3 1 2 3
 
@@ -12570,7 +12576,7 @@ G == [direco] cons [swap] swoncat cons
-

Project Euler Problem One

+

Project Euler Problem One

@@ -12631,7 +12637,7 @@ G == [direco] cons [swap] swoncat cons
-

A generator for the Fibonacci Sequence.

Consider:

+

A generator for the Fibonacci Sequence.

Consider:

[b a F] x
 [b a F] b a F
@@ -12818,7 +12824,7 @@ fib_gen == [1 1 F]
-

Project Euler Problem Two

+

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.
 
@@ -13115,7 +13121,7 @@ o + e = o
 
-

How to compile these?

You would probably start with a special version of G, and perhaps modifications to the default x?

+

How to compile these?

You would probably start with a special version of G, and perhaps modifications to the default x?

@@ -13124,7 +13130,7 @@ o + e = o
-

An Interesting Variation

+

An Interesting Variation

diff --git a/docs/Generator Programs.ipynb b/docs/Generator Programs.ipynb index 0ed86be..dcb3f61 100644 --- a/docs/Generator Programs.ipynb +++ b/docs/Generator Programs.ipynb @@ -24,9 +24,14 @@ "source": [ "Consider the `x` combinator:\n", "\n", - " x == dup i\n", - "\n", - "We can apply it to a quoted program consisting of some value `a` and a function `B`:\n", + " x == dup i" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can apply it to a quoted program consisting of some value `a` and some function `B`:\n", "\n", " [a B] x\n", " [a B] a B" @@ -62,7 +67,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Putting it together, this is the definition of `B`:\n", + "Altogether, this is the definition of `B`:\n", "\n", " B == swap [C] dip rest cons" ] @@ -71,7 +76,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can create a quoted program that generates the Natural numbers (0, 1, 2, ...) by using `0` for `a` and `[dup ++]` for `[C]`:\n", + "We can make a generator for the Natural numbers (0, 1, 2, ...) by using `0` for `a` and `[dup ++]` for `[C]`:\n", "\n", " [0 swap [dup ++] dip rest cons]\n", "\n", @@ -136,7 +141,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### `direco`" + "## `direco`" ] }, { @@ -181,7 +186,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Making Generators\n", + "## Making Generators\n", "We want to define a function that accepts `a` and `[C]` and builds our quoted program:\n", "\n", " a [C] G\n", @@ -310,8 +315,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Generating Multiples of Three and Five\n", - "Look at the treatment of the Project Euler Problem One in [Developing a Program.ipynb](./Developing a Program.ipynb) and you'll see that we might be interested in generating an endless cycle of:\n", + "## Generating Multiples of Three and Five\n", + "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:\n", "\n", " 3 2 1 3 1 2 3\n", "\n", @@ -541,7 +546,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Project Euler Problem One" + "## Project Euler Problem One" ] }, { @@ -581,7 +586,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# A generator for the Fibonacci Sequence.\n", + "## A generator for the Fibonacci Sequence.\n", "Consider:\n", "\n", " [b a F] x\n", @@ -725,7 +730,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Project Euler Problem Two\n", + "## Project Euler Problem Two\n", " By considering the terms in the Fibonacci sequence whose values do not exceed four million,\n", " find the sum of the even-valued terms.\n", "\n", @@ -921,7 +926,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# How to compile these?\n", + "## How to compile these?\n", "You would probably start with a special version of `G`, and perhaps modifications to the default `x`?" ] }, @@ -929,7 +934,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# An Interesting Variation" + "## An Interesting Variation" ] }, { diff --git a/docs/Generator Programs.md b/docs/Generator Programs.md index 6190a1b..d22f64f 100644 --- a/docs/Generator Programs.md +++ b/docs/Generator Programs.md @@ -12,7 +12,7 @@ Consider the `x` combinator: x == dup i -We can apply it to a quoted program consisting of some value `a` and a function `B`: +We can apply it to a quoted program consisting of some value `a` and some function `B`: [a B] x [a B] a B @@ -33,11 +33,11 @@ Now discard the quoted `a` with `rest` then `cons` `b`: b [B] cons [b B] -Putting it together, this is the definition of `B`: +Altogether, this is the definition of `B`: B == swap [C] dip rest cons -We can create a quoted program that generates the Natural numbers (0, 1, 2, ...) by using `0` for `a` and `[dup ++]` for `[C]`: +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] @@ -72,7 +72,7 @@ J('[0 swap [dup ++] dip rest cons] x x x x x pop') 0 1 2 3 4 -### `direco` +## `direco` ```python @@ -99,7 +99,7 @@ V('[0 swap [dup ++] direco] x') 0 [1 swap [dup ++] direco] . -# Making Generators +## Making Generators We want to define a function that accepts `a` and `[C]` and builds our quoted program: a [C] G @@ -163,7 +163,7 @@ J('23 [dup ++] G 5 [x] times') 23 24 25 26 27 [28 swap [dup ++] direco] -# Generating Multiples of Three and Five +## Generating Multiples of Three and Five Look at the treatment of the Project Euler Problem One in [Developing a Program.ipynb](./Developing a Program.ipynb) and you'll see that we might be interested in generating an endless cycle of: 3 2 1 3 1 2 3 @@ -273,7 +273,7 @@ J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum') 999 -# Project Euler Problem One +## Project Euler Problem One ```python @@ -290,7 +290,7 @@ J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop') 233168 -# A generator for the Fibonacci Sequence. +## A generator for the Fibonacci Sequence. Consider: [b a F] x @@ -362,7 +362,7 @@ J('fib_gen 10 [x] times') 1 2 3 5 8 13 21 34 55 89 [144 89 fib] -### Project Euler Problem Two +## 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. @@ -463,10 +463,10 @@ J('0 [1 0 fib] PE2.2 [pop >4M] [popop] [[PE2.1] dip PE2.2] primrec') 4613732 -# How to compile these? +## How to compile these? You would probably start with a special version of `G`, and perhaps modifications to the default `x`? -# An Interesting Variation +## An Interesting Variation ```python diff --git a/docs/Generator Programs.rst b/docs/Generator Programs.rst index 4ae0294..d5ee3ca 100644 --- a/docs/Generator Programs.rst +++ b/docs/Generator Programs.rst @@ -14,8 +14,8 @@ Consider the ``x`` combinator: x == dup i -We can apply it to a quoted program consisting of some value ``a`` and a -function ``B``: +We can apply it to a quoted program consisting of some value ``a`` and +some function ``B``: :: @@ -43,14 +43,14 @@ Now discard the quoted ``a`` with ``rest`` then ``cons`` ``b``: b [B] cons [b B] -Putting it together, this is the definition of ``B``: +Altogether, this is the definition of ``B``: :: B == swap [C] dip rest cons -We can create a quoted program that generates the Natural numbers (0, 1, -2, ...) by using ``0`` for ``a`` and ``[dup ++]`` for ``[C]``: +We can make a generator for the Natural numbers (0, 1, 2, ...) by using +``0`` for ``a`` and ``[dup ++]`` for ``[C]``: :: @@ -93,7 +93,7 @@ After one application of ``x`` the quoted program contains ``1`` and ``direco`` -~~~~~~~~~~ +---------- .. code:: ipython2 @@ -122,7 +122,7 @@ After one application of ``x`` the quoted program contains ``1`` and Making Generators -================= +----------------- We want to define a function that accepts ``a`` and ``[C]`` and builds our quoted program: @@ -206,7 +206,7 @@ with the ``x`` combinator. Generating Multiples of Three and Five -====================================== +-------------------------------------- Look at the treatment of the Project Euler Problem One in `Developing a Program.ipynb <./Developing%20a%20Program.ipynb>`__ and you'll see that @@ -351,7 +351,7 @@ If we drive our generator 466 times and sum the stack we get 999. Project Euler Problem One -========================= +------------------------- .. code:: ipython2 @@ -370,7 +370,7 @@ Now we can add ``PE1.2`` to the quoted program given to ``G``. A generator for the Fibonacci Sequence. -======================================= +--------------------------------------- Consider: @@ -466,7 +466,7 @@ Putting it all together: Project Euler Problem Two -~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------- :: @@ -589,13 +589,13 @@ Replace ``x`` with our new driver function ``PE2.2`` and start our 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:: ipython2 diff --git a/docs/sphinx_docs/_build/html/_modules/joy/library.html b/docs/sphinx_docs/_build/html/_modules/joy/library.html index b3c1333..b0d5920 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/library.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/library.html @@ -1177,14 +1177,17 @@ @FunctionWrapper def cond(stack, expression, dictionary): ''' - like a case statement; works by rewriting into a chain of ifte. + 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. - [..[[Bi] Ti]..[D]] -> ... + 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 + [[[B0] T0] [[B1] T1] [D]] cond + ----------------------------------------- + [B0] [T0] [[B1] [T1] [D] ifte] ifte ''' conditions, stack = stack @@ -1433,9 +1436,10 @@
[docs]@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 @@ -1448,10 +1452,10 @@ a b [G] [E] [L] cmp ------------------------- a < b L - ''' - L, (E, (G, (b, (a, stack)))) = stack - expression = pushback(G if a > b else L if a < b else E, expression) - return stack, expression, dictionary
+ ''' + L, (E, (G, (b, (a, stack)))) = stack + expression = pushback(G if a > b else L if a < b else E, expression) + return stack, expression, dictionary
#def nullary(S, expression, dictionary): diff --git a/docs/sphinx_docs/_build/html/index.html b/docs/sphinx_docs/_build/html/index.html index e06d2e9..f8fe488 100644 --- a/docs/sphinx_docs/_build/html/index.html +++ b/docs/sphinx_docs/_build/html/index.html @@ -135,6 +135,7 @@ interesting aspects. It’s quite a treasure trove.

  • Replacing Functions in the Dictionary
  • Treating Trees I: Ordered Binary Trees
  • Treating Trees II: treestep
  • +
  • Using x to Generate Values
  • Newton’s method
  • Quadratic formula
  • No Updates
  • diff --git a/docs/sphinx_docs/_build/html/library.html b/docs/sphinx_docs/_build/html/library.html index 304a854..cc1198d 100644 --- a/docs/sphinx_docs/_build/html/library.html +++ b/docs/sphinx_docs/_build/html/library.html @@ -198,24 +198,19 @@ Boolean value (so empty string, zero, etc. are counted as false, etc.)

    joy.library.cmp_(stack, expression, dictionary)[source]

    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
    -
    -
    E
    -

    a b [G] [E] [L] cmp

    -
    -
    ————————- a < b
    -
    L
    -
    -
    +
       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
    +
    +
    @@ -227,12 +222,17 @@ one of the three depending on the results of comparing the two values:

    joy.library.cond(stack, expression, dictionary)[source]
    -

    like a case statement; works by rewriting into a chain of ifte.

    -

    [..[[Bi] Ti]..[D]] -> …

    -
    -
    [[[B0] T0] [[B1] T1] [D]] cond
    -
    -
    [B0] [T0] [[B1] [T1] [D] ifte] ifte
    +

    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
    +
    +
    diff --git a/docs/sphinx_docs/_build/html/notebooks/Generator Programs.html b/docs/sphinx_docs/_build/html/notebooks/Generator Programs.html index 4c3cc83..690e8c4 100644 --- a/docs/sphinx_docs/_build/html/notebooks/Generator Programs.html +++ b/docs/sphinx_docs/_build/html/notebooks/Generator Programs.html @@ -16,6 +16,8 @@ + + @@ -36,33 +38,39 @@
    from notebook_preamble import J, V, define
     
    -

    Consider the x combinator x == dup i:

    +

    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 swap the a with the quote and run some function -[C] on it.

    -
    [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 and cons the result of -C on a whatever that is:

    -
    aC [a B] rest cons
    -aC [B] cons
    -[aC 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 create a quoted program that generates the Natural numbers -(integers 0, 1, 2, …) by using 0 for a and [dup ++] for -[C]:

    +

    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]
     
    @@ -116,15 +124,13 @@
    -
    -
    -

    Generating Generators

    -

    We want to go from:

    -
    a [C] G
    -
    -
    -

    to:

    -
    [a swap [C] 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:

    @@ -140,107 +146,45 @@ G == [direco] cons [swap] swoncat cons
    -

    We can try it out:

    -
    0 [dup ++] G
    -
    -
    define('G == [direco] cons [swap] swoncat cons')
     
    -
    V('0 [dup ++] G')
    +

    Let’s try it out:

    +
    J('0 [dup ++] G')
     
    -
                               . 0 [dup ++] G
    -                         0 . [dup ++] G
    -                0 [dup ++] . G
    -                0 [dup ++] . [direco] cons [swap] swoncat cons
    -       0 [dup ++] [direco] . cons [swap] swoncat cons
    -       0 [[dup ++] direco] . [swap] swoncat cons
    -0 [[dup ++] direco] [swap] . swoncat cons
    -0 [[dup ++] direco] [swap] . swap concat cons
    -0 [swap] [[dup ++] direco] . concat cons
    -  0 [swap [dup ++] direco] . cons
    -  [0 swap [dup ++] direco] .
    +
    [0 swap [dup ++] direco]
     
    -
    V('0 [dup ++] G x')
    +
    J('0 [dup ++] G x x x pop')
     
    -
                                        . 0 [dup ++] G x
    -                                  0 . [dup ++] G x
    -                         0 [dup ++] . G x
    -                         0 [dup ++] . [direco] cons [swap] swoncat cons x
    -                0 [dup ++] [direco] . cons [swap] swoncat cons x
    -                0 [[dup ++] direco] . [swap] swoncat cons x
    -         0 [[dup ++] direco] [swap] . swoncat cons x
    -         0 [[dup ++] direco] [swap] . swap concat cons x
    -         0 [swap] [[dup ++] direco] . concat cons x
    -           0 [swap [dup ++] direco] . cons 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] .
    +
    0 1 2
     
    -

    Powers of 2

    -
    J('1 [dup 1 <<] G x x x x x x x x x')
    +

    Powers of 2

    +
    J('1 [dup 1 <<] G x x x x x x x x x pop')
     
    -
    1 2 4 8 16 32 64 128 256 [512 swap [dup 1 <<] direco]
    +
    1 2 4 8 16 32 64 128 256
     
    -
    -
    -

    n [x] times

    +
    +

    [x] times

    If we have one of these quoted programs we can drive it using times with the x combinator.

    -

    Let’s define a word n_range that takes a starting integer and a -count and leaves that many consecutive integers on the stack. For -example:

    -
    J('23 [dup ++] G 5 [x] times pop')
    +
    J('23 [dup ++] G 5 [x] times')
     
    -
    23 24 25 26 27
    +
    23 24 25 26 27 [28 swap [dup ++] direco]
     
    -

    We can use dip to untangle [dup ++] G from the arguments.

    -
    J('23 5 [[dup ++] G] dip [x] times pop')
    -
    -
    -
    23 24 25 26 27
    -
    -
    -

    Now that the givens (arguments) are on the left we have the definition -we’re looking for:

    -
    define('n_range == [[dup ++] G] dip [x] times pop')
    -
    -
    -
    J('450 10 n_range')
    -
    -
    -
    450 451 452 453 454 455 456 457 458 459
    -
    -
    -

    This is better just using the times combinator though…

    -
    J('450 9 [dup ++] times')
    -
    -
    -
    450 451 452 453 454 455 456 457 458 459
    -
    -

    Generating Multiples of Three and Five

    +

    Generating Multiples of Three and Five

    Look at the treatment of the Project Euler Problem One in Developing a Program.ipynb and you’ll see that we might be interested in generating an endless cycle of:

    @@ -281,12 +225,6 @@ int right two bits.

    [14811 swap [PE1.1] direco]
     
    -
    J('[14811 swap [PE1.1] direco] x')
    -
    -
    -
    3 [3702 swap [PE1.1] direco]
    -
    -

    …we get a generator that works for seven cycles before it reaches zero:

    J('[14811 swap [PE1.1] direco] 7 [x] times')
    @@ -296,21 +234,31 @@ zero:

    -

    Reset at Zero

    +

    Reset at Zero

    We need a function that checks if the int has reached zero and resets it if so.

    define('PE1.1.check == dup [pop 14811] [] branch')
     
    +
    J('14811 [PE1.1.check PE1.1] G')
    +
    +
    +
    [14811 swap [PE1.1.check PE1.1] direco]
    +
    +
    J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times')
     
    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

    +

    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.

    @@ -321,13 +269,13 @@ numbers sixty-six times and then four more.

    If we drive our generator 466 times and sum the stack we get 999.

    -
    J('[14811 swap [PE1.1.check PE1.1] dip rest cons] 466 [x] times')
    +
    J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times')
     
    -
    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] dip rest cons]
    +
    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]
     
    -
    J('[14811 swap [PE1.1.check PE1.1] dip rest cons] 466 [x] times pop enstacken sum')
    +
    J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum')
     
    999
    @@ -336,18 +284,11 @@ numbers sixty-six times and then four more.

    -

    Project Euler Problem One

    +

    Project Euler Problem One

    define('PE1.2 == + dup [+] dip')
     
    -

    Now we can add PE1.2 to the quoted program given to times.

    -
    J('0 0 [0 swap [PE1.1.check PE1.1] direco] 466 [x [PE1.2] dip] times popop')
    -
    -
    -
    233168
    -
    -
    -

    Or using G we can write:

    +

    Now we can add PE1.2 to the quoted program given to G.

    J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop')
     
    @@ -356,7 +297,7 @@ numbers sixty-six times and then four more.

    -

    A generator for the Fibonacci Sequence.

    +

    A generator for the Fibonacci Sequence.

    Consider:

    [b a F] x
     [b a F] b a F
    @@ -394,21 +335,23 @@ numbers sixty-six times and then four more.

    [b b+a b F]
    -

    And lastly:

    +

    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]
     
    -

    Done.

    Putting it all together:

    -
    F == + swons [popdd over] infra uncons
    +
    F == + [popdd over] cons infra uncons
    +fib_gen == [1 1 F]
     
    -

    And:

    -
    fib_gen == [1 1 F]
    -
    -
    -
    define('fib == + swons [popdd over] infra uncons')
    +
    define('fib == + [popdd over] cons infra uncons')
     
    define('fib_gen == [1 1 fib]')
    @@ -420,9 +363,11 @@ numbers sixty-six times and then four more.

    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.
    +
    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 @@ -459,9 +404,8 @@ and sums the even ones.

    PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec
    -
    -

    Even-valued Fibonacci Terms

    +

    Even-valued Fibonacci Terms

    Using o for odd and e for even:

    o + o = e
     e + e = e
    @@ -507,9 +451,44 @@ and sums the even ones.

    -

    How to compile these?

    +

    How to compile these?

    You would probably start with a special version of G, and perhaps modifications to the default x?

    +
    +
    +

    An Interesting Variation

    +
    define('codireco == cons dip rest cons')
    +
    +
    +
    V('[0 [dup ++] codireco] x')
    +
    +
    +
                                     . [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] .
    +
    +
    +
    define('G == [codireco] cons cons')
    +
    +
    +
    J('230 [dup ++] G 5 [x] times pop')
    +
    +
    +
    230 231 232 233 234
    +
    +
    +
    @@ -522,30 +501,35 @@ modifications to the default
  • Using x to Generate Values -
  • -
  • Generating Generators diff --git a/docs/sphinx_docs/_build/html/notebooks/index.html b/docs/sphinx_docs/_build/html/notebooks/index.html index 84ee6af..d6eeb83 100644 --- a/docs/sphinx_docs/_build/html/notebooks/index.html +++ b/docs/sphinx_docs/_build/html/notebooks/index.html @@ -73,6 +73,17 @@
  • Putting it together
  • +
  • Using x to Generate Values +
  • Newton’s method
    • A Generator for Approximations
    • Finding Consecutive Approximations within a Tolerance
    • diff --git a/docs/sphinx_docs/_build/html/searchindex.js b/docs/sphinx_docs/_build/html/searchindex.js index cde5b78..f42664a 100644 --- a/docs/sphinx_docs/_build/html/searchindex.js +++ b/docs/sphinx_docs/_build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["index","joy","lib","library","notebooks/Advent of Code 2017 December 1st","notebooks/Advent of Code 2017 December 2nd","notebooks/Advent of Code 2017 December 3rd","notebooks/Advent of Code 2017 December 4th","notebooks/Advent of Code 2017 December 5th","notebooks/Advent of Code 2017 December 6th","notebooks/Categorical","notebooks/Developing","notebooks/Generator Programs","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Replacing","notebooks/Trees","notebooks/Treestep","notebooks/Zipper","notebooks/index","parser","pretty","stack"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Advent of Code 2017 December 1st.rst","notebooks/Advent of Code 2017 December 2nd.rst","notebooks/Advent of Code 2017 December 3rd.rst","notebooks/Advent of Code 2017 December 4th.rst","notebooks/Advent of Code 2017 December 5th.rst","notebooks/Advent of Code 2017 December 6th.rst","notebooks/Categorical.rst","notebooks/Developing.rst","notebooks/Generator Programs.rst","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Replacing.rst","notebooks/Trees.rst","notebooks/Treestep.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst"],objects:{"joy.joy":{joy:[1,1,1,""],repl:[1,1,1,""],run:[1,1,1,""]},"joy.library":{"void":[3,1,1,""],BinaryBuiltinWrapper:[3,1,1,""],DefinitionWrapper:[3,2,1,""],FunctionWrapper:[3,1,1,""],SimpleFunctionWrapper:[3,1,1,""],UnaryBuiltinWrapper:[3,1,1,""],add_aliases:[3,1,1,""],app1:[3,1,1,""],app2:[3,1,1,""],app3:[3,1,1,""],b:[3,1,1,""],branch:[3,1,1,""],choice:[3,1,1,""],clear:[3,1,1,""],cmp_:[3,1,1,""],concat:[3,1,1,""],cond:[3,1,1,""],cons:[3,1,1,""],dip:[3,1,1,""],dipd:[3,1,1,""],dipdd:[3,1,1,""],divmod_:[3,1,1,""],drop:[3,1,1,""],dup:[3,1,1,""],dupd:[3,1,1,""],dupdip:[3,1,1,""],first:[3,1,1,""],floor:[3,1,1,""],genrec:[3,1,1,""],getitem:[3,1,1,""],help_:[3,1,1,""],i:[3,1,1,""],id_:[3,1,1,""],ifte:[3,1,1,""],infra:[3,1,1,""],initialize:[3,1,1,""],inscribe:[3,1,1,""],loop:[3,1,1,""],map_:[3,1,1,""],max_:[3,1,1,""],min_:[3,1,1,""],over:[3,1,1,""],parse:[3,1,1,""],pm:[3,1,1,""],pop:[3,1,1,""],popd:[3,1,1,""],popdd:[3,1,1,""],popop:[3,1,1,""],pred:[3,1,1,""],remove:[3,1,1,""],rest:[3,1,1,""],reverse:[3,1,1,""],rolldown:[3,1,1,""],rollup:[3,1,1,""],select:[3,1,1,""],sharing:[3,1,1,""],shunt:[3,1,1,""],sort_:[3,1,1,""],sqrt:[3,1,1,""],stack_:[3,1,1,""],step:[3,1,1,""],succ:[3,1,1,""],sum_:[3,1,1,""],swaack:[3,1,1,""],swap:[3,1,1,""],take:[3,1,1,""],times:[3,1,1,""],tuck:[3,1,1,""],uncons:[3,1,1,""],unique:[3,1,1,""],unstack:[3,1,1,""],warranty:[3,1,1,""],words:[3,1,1,""],x:[3,1,1,""],zip_:[3,1,1,""]},"joy.library.DefinitionWrapper":{add_def:[3,3,1,""],add_definitions:[3,3,1,""],parse_definition:[3,3,1,""]},"joy.parser":{ParseError:[24,4,1,""],Symbol:[24,2,1,""],text_to_expression:[24,1,1,""]},"joy.utils":{pretty_print:[25,0,0,"-"],stack:[26,0,0,"-"]},"joy.utils.pretty_print":{TracePrinter:[25,2,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[25,5,1,""],viewer:[25,5,1,""]},"joy.utils.stack":{expression_to_string:[26,1,1,""],iter_stack:[26,1,1,""],list_to_stack:[26,1,1,""],pick:[26,1,1,""],pushback:[26,1,1,""],stack_to_string:[26,1,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[24,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","classmethod","Python class method"],"4":["py","exception","Python exception"],"5":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:classmethod","4":"py:exception","5":"py:method"},terms:{"0b11100111011011":11,"10m":13,"10n":13,"4ac":18,"5bkei":[17,20],"\u03b5":15,"abstract":[14,17,20],"boolean":[2,3,14,17,20],"break":[9,14],"byte":11,"case":[2,3,5,9,13,21,26],"class":[3,14,24,25,26],"default":[3,8,12,17,26],"export":[3,24],"final":[2,6,13,17],"float":[3,14,22,24],"function":[0,1,4,5,6,7,8,10,11,12,16,22,23,24,25,26],"g\u00e9rard":22,"import":[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],"int":[6,12,13,14,22,24,26],"long":[17,23],"new":[2,3,6,12,13,14,15,16,19,20],"public":16,"return":[1,3,5,6,8,9,11,13,14,15,17,18,19,20,21,24,25,26],"short":18,"static":[2,16],"switch":2,"throw":17,"true":[2,3,5,6,11,13,20],"try":[6,12,13,21],"void":[0,3],"while":[3,6,8,9,14,17,20,24,26],Adding:[14,23],And:[4,6,11,12,13,15,17,20,22,26],But:[0,5,10,11,13,14,17,19,20],CPS:14,For:[2,3,4,5,6,7,8,12,13,17,20,23,26],Going:5,Has:3,Its:3,Not:6,One:[2,14],RHS:20,TOS:[2,3,13],That:[11,13,17,20],The:[0,1,2,3,4,5,6,7,8,10,12,15,16,18,22,23,24,26],Then:[2,3,5,8,17,18,20],There:[6,8,13,20,21,26],These:[23,26],Use:[3,13,15],Using:[6,13,15,17,20],With:[4,13,15,23],__str__:25,_tree_add_:17,_tree_add_e:17,_tree_add_p:17,_tree_add_r:17,_tree_add_t:17,_tree_delete_:17,_tree_delete_clear_stuff:17,_tree_delete_del:17,_tree_delete_r0:17,_tree_delete_r1:17,_tree_delete_rightmost:17,_tree_delete_w:17,_tree_get_:17,_tree_get_p:17,_tree_get_r:17,_tree_get_t:17,_tree_iter_order_curr:17,_tree_iter_order_left:17,_tree_iter_order_r:17,_tree_iter_order_right:17,_tree_t:17,_treestep_0:21,_treestep_1:21,_within_b:15,_within_p:15,_within_r:15,aaa:7,abbrevi:[20,21],abl:18,about:[0,6,8,14,17,20,22,26],abov:[0,6,11,15,17,18,20],abs:[6,15],absolut:[6,14],accept:[1,2,3,11,13,14,15,17,20,21,22],access:[6,8],accomplish:18,accordingli:[17,20],accumul:11,across:[6,8],act:15,action:[14,22],actual:[2,6,11,14,17,20],adapt:23,add:[3,4,5,6,11,12,14,18,25],add_alias:3,add_def:3,add_definit:[3,8,13,17,20,21],add_if_match:4,add_valu:8,added:[10,17,20],adding:[6,16],addit:[0,2,3,8,11,13,14,20,21],adjust:17,admit:6,advantag:13,after:[4,6,8,11,12,14],afterward:14,again:[2,3,6,8,11,14,15,17,20],against:[5,6],aggreg:[3,22],aka:[14,22],albrecht:0,algebra:20,algorithm:14,alia:3,alias:[3,14],align:[14,25],all:[3,4,5,11,12,13,14,17,20,21,25],alloc:6,allow:[13,16,17,20],almost:[17,20],along:[13,14,18],alphabet:3,alreadi:[6,15,19,22],also:[0,11,13,14,17,20,26],altern:[10,20],although:[4,10,17,20],altogeth:12,alwai:[6,11,13,16],amort:[17,20],amount:6,analysi:[10,23],anamorph:14,ani:[8,10,11,14,16,17,20,22,24],annual:14,anonym:[17,20],anoth:[4,13,17,20,26],answer:6,anyth:[2,3,14],aoc20017:5,aoc20173:6,aoc2017:[4,5,6,7,8,9],api:16,app1:3,app2:[3,5,14,18,19],app3:3,app:14,appear:[2,7,10,11,17,20],append:8,appendix:23,appli:[2,3,5,11,17,20],applic:12,approach:[11,18],approxim:23,archiv:0,aren:22,arg:[2,3],argument:[2,3,12,13,14,15,25,26],arithmet:2,ariti:2,around:[11,26],arrai:8,arrang:[8,21],arriv:[12,20,21],articl:[0,10],ask:[6,10,12],aspect:[0,6],assembl:8,assert:[6,9],assign:26,associ:[17,20],assum:[4,5,7,8,15],asterisk:[20,21],attack:14,attempt:[0,1],attribut:3,automat:[10,13],auxiliari:21,avail:[0,7],averag:[14,19],avoid:[17,20],awai:17,awar:2,awkward:[17,20],azur:23,back:[6,8,17,20],backward:[16,17,20,21],bag:14,banana:[13,20],bank:9,barb:13,base:[0,2,3,5,9,13,16,21],basic:[1,2,3,4,6,14,17,20],bear:8,beat:8,becaus:[2,3,4,5,6,8,13,14,17,20,21,22,26],becom:[4,17,18,20,21,26],been:[13,15,16,17,20,22],befor:[5,8,12,13,14,17,20],begin:[6,13,17,20,21],behavior:[16,20,21],behaviour:[0,1],behind:8,being:0,belong:8,below:[2,3,6,11,12,17,20,22],bespok:14,best:0,better:[6,11,12,17,20],between:[0,5,6,11],biannual:14,big:[6,8,20],binari:[0,12,14,20,23],binary_search_tre:[17,20],binarybuiltinwrapp:3,bind:14,bingo:22,bit:[6,11,12,17,20],block:[9,11],bodi:[2,14,17,20],body_text:3,bool:[5,13],borrow:14,both:[2,6,8,11,13,14,18,19,20,26],bottom:12,boundari:6,bracket:[6,14,24],branch:[3,4,5,8,11,12,20],breakpoint:14,bring:[11,14],btree:[17,21],buck:[17,20],bug:[0,14],build:[13,14,20,22,26],built:[13,18],bundl:[2,3],burgeon:14,calcul:6,calculu:10,call:[2,13,14,15,16,17,18,20,25,26],caller:[17,20],came:[8,20],can:[0,2,3,4,5,6,10,11,12,13,14,15,16,18,19,21,22,23,26],candid:5,captur:14,card:14,care:[6,11,26],carefulli:[20,22],carri:[4,6,13,17],cartesian:10,categor:[0,18,23],categori:10,ccc:10,ccon:[17,20],ceil:6,certain:[14,26],certainli:[17,20],chain:3,chang:[2,6,8,16,17,20,22],charact:22,chat:14,chatter:0,cheat:9,check:[5,12,13],checksum:5,child0:20,child:21,childn:20,children:20,choic:[3,13],choos:[16,20],cinf:17,circuit:10,circular:[4,20],cite_not:[17,20],classmethod:3,clear:[3,6,11,14],clear_stuff:17,cleav:[4,5,7,14,18,19],close:[0,1,10],clunki:11,cmp:[3,21,23],cmp_:[3,20],code:[0,1,10,13,20,23],collaps:13,collect:[10,12,14],column:6,combin:[0,3,7,11,12,14,15,18,21,22,23],come:[6,8,14,17],command:[4,14,17,18,20],common:[2,11,13],compar:[3,6,10],comparison:[0,17],compel:10,compil:[2,8,10,13,14,17,19],complet:10,complex:[3,22],compos:13,compound:[17,20],comput:[2,5,6,8,10,11,14,18],con:[3,5,8,9,11,12,13,14,15,17,18,21,22,26],conal:10,concat:[3,4,12,13,14,20,21],concaten:0,concatin:[0,3,26],concis:6,concret:13,concurr:2,cond:[3,17],condit:[8,14],condition:5,confid:6,conflict:[17,20],cons2:20,consecut:[12,23],consid:[8,11,12,13,17,20,21,22],consist:[2,6,14,20,21],constant:[17,20],constitu:13,consum:[5,13],contain:[0,2,3,6,7,12,13,14],context:2,conting:17,continu:[0,5,13,22],control:14,conveni:10,convert:[13,19,20,21,24,26],cook:13,cool:[17,20],copi:[2,3,4,11,13,17,20,21,23],copyright:14,corner:6,correct:6,correctli:20,correspond:10,could:[2,6,8,10,11,13,14,16,17,20,22],count:[3,6,7,12],count_stat:9,counter:11,coupl:21,cours:[6,8,11,13,17,20],cover:6,cpu:6,crack:[17,20],crap:[],crash:[17,20],creat:[0,2,3,4,11,12,13,15,17,20],crude:[17,20,24],current:[2,3,8,13,14,21,22,25],custom:16,cycl:[11,12],cython:14,dai:[13,14],data:[2,3,6],datastructur:[0,2,13,22,23,24,26],datatyp:26,ddididi:22,deal:[0,4,17,20],debugg:13,decid:[17,20],decor:3,decoupl:13,decreas:6,decrement:3,deduc:11,deeper:0,deepli:10,def:[3,6,8,9,13,14,18,19,20,26],defi:3,defin:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23],definit:[2,3,7,8,11,12,13,14,15,16,17,20,21,23],definitionwrapp:[3,8,13,17,20,21],deleg:14,delet:23,demonstr:[10,13],depend:[3,13,17,20],deposit:[20,21],dequot:[4,13],der:17,deriv:[2,3,4,5,11,14,15,17,23],descend:5,describ:[3,10,13,17,20,21,24],descript:[11,14,20],design:[2,3,5,17,20],desir:[6,14,20,21],destruct:[17,20],detail:[6,14,17,20],detect:[5,12,13,17,20],determin:[5,6],develop:[0,12,14,23],diagram:11,dialect:1,dict:[1,3],dictionari:[0,1,3,14,15,18,20,23],did:6,didn:13,differ:[0,5,7,10,11,13,15,17,18,20,26],differenti:10,dig:[17,22],digit:[4,11],dimension:6,dinfrirst:14,dip:[3,5,6,8,9,11,12,13,14,15,17,18,19,20,21],dipd:[3,8,12,13,14,17,18,20,22],dipdd:[3,17,20],direco:[9,15],direct:14,directli:[6,11,20,21,26],disappear:2,discard:[3,12,13,15,17,20],disciplin:17,discov:5,disenstacken:[14,20],disk:14,displac:2,distanc:6,distribut:9,ditch:[17,20],div:[3,14],dive:[20,21],divid:5,divis:[5,17,20],divisor:5,divmod:[3,5],divmod_:3,doc:[2,3,14],document:[23,24,26],doe:[0,1,5,6,8,10,13,14,23,25],doesn:[4,8,11,13,16,17,20,21,26],dog:20,doing:[6,10,11,13,14,22],domain:[6,10],don:[5,6,8,11,14,17,20],done:[2,11,12,14,16],doodl:6,door:14,dot:25,doubl:[11,14],down:[2,3,6,8,15,22],down_to_zero:14,downward:8,dozen:14,draft:[9,10,16],dream:14,drive:12,driven:[11,15],driver:12,drop:[3,4,17,20],dudipd:14,due:4,dummi:5,dup:[3,4,5,6,8,9,11,12,13,14,15,17,18,20,22,26],dupd:3,dupdip:[3,5,6,11,13,17,18,20],duplic:[3,7,13,17,20],durat:2,dure:[2,13],each:[2,3,4,5,6,8,10,11,13,14,19,20,21,25],easi:[0,6,17,20,21,22],easier:[3,4,17,20],easili:10,edit:23,effect:[2,3,14,22],effici:[6,8,19,22],either:[1,2,3,5,13,17,20],eleg:[8,14,17,18,20],element:[2,3],elliott:10,els:[2,3,4,5,8,9,13],embed:[10,17,20,22],empti:[3,5,14,21,26],encapsul:14,enclos:14,encod:[8,12],encount:8,end:[6,8,11,13,17,21,26],endless:12,enforc:[2,14],engend:14,enlarg:6,enough:[6,13,14,18,25],enstacken:[12,14],ensur:7,enter:14,entir:26,entri:[3,22,25],epsilon:15,equal:[11,21,26],equat:[6,14,15],ergo:[6,13,17,20],err:[17,20],error:[6,14,24],escap:8,essai:0,etc:[3,6,21,22,24],euler:23,eval:0,evalu:[1,2,3,4,13,14,15,17,18,19,20,21],even:8,evenli:5,eventu:[6,18],everi:12,everyth:[3,17,20],evolv:16,exactli:13,exampl:[0,3,4,5,6,7,8,11,12,13,15,20,23,24,26],exce:12,except:[14,17,20,24],execut:[0,1,2,3,5,14,19,21,22,26],exercis:17,exist:[10,17],exit:8,expand:17,expect:[2,3,5,13,20,21,26],experi:[14,21],experiment:6,explan:14,explor:14,express:[0,1,2,3,10,13,17,19,20,22,25,26],expression_to_str:26,extend:6,extra:[4,5,11],extract:[17,23],extrem:14,extrememli:14,facet:0,facil:14,fact:[20,24],factor:[2,11,14,17],fail:[2,3,5,17,20,24],fals:[2,3,5,9,11,13],far:[8,13,15,17,20],fascin:0,fast:6,faster:6,favorit:18,fear:[17,20],feel:6,few:[6,11,14],fewer:[3,14],fib:12,fib_gen:12,figur:[2,3,6,17,20],filter:[17,20],fin:11,find:[2,3,4,5,11,12,20,21,23],finder:15,fine:[0,11,17,20],finish:18,first:[3,4,5,6,8,9,12,13,14,15,17,18,19,20,21,22,23],first_two:17,fit:[11,14,18],five:[11,13,14],fix:[2,3],flag:5,flatten:[14,20,21],flexibl:[20,23],floor:[3,6],floordiv:11,flow:14,follow:[0,2,3,5,8,13,14,15,16,21,22],foo:[14,16,17,20],foo_ii:16,form:[2,3,5,7,10,11,12,21,26],forman:14,format:[23,25],formula:[0,6,11,23],forth:[4,8,14,20],fortun:8,forum:0,forward:[5,8],found:[8,9,14,20],four:[2,3,6,8,11,12,14,17,20],fourteen:11,fourth:[2,3,4,17,20],fractal:14,fraction0:14,fraction:[2,14],framework:14,free:[10,14,17,20],freeli:[2,6],from:[0,1,2,3,4,5,6,7,8,9,11,12,14,15,17,18,19,20,21,22,23,26],front:[2,3],full:[7,11],fun:6,functionwrapp:[3,20],funtion:[17,20],further:[15,23],futur:18,garbag:14,gari:[17,20],gcd:14,gen:9,gener:[2,3,6,8,10,23,26],genrec:[3,5,8,13,14,17,20,21],geometr:11,geometri:20,get:[2,5,6,10,11,12,13,14,23],get_valu:8,getitem:3,getrecursionlimit:26,getsourc:14,ghc:10,give:[6,10,11,13,15,17,21,26],given:[2,3,4,5,6,8,9,11,12,15,17,22,23],glue:14,goal:8,going:[5,6,8,17,20,21,22],good:[8,11,17,20],grab:3,grammar:24,grand:14,graph:6,great:[0,4,6,14,23],greater:[6,26],grid:6,group:[0,6],gsra:15,guard:[5,6,17],had:[11,22],haiku:14,half:[11,22],half_of_s:4,halfwai:4,hand:[14,18,19,20,23],handi:15,handl:[17,26],happen:[6,14,20],hard:22,hardli:13,hardwar:10,has:[0,2,5,6,8,12,13,14,15,16,17,20,22,26],haskel:10,have:[2,3,4,5,6,8,9,11,12,13,14,15,16,20,22,23,26],head:[5,13,26],help:[7,13,14,17,20],help_:3,helper:[3,5],herd:14,here:[6,11,12,13,17,18,20,21,22],heterogen:20,heurist:[4,8],hide:[17,20],higher:[14,17,20],highest:[5,20],highli:[14,20],hindsight:5,histori:25,hmm:[17,20],hog:20,hoist:3,hold:11,hood:[8,17],hope:[0,11,14,23],host:23,how:[0,6,7,8,10,13,17,20,22],html:[2,3,12,18,23],http:[17,20],huet:22,huge:17,hugh:[15,20,21],human:14,hypothet:2,id_:3,idea:[10,11,14,20],ident:[3,13],identifi:6,if_not_empti:17,ift:[3,4,5,8,13,17,20,21],ignor:[3,17,20],illustr:13,imagin:22,imit:21,immedi:[8,13],immut:[14,17,20],imper:13,implement:[0,1,2,3,6,9,10,13,14,16,17,18,20],impli:5,implicit:14,includ:[7,10,17,21],inclus:11,incom:26,incompat:16,incr_at:8,incr_step_count:8,incr_valu:8,increas:[6,8,11],increment:[3,10,11,16],index:[0,6,9,14,26],index_of:9,indexerror:26,indic:[20,21],infil:20,infinit:6,inform:3,infra:[3,12,13,14,17,18,19,21],infrastructur:3,init:8,init_print:6,initi:[2,3,5,6,7,8,14,15,17,20],inlin:[17,20],inner:5,input:[1,4,5,6,7,13,15],inscrib:3,inspect:14,instal:0,instanti:[10,25],instead:[6,11,12,13,17,20,22,26],instruct:8,integ:[2,3,4,5,6,7,8,12,13,14,21],integr:3,intend:[0,14],interact:[14,23],interest:[0,6,11,12,17,20],interlock:6,interlud:23,intermedi:13,intern:[0,25,26],interpret:[0,10,13,16,24,25],interrupt:14,interv:[10,11],introduc:16,introduct:0,invari:3,invers:3,investig:18,ipf:14,ipynb:12,isn:[13,17,22],item:[2,3,4,5,9,13,14,17,20,21,26],iter:[1,3,6,13,14,21,23,26],iter_stack:[9,19,26],its:[0,2,3,5,6,10,11,13,14,17,20,21,26],itself:[0,2,8,14,17,20],j05cmp:[2,3],jenni:20,job:[8,23],john:[15,20,21],joi:[2,4,5,7,8,9,10,15,16,17,18,19,20],joypi:[8,9,13,14,20,22],jump:8,jupyt:23,just:[0,2,3,4,5,6,8,12,13,14,16,17,21,22],keep:[17,22],kei:[21,23],kevin:0,key_n:[17,20],keyerror:[17,20],kind:[2,6,8,10,13,14,17,20,21],kleen:[20,21],know:[6,11,13,17,20],known:10,l_kei:17,l_left:17,l_right:17,l_valu:17,labda:[],lambda:[10,13],lambdifi:6,languag:[10,14,16,17,18,20],larg:6,larger:[6,26],largest:[3,5,8],last:[4,8,11,13,17],lastli:[12,13],later:[8,14,21],law:2,lazi:15,lazili:15,lcm:11,lead:[8,14],leaf:[17,20],lean:14,learn:[0,9],least:[2,6,8,11,13,26],least_fract:14,leav:[5,6,8,11,12,20],left:[6,12,13,14,21,22,25,26],leftov:13,legendari:8,legibl:8,len:9,length:[3,11,26],lens:13,less:[11,12,13,14,26],lesser:6,let:[4,5,6,8,12,13,15,17,18,20,21,22],level:[10,17,20],librari:[0,6,8,9,15,18,19,20],lieu:20,like:[2,3,5,6,9,11,13,14,15,18,21,23,24],line:[3,5,8,13,14,17,20,25],linear:26,link:0,linux:0,list:[0,3,4,5,7,8,9,11,14,15,17,21,22,25],list_to_stack:[8,9,26],liter:[1,17,20,21,22,24],littl:[6,8,17,20,23],live:23,lkei:[20,21],load:[11,14],locat:[2,6],locu:25,log_2:[17,20],logic:[0,11],longer:[17,20],look:[6,12,14,15,17,20],lookup:[14,20],loop:[0,1,3,11],lot:[14,17,18,20,22],love:11,low:10,lower:[11,20],lowest:[5,17,20],machin:[0,20],machineri:[17,20],macro:14,made:[0,5,14,20,22],mai:[2,8,13,20],mail:0,main:[0,3,4,14,22],mainloop:16,maintain:22,major:16,make:[2,3,4,10,11,13,14,17,19,21,22],make_distributor:9,make_gener:15,manfr:[0,2,3,10],manhattan:6,mani:[0,6,7,8,12,13,14],manipul:6,manual:[6,13],map:[1,3,11,13,14,16,18,20,21],map_:3,mark:[6,8],marker:14,mask:[11,12],match:[0,1,4],materi:0,math:[0,6,8,14,17,20],mathemat:[6,14],matter:[4,11,13,15,17,20,21],max:[5,6,9],max_:3,maximum:[3,20],maxmin:5,mayb:[13,17,20],maze:8,mean:[5,10,11,13,14,15,17,20,21,26],meant:[13,14,17,18,20,21],meantim:8,mem:8,member:[2,3,6],memori:6,mental:14,mention:2,mercuri:0,merg:20,meta:[14,17,20],methink:20,method:[0,3,6,14,23,25],mfloor:6,midpoint:11,might:[4,10,12,13,17,20],mike:17,million:12,min:5,min_:3,mind:8,minimum:3,minor:17,minu:[3,18],mirror:0,miscellan:0,mistak:9,mix:14,mnemon:4,mod:3,model:[10,14],modern:0,modif:12,modifi:[8,14,17,22],modul:[0,1,3,14,24],modulu:14,monkei:6,month:14,more:[0,3,7,8,10,11,12,13,14,15,18,19,20,21,24,26],most:20,mostli:0,move:[4,6,8,17],movement:2,mrank_of:6,much:[6,8,11,13,17,20],muck:[17,20],mul:[14,18,22,25],multi:3,multipl:[13,23],must:[2,3,5,6,7,11,13,16,21],mutabl:8,n_rang:12,nail:8,name:[1,3,4,14,16,17,22,23,24,26],natur:[11,12,17,20],navig:22,neat:17,need:[2,3,4,5,6,8,9,11,12,13,15,16,17,20],neg:[3,8,18],nest:[14,17,20,22],network:14,never:16,new_kei:17,new_valu:17,newton:[0,23],next:[4,5,6,8,11,13,20,21],nice:[0,4,6,13,26],niether:2,node:[21,23],node_kei:[17,20],node_valu:[17,20],non:[5,20,21],none:[1,3],nope:21,normal:[7,13],notat:[14,17,20],note:[2,6,11,15,17,20,26],notebook:[11,14,22,23],notebook_preambl:[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],noth:[2,17,20],notic:11,now:[4,5,6,11,12,13,14,19,21,23],nth:[3,26],nullari:[5,8,9,14,17,20],number:[1,2,3,5,11,12,26],object:24,observ:11,obviou:12,obvious:[5,7,8],occur:[17,20],odd:[11,12],off:[2,3,6,11,12,22],offset:8,offset_of:6,old:[2,19],old_k:17,old_kei:17,old_valu:17,omit:13,onc:[3,7,16,17,18,20],one:[2,3,4,5,6,7,8,11,12,13,17,18,20,21,25,26],ones:12,onli:[2,3,4,5,6,8,11,13,17,20,22,26],onto:[1,2,3,14,26],open:[7,14],oper:[3,5,13,14,17,20,26],oppos:4,optim:17,option:[1,14,17,20,26],order:[0,2,3,4,5,13,14,23,26],org:[0,17,20],origin:[0,1,2,3,4,17,20,22],other:[0,2,3,5,6,10,13,14,17,20,21,26],otherwis:[3,5,11,12,17,20,21],our:[4,5,6,11,12,13,14,15,21],ourselv:13,out:[2,3,6,10,11,12,13,14,17,20,22],outcom:[20,21],output:[6,13,15],outsid:[8,10],outward:6,over:[3,4,6,10,11,12,14,15,17,18,20,21,23],overhead:6,overkil:13,overshadow:6,own:[6,17,20],pack:[20,26],packag:[0,14],page:[0,17,18,20,26],pair:[2,3,4,5,11,12,17],pair_up:4,palidrom:11,palindrom:11,pam:[14,18],paper:[6,10,13,14,20,22],parallel:2,paramet:[1,2,3,8,13,24,25,26],parameter:23,paranthes:20,parenthes:[8,17,20,26],pariti:12,pars:[0,3,14,20],parse_definit:3,parseerror:24,parser:0,part:[2,3,5,8,13,15,18,20,21],partial:[6,13],particular:22,particularli:8,pass:[0,17,20,25],passphras:7,path:6,pattern:[6,11,20,21],payoff:13,pe1:[11,12],pe2:12,pearl:22,pend:[3,13,14,22,25],peopl:23,per:[6,14,21],perform:8,perhap:12,period:14,permit:[8,26],persist:[17,20],phase:2,pick:[11,12,26],pickl:14,pictur:[17,20],piec:13,pip:0,pita:9,place:[3,6,8,11,13,14],plai:0,plain:8,plane:6,plu:[3,6,18],plug:[12,13,20,21],point:[6,10,13,14,17,20],pointless:2,pop:[3,4,5,8,9,11,12,13,14,17,18,19,20,21,26],popd:[3,8,14,15,17,19],popdd:[3,5,12,18],popop:[3,4,5,8,9,11,12,13,14,15,17,20,21],port:6,posit:[3,8,11,13,14],possibilit:[17,20],possibl:[5,17,20,21,23],post:[14,20],potenti:3,power:14,pragmat:11,pre:[8,13,20],preambl:15,precis:[0,1],pred:3,predic:[2,5,12,13],prefer:13,prefix:[13,25],prep:[5,20],prepar:[8,13],preprocessor:13,present:20,preserv:[10,21],pretti:[6,17,18,20,21,25,26],pretty_print:0,prevent:13,previou:[6,8,14],prime:[5,15],primit:[2,3,8,18],primrec:[3,5,8,9,12,13,14,15],print:[0,1,2,3,6,13,25,26],probabl:[4,12,14,17,20],problem:[6,14,23],proc_curr:[17,20],proc_left:[17,20],proc_right:[17,20],proce:[4,11],process:[8,13,14,21,25],processor:20,produc:[4,11,13,17,20,21],product:14,program:[0,2,3,4,5,6,8,12,14,15,17,22],project:23,prompt:14,proper:[2,3],properli:8,properti:0,provid:[0,3,10,14],prune:20,pun:[0,14],pure:[0,20],puriti:14,purpos:14,push:[2,3,13,14,22,26],pushback:[14,20,26],put:[1,2,12,14,23,26],puzzl:[4,5,6,7],pypi:0,pyramid:6,python:[0,2,3,6,8,13,17,18,20,22,23,24,26],quadrat:[0,6,23],queri:[17,20,21],query_kei:21,queu:13,quit:[0,1,6,21],quot:[0,3,12,13,14,15,17,18,20,21,22,25],quotat:[2,3],quotient:3,r_kei:17,r_left:17,r_right:17,r_valu:17,rais:[17,20,24,26],random:8,rang:[6,13,14],range_sum:13,range_to_zero:14,rank_and_offset:6,rank_of:6,raphson:15,rather:[11,13,14,20,21],ratio:14,reach:[8,11,12,13],read:[0,1,11,12,17,20,22],readabl:19,reader:17,real:[17,20],realiz:[4,8,10,17,20],realli:6,rearrang:[2,13,17],reason:[6,11,14],rebuild:[21,22],rec1:[2,3],rec2:[2,3],recogn:24,record:[14,25],recur:13,recurs:[2,3,5,8,9,12,14,15,23,26],recus:14,recusr:20,redefin:23,redistribut:[3,14],reduc:2,redund:26,reexamin:20,refactor:[13,14,16],refer:[0,2],regist:2,regular:24,reimplement:23,rel:[8,18],releas:16,relev:6,remain:[2,3,14,16],remaind:[3,15],remind:13,remov:[3,6,17,20,26],renam:20,render:[20,23],repeat:[4,6,11],repeatedli:11,repl:[0,1],replac:[0,2,3,12,13,20,21,22,23,26],repositori:0,repres:[2,14,17,20,24,25],represent:26,reprod:12,request:6,requir:[6,26],resembl:14,respect:11,rest:[3,5,9,11,12,14,17,20,22,23,26],rest_two:17,restor:2,result:[1,2,3,5,11,12,13,17,18,20,21,22],resum:14,retir:2,retri:14,reus:[17,20],revers:[3,4,5,11,12,13,22,26],rewrit:[3,8,14],rewritten:14,richard:20,rid:[17,20],right:[6,12,13,14,21,25,26],rightest:17,rightmost:11,rkei:[20,21],role:20,roll:[3,5,7,8,13,15,17,18,20,21],rolldown:3,rollup:3,root:[3,6,18,23],rotate_seq:4,round:4,row:[5,6],row_valu:6,run:[0,1,3,6,11,13,14,15,17,20,21,22],runtim:6,runtimeerror:26,sai:[17,20,21],same:[2,10,11,13,17,20,26],sandwich:[2,3],save:[2,11,14],scan:3,scanner:[14,24],scenario:22,scheme:[18,20],scope:[4,17,20],search:[0,6,17,20],second:[3,4,5,13,14,17,20,21,26],secur:7,see:[0,6,12,13,14,16,19,20,22,25],seem:[0,9,11,14,20,21],seen:22,select:[3,6],semant:[2,3,14,16,17,20],semi:14,send:14,sens:[0,2,11,22],separ:14,sequenc:[0,1,2,3,4,5,7,8,9,11,14,17,19,20,22,24],seri:[6,11,12,13,17,20,22],serv:13,set:[2,3,13,23],seven:[11,12],sever:[0,10,14],share:[3,6,14],shelf:2,shift:[11,12],shine:8,shorter:23,shortest:6,shorthand:17,should:[2,5,11,13,17,20],shouldn:14,show:[6,10,20,22],shunt:[3,22],side:[17,20],sign:6,signal:5,signifi:[14,17,20],silli:20,similar:[17,20,21],simon:14,simpl:[6,13,14,26],simplefunctionwrapp:[3,8,9,18,19],simpler:21,simplest:23,simpli:10,simplifi:[6,11,17,20,22],sinc:[2,6,11,17,18,20],singl:[3,12,14,19,24],situ:[17,20],situat:[17,20],six:[11,12,14],sixti:[11,12],size:[4,7,8,9,14,23],skeptic:14,skip:[6,8],slight:15,slightli:[13,17,20],small:[4,20],smallest:[3,5],smart:[8,13,17],sneaki:6,softwar:14,solei:2,solut:[6,11],solv:6,solvabl:14,some:[2,3,5,6,8,12,13,14,17,20,21,23,26],somehow:[17,20],someth:[2,4,8,16,17],sometim:[17,20],somewher:[13,17,20,23],sophist:6,sort:[3,5,13,17,18,20],sort_:3,sourc:[0,1,3,23,24,25,26],space:[6,11,25],span:11,special:[12,13,17,20],specif:[0,10],specifi:17,speed:[6,8,19],spell:21,sphinx:[23,26],spiral:6,spirit:[0,1,20,21],split_at:4,spreadsheet:5,sqr:[14,18,22],sqrt:[3,6,15,18],squar:[3,6,23,24],stack:[0,1,3,5,8,9,11,12,13,15,17,18,19,20,21,22,24,25],stack_:3,stack_to_str:26,stage:[20,21],stai:[0,1],stand:10,standard:[14,17],star:[20,21],stare:[17,20],start:[5,6,8,9,11,12,13,14,15,17,18,20,21],state:[5,8,14],statement:3,step:[3,4,5,6,7,11,14,17,18,19,20,22,23],step_zero:[4,5,7],still:[6,8,13,17],stop:[17,20],storag:[11,13,17,20],store:[6,11,13],stori:13,str:[1,24,25,26],straightforward:[1,4,6,12],strang:8,stream:[11,15],stretch:17,string:[1,2,3,4,14,22,24,25,26],strip:6,structur:[13,14,20,21,22,23,26],stuff:[17,20],style:[0,10],sub:[16,20],subclass:14,subject:22,subract:6,substitut:[6,13,17],subtract:[5,6,11],succ:3,success:15,suffici:[8,13,17],suggest:[5,10,17,20],suitabl:[3,10,11],sum:[3,4,5,12,13,14,18,19,20,21],sum_:3,summand:11,sumtre:21,suppli:[13,17,20,24],support:[6,14,25,26],sure:[6,13],suspect:2,swaack:[3,13,18,19,20,22],swap:[3,4,5,6,7,9,11,12,13,14,15,17,19,20,21,22],swon:[3,9,12,13,14,20,21,22],swoncat:[8,9,12,13,14,15,20,21],symbol:[2,3,6,18,22,24],symmetr:[11,17,20],sympi:18,syntact:14,syntax:[14,26],sys:[6,26],system:[6,7,14,17,20],tail:[5,17,20,26],take:[3,4,6,8,11,12,14,15,17,18,20,26],taken:8,talk:[14,17,20,26],target:[6,22],task:6,tast:10,tbd:14,technic:2,techniqu:[10,22],technolog:2,teh:20,temporari:22,ten:11,term:[1,2,5,8,9,13,14,15,23,24,26],termin:[2,3,5],ternari:14,test:[2,3],text:[0,1,3],text_to_express:[14,24],textual:14,than:[0,3,6,7,11,12,14,15,18,21,26],thei:[2,5,6,11,12,13,14,17,20,22,24,26],them:[2,3,5,6,11,12,13,17,20,22,23],theori:[2,3],therefor:[12,20],thi:[0,1,2,3,4,5,6,8,9,10,11,12,13,14,18,21,22,23,24,25,26],thing:[2,5,6,8,12,13,17,18,20,22,24,26],think:[2,8,11,13,14,17,20,21],third:[3,4,5,12,14,17,20],thirti:11,those:[2,3,5,6,8,13,17,20,23],though:[11,12,20],thought:14,thousand:11,thread:2,three:[2,3,8,11,14,17,20,21],through:[1,11,14,21,22,26],thu:4,thun:[2,3,10,16],thunder:14,tied:20,tile:6,time:[3,6,8,9,11,13,14,17,20,22],tini:20,to_set:[17,20],todai:14,todo:[14,24],togeth:[12,14,23],token:24,toler:23,tommi:20,too:[13,20],took:6,tool:14,top:[2,3,14,25,26],total:[4,6,11],total_match:4,trace:[0,14,18,22,23,26],traceprint:25,track:22,tracker:0,trade:6,transform:[10,13],translat:[6,10,13],travers:[22,23],treasur:0,treat:[0,2,3,23],treatment:12,tree:[0,14,23],treegrind:23,treemap:13,treestep:[0,23],tri:11,trick:[11,20],tricki:[6,8],trivial:[5,8,20],trobe:0,trove:0,truediv:18,truthi:[3,14],ts0:[13,20],ts1:[13,20],tuck:[3,5,14,20],tupl:[3,14,26],turn:[2,3,6],twice:[6,13,17,20],two:[2,3,5,6,11,13,14,15,17,20,21,22,26],type:[1,10,13,14,17,24,25,26],typic:[2,3],unari:[8,13,14],unarybuiltinwrapp:3,unbalanc:[17,20,24],unchang:17,uncon:[3,4,5,12,13,14,17,20,21,22],under:[2,3,8,14,17],understand:[0,6,17,20],undistinguish:17,undocu:14,unfortun:26,uniqu:[3,7,17,20],unit:[4,13,14,20],univers:[0,14],unless:[6,13],unlik:13,unnecessari:23,unpack:[2,3,17,26],unpair:11,unquot:[13,14,20,21],unstack:3,untangl:[12,13],until:[5,6,8,12],unus:11,unusu:[17,20],updat:[0,23],upward:8,usag:14,use:[0,2,3,6,8,10,11,12,14,15,16,17,18,19,20,21,22,26],used:[3,10,13,14,17,20,22,24,26],useful:0,user:[6,21],uses:[2,5,11,13],using:[3,5,6,12,13,17,18,20,21,22],usual:[0,2],util:[0,8,9,19,20],valid:7,valu:[2,3,5,6,11,13,14,15,19,21,23,26],value_n:[17,20],valueerror:26,vanilla:8,variabl:[13,23],variant:17,variat:13,varient:20,varieti:[10,14],variou:0,vener:26,verbos:10,veri:[0,1,6,10,14,17,20,26],versa:2,version:[0,1,2,12,16,18,21,22,23],via:14,vice:2,view:[17,23],viewer:[1,14,16,25],von:[0,2,3,10],wai:[0,2,3,4,6,8,10,11,13,14,20],walk:20,wall:6,want:[2,6,8,11,12,15,17,20],warranti:[3,14],wash:14,wast:14,web:26,websit:[0,11],welcom:14,well:[0,4,5,6,10,14,17,20,24],were:[6,8,13,14,22],what:[2,3,5,8,9,10,13,14,17,18,20,21,25],whatev:[2,3,12,20,21,26],when:[11,12,13,14,15,17,20,22,24,26],where:[2,3,4,5,8,13,14,17,20,23,26],whether:13,which:[0,1,3,5,6,8,11,13,14,15,17,18,20,21,22,26],whole:[2,3,5,11,20,21],whose:12,why:[6,15,20,21],wiki:[17,20],wikipedia:[0,17,20,22],wildli:14,wind:14,winner:6,wire:13,wit:8,within:[14,17,20,23],without:[2,14,17,20],won:[17,20,26],word:[0,3,4,5,7,11,12,14,20,22],work:[0,3,4,5,6,8,11,12,13,14,17,20,21,22,26],worth:[6,11],would:[2,5,6,7,8,9,11,12,13,14,15,17,20,22,26],wouldn:8,wrap:[3,6,14],write:[4,6,8,10,12,13,15,17,20,21,22,23,26],written:[0,1,8,15,17,18,19,26],wrong:2,wtf:13,wtfmorphism:13,year:14,yet:[8,13,17,20,22],yield:[2,3,26],you:[0,2,3,5,6,8,11,12,13,14,16,17,19,20,21,22,25,26],your:[2,3,4,5,6,7,14],yourself:[14,17,20],zero:[3,5,6,8,13,17,20,21,24,26],zip:[4,11],zip_:3,zstr:22},titles:["Thun 0.2.0 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Categorical Programming","Developing a Program in Joy","Using x to Generate Values","Hylomorphism","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Replacing Functions in the Dictionary","Treating Trees","Treating Trees II: treestep","Preamble","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026"],titleterms:{"1st":4,"2nd":5,"3rd":6,"4th":7,"5th":8,"6th":9,"case":[15,17,20],"final":5,"function":[2,3,9,13,14,15,17,18,19,20,21],"long":19,"new":17,"void":2,"while":2,Adding:[17,20],One:[12,17],The:[11,13,14,17,20,21],There:14,Use:20,Using:12,With:21,about:23,abov:13,add:[2,8,17,20],adding:[17,20],address:22,advent:[4,5,6,7,8,9],all:[6,8],altern:21,ana:13,analysi:[6,11],anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[13,17],approxim:15,automat:20,averag:2,base:[15,17,20],befor:9,better:13,binari:[2,17,21],block:5,both:17,branch:[2,17],breakdown:8,btree:20,can:[17,20],cata:13,catamorph:13,categor:10,chatter:2,check:18,child:[17,20],choic:2,cleanup:18,clear:2,cleav:2,cmp:[17,20],code:[4,5,6,7,8,9,14,17],combin:[2,13,17,20],compar:[17,20],comparison:2,compil:12,comput:15,con:[2,20],concat:2,consecut:15,continu:14,count:[8,9],crap:20,current:[17,20],data:20,datastructur:[14,17,20],decemb:[4,5,6,7,8,9],defin:[17,18,20,21],definit:18,delet:[17,20],deriv:[13,18,20,21],determin:22,develop:11,dialect:0,dictionari:19,dip:[2,22],dipd:2,dipdd:2,direco:12,disenstacken:2,div:2,document:0,doe:[17,20],down:5,down_to_zero:2,drive:9,drop:2,dup:2,dupd:2,dupdip:2,els:[17,20],empti:[17,20],enstacken:2,equal:[17,20],essai:23,euler:[11,12],eval:14,even:12,exampl:[2,14,17,21],execut:25,express:[14,24],extract:[13,20,21],factor:[13,20],factori:13,fibonacci:12,filter:11,find:[6,13,15,17],first:[2,11],five:12,flatten:2,flexibl:21,floordiv:2,form:[13,20],formula:18,found:17,four:13,from:13,ftw:4,fun:13,further:11,fusion:13,gcd:2,gener:[9,11,12,13,15,20],genrec:2,get:[8,17,20,21],getitem:2,given:[13,20,21],gotten:8,greater:[17,20],group:2,have:[17,21],help:2,highest:17,host:0,how:[9,11,12],hylo:13,hylomorph:13,ift:2,increment:8,index:8,indic:0,inform:0,infra:[2,20,22],integ:11,interlud:[17,20],intern:24,interpret:[1,14],isn:20,item:22,iter:[11,17,20],joi:[0,1,3,6,11,13,14,22,23,24,25,26],just:[11,20],kei:[17,20],languag:0,law:13,least_fract:2,left:[17,20],less:[17,20],let:11,librari:[3,14],like:[17,20],list:[2,13,20,26],literari:14,littl:11,logic:2,loop:[2,5,14],lower:17,lshift:2,make:[15,20],mani:[9,11],map:2,math:2,method:15,min:2,miscellan:[2,20],mod:2,modif:20,modulu:2,more:17,most:17,mul:2,multipl:[11,12],must:[17,20],name:[18,20],nativ:18,neg:2,newton:15,next:15,node:[13,17,20],non:17,now:[8,17,20],nullari:2,number:[6,13],offset:6,one:14,onli:14,order:[17,20,21],osdn:0,our:[17,20],out:5,over:2,pack:11,pam:2,paper:5,para:13,paramet:20,parameter:[13,17,20,21],paramorph:13,pars:[2,24],parser:[14,24],pass:14,path:22,pattern:13,per:[17,20],piec:5,pop:2,popd:2,popop:2,pow:2,power:12,preambl:[8,13,22],pred:2,predic:[8,11,15,17,20,21],pretty_print:25,primrec:2,print:14,problem:[11,12],process:[17,20],product:2,program:[9,10,11,13,18,20,21,23],project:[0,11,12],pure:14,put:[6,17,20,21],python:[14,19],quadrat:18,quick:0,quot:[2,26],rang:[2,11],range_to_zero:2,rank:6,read:14,recal:9,recur:[15,17,20],recurs:[13,17,20,21],redefin:[17,20,21],refactor:[4,11,17,20],refer:3,regular:14,reimplement:21,rem:2,remaind:2,remov:2,render:11,repeat:9,repl:14,replac:[17,19],rescu:6,reset:12,rest:[2,13],revers:2,right:[17,20,22],rightmost:17,roll:2,rolldown:2,rollup:2,root:15,rshift:2,run:[2,12],sat:5,second:2,select:2,sequenc:[12,26],set:[8,15,17,20],shorter:19,should:14,shunt:2,simplest:11,simplifi:18,size:[2,19],slight:20,sourc:17,sqr:2,sqrt:2,squar:15,stack:[2,14,26],start:0,state:9,step:[2,8,13,21],structur:17,style:14,sub:[2,17],succ:2,sum:[2,11],swaack:2,swap:2,swon:2,swoncat:2,symbol:[13,14],sympi:6,tabl:0,tail:13,take:2,term:[11,12,20,21],ternari:2,text:24,than:[13,17,20],thi:[17,20],think:5,third:2,three:12,thun:[0,14],time:[2,12],todo:20,togeth:[6,8,17,20,21],toi:20,token:14,toler:15,trace:[19,25],traceprint:14,travers:[17,20,21],treat:[17,20,21],tree:[13,17,20,21,22],treegrind:21,treestep:[13,20,21],triangular:13,tricki:5,truediv:2,truthi:2,tuck:2,two:12,type:20,unari:2,uncon:2,unfinish:13,unit:2,unnecessari:11,unquot:2,unstack:2,updat:16,use:13,usual:13,util:[25,26],valu:[8,12,17,20],variabl:18,version:[6,11,17,19,20],view:14,want:5,within:15,word:2,write:18,xor:2,zero:12,zip:2,zipper:22}}) \ No newline at end of file +Search.setIndex({docnames:["index","joy","lib","library","notebooks/Advent of Code 2017 December 1st","notebooks/Advent of Code 2017 December 2nd","notebooks/Advent of Code 2017 December 3rd","notebooks/Advent of Code 2017 December 4th","notebooks/Advent of Code 2017 December 5th","notebooks/Advent of Code 2017 December 6th","notebooks/Categorical","notebooks/Developing","notebooks/Generator Programs","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators","notebooks/Intro","notebooks/Newton-Raphson","notebooks/NoUpdates","notebooks/Ordered_Binary_Trees","notebooks/Quadratic","notebooks/Replacing","notebooks/Trees","notebooks/Treestep","notebooks/Zipper","notebooks/index","parser","pretty","stack"],envversion:52,filenames:["index.rst","joy.rst","lib.rst","library.rst","notebooks/Advent of Code 2017 December 1st.rst","notebooks/Advent of Code 2017 December 2nd.rst","notebooks/Advent of Code 2017 December 3rd.rst","notebooks/Advent of Code 2017 December 4th.rst","notebooks/Advent of Code 2017 December 5th.rst","notebooks/Advent of Code 2017 December 6th.rst","notebooks/Categorical.rst","notebooks/Developing.rst","notebooks/Generator Programs.rst","notebooks/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst","notebooks/Intro.rst","notebooks/Newton-Raphson.rst","notebooks/NoUpdates.rst","notebooks/Ordered_Binary_Trees.rst","notebooks/Quadratic.rst","notebooks/Replacing.rst","notebooks/Trees.rst","notebooks/Treestep.rst","notebooks/Zipper.rst","notebooks/index.rst","parser.rst","pretty.rst","stack.rst"],objects:{"joy.joy":{joy:[1,1,1,""],repl:[1,1,1,""],run:[1,1,1,""]},"joy.library":{"void":[3,1,1,""],BinaryBuiltinWrapper:[3,1,1,""],DefinitionWrapper:[3,2,1,""],FunctionWrapper:[3,1,1,""],SimpleFunctionWrapper:[3,1,1,""],UnaryBuiltinWrapper:[3,1,1,""],add_aliases:[3,1,1,""],app1:[3,1,1,""],app2:[3,1,1,""],app3:[3,1,1,""],b:[3,1,1,""],branch:[3,1,1,""],choice:[3,1,1,""],clear:[3,1,1,""],cmp_:[3,1,1,""],concat:[3,1,1,""],cond:[3,1,1,""],cons:[3,1,1,""],dip:[3,1,1,""],dipd:[3,1,1,""],dipdd:[3,1,1,""],divmod_:[3,1,1,""],drop:[3,1,1,""],dup:[3,1,1,""],dupd:[3,1,1,""],dupdip:[3,1,1,""],first:[3,1,1,""],floor:[3,1,1,""],genrec:[3,1,1,""],getitem:[3,1,1,""],help_:[3,1,1,""],i:[3,1,1,""],id_:[3,1,1,""],ifte:[3,1,1,""],infra:[3,1,1,""],initialize:[3,1,1,""],inscribe:[3,1,1,""],loop:[3,1,1,""],map_:[3,1,1,""],max_:[3,1,1,""],min_:[3,1,1,""],over:[3,1,1,""],parse:[3,1,1,""],pm:[3,1,1,""],pop:[3,1,1,""],popd:[3,1,1,""],popdd:[3,1,1,""],popop:[3,1,1,""],pred:[3,1,1,""],remove:[3,1,1,""],rest:[3,1,1,""],reverse:[3,1,1,""],rolldown:[3,1,1,""],rollup:[3,1,1,""],select:[3,1,1,""],sharing:[3,1,1,""],shunt:[3,1,1,""],sort_:[3,1,1,""],sqrt:[3,1,1,""],stack_:[3,1,1,""],step:[3,1,1,""],succ:[3,1,1,""],sum_:[3,1,1,""],swaack:[3,1,1,""],swap:[3,1,1,""],take:[3,1,1,""],times:[3,1,1,""],tuck:[3,1,1,""],uncons:[3,1,1,""],unique:[3,1,1,""],unstack:[3,1,1,""],warranty:[3,1,1,""],words:[3,1,1,""],x:[3,1,1,""],zip_:[3,1,1,""]},"joy.library.DefinitionWrapper":{add_def:[3,3,1,""],add_definitions:[3,3,1,""],parse_definition:[3,3,1,""]},"joy.parser":{ParseError:[24,4,1,""],Symbol:[24,2,1,""],text_to_expression:[24,1,1,""]},"joy.utils":{pretty_print:[25,0,0,"-"],stack:[26,0,0,"-"]},"joy.utils.pretty_print":{TracePrinter:[25,2,1,""]},"joy.utils.pretty_print.TracePrinter":{go:[25,5,1,""],viewer:[25,5,1,""]},"joy.utils.stack":{expression_to_string:[26,1,1,""],iter_stack:[26,1,1,""],list_to_stack:[26,1,1,""],pick:[26,1,1,""],pushback:[26,1,1,""],stack_to_string:[26,1,1,""]},joy:{joy:[1,0,0,"-"],library:[3,0,0,"-"],parser:[24,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","classmethod","Python class method"],"4":["py","exception","Python exception"],"5":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:classmethod","4":"py:exception","5":"py:method"},terms:{"0b11100111011011":11,"10m":13,"10n":13,"4ac":18,"5bkei":[17,20],"\u03b5":15,"abstract":[14,17,20],"boolean":[2,3,14,17,20],"break":[9,14],"byte":11,"case":[2,3,5,9,13,21,26],"class":[3,14,24,25,26],"default":[3,8,12,17,26],"export":[3,24],"final":[2,6,13,17],"float":[3,14,22,24],"function":[0,1,4,5,6,7,8,10,11,12,16,22,23,24,25,26],"g\u00e9rard":22,"import":[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],"int":[6,12,13,14,22,24,26],"long":[17,23],"new":[2,3,6,12,13,14,15,16,19,20],"public":16,"return":[1,3,5,6,8,9,11,13,14,15,17,18,19,20,21,24,25,26],"short":18,"static":[2,16],"switch":2,"throw":17,"true":[2,3,5,6,11,13,20],"try":[6,12,13,21],"void":[0,3],"while":[3,6,8,9,14,17,20,24,26],Adding:[14,23],And:[4,6,11,12,13,15,17,20,22,26],But:[0,5,10,11,12,13,14,17,19,20],CPS:14,For:[2,3,4,5,6,7,8,13,17,20,23,26],Going:5,Has:3,Its:3,Not:6,One:[2,14,23],RHS:20,TOS:[2,3,13],That:[11,13,17,20],The:[0,1,2,3,4,5,6,7,8,10,12,15,16,18,22,23,24,26],Then:[2,3,5,8,17,18,20],There:[6,8,13,20,21,26],These:[23,26],Use:[3,13,15],Using:[0,6,13,15,17,20,23],With:[4,13,15,23],__str__:25,_tree_add_:17,_tree_add_e:17,_tree_add_p:17,_tree_add_r:17,_tree_add_t:17,_tree_delete_:17,_tree_delete_clear_stuff:17,_tree_delete_del:17,_tree_delete_r0:17,_tree_delete_r1:17,_tree_delete_rightmost:17,_tree_delete_w:17,_tree_get_:17,_tree_get_p:17,_tree_get_r:17,_tree_get_t:17,_tree_iter_order_curr:17,_tree_iter_order_left:17,_tree_iter_order_r:17,_tree_iter_order_right:17,_tree_t:17,_treestep_0:21,_treestep_1:21,_within_b:15,_within_p:15,_within_r:15,aaa:7,abbrevi:[20,21],abl:18,about:[0,6,8,14,17,20,22,26],abov:[0,6,11,15,17,18,20],abs:[6,15],absolut:[6,14],accept:[1,2,3,11,12,13,14,15,17,20,21,22],access:[6,8],accomplish:18,accordingli:[17,20],accumul:11,across:[6,8],act:15,action:[14,22],actual:[2,6,11,14,17,20],adapt:23,add:[3,4,5,6,11,12,14,18,25],add_alias:3,add_def:3,add_definit:[3,8,13,17,20,21],add_if_match:4,add_valu:8,added:[10,17,20],adding:[6,16],addit:[0,2,3,8,11,13,14,20,21],adjust:17,admit:6,advantag:13,after:[4,6,8,11,12,14],afterward:14,again:[2,3,6,8,11,14,15,17,20],against:[5,6],aggreg:[3,22],aka:[14,22],albrecht:0,algebra:20,algorithm:14,alia:3,alias:[3,14],align:[14,25],all:[3,4,5,11,12,13,14,17,20,21,25],alloc:6,allow:[13,16,17,20],almost:[17,20],along:[13,14,18],alphabet:3,alreadi:[6,15,19,22],also:[0,11,13,14,17,20,26],altern:[10,20],although:[4,10,17,20],altogeth:12,alwai:[6,11,13,16],amort:[17,20],amount:6,analysi:[10,23],anamorph:14,ani:[8,10,11,14,16,17,20,22,24],annual:14,anonym:[17,20],anoth:[4,13,17,20,26],answer:6,anyth:[2,3,14],aoc20017:5,aoc20173:6,aoc2017:[4,5,6,7,8,9],api:16,app1:3,app2:[3,5,14,18,19],app3:3,app:14,appear:[2,7,10,11,17,20],append:8,appendix:23,appli:[2,3,5,11,12,17,20],applic:12,approach:[11,18],approxim:23,archiv:0,aren:22,arg:[2,3],argument:[2,3,13,14,15,25,26],arithmet:2,ariti:2,around:[11,26],arrai:8,arrang:[8,21],arriv:[12,20,21],articl:[0,10,12],ask:[6,10,12],aspect:[0,6],assembl:8,assert:[6,9],assign:26,associ:[17,20],assum:[4,5,7,8,15],asterisk:[20,21],attack:14,attempt:[0,1],attribut:3,automat:[10,13],auxiliari:21,avail:[0,7],averag:[14,19],avoid:[17,20],awai:17,awar:2,awkward:[17,20],azur:23,back:[6,8,17,20],backward:[16,17,20,21],bag:14,banana:[13,20],bank:9,barb:13,base:[0,2,3,5,9,13,16,21],basic:[1,2,3,4,6,14,17,20],bear:8,beat:8,becaus:[2,3,4,5,6,8,13,14,17,20,21,22,26],becom:[4,17,18,20,21,26],been:[13,15,16,17,20,22],befor:[5,8,12,13,14,17,20],begin:[6,13,17,20,21],behavior:[16,20,21],behaviour:[0,1],behind:8,being:0,belong:8,below:[2,3,6,11,12,17,20,22],bespok:14,best:0,better:[6,11,17,20],between:[0,5,6,11],beyond:12,biannual:14,big:[6,8,20],binari:[0,12,14,20,23],binary_search_tre:[17,20],binarybuiltinwrapp:3,bind:14,bingo:22,bit:[6,11,12,17,20],block:[9,11],bodi:[2,14,17,20],body_text:3,bool:[5,13],borrow:14,both:[2,6,8,11,13,14,18,19,20,26],bottom:12,boundari:6,bracket:[6,14,24],branch:[3,4,5,8,11,12,20],breakpoint:14,bring:[11,14],btree:[17,21],buck:[17,20],bug:[0,14],build:[12,13,14,20,22,26],built:[13,18],bundl:[2,3],burgeon:14,calcul:6,calculu:10,call:[2,13,14,15,16,17,18,20,25,26],caller:[17,20],came:[8,20],can:[0,2,3,4,5,6,10,11,12,13,14,15,16,18,19,21,22,23,26],candid:5,captur:14,card:14,care:[6,11,26],carefulli:[20,22],carri:[4,6,12,13,17],cartesian:10,categor:[0,18,23],categori:10,ccc:10,ccon:[17,20],ceil:6,certain:[14,26],certainli:[17,20],chain:3,chang:[2,6,8,16,17,20,22],charact:22,chat:14,chatter:0,cheat:9,check:[5,12,13],checksum:5,child0:20,child:21,childn:20,children:20,choic:[3,13],choos:[16,20],cinf:17,circuit:10,circular:[4,20],cite_not:[17,20],classmethod:3,claus:3,clear:[3,6,11,14],clear_stuff:17,cleav:[4,5,7,14,18,19],close:[0,1,10],clunki:11,cmp:[3,21,23],cmp_:[3,20],code:[0,1,10,13,20,23],codireco:12,collaps:13,collect:[10,12,14],column:6,combin:[0,3,7,11,12,14,15,18,21,22,23],come:[6,8,14,17],command:[4,14,17,18,20],common:[2,11,13],compar:[3,6,10],comparison:[0,17],compel:10,compil:[2,8,10,13,14,17,19,23],complet:10,complex:[3,22],compos:13,compound:[17,20],comput:[2,5,6,8,10,11,14,18],con:[3,5,8,9,11,12,13,14,15,17,18,21,22,26],conal:10,concat:[3,4,12,13,14,20,21],concaten:0,concatin:[0,3,26],concis:6,concret:13,concurr:2,cond:[3,17],condit:[3,8,14],condition:5,confid:6,conflict:[17,20],cons2:20,consecut:23,consid:[8,11,12,13,17,20,21,22],consist:[2,6,12,14,20,21],constant:[17,20],constitu:13,consum:[5,13],contain:[0,2,3,6,7,12,13,14],context:2,conting:17,continu:[0,5,13,22],control:14,conveni:10,convert:[13,19,20,21,24,26],cook:13,cool:[17,20],copi:[2,3,4,11,13,17,20,21,23],copyright:14,corner:6,correct:6,correctli:20,correspond:10,could:[2,6,8,10,11,13,14,16,17,20,22],count:[3,6,7],count_stat:9,counter:11,coupl:21,cours:[6,8,11,13,17,20],cover:6,cpu:6,crack:[17,20],crap:[],crash:[17,20],creat:[0,2,3,4,11,13,15,17,20],crude:[17,20,24],current:[2,3,8,13,14,21,22,25],custom:16,cycl:[11,12],cython:14,dai:[13,14],data:[2,3,6],datastructur:[0,2,13,22,23,24,26],datatyp:26,ddididi:22,deal:[0,4,17,20],debugg:13,decid:[17,20],decor:3,decoupl:13,decreas:6,decrement:3,deduc:11,deeper:0,deepli:10,def:[3,6,8,9,13,14,18,19,20,26],defi:3,defin:[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23],definit:[2,3,7,8,11,12,13,14,15,16,17,20,21,23],definitionwrapp:[3,8,13,17,20,21],deleg:14,delet:23,demonstr:[10,13],depend:[3,13,17,20],deposit:[20,21],dequot:[4,13],der:17,deriv:[2,3,4,5,11,14,15,17,23],descend:5,describ:[3,10,13,17,20,21,24],descript:[11,14,20],design:[2,3,5,17,20],desir:[6,14,20,21],destruct:[17,20],detail:[6,14,17,20],detect:[5,12,13,17,20],determin:[5,6],develop:[0,12,14,23],diagram:11,dialect:1,dict:[1,3],dictionari:[0,1,3,14,15,18,20,23],did:6,didn:13,differ:[0,5,7,10,11,13,15,17,18,20,26],differenti:10,dig:[17,22],digit:[4,11],dimension:6,dinfrirst:14,dip:[3,5,6,8,9,11,12,13,14,15,17,18,19,20,21],dipd:[3,8,12,13,14,17,18,20,22],dipdd:[3,17,20],direco:[9,15,23],direct:14,directli:[6,11,20,21,26],disappear:2,discard:[3,12,13,15,17,20],disciplin:17,discov:5,disenstacken:[14,20],disk:14,displac:2,distanc:6,distribut:9,ditch:[17,20],div:[3,14],dive:[20,21],divid:5,divis:[5,17,20],divisor:5,divmod:[3,5],divmod_:3,doc:[2,3,14],document:[23,24,26],doe:[0,1,5,6,8,10,12,13,14,23,25],doesn:[4,8,11,13,16,17,20,21,26],dog:20,doing:[6,10,11,13,14,22],domain:[6,10],don:[5,6,8,11,14,17,20],done:[2,11,14,16],doodl:6,door:14,dot:25,doubl:[11,14],down:[2,3,6,8,15,22],down_to_zero:14,downward:8,dozen:14,draft:[9,10,16],dream:14,drive:12,driven:[11,15],driver:12,drop:[3,4,17,20],dudipd:14,due:4,dummi:5,dup:[3,4,5,6,8,9,11,12,13,14,15,17,18,20,22,26],dupd:3,dupdip:[3,5,6,11,13,17,18,20],duplic:[3,7,13,17,20],durat:2,dure:[2,13],each:[2,3,4,5,6,8,10,11,13,14,19,20,21,25],easi:[0,6,17,20,21,22],easier:[3,4,17,20],easili:10,edit:23,effect:[2,3,14,22],effici:[6,8,12,19,22],either:[1,2,3,5,13,17,20],eleg:[8,14,17,18,20],element:[2,3],elliott:10,els:[2,3,4,5,8,9,13],embed:[10,17,20,22],empti:[3,5,14,21,26],encapsul:14,enclos:14,encod:[8,12],encount:8,end:[6,8,11,13,17,21,26],endless:12,enforc:[2,14],engend:14,enlarg:6,enough:[6,13,14,18,25],enstacken:[12,14],ensur:7,enter:14,entir:26,entri:[3,22,25],epsilon:15,equal:[11,21,26],equat:[6,14,15],ergo:[6,13,17,20],err:[17,20],error:[6,14,24],escap:8,essai:0,etc:[3,6,21,22,24],euler:23,eval:0,evalu:[1,2,3,4,13,14,15,17,18,19,20,21],even:8,evenli:5,eventu:[6,18],everi:12,everyth:[3,17,20],evolv:16,exactli:13,exampl:[0,3,4,5,6,7,8,11,13,15,20,23,24,26],exce:12,except:[14,17,20,24],execut:[0,1,2,3,5,14,19,21,22,26],exercis:17,exist:[10,17],exit:8,expand:17,expect:[2,3,5,13,20,21,26],experi:[14,21],experiment:6,explan:14,explor:14,express:[0,1,2,3,10,13,17,19,20,22,25,26],expression_to_str:26,extend:6,extra:[4,5,11,12],extract:[17,23],extrem:14,extrememli:14,facet:0,facil:14,fact:[20,24],factor:[2,11,14,17],fail:[2,3,5,17,20,24],fals:[2,3,5,9,11,13],far:[8,13,15,17,20],fascin:0,fast:6,faster:6,favorit:18,fear:[17,20],feel:6,few:[6,11,14],fewer:[3,14],fib:12,fib_gen:12,fibonacci:23,figur:[2,3,6,17,20],filter:[17,20],fin:11,find:[2,3,4,5,11,12,20,21,23],finder:15,fine:[0,11,17,20],finish:18,first:[3,4,5,6,8,9,12,13,14,15,17,18,19,20,21,22,23],first_two:17,fit:[11,14,18],five:[11,13,14,23],fix:[2,3],flag:5,flatten:[14,20,21],flexibl:[20,23],floor:[3,6],floordiv:11,flow:14,follow:[0,2,3,5,8,13,14,15,16,21,22],foo:[14,16,17,20],foo_ii:16,form:[2,3,5,7,10,11,12,21,26],forman:14,format:[23,25],formula:[0,6,11,23],forth:[4,8,14,20],fortun:8,forum:0,forward:[5,8],found:[8,9,14,20],four:[2,3,6,8,11,12,14,17,20],fourteen:11,fourth:[2,3,4,17,20],fractal:14,fraction0:14,fraction:[2,14],framework:14,free:[10,14,17,20],freeli:[2,6],from:[0,1,2,3,4,5,6,7,8,9,11,12,14,15,17,18,19,20,21,22,23,26],front:[2,3],full:[7,11],fun:6,functionwrapp:[3,20],funtion:[17,20],further:[15,23],futur:18,garbag:14,gari:[17,20],gcd:14,gen:9,gener:[0,2,3,6,8,10,23,26],genrec:[3,5,8,13,14,17,20,21],geometr:11,geometri:20,get:[2,5,6,10,11,12,13,14,23],get_valu:8,getitem:3,getrecursionlimit:26,getsourc:14,ghc:10,give:[6,10,11,13,15,17,21,26],given:[2,3,4,5,6,8,9,11,12,15,17,22,23],glue:14,goal:8,going:[5,6,8,17,20,21,22],good:[8,11,17,20],grab:3,grammar:24,grand:14,graph:6,great:[0,4,6,14,23],greater:[6,26],grid:6,group:[0,6],gsra:15,guard:[5,6,17],had:[11,22],haiku:14,half:[11,22],half_of_s:4,halfwai:4,hand:[14,18,19,20,23],handi:15,handl:[17,26],happen:[6,14,20],hard:22,hardli:13,hardwar:10,has:[0,2,5,6,8,12,13,14,15,16,17,20,22,26],haskel:10,have:[2,3,4,5,6,8,9,11,12,13,14,15,16,20,22,23,26],head:[5,13,26],help:[7,13,14,17,20],help_:3,helper:[3,5],herd:14,here:[6,11,12,13,17,18,20,21,22],heterogen:20,heurist:[4,8],hide:[17,20],higher:[14,17,20],highest:[5,20],highli:[14,20],hindsight:5,histori:25,hmm:[17,20],hog:20,hoist:3,hold:11,hood:[8,17],hope:[0,11,14,23],host:23,how:[0,6,7,8,10,13,17,20,22,23],html:[2,3,12,18,23],http:[17,20],huet:22,huge:17,hugh:[15,20,21],human:14,hypothet:2,id_:3,idea:[10,11,14,20],ident:[3,13],identifi:6,if_not_empti:17,ift:[3,4,5,8,13,17,20,21],ignor:[3,17,20],illustr:13,imagin:22,imit:21,immedi:[8,13],immut:[14,17,20],imper:13,implement:[0,1,2,3,6,9,10,13,14,16,17,18,20],impli:5,implicit:14,includ:[7,10,17,21],inclus:11,incom:26,incompat:16,incr_at:8,incr_step_count:8,incr_valu:8,increas:[6,8,11],increment:[3,10,11,16],index:[0,6,9,14,26],index_of:9,indexerror:26,indic:[20,21],infil:20,infinit:6,inform:3,infra:[3,12,13,14,17,18,19,21],infrastructur:3,init:8,init_print:6,initi:[2,3,5,6,7,8,14,15,17,20],inlin:[17,20],inner:5,input:[1,4,5,6,7,13,15],inscrib:3,inspect:14,instal:0,instanti:[10,25],instead:[6,11,12,13,17,20,22,26],instruct:8,integ:[2,3,4,5,6,7,8,13,14,21],integr:3,intend:[0,14],interact:[14,23],interest:[0,6,11,17,20,23],interlock:6,interlud:23,intermedi:13,intern:[0,25,26],interpret:[0,10,13,16,24,25],interrupt:14,interv:[10,11],introduc:16,introduct:0,invari:3,invers:3,investig:18,ipf:14,ipynb:12,isn:[13,17,22],item:[2,3,4,5,9,13,14,17,20,21,26],iter:[1,3,6,13,14,21,23,26],iter_stack:[9,19,26],its:[0,2,3,5,6,10,11,13,14,17,20,21,26],itself:[0,2,8,14,17,20],j05cmp:[2,3],jenni:20,job:[8,23],john:[15,20,21],joi:[2,4,5,7,8,9,10,15,16,17,18,19,20],joypi:[8,9,13,14,20,22],jump:8,jupyt:23,just:[0,2,3,4,5,6,8,12,13,14,16,17,21,22],keep:[17,22],kei:[21,23],kevin:0,key_n:[17,20],keyerror:[17,20],kind:[2,6,8,10,13,14,17,20,21],kleen:[20,21],know:[6,11,13,17,20],known:10,l_kei:17,l_left:17,l_right:17,l_valu:17,labda:[],lambda:[10,13],lambdifi:6,languag:[10,14,16,17,18,20],larg:6,larger:[6,26],largest:[3,5,8],last:[4,8,11,13,17],lastli:[12,13],later:[8,14,21],law:2,lazi:15,lazili:15,lcm:11,lead:[8,14],leaf:[17,20],lean:14,learn:[0,9],least:[2,6,8,11,13,26],least_fract:14,leav:[5,6,8,11,20],left:[6,13,14,21,22,25,26],leftov:13,legendari:8,legibl:8,len:9,length:[3,11,26],lens:13,less:[11,12,13,14,26],lesser:6,let:[4,5,6,8,12,13,15,17,18,20,21,22],level:[10,17,20],librari:[0,6,8,9,15,18,19,20],lieu:20,like:[2,3,5,6,9,11,13,14,15,18,21,23,24],line:[3,5,8,13,14,17,20,25],linear:26,link:0,linux:0,list:[0,3,4,5,7,8,9,11,14,15,17,21,22,25],list_to_stack:[8,9,26],liter:[1,17,20,21,22,24],littl:[6,8,12,17,20,23],live:23,lkei:[20,21],load:[11,14],locat:[2,6],locu:25,log_2:[17,20],logic:[0,11],longer:[17,20],look:[6,12,14,15,17,20],lookup:[14,20],loop:[0,1,3,11],lot:[14,17,18,20,22],love:11,low:10,lower:[11,20],lowest:[5,17,20],machin:[0,20],machineri:[17,20],macro:14,made:[0,5,14,20,22],mai:[2,8,13,20],mail:0,main:[0,3,4,14,22],mainloop:16,maintain:22,major:16,make:[2,3,4,10,11,13,14,17,19,21,22,23],make_distributor:9,make_gener:15,manfr:[0,2,3,10],manhattan:6,mani:[0,6,7,8,13,14],manipul:6,manual:[6,13],map:[1,3,11,13,14,16,18,20,21],map_:3,mark:[6,8],marker:14,mask:[11,12],match:[0,1,4],materi:0,math:[0,6,8,14,17,20],mathemat:[6,14],matter:[4,11,13,15,17,20,21],max:[5,6,9],max_:3,maximum:[3,20],maxmin:5,mayb:[13,17,20],maze:8,mean:[5,10,11,13,14,15,17,20,21,26],meant:[13,14,17,18,20,21],meantim:8,mem:8,member:[2,3,6],memori:6,mental:14,mention:2,mercuri:0,merg:20,meta:[14,17,20],methink:20,method:[0,3,6,14,23,25],mfloor:6,midpoint:11,might:[4,10,12,13,17,20],mike:17,million:12,min:5,min_:3,mind:8,minimum:3,minor:17,minu:[3,18],mirror:0,miscellan:0,mistak:9,mix:14,mnemon:4,mod:3,model:[10,14],modern:0,modif:12,modifi:[8,14,17,22],modul:[0,1,3,14,24],modulu:14,monkei:6,month:14,more:[0,3,7,8,10,11,12,13,14,15,18,19,20,21,24,26],most:20,mostli:0,move:[4,6,8,17],movement:2,mrank_of:6,much:[6,8,11,12,13,17,20],muck:[17,20],mul:[14,18,22,25],multi:3,multipl:[13,23],must:[2,3,5,6,7,11,13,16,21],mutabl:8,n_rang:[],nail:8,name:[1,3,4,14,16,17,22,23,24,26],natur:[11,12,17,20],navig:22,neat:17,need:[2,3,4,5,6,8,9,11,12,13,15,16,17,20],neg:[3,8,18],nest:[3,14,17,20,22],network:14,never:16,new_kei:17,new_valu:17,newton:[0,23],next:[4,5,6,8,11,13,20,21],nice:[0,4,6,13,26],niether:2,node:[21,23],node_kei:[17,20],node_valu:[17,20],non:[5,20,21],none:[1,3],nope:21,normal:[7,13],notat:[14,17,20],note:[2,6,11,15,17,20,26],notebook:[11,14,22,23],notebook_preambl:[2,4,5,6,7,8,9,11,12,13,15,17,18,19,20,21,22],noth:[2,17,20],notic:11,now:[4,5,6,11,12,13,14,19,21,23],nth:[3,26],nullari:[5,8,9,14,17,20],number:[1,2,3,5,11,12,26],object:24,observ:11,obviou:12,obvious:[5,7,8],occur:[17,20],odd:[11,12],off:[2,3,6,11,12,22],offset:8,offset_of:6,old:[2,19],old_k:17,old_kei:17,old_valu:17,omit:13,onc:[3,7,16,17,18,20],one:[2,3,4,5,6,7,8,11,12,13,17,18,20,21,25,26],ones:12,onli:[2,3,4,5,6,8,11,13,17,20,22,26],onto:[1,2,3,14,26],open:[7,14],oper:[3,5,13,14,17,20,26],oppos:4,optim:17,option:[1,14,17,20,26],order:[0,2,3,4,5,13,14,23,26],org:[0,17,20],origin:[0,1,2,3,4,17,20,22],other:[0,2,3,5,6,10,13,14,17,20,21,26],otherwis:[3,5,11,12,17,20,21],our:[4,5,6,11,12,13,14,15,21],ourselv:13,out:[2,3,6,10,11,12,13,14,17,20,22],outcom:[20,21],output:[6,13,15],outsid:[8,10],outward:6,over:[3,4,6,10,11,12,14,15,17,18,20,21,23],overhead:6,overkil:13,overshadow:6,own:[6,17,20],pack:[20,26],packag:[0,14],page:[0,17,18,20,26],pair:[2,3,4,5,11,12,17],pair_up:4,palidrom:11,palindrom:11,pam:[14,18],paper:[6,10,13,14,20,22],parallel:2,paramet:[1,2,3,8,13,24,25,26],parameter:23,paranthes:20,parenthes:[8,17,20,26],pariti:12,pars:[0,3,14,20],parse_definit:3,parseerror:24,parser:0,part:[2,3,5,8,13,15,18,20,21],partial:[6,13],particular:22,particularli:8,pass:[0,17,20,25],passphras:7,path:6,pattern:[6,11,20,21],payoff:13,pe1:[11,12],pe2:12,pearl:22,pend:[3,13,14,22,25],peopl:23,per:[6,14,21],perform:8,perhap:12,period:14,permit:[8,26],persist:[17,20],phase:2,pick:[11,12,26],pickl:14,pictur:[17,20],piec:13,pip:0,pita:9,place:[3,6,8,11,13,14],plai:0,plain:8,plane:6,plu:[3,6,18],plug:[12,13,20,21],point:[6,10,13,14,17,20],pointless:2,pop:[3,4,5,8,9,11,12,13,14,17,18,19,20,21,26],popd:[3,8,14,15,17,19],popdd:[3,5,12,18],popop:[3,4,5,8,9,11,12,13,14,15,17,20,21],port:6,posit:[3,8,11,13,14],possibilit:[17,20],possibl:[5,17,20,21,23],post:[14,20],potenti:3,power:14,pragmat:11,pre:[8,13,20],preambl:15,precis:[0,1],pred:3,predic:[2,3,5,12,13],prefer:13,prefix:[13,25],prep:[5,20],prepar:[8,13],preprocessor:13,present:20,preserv:[10,21],pretti:[6,17,18,20,21,25,26],pretty_print:0,prevent:13,previou:[6,8,14],prime:[5,15],primit:[2,3,8,18],primrec:[3,5,8,9,12,13,14,15],print:[0,1,2,3,6,13,25,26],probabl:[4,12,14,17,20],problem:[6,14,23],proc_curr:[17,20],proc_left:[17,20],proc_right:[17,20],proce:[4,11],process:[8,13,14,21,25],processor:20,produc:[4,11,13,17,20,21],product:[12,14],program:[0,2,3,4,5,6,8,12,14,15,17,22],project:23,prompt:14,proper:[2,3],properli:8,properti:0,provid:[0,3,10,14],prune:20,pun:[0,14],pure:[0,20],puriti:14,purpos:14,push:[2,3,13,14,22,26],pushback:[14,20,26],put:[1,2,12,14,23,26],puzzl:[4,5,6,7],pypi:0,pyramid:6,python:[0,2,3,6,8,13,17,18,20,22,23,24,26],quadrat:[0,6,23],queri:[17,20,21],query_kei:21,queu:13,quit:[0,1,6,21],quot:[0,3,12,13,14,15,17,18,20,21,22,25],quotat:[2,3],quotient:3,r_kei:17,r_left:17,r_right:17,r_valu:17,rais:[17,20,24,26],random:8,rang:[6,13,14],range_sum:13,range_to_zero:14,rank_and_offset:6,rank_of:6,raphson:15,rather:[11,13,14,20,21],ratio:14,reach:[8,11,12,13],read:[0,1,11,12,17,20,22],readabl:19,reader:17,real:[17,20],realiz:[4,8,10,17,20],realli:6,rearrang:[2,13,17],reason:[6,11,14],rebuild:[21,22],rec1:[2,3],rec2:[2,3],recogn:24,record:[14,25],recur:13,recurs:[2,3,5,8,9,12,14,15,23,26],recus:14,recusr:20,redefin:23,redistribut:[3,14],reduc:2,redund:26,reexamin:20,refactor:[13,14,16],refer:[0,2],regist:2,regular:24,reimplement:23,rel:[8,18],releas:16,relev:6,remain:[2,3,14,16],remaind:[3,15],remind:13,remov:[3,6,17,20,26],renam:20,render:[20,23],repeat:[4,6,11],repeatedli:11,repl:[0,1],replac:[0,2,3,12,13,20,21,22,23,26],repositori:0,repres:[2,14,17,20,24,25],represent:26,reprod:12,request:6,requir:[6,26],resembl:14,reset:[],respect:11,rest:[3,5,9,11,12,14,17,20,22,23,26],rest_two:17,restor:2,result:[1,2,3,5,11,13,17,18,20,21,22],resum:14,retir:2,retri:14,reus:[17,20],revers:[3,4,5,11,12,13,22,26],rewrit:[3,8,14],rewritten:14,richard:20,rid:[17,20],right:[6,12,13,14,21,25,26],rightest:17,rightmost:11,rkei:[20,21],role:20,roll:[3,5,7,8,13,15,17,18,20,21],rolldown:3,rollup:3,root:[3,6,18,23],rotate_seq:4,round:4,row:[5,6],row_valu:6,run:[0,1,3,6,11,13,14,15,17,20,21,22],runtim:6,runtimeerror:26,sai:[12,17,20,21],same:[2,10,11,13,17,20,26],sandwich:[2,3],save:[2,11,14],scan:3,scanner:[14,24],scenario:22,scheme:[18,20],scope:[4,12,17,20],search:[0,6,17,20],second:[3,4,5,13,14,17,20,21,26],secur:7,see:[0,6,12,13,14,16,19,20,22,25],seem:[0,9,11,14,20,21],seen:22,select:[3,6],semant:[2,3,14,16,17,20],semi:14,send:14,sens:[0,2,11,22],separ:14,sequenc:[0,1,2,3,4,5,7,8,9,11,14,17,19,20,22,23,24],seri:[6,11,12,13,17,20,22],serv:13,set:[2,3,13,23],seven:[11,12],sever:[0,10,14],share:[3,6,14],shelf:2,shift:[11,12],shine:8,shorter:23,shortest:6,shorthand:17,should:[2,3,5,11,13,17,20],shouldn:14,show:[6,10,20,22],shunt:[3,22],side:[17,20],sign:6,signal:5,signifi:[14,17,20],silli:20,similar:[17,20,21],simon:14,simpl:[6,13,14,26],simplefunctionwrapp:[3,8,9,18,19],simpler:21,simplest:23,simpli:10,simplifi:[6,11,17,20,22],sinc:[2,6,11,17,18,20],singl:[3,12,14,19,24],situ:[17,20],situat:[17,20],six:[11,12,14],sixti:[11,12],size:[4,7,8,9,14,23],skeptic:14,skip:[6,8],slight:15,slightli:[13,17,20],small:[4,20],smallest:[3,5],smart:[8,13,17],sneaki:6,softwar:14,solei:2,solut:[6,11,12],solv:6,solvabl:14,some:[2,3,5,6,8,12,13,14,17,20,21,23,26],somehow:[17,20],someth:[2,4,8,16,17],sometim:[17,20],somewher:[13,17,20,23],sophist:6,sort:[3,5,13,17,18,20],sort_:3,sourc:[0,1,3,23,24,25,26],space:[6,11,25],span:11,special:[12,13,17,20],specif:[0,10],specifi:17,speed:[6,8,19],spell:21,sphinx:[23,26],spiral:6,spirit:[0,1,20,21],split_at:4,spreadsheet:5,sqr:[14,18,22],sqrt:[3,6,15,18],squar:[3,6,23,24],stack:[0,1,3,5,8,9,11,12,13,15,17,18,19,20,21,22,24,25],stack_:3,stack_to_str:26,stage:[20,21],stai:[0,1],stand:10,standard:[14,17],star:[20,21],stare:[17,20],start:[5,6,8,9,11,12,13,14,15,17,18,20,21],state:[5,8,14],statement:3,step:[3,4,5,6,7,11,14,17,18,19,20,22,23],step_zero:[4,5,7],still:[6,8,13,17],stop:[17,20],storag:[11,13,17,20],store:[6,11,13],stori:13,str:[1,24,25,26],straightforward:[1,4,6,12],strang:8,stream:[11,15],stretch:17,string:[1,2,3,4,14,22,24,25,26],strip:6,structur:[13,14,20,21,22,23,26],stuff:[17,20],style:[0,10],sub:[16,20],subclass:14,subject:22,subract:6,substitut:[6,13,17],subtract:[5,6,11],succ:3,success:15,suffici:[8,13,17],suggest:[5,10,17,20],suitabl:[3,10,11],sum:[3,4,5,12,13,14,18,19,20,21],sum_:3,summand:11,sumtre:21,suppli:[13,17,20,24],support:[6,14,25,26],sure:[6,13],suspect:2,swaack:[3,13,18,19,20,22],swap:[3,4,5,6,7,9,11,12,13,14,15,17,19,20,21,22],swon:[3,9,12,13,14,20,21,22],swoncat:[8,9,12,13,14,15,20,21],symbol:[2,3,6,18,22,24],symmetr:[11,17,20],sympi:18,syntact:14,syntax:[14,26],sys:[6,26],system:[6,7,14,17,20],tail:[5,17,20,26],take:[3,4,6,8,11,14,15,17,18,20,26],taken:8,talk:[14,17,20,26],target:[6,22],task:6,tast:10,tbd:14,technic:2,techniqu:[10,22],technolog:2,teh:20,temporari:22,ten:11,term:[1,2,5,8,9,13,14,15,23,24,26],termin:[2,3,5],ternari:14,test:[2,3],text:[0,1,3],text_to_express:[14,24],textual:14,than:[0,3,6,7,11,12,14,15,18,21,26],thei:[2,5,6,11,12,13,14,17,20,22,24,26],them:[2,3,5,6,11,12,13,17,20,22,23],theori:[2,3],therefor:[12,20],thi:[0,1,2,3,4,5,6,8,9,10,11,12,13,14,18,21,22,23,24,25,26],thing:[2,5,6,8,12,13,17,18,20,22,24,26],think:[2,8,11,13,14,17,20,21],third:[3,4,5,12,14,17,20],thirti:11,those:[2,3,5,6,8,13,17,20,23],though:[11,20],thought:14,thousand:11,thread:2,three:[2,3,8,11,14,17,20,21,23],through:[1,11,14,21,22,26],thu:4,thun:[2,3,10,16],thunder:14,tied:20,tile:6,time:[3,6,8,9,11,13,14,17,20,22],tini:20,to_set:[17,20],todai:14,todo:[14,24],togeth:[12,14,23],token:24,toler:23,tommi:20,too:[13,20],took:6,tool:14,top:[2,3,14,25,26],total:[4,6,11],total_match:4,trace:[0,14,18,22,23,26],traceprint:25,track:22,tracker:0,trade:6,transform:[10,13],translat:[6,10,13],travers:[22,23],treasur:0,treat:[0,2,3,23],treatment:12,tree:[0,14,23],treegrind:23,treemap:13,treestep:[0,23],tri:11,trick:[11,20],tricki:[6,8],trivial:[5,8,20],trobe:0,trove:0,truediv:18,truthi:[3,14],ts0:[13,20],ts1:[13,20],tuck:[3,5,14,20],tupl:[3,14,26],turn:[2,3,6],twice:[6,13,17,20],two:[2,3,5,6,11,13,14,15,17,20,21,22,23,26],type:[1,10,13,14,17,24,25,26],typic:[2,3],unari:[8,13,14],unarybuiltinwrapp:3,unbalanc:[17,20,24],unchang:17,uncon:[3,4,5,12,13,14,17,20,21,22],under:[2,3,8,14,17],understand:[0,6,17,20],undistinguish:17,undocu:14,unfortun:26,uniqu:[3,7,17,20],unit:[4,13,14,20],univers:[0,14],unless:[6,13],unlik:13,unnecessari:23,unpack:[2,3,17,26],unpair:11,unquot:[13,14,20,21],unstack:3,untangl:13,until:[5,6,8,12],unus:11,unusu:[17,20],updat:[0,23],upward:8,usag:14,use:[0,2,3,6,8,10,11,12,14,15,16,17,18,19,20,21,22,26],used:[3,10,13,14,17,20,22,24,26],useful:0,user:[6,21],uses:[2,5,11,13],using:[3,5,6,12,13,17,18,20,21,22],usual:[0,2],util:[0,8,9,19,20],valid:7,valu:[0,2,3,5,6,11,13,14,15,19,21,23,26],value_n:[17,20],valueerror:26,vanilla:8,variabl:[13,23],variant:17,variat:[13,23],varient:20,varieti:[10,14],variou:0,vener:26,verbos:10,veri:[0,1,6,10,14,17,20,26],versa:2,version:[0,1,2,12,16,18,21,22,23],via:14,vice:2,view:[17,23],viewer:[1,14,16,25],von:[0,2,3,10],wai:[0,2,3,4,6,8,10,11,13,14,20],walk:20,wall:6,want:[2,6,8,11,12,15,17,20],warranti:[3,14],wash:14,wast:14,web:26,websit:[0,11],welcom:14,well:[0,4,5,6,10,14,17,20,24],were:[6,8,13,14,22],what:[2,3,5,8,9,10,13,14,17,18,20,21,25],whatev:[2,3,20,21,26],when:[11,12,13,14,15,17,20,22,24,26],where:[2,3,4,5,8,13,14,17,20,23,26],whether:13,which:[0,1,3,5,6,8,11,13,14,15,17,18,20,21,22,26],whole:[2,3,5,11,20,21],whose:12,why:[6,15,20,21],wiki:[17,20],wikipedia:[0,17,20,22],wildli:14,wind:14,winner:6,wire:13,wit:8,within:[14,17,20,23],without:[2,14,17,20],won:[17,20,26],word:[0,3,4,5,7,11,14,20,22],work:[0,3,4,5,6,8,11,12,13,14,17,20,21,22,26],worth:[6,11],would:[2,5,6,7,8,9,11,12,13,14,15,17,20,22,26],wouldn:8,wrap:[3,6,14],write:[4,6,8,10,13,15,17,20,21,22,23,26],written:[0,1,8,15,17,18,19,26],wrong:2,wtf:13,wtfmorphism:13,year:14,yet:[8,13,17,20,22],yield:[2,3,26],you:[0,2,3,5,6,8,11,12,13,14,16,17,19,20,21,22,25,26],your:[2,3,4,5,6,7,14],yourself:[14,17,20],zero:[3,5,6,8,13,17,20,21,24,26],zip:[4,11],zip_:3,zstr:22},titles:["Thun 0.2.0 Documentation","Joy Interpreter","Functions Grouped by, er, Function with Examples","Function Reference","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Advent of Code 2017","Categorical Programming","Developing a Program in Joy","Using x to Generate Values","Hylomorphism","Thun: Joy in Python","Newton\u2019s method","No Updates","Treating Trees I: Ordered Binary Trees","Quadratic formula","Replacing Functions in the Dictionary","Treating Trees","Treating Trees II: treestep","Preamble","Essays about Programming in Joy","Parsing Text into Joy Expressions","Tracing Joy Execution","Stack or Quote or Sequence or List\u2026"],titleterms:{"1st":4,"2nd":5,"3rd":6,"4th":7,"5th":8,"6th":9,"case":[15,17,20],"final":5,"function":[2,3,9,13,14,15,17,18,19,20,21],"long":19,"new":17,"void":2,"while":2,Adding:[17,20],One:[12,17],The:[11,13,14,17,20,21],There:14,Use:20,Using:12,With:21,about:23,abov:13,add:[2,8,17,20],adding:[17,20],address:22,advent:[4,5,6,7,8,9],all:[6,8],altern:21,ana:13,analysi:[6,11],anamorph:[2,13],app1:2,app2:2,app3:2,appendix:[13,17],approxim:15,automat:20,averag:2,base:[15,17,20],befor:9,better:13,binari:[2,17,21],block:5,both:17,branch:[2,17],breakdown:8,btree:20,can:[17,20],cata:13,catamorph:13,categor:10,chatter:2,check:18,child:[17,20],choic:2,cleanup:18,clear:2,cleav:2,cmp:[17,20],code:[4,5,6,7,8,9,14,17],combin:[2,13,17,20],compar:[17,20],comparison:2,compil:12,comput:15,con:[2,20],concat:2,consecut:15,continu:14,count:[8,9],crap:20,current:[17,20],data:20,datastructur:[14,17,20],decemb:[4,5,6,7,8,9],defin:[17,18,20,21],definit:18,delet:[17,20],deriv:[13,18,20,21],determin:22,develop:11,dialect:0,dictionari:19,dip:[2,22],dipd:2,dipdd:2,direco:12,disenstacken:2,div:2,document:0,doe:[17,20],down:5,down_to_zero:2,drive:9,drop:2,dup:2,dupd:2,dupdip:2,els:[17,20],empti:[17,20],enstacken:2,equal:[17,20],essai:23,euler:[11,12],eval:14,even:12,exampl:[2,14,17,21],execut:25,express:[14,24],extract:[13,20,21],factor:[13,20],factori:13,fibonacci:12,filter:11,find:[6,13,15,17],first:[2,11],five:12,flatten:2,flexibl:21,floordiv:2,form:[13,20],formula:18,found:17,four:13,from:13,ftw:4,fun:13,further:11,fusion:13,gcd:2,gener:[9,11,12,13,15,20],genrec:2,get:[8,17,20,21],getitem:2,given:[13,20,21],gotten:8,greater:[17,20],group:2,have:[17,21],help:2,highest:17,host:0,how:[9,11,12],hylo:13,hylomorph:13,ift:2,increment:8,index:8,indic:0,inform:0,infra:[2,20,22],integ:11,interest:12,interlud:[17,20],intern:24,interpret:[1,14],isn:20,item:22,iter:[11,17,20],joi:[0,1,3,6,11,13,14,22,23,24,25,26],just:[11,20],kei:[17,20],languag:0,law:13,least_fract:2,left:[17,20],less:[17,20],let:11,librari:[3,14],like:[17,20],list:[2,13,20,26],literari:14,littl:11,logic:2,loop:[2,5,14],lower:17,lshift:2,make:[12,15,20],mani:[9,11],map:2,math:2,method:15,min:2,miscellan:[2,20],mod:2,modif:20,modulu:2,more:17,most:17,mul:2,multipl:[11,12],must:[17,20],name:[18,20],nativ:18,neg:2,newton:15,next:15,node:[13,17,20],non:17,now:[8,17,20],nullari:2,number:[6,13],offset:6,one:14,onli:14,order:[17,20,21],osdn:0,our:[17,20],out:5,over:2,pack:11,pam:2,paper:5,para:13,paramet:20,parameter:[13,17,20,21],paramorph:13,pars:[2,24],parser:[14,24],pass:14,path:22,pattern:13,per:[17,20],piec:5,pop:2,popd:2,popop:2,pow:2,power:12,preambl:[8,13,22],pred:2,predic:[8,11,15,17,20,21],pretty_print:25,primrec:2,print:14,problem:[11,12],process:[17,20],product:2,program:[9,10,11,13,18,20,21,23],project:[0,11,12],pure:14,put:[6,17,20,21],python:[14,19],quadrat:18,quick:0,quot:[2,26],rang:[2,11],range_to_zero:2,rank:6,read:14,recal:9,recur:[15,17,20],recurs:[13,17,20,21],redefin:[17,20,21],refactor:[4,11,17,20],refer:3,regular:14,reimplement:21,rem:2,remaind:2,remov:2,render:11,repeat:9,repl:14,replac:[17,19],rescu:6,reset:12,rest:[2,13],revers:2,right:[17,20,22],rightmost:17,roll:2,rolldown:2,rollup:2,root:15,rshift:2,run:[2,12],sat:5,second:2,select:2,sequenc:[12,26],set:[8,15,17,20],shorter:19,should:14,shunt:2,simplest:11,simplifi:18,size:[2,19],slight:20,sourc:17,sqr:2,sqrt:2,squar:15,stack:[2,14,26],start:0,state:9,step:[2,8,13,21],structur:17,style:14,sub:[2,17],succ:2,sum:[2,11],swaack:2,swap:2,swon:2,swoncat:2,symbol:[13,14],sympi:6,tabl:0,tail:13,take:2,term:[11,12,20,21],ternari:2,text:24,than:[13,17,20],thi:[17,20],think:5,third:2,three:12,thun:[0,14],time:[2,12],todo:20,togeth:[6,8,17,20,21],toi:20,token:14,toler:15,trace:[19,25],traceprint:14,travers:[17,20,21],treat:[17,20,21],tree:[13,17,20,21,22],treegrind:21,treestep:[13,20,21],triangular:13,tricki:5,truediv:2,truthi:2,tuck:2,two:12,type:20,unari:2,uncon:2,unfinish:13,unit:2,unnecessari:11,unquot:2,unstack:2,updat:16,use:13,usual:13,util:[25,26],valu:[8,12,17,20],variabl:18,variat:12,version:[6,11,17,19,20],view:14,want:5,within:15,word:2,write:18,xor:2,zero:12,zip:2,zipper:22}}) \ No newline at end of file diff --git a/docs/sphinx_docs/notebooks/Generator Programs.rst b/docs/sphinx_docs/notebooks/Generator Programs.rst index f1b99a6..d5ee3ca 100644 --- a/docs/sphinx_docs/notebooks/Generator Programs.rst +++ b/docs/sphinx_docs/notebooks/Generator Programs.rst @@ -8,31 +8,40 @@ Cf. jp-reprod.html from notebook_preamble import J, V, define -Consider the ``x`` combinator ``x == dup i``: +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`` ``swap`` the ``a`` with the quote and run some function -``[C]`` on it. +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`` and ``cons`` the result of -``C`` on ``a`` whatever that is: +Now discard the quoted ``a`` with ``rest`` then ``cons`` ``b``: :: - aC [a B] rest cons - aC [B] cons - [aC B] + b [a B] rest cons + b [B] cons + [b B] Altogether, this is the definition of ``B``: @@ -40,9 +49,8 @@ Altogether, this is the definition of ``B``: B == swap [C] dip rest cons -We can create a quoted program that generates the Natural numbers -(integers 0, 1, 2, ...) by using ``0`` for ``a`` and ``[dup ++]`` for -``[C]``: +We can make a generator for the Natural numbers (0, 1, 2, ...) by using +``0`` for ``a`` and ``[dup ++]`` for ``[C]``: :: @@ -85,7 +93,7 @@ After one application of ``x`` the quoted program contains ``1`` and ``direco`` -~~~~~~~~~~ +---------- .. code:: ipython2 @@ -113,20 +121,17 @@ After one application of ``x`` the quoted program contains ``1`` and 0 [1 swap [dup ++] direco] . -Generating Generators -===================== +Making Generators +----------------- -We want to go from: +We want to define a function that accepts ``a`` and ``[C]`` and builds +our quoted program: :: - a [C] G - -to: - -:: - - [a swap [C] direco] + a [C] G + ------------------------- + [a swap [C] direco] Working in reverse: @@ -145,65 +150,30 @@ Reading from the bottom up: G == [direco] cons [swap] swap concat cons G == [direco] cons [swap] swoncat cons -We can try it out: - -:: - - 0 [dup ++] G - .. code:: ipython2 define('G == [direco] cons [swap] swoncat cons') +Let's try it out: + .. code:: ipython2 - V('0 [dup ++] G') + J('0 [dup ++] G') .. parsed-literal:: - . 0 [dup ++] G - 0 . [dup ++] G - 0 [dup ++] . G - 0 [dup ++] . [direco] cons [swap] swoncat cons - 0 [dup ++] [direco] . cons [swap] swoncat cons - 0 [[dup ++] direco] . [swap] swoncat cons - 0 [[dup ++] direco] [swap] . swoncat cons - 0 [[dup ++] direco] [swap] . swap concat cons - 0 [swap] [[dup ++] direco] . concat cons - 0 [swap [dup ++] direco] . cons - [0 swap [dup ++] direco] . + [0 swap [dup ++] direco] .. code:: ipython2 - V('0 [dup ++] G x') + J('0 [dup ++] G x x x pop') .. parsed-literal:: - . 0 [dup ++] G x - 0 . [dup ++] G x - 0 [dup ++] . G x - 0 [dup ++] . [direco] cons [swap] swoncat cons x - 0 [dup ++] [direco] . cons [swap] swoncat cons x - 0 [[dup ++] direco] . [swap] swoncat cons x - 0 [[dup ++] direco] [swap] . swoncat cons x - 0 [[dup ++] direco] [swap] . swap concat cons x - 0 [swap] [[dup ++] direco] . concat cons x - 0 [swap [dup ++] direco] . cons 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] . + 0 1 2 Powers of 2 @@ -211,77 +181,32 @@ Powers of 2 .. code:: ipython2 - J('1 [dup 1 <<] G x x x x x x x x x') + 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 [512 swap [dup 1 <<] direco] + 1 2 4 8 16 32 64 128 256 -``n [x] times`` -=============== +``[x] times`` +~~~~~~~~~~~~~ If we have one of these quoted programs we can drive it using ``times`` with the ``x`` combinator. -Let's define a word ``n_range`` that takes a starting integer and a -count and leaves that many consecutive integers on the stack. For -example: - .. code:: ipython2 - J('23 [dup ++] G 5 [x] times pop') + J('23 [dup ++] G 5 [x] times') .. parsed-literal:: - 23 24 25 26 27 - - -We can use ``dip`` to untangle ``[dup ++] G`` from the arguments. - -.. code:: ipython2 - - J('23 5 [[dup ++] G] dip [x] times pop') - - -.. parsed-literal:: - - 23 24 25 26 27 - - -Now that the givens (arguments) are on the left we have the definition -we're looking for: - -.. code:: ipython2 - - define('n_range == [[dup ++] G] dip [x] times pop') - -.. code:: ipython2 - - J('450 10 n_range') - - -.. parsed-literal:: - - 450 451 452 453 454 455 456 457 458 459 - - -This is better just using the ``times`` combinator though... - -.. code:: ipython2 - - J('450 9 [dup ++] times') - - -.. parsed-literal:: - - 450 451 452 453 454 455 456 457 458 459 + 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 `Developing a Program.ipynb <./Developing%20a%20Program.ipynb>`__ and you'll see that @@ -338,16 +263,6 @@ If we plug ``14811`` and ``[PE1.1]`` into our generator form... [14811 swap [PE1.1] direco] -.. code:: ipython2 - - J('[14811 swap [PE1.1] direco] x') - - -.. parsed-literal:: - - 3 [3702 swap [PE1.1] direco] - - ...we get a generator that works for seven cycles before it reaches zero: @@ -371,6 +286,16 @@ if so. define('PE1.1.check == dup [pop 14811] [] branch') +.. code:: ipython2 + + J('14811 [PE1.1.check PE1.1] G') + + +.. parsed-literal:: + + [14811 swap [PE1.1.check PE1.1] direco] + + .. code:: ipython2 J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times') @@ -381,6 +306,11 @@ if so. 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 ~~~~~~~~~~~~~ @@ -402,17 +332,17 @@ If we drive our generator 466 times and sum the stack we get 999. .. code:: ipython2 - J('[14811 swap [PE1.1.check PE1.1] dip rest cons] 466 [x] times') + 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] dip rest cons] + 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 - J('[14811 swap [PE1.1.check PE1.1] dip rest cons] 466 [x] times pop enstacken sum') + J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum') .. parsed-literal:: @@ -421,25 +351,13 @@ If we drive our generator 466 times and sum the stack we get 999. Project Euler Problem One -========================= +------------------------- .. code:: ipython2 define('PE1.2 == + dup [+] dip') -Now we can add ``PE1.2`` to the quoted program given to ``times``. - -.. code:: ipython2 - - J('0 0 [0 swap [PE1.1.check PE1.1] direco] 466 [x [PE1.2] dip] times popop') - - -.. parsed-literal:: - - 233168 - - -Or using ``G`` we can write: +Now we can add ``PE1.2`` to the quoted program given to ``G``. .. code:: ipython2 @@ -452,7 +370,7 @@ Or using ``G`` we can write: A generator for the Fibonacci Sequence. -======================================= +--------------------------------------- Consider: @@ -507,30 +425,31 @@ And therefore: [b+a b a F] [popdd over] infra [b b+a b F] -And lastly: +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] -Done. - Putting it all together: :: - F == + swons [popdd over] infra uncons - -And: - -:: - + F == + [popdd over] cons infra uncons fib_gen == [1 1 F] .. code:: ipython2 - define('fib == + swons [popdd over] infra uncons') + define('fib == + [popdd over] cons infra uncons') .. code:: ipython2 @@ -547,11 +466,12 @@ And: 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. + 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 @@ -669,7 +589,51 @@ Replace ``x`` with our new driver function ``PE2.2`` and start our 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:: ipython2 + + define('codireco == cons dip rest cons') + +.. code:: ipython2 + + 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:: ipython2 + + define('G == [codireco] cons cons') + +.. code:: ipython2 + + J('230 [dup ++] G 5 [x] times pop') + + +.. parsed-literal:: + + 230 231 232 233 234 + diff --git a/docs/sphinx_docs/notebooks/index.rst b/docs/sphinx_docs/notebooks/index.rst index 00fa66a..c5abc23 100644 --- a/docs/sphinx_docs/notebooks/index.rst +++ b/docs/sphinx_docs/notebooks/index.rst @@ -12,6 +12,7 @@ These essays are adapted from Jupyter notebooks. I hope to have those hosted so Replacing Ordered_Binary_Trees Treestep + Generator Programs Newton-Raphson Quadratic NoUpdates diff --git a/joy/library.py b/joy/library.py index 98f44d8..3157dc8 100644 --- a/joy/library.py +++ b/joy/library.py @@ -1144,14 +1144,17 @@ def ifte(stack, expression, dictionary): @FunctionWrapper def cond(stack, expression, dictionary): ''' - like a case statement; works by rewriting into a chain of ifte. + 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. - [..[[Bi] Ti]..[D]] -> ... + 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 + [[[B0] T0] [[B1] T1] [D]] cond + ----------------------------------------- + [B0] [T0] [[B1] [T1] [D] ifte] ifte ''' conditions, stack = stack @@ -1400,9 +1403,10 @@ def loop(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 @@ -1415,10 +1419,10 @@ def cmp_(stack, expression, dictionary): a b [G] [E] [L] cmp ------------------------- a < b L - ''' - L, (E, (G, (b, (a, stack)))) = stack - expression = pushback(G if a > b else L if a < b else E, expression) - return stack, expression, dictionary + ''' + L, (E, (G, (b, (a, stack)))) = stack + expression = pushback(G if a > b else L if a < b else E, expression) + return stack, expression, dictionary #def nullary(S, expression, dictionary):