From 04e8f70dd21441f940b374e9379a2e89a2480441 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Mon, 30 Apr 2018 10:12:56 -0700 Subject: [PATCH] More docs changes. --- .../_build/html/_modules/joy/joy.html | 20 +- .../_build/html/_modules/joy/library.html | 7 + .../_build/html/_modules/joy/parser.html | 2 +- .../html/_modules/joy/utils/pretty_print.html | 52 +- .../_build/html/_modules/joy/utils/stack.html | 77 ++- docs/sphinx_docs/_build/html/genindex.html | 2 + docs/sphinx_docs/_build/html/index.html | 2 +- docs/sphinx_docs/_build/html/joy.html | 47 +- ... This Implementation of Joy in Python.html | 512 ------------------ .../_build/html/notebooks/AlsoNewton.html | 113 +++- .../_build/html/notebooks/Intro.html | 6 +- docs/sphinx_docs/_build/html/objects.inv | Bin 1372 -> 1388 bytes docs/sphinx_docs/_build/html/parser.html | 2 +- docs/sphinx_docs/_build/html/pretty.html | 50 +- docs/sphinx_docs/_build/html/searchindex.js | 2 +- docs/sphinx_docs/_build/html/stack.html | 107 +++- docs/sphinx_docs/notebooks/AlsoNewton.rst | 139 +++-- 17 files changed, 513 insertions(+), 627 deletions(-) delete mode 100644 docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html diff --git a/docs/sphinx_docs/_build/html/_modules/joy/joy.html b/docs/sphinx_docs/_build/html/_modules/joy/joy.html index 0c54fb9..a0aff00 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/joy.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/joy.html @@ -75,11 +75,11 @@ or functions. Literals are put onto the stack and functions are executed. - - :param quote stack: The stack. - :param quote expression: The expression to evaluate. - :param dict dictionary: A `dict` mapping names to Joy functions. + :param stack stack: The stack. + :param stack expression: The expression to evaluate. + :param dict dictionary: A ``dict`` mapping names to Joy functions. :param function viewer: Optional viewer function. + :rtype: (stack, (), dictionary) ''' while expression: @@ -100,6 +100,13 @@
[docs]def run(text, stack, dictionary, viewer=None): ''' Return the stack resulting from running the Joy code text on the stack. + + :param str text: Joy code. + :param stack stack: The stack. + :param dict dictionary: A ``dict`` mapping names to Joy functions. + :param function viewer: Optional viewer function. + :rtype: (stack, (), dictionary) + ''' expression = text_to_expression(text) return joy(stack, expression, dictionary, viewer)
@@ -110,6 +117,11 @@ Read-Evaluate-Print Loop Accept input and run it on the stack, loop. + + :param stack stack: The stack. + :param dict dictionary: A ``dict`` mapping names to Joy functions. + :rtype: stack + ''' if dictionary is None: dictionary = {} diff --git a/docs/sphinx_docs/_build/html/_modules/joy/library.html b/docs/sphinx_docs/_build/html/_modules/joy/library.html index 06c4a01..7c4499a 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/library.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/library.html @@ -157,6 +157,13 @@ dudipd == dup dipd primrec == [i] genrec step_zero == 0 roll> step +direco == dip rest cons +make_generator == [direco] cons [swap] swoncat cons +gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator +_within_P == [first - abs] dip <= +_within_B == roll< popop first +_within_R == [popd x] dip +within == x 0.000001 [_within_P] [_within_B] [_within_R] primrec ''' ##Zipper diff --git a/docs/sphinx_docs/_build/html/_modules/joy/parser.html b/docs/sphinx_docs/_build/html/_modules/joy/parser.html index ad8404c..a847615 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/parser.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/parser.html @@ -84,7 +84,7 @@ Any unbalanced square brackets will raise a ParseError. :param str text: Text to convert. - :rtype: quote + :rtype: stack :raises ParseError: if the parse fails. ''' return _parse(_tokenize(text)) diff --git a/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html b/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html index 89b5ac4..6bc0d94 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/utils/pretty_print.html @@ -51,7 +51,24 @@ # along with Thun. If not see <http://www.gnu.org/licenses/>. # ''' -Pretty printing support. +Pretty printing support, e.g.:: + + Joy? 23 18 * 99 + + . 23 18 mul 99 add + 23 . 18 mul 99 add + 23 18 . mul 99 add + 414 . 99 add + 414 99 . add + 513 . + + 513 <-top + + joy? + +On each line the stack is printed with the top to the right, then a ``.`` to +represent the current locus of processing, then the pending expression to the +left. + ''' # (Kinda clunky and hacky. This should be swapped out in favor of much # smarter stuff.) @@ -62,29 +79,36 @@
[docs]class TracePrinter(object): ''' - This is what does the formatting, e.g.:: - - Joy? 23 18 * 99 + - . 23 18 mul 99 add - 23 . 18 mul 99 add - 23 18 . mul 99 add - 414 . 99 add - 414 99 . add - 513 . - + This is what does the formatting. You instantiate it and pass the ``viewer()`` + method to the :py:func:`joy.joy.joy` function, then print it to see the + trace. ''' def __init__(self): self.history = []
[docs] def viewer(self, stack, expression): - '''Pass this method as the viewer to joy() function.''' + ''' + Record the current stack and expression in the TracePrinter's history. + Pass this method as the ``viewer`` argument to the :py:func:`joy.joy.joy` function. + + :param stack quote: A stack. + :param stack expression: A stack. + ''' self.history.append((stack, expression))
def __str__(self): return '\n'.join(self.go()) - def go(self): +
[docs] def go(self): + ''' + Return a list of strings, one for each entry in the history, prefixed + with enough spaces to align all the interpreter dots. + + This method is called internally by the ``__str__()`` method. + + :rtype: list(str) + ''' max_stack_length = 0 lines = [] for stack, expression in self.history: @@ -97,7 +121,7 @@ return [ # Prefix spaces to line up '.'s. (' ' * (max_stack_length - length) + line) for length, line in lines - ] + ]
def print_(self): try: diff --git a/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html b/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html index e37004b..01cb345 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html @@ -51,12 +51,13 @@ # along with Thun. If not see <http://www.gnu.org/licenses/>. # ''' -When talking about Joy we use the terms "stack", "list", "sequence", -"quote" and others to mean the same thing: a simple linear datatype that +When talking about Joy we use the terms "stack", "quote", "sequence", +"list", and others to mean the same thing: a simple linear datatype that permits certain operations such as iterating and pushing and popping values from (at least) one end. -We use the `cons list`_, a venerable two-tuple recursive sequence datastructure, where the +There is no "Stack" Python class, instead we use the `cons list`_, a +venerable two-tuple recursive sequence datastructure, where the empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the recursive form of a stack with one or more items on it:: @@ -84,33 +85,36 @@ syntax doesn't require parentheses around tuples used in expressions where they would be redundant.) +Unfortunately, the Sphinx documentation generator, which is used to generate this +web page, doesn't handle tuples in the function parameters. And in Python 3, this +syntax was removed entirely. Instead you would have to write:: + + def dup(stack): + head, tail = stack + return head, (head, tail) + + +We have two very simple functions, one to build up a stack from a Python +iterable and another to iterate through a stack and yield its items +one-by-one in order. There are also two functions to generate string representations +of stacks. They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left. In both functions *internal stacks* are +printed left-to-right. These functions are written to support :doc:`../pretty`. + .. _cons list: https://en.wikipedia.org/wiki/Cons#Lists ''' -##We have two very simple functions to build up a stack from a Python -##iterable and also to iterate through a stack and yield its items -##one-by-one in order, and two functions to generate string representations -##of stacks:: -## -## list_to_stack() -## -## iter_stack() -## -## expression_to_string() (prints left-to-right) -## -## stack_to_string() (prints right-to-left) -## -## -##A word about the stack data structure. - -
[docs]def list_to_stack(el, stack=()): '''Convert a Python list (or other sequence) to a Joy stack:: [1, 2, 3] -> (1, (2, (3, ()))) + :param list el: A Python list or other sequence (iterators and generators + won't work because ``reverse()`` is called on ``el``.) + :param stack stack: A stack, optional, defaults to the empty stack. + :rtype: stack + ''' for item in reversed(el): stack = item, stack @@ -118,7 +122,11 @@
[docs]def iter_stack(stack): - '''Iterate through the items on the stack.''' + '''Iterate through the items on the stack. + + :param stack stack: A stack. + :rtype: iterator + ''' while stack: item, stack = stack yield item
@@ -131,6 +139,9 @@ The items are written right-to-left:: (top, (second, ...)) -> '... second top' + + :param stack stack: A stack. + :rtype: str ''' f = lambda stack: reversed(list(iter_stack(stack))) return _to_string(stack, f)
@@ -143,6 +154,9 @@ The items are written left-to-right:: (top, (second, ...)) -> 'top second ...' + + :param stack expression: A stack. + :rtype: str ''' return _to_string(expression, iter_stack)
@@ -165,7 +179,16 @@ '''Concatinate quote onto expression. In joy [1 2] [3 4] would become [1 2 3 4]. + + :param stack quote: A stack. + :param stack expression: A stack. + :raises RuntimeError: if quote is larger than sys.getrecursionlimit(). + :rtype: stack ''' + # This is the fastest implementation, but will trigger + # RuntimeError: maximum recursion depth exceeded + # on quotes longer than sys.getrecursionlimit(). + return (quote[0], pushback(quote[1], expression)) if quote else expression # Original implementation. @@ -182,15 +205,17 @@ ## expression = item, expression ## return expression - # This is the fastest, but will trigger - # RuntimeError: maximum recursion depth exceeded - # on quotes longer than sys.getrecursionlimit(). - return (quote[0], pushback(quote[1], expression)) if quote else expression
[docs]def pick(s, n): ''' - Find the nth item on the stack. (Pick with zero is the same as "dup".) + Return the nth item on the stack. + + :param stack s: A stack. + :param int n: An index into the stack. + :raises ValueError: if ``n`` is less than zero. + :raises IndexError: if ``n`` is equal to or greater than the length of ``s``. + :rtype: whatever ''' if n < 0: raise ValueError diff --git a/docs/sphinx_docs/_build/html/genindex.html b/docs/sphinx_docs/_build/html/genindex.html index 9d8ecce..6eb5d7f 100644 --- a/docs/sphinx_docs/_build/html/genindex.html +++ b/docs/sphinx_docs/_build/html/genindex.html @@ -165,6 +165,8 @@ diff --git a/docs/sphinx_docs/_build/html/index.html b/docs/sphinx_docs/_build/html/index.html index 3f769aa..4a4ef75 100644 --- a/docs/sphinx_docs/_build/html/index.html +++ b/docs/sphinx_docs/_build/html/index.html @@ -93,7 +93,7 @@ interesting aspects. It’s quite a treasure trove.

  • Thun: Joy in Python
    • Read-Eval-Print Loop (REPL)
    • The Stack
    • -
    • Purely Functional Datastructures.
    • +
    • Purely Functional Datastructures
    • The joy() function
    • Parser
    • Library
    • diff --git a/docs/sphinx_docs/_build/html/joy.html b/docs/sphinx_docs/_build/html/joy.html index aa8ced9..5c31265 100644 --- a/docs/sphinx_docs/_build/html/joy.html +++ b/docs/sphinx_docs/_build/html/joy.html @@ -17,7 +17,7 @@ - + @@ -51,14 +51,17 @@ executed.

      -Parameters:
        -
      • stack (quote) – The stack.
      • -
      • expression (quote) – The expression to evaluate.
      • -
      • dictionary (dict) – A dict mapping names to Joy functions.
      • +Parameters:
          +
        • stack (stack) – The stack.
        • +
        • expression (stack) – The expression to evaluate.
        • +
        • dictionary (dict) – A dict mapping names to Joy functions.
        • viewer (function) – Optional viewer function.
        +Return type:

        (stack, (), dictionary)

        + + @@ -68,12 +71,44 @@ executed.

        joy.joy.repl(stack=(), dictionary=None)[source]

        Read-Evaluate-Print Loop

        Accept input and run it on the stack, loop.

        + +++ + + + + + +
        Parameters:
          +
        • stack (stack) – The stack.
        • +
        • dictionary (dict) – A dict mapping names to Joy functions.
        • +
        +
        Return type:

        stack

        +
        joy.joy.run(text, stack, dictionary, viewer=None)[source]

        Return the stack resulting from running the Joy code text on the stack.

        + +++ + + + + + +
        Parameters:
          +
        • text (str) – Joy code.
        • +
        • stack (stack) – The stack.
        • +
        • dictionary (dict) – A dict mapping names to Joy functions.
        • +
        • viewer (function) – Optional viewer function.
        • +
        +
        Return type:

        (stack, (), dictionary)

        +
  • @@ -96,7 +131,7 @@ executed.

    Related Topics

    diff --git a/docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html b/docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html deleted file mode 100644 index 7e2bc5c..0000000 --- a/docs/sphinx_docs/_build/html/notebooks/0. This Implementation of Joy in Python.html +++ /dev/null @@ -1,512 +0,0 @@ - - - - - - - - Joypy — Thun 0.1.1 documentation - - - - - - - - - - - - - - - - - - -
    -
    -
    -
    - -
    -

    Joypy

    -
    -

    Joy in Python

    -

    This implementation is meant as a tool for exploring the programming -model and method of Joy. Python seems like a great implementation -language for Joy for several reasons.

    -

    We can lean on the Python immutable types for our basic semantics and -types: ints, floats, strings, and tuples, which enforces functional -purity. We get garbage collection for free. Compilation via Cython. Glue -language with loads of libraries.

    -
    -

    Read-Eval-Print Loop (REPL)

    -

    The main way to interact with the Joy interpreter is through a simple -REPL -that you start by running the package:

    -
    $ python -m joy
    -Joypy - Copyright © 2017 Simon Forman
    -This program comes with ABSOLUTELY NO WARRANTY; for details type "warranty".
    -This is free software, and you are welcome to redistribute it
    -under certain conditions; type "sharing" for details.
    -Type "words" to see a list of all words, and "[<name>] help" to print the
    -docs for a word.
    -
    -
    - <-top
    -
    -joy? _
    -
    -
    -

    The <-top marker points to the top of the (initially empty) stack. -You can enter Joy notation at the prompt and a trace of -evaluation will be printed followed by the stack -and prompt again:

    -
    joy? 23 sqr 18 +
    -       . 23 sqr 18 +
    -    23 . sqr 18 +
    -    23 . dup mul 18 +
    - 23 23 . mul 18 +
    -   529 . 18 +
    -529 18 . +
    -   547 .
    -
    -547 <-top
    -
    -joy?
    -
    -
    -
    -
    -
    -
    -

    Stacks (aka list, quote, sequence, etc.)

    -

    In Joy, in addition to the types Boolean, integer, float, and string, -there is a single sequence type represented by enclosing a sequence of -terms in brackets [...]. This sequence type is used to represent -both the stack and the expression. It is a cons -list made from Python -tuples.

    -
    import inspect
    -import joy.utils.stack
    -
    -
    -print inspect.getdoc(joy.utils.stack)
    -
    -
    -
    § Stack
    -
    -
    -When talking about Joy we use the terms "stack", "list", "sequence" and
    -"aggregate" to mean the same thing: a simple datatype that permits
    -certain operations such as iterating and pushing and popping values from
    -(at least) one end.
    -
    -We use the venerable two-tuple recursive form of sequences where the
    -empty tuple () is the empty stack and (head, rest) gives the recursive
    -form of a stack with one or more items on it.
    -
    -  ()
    -  (1, ())
    -  (2, (1, ()))
    -  (3, (2, (1, ())))
    -  ...
    -
    -And so on.
    -
    -
    -We have two very simple functions to build up a stack from a Python
    -iterable and also to iterate through a stack and yield its items
    -one-by-one in order, and two functions to generate string representations
    -of stacks:
    -
    -  list_to_stack()
    -
    -  iter_stack()
    -
    -  expression_to_string()  (prints left-to-right)
    -
    -  stack_to_string()  (prints right-to-left)
    -
    -
    -A word about the stack data structure.
    -
    -Python has very nice "tuple packing and unpacking" in its syntax which
    -means we can directly "unpack" the expected arguments to a Joy function.
    -
    -For example:
    -
    -  def dup(stack):
    -    head, tail = stack
    -    return head, (head, tail)
    -
    -We replace the argument "stack" by the expected structure of the stack,
    -in this case "(head, tail)", and Python takes care of de-structuring the
    -incoming argument and assigning values to the names.  Note that Python
    -syntax doesn't require parentheses around tuples used in expressions
    -where they would be redundant.
    -
    -
    -

    The 0th item in the list will be on the top of the stack and vise -versa.

    -
    joy.utils.stack.list_to_stack([1, 2, 3])
    -
    -
    -
    (1, (2, (3, ())))
    -
    -
    -
    list(joy.utils.stack.iter_stack((1, (2, (3, ())))))
    -
    -
    -
    [1, 2, 3]
    -
    -
    -

    This requires reversing the sequence (or iterating backwards) otherwise:

    -
    stack = ()
    -
    -for n in [1, 2, 3]:
    -    stack = n, stack
    -
    -print stack
    -print list(joy.utils.stack.iter_stack(stack))
    -
    -
    -
    (3, (2, (1, ())))
    -[3, 2, 1]
    -
    -
    -

    Because Joy lists are made out of Python tuples they are immutable, so -all Joy datastructures are `purely -functional <https://en.wikipedia.org/wiki/Purely_functional_data_structure>`__.

    -
    -
    -

    The joy() function.

    -
    -

    An Interpreter

    -

    The joy() function is extrememly simple. It accepts a stack, an -expression, and a dictionary, and it iterates through the expression -putting values onto the stack and delegating execution to functions it -looks up in the dictionary.

    -

    Each function is passed the stack, expression, and dictionary and -returns them. Whatever the function returns becomes the new stack, -expression, and dictionary. (The dictionary is passed to enable e.g. -writing words that let you enter new words into the dictionary at -runtime, which nothing does yet and may be a bad idea, and the help -command.)

    -
    import joy.joy
    -
    -print inspect.getsource(joy.joy.joy)
    -
    -
    -
    def joy(stack, expression, dictionary, viewer=None):
    -  '''
    -  Evaluate the Joy expression on the stack.
    -  '''
    -  while expression:
    -
    -    if viewer: viewer(stack, expression)
    -
    -    term, expression = expression
    -    if isinstance(term, Symbol):
    -      term = dictionary[term]
    -      stack, expression, dictionary = term(stack, expression, dictionary)
    -    else:
    -      stack = term, stack
    -
    -  if viewer: viewer(stack, expression)
    -  return stack, expression, dictionary
    -
    -
    -
    -

    View function

    -

    The joy() function accepts a “viewer” function which it calls on -each iteration passing the current stack and expression just before -evaluation. This can be used for tracing, breakpoints, retrying after -exceptions, or interrupting an evaluation and saving to disk or sending -over the network to resume later. The stack and expression together -contain all the state of the computation at each step.

    -
    -
    -

    The TracePrinter.

    -

    A viewer records each step of the evaluation of a Joy program. The -TracePrinter has a facility for printing out a trace of the -evaluation, one line per step. Each step is aligned to the current -interpreter position, signified by a period separating the stack on the -left from the pending expression (“continuation”) on the right.

    -
    -
    -

    Continuation-Passing Style

    -

    One day I thought, What happens if you rewrite Joy to use -CSP? I -made all the functions accept and return the expression as well as the -stack and found that all the combinators could be rewritten to work by -modifying the expression rather than making recursive calls to the -joy() function.

    -
    -
    -
    -
    -

    Parser

    -
    import joy.parser
    -
    -print inspect.getdoc(joy.parser)
    -
    -
    -
    § Converting text to a joy expression.
    -
    -This module exports a single function:
    -
    -  text_to_expression(text)
    -
    -As well as a single Symbol class and a single Exception type:
    -
    -  ParseError
    -
    -When supplied with a string this function returns a Python datastructure
    -that represents the Joy datastructure described by the text expression.
    -Any unbalanced square brackets will raise a ParseError.
    -
    -
    -

    The parser is extremely simple, the undocumented re.Scanner class -does most of the tokenizing work and then you just build the tuple -structure out of the tokens. There’s no Abstract Syntax Tree or anything -like that.

    -
    print inspect.getsource(joy.parser._parse)
    -
    -
    -
    def _parse(tokens):
    -  '''
    -  Return a stack/list expression of the tokens.
    -  '''
    -  frame = []
    -  stack = []
    -  for tok in tokens:
    -    if tok == '[':
    -      stack.append(frame)
    -      frame = []
    -      stack[-1].append(frame)
    -    elif tok == ']':
    -      try:
    -        frame = stack.pop()
    -      except IndexError:
    -        raise ParseError('One or more extra closing brackets.')
    -      frame[-1] = list_to_stack(frame[-1])
    -    else:
    -      frame.append(tok)
    -  if stack:
    -    raise ParseError('One or more unclosed brackets.')
    -  return list_to_stack(frame)
    -
    -
    -

    That’s pretty much all there is to it.

    -
    joy.parser.text_to_expression('1 2 3 4 5')  # A simple sequence.
    -
    -
    -
    (1, (2, (3, (4, (5, ())))))
    -
    -
    -
    joy.parser.text_to_expression('[1 2 3] 4 5')  # Three items, the first is a list with three items
    -
    -
    -
    ((1, (2, (3, ()))), (4, (5, ())))
    -
    -
    -
    joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888')  # A mixed bag. cons is
    -                                                                 # a Symbol, no lookup at
    -                                                                 # parse-time.  Haiku docs.
    -
    -
    -
    (1, (23, (('four', ((-5.0, ()), (cons, ()))), (8888, ()))))
    -
    -
    -
    joy.parser.text_to_expression('[][][][][]')  # Five empty lists.
    -
    -
    -
    ((), ((), ((), ((), ((), ())))))
    -
    -
    -
    joy.parser.text_to_expression('[[[[[]]]]]')  # Five nested lists.
    -
    -
    -
    ((((((), ()), ()), ()), ()), ())
    -
    -
    -
    -
    -

    Library

    -

    The Joy library of functions (aka commands, or “words” after Forth -usage) encapsulates all the actual functionality (no pun intended) of -the Joy system. There are simple functions such as addition add (or -+, the library module supports aliases), and combinators which -provide control-flow and higher-order operations.

    -
    import joy.library
    -
    -print ' '.join(sorted(joy.library.initialize()))
    -
    -
    -
    != % & * *fraction *fraction0 + ++ - -- / < << <= <> = > >= >> ? ^ add anamorphism and app1 app2 app3 average b binary branch choice clear cleave concat cons dinfrirst dip dipd dipdd disenstacken div down_to_zero dudipd dup dupd dupdip enstacken eq first flatten floordiv gcd ge genrec getitem gt help i id ifte infra le least_fraction loop lshift lt map min mod modulus mul ne neg not nullary or over pam parse pm pop popd popdd popop pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup rshift run second select sharing shunt size sqr sqrt stack step sub succ sum swaack swap swoncat swons ternary third times truediv truthy tuck unary uncons unit unquoted unstack void warranty while words x xor zip •
    -
    -
    -

    Many of the functions are defined in Python, like dip:

    -
    print inspect.getsource(joy.library.dip)
    -
    -
    -
    def dip(stack, expression, dictionary):
    -  (quote, (x, stack)) = stack
    -  expression = x, expression
    -  return stack, pushback(quote, expression), dictionary
    -
    -
    -

    Some functions are defined in equations in terms of other functions. -When the interpreter executes a definition function that function just -pushes its body expression onto the pending expression (the -continuation) and returns control to the interpreter.

    -
    print joy.library.definitions
    -
    -
    -
    -second == rest first
    -third == rest rest first
    -product == 1 swap [*] step
    -swons == swap cons
    -swoncat == swap concat
    -flatten == [] swap [concat] step
    -unit == [] cons
    -quoted == [unit] dip
    -unquoted == [i] dip
    -enstacken == stack [clear] dip
    -disenstacken == ? [uncons ?] loop pop
    -? == dup truthy
    -dinfrirst == dip infra first
    -nullary == [stack] dinfrirst
    -unary == [stack [pop] dip] dinfrirst
    -binary == [stack [popop] dip] dinfrirst
    -ternary == [stack [popop pop] dip] dinfrirst
    -pam == [i] map
    -run == [] swap infra
    -sqr == dup mul
    -size == 0 swap [pop ++] step
    -cleave == [i] app2 [popd] dip
    -average == [sum 1.0 ] [size] cleave /
    -gcd == 1 [tuck modulus dup 0 >] loop pop
    -least_fraction == dup [gcd] infra [div] concat map
    -*fraction == [uncons] dip uncons [swap] dip concat [] infra [*] dip cons
    -fraction0 == concat [[swap] dip * [] dip] infra
    -down_to_zero == [0 >] [dup --] while
    -range_to_zero == unit [down_to_zero] infra
    -anamorphism == [pop []] swap [dip swons] genrec
    -range == [0 <=] [1 - dup] anamorphism
    -while == swap [nullary] cons dup dipd concat loop
    -dudipd == dup dipd
    -primrec == [i] genrec
    -
    -

    Currently, there’s no function to add new definitions to the dictionary -from “within” Joy code itself. Adding new definitions remains a -meta-interpreter action. You have to do it yourself, in Python, and wash -your hands afterward.

    -

    It would be simple enough to define one, but it would open the door to -name binding and break the idea that all state is captured in the -stack and expression. There’s an implicit standard dictionary that -defines the actual semantics of the syntactic stack and expression -datastructures (which only contain symbols, not the actual functions. -Pickle some and see for yourself.)

    -

    Which brings me to talking about one of my hopes and dreams for this -notation: “There should be only one.” What I mean is that there should -be one universal standard dictionary of commands, and all bespoke work -done in a UI for purposes takes place by direct interaction and macros. -There would be a Grand Refactoring biannually (two years, not six -months, that’s semi-annually) where any new definitions factored out of -the usage and macros of the previous time, along with new algorithms and -such, were entered into the dictionary and posted to e.g. IPFS.

    -

    Code should not burgeon wildly, as it does today. The variety of code -should map more-or-less to the well-factored variety of human -computably-solvable problems. There shouldn’t be dozens of chat apps, JS -frameworks, programming languages. It’s a waste of time, a fractal -“thundering herd” -attack on -human mentality.

    -

    If you read over the other notebooks you’ll see that developing code in -Joy is a lot like doing simple mathematics, and the descriptions of the -code resemble math papers. The code also works the first time, no bugs. -If you have any experience programming at all, you are probably -skeptical, as I was, but it seems to work: deriving code mathematically -seems to lead to fewer errors.

    -

    But my point now is that this great ratio of textual explanation to wind -up with code that consists of a few equations and could fit on an index -card is highly desirable. Less code has fewer errors. The structure of -Joy engenders a kind of thinking that seems to be very effective for -developing structured processes.

    -

    There seems to be an elegance and power to the notation.

    -
    - - -
    -
    -
    - -
    -
    - - - - \ No newline at end of file diff --git a/docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html b/docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html index c53e852..f1ca011 100644 --- a/docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html +++ b/docs/sphinx_docs/_build/html/notebooks/AlsoNewton.html @@ -6,7 +6,7 @@ - within — Thun 0.1.1 documentation + A Generator for Approximations — Thun 0.1.1 documentation @@ -30,25 +30,88 @@
    -
    -

    within

    +
    +

    A Generator for Approximations

    +

    In Using x to Generate Values we derive a function G (called make_generator in the dictionary) that accepts an initial value and a quoted program and returns a new quoted program that, when driven by the x combinator (joy.library.x()), acts like a lazy stream.

    +

    To make a generator that generates successive approximations let’s start by assuming an initial approximation and then derive the function that computes the next approximation:

    +
       a F
    +---------
    +    a'
    +
    +
    +
    +

    A Function to Compute the Next Approximation

    +

    Looking at the equation again:

    +

    \(a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}\)

    +
    a n over / + 2 /
    +a n a    / + 2 /
    +a n/a      + 2 /
    +a+n/a        2 /
    +(a+n/a)/2
    +
    +
    +

    The function we want has the argument n in it:

    +
    F == n over / + 2 /
    +
    +
    +
    +
    +

    Make it into a Generator

    +

    Our generator would be created by:

    +
    a [dup F] make_generator
    +
    +
    +

    With n as part of the function F, but n is the input to the sqrt function we’re writing. If we let 1 be the initial approximation:

    +
    1 n 1 / + 2 /
    +1 n/1   + 2 /
    +1 n     + 2 /
    +n+1       2 /
    +(n+1)/2
    +
    +
    +

    The generator can be written as:

    +
    1 swap [over / + 2 /] cons [dup] swoncat make_generator
    +
    +
    +

    Example:

    +
    23 1 swap  [over / + 2 /] cons [dup] swoncat make_generator
    +1 23       [over / + 2 /] cons [dup] swoncat make_generator
    +1       [23 over / + 2 /]      [dup] swoncat make_generator
    +1   [dup 23 over / + 2 /]                    make_generator
    +.
    +.
    +.
    +[1 swap [dup 23 over / + 2 /] direco]
    +
    +
    +
    +
    +

    A Generator of Square Root Approximations

    +
    gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator
    +
    +
    +
    +
    +
    +

    Finding Consecutive Approximations within a Tolerance

    The remainder of a square root finder is a function within, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance.

    From “Why Functional Programming Matters” by John Hughes

    (And note that by “list” he means a lazily-evaluated list.)

    -

    Using a generator driven by x and assuming such for square root approximations (or whatever) G, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack…

    +

    Using the output [a G] of the above generator for square root approximations, and further assuming that the first term a has been generated already and epsilon ε is handy on the stack…

       a [b G] ε within
    --------------------- a b - abs ε <=
    +---------------------- a b - abs ε <=
           b
    -
    -   a [b G] ε within
    --------------------- a b - abs ε >
    +
    +
    +
       a [b G] ε within
    +---------------------- a b - abs ε >
            .
        [b G] x ε ...
        b [c G] ε ...
            .
    ---------------------
    +----------------------
        b [c G] ε within
     
    @@ -85,7 +148,7 @@ Hughes

    1. Discard a.
    2. -
    3. Use x combinator to generate next term from G.
    4. +
    5. Use x combinator to generate next term from G.
    6. Run within with i (it is a primrec function.)
    a [b G]        ε R0           [within] R1
    @@ -104,14 +167,28 @@ Hughes

    Setting up

    -
    [a G] x ε
    -a [b G] ε
    +

    The recursive function we have defined so far needs a slight preamble: x to prime the generator and the epsilon value to use:

    +
    [a G] x ε ...
    +a [b G] ε ...
     
    -
    within == x ε [[first - abs] dip <=] [roll< popop first] [[popd x] dip] primrec
    +
    +
    +

    within

    +

    Giving us the following definitions:

    +
    _within_P == [first - abs] dip <=
    +_within_B == roll< popop first
    +_within_R == [popd x] dip
    +within == x ε [_within_P] [_within_B] [_within_R] primrec
     
    +
    +
    +

    Finding Square Roots

    +
    sqrt == gsra within
    +
    +
    @@ -122,13 +199,21 @@ Hughes

    Table Of Contents

      -
    • within

      Related Topics

      diff --git a/docs/sphinx_docs/_build/html/notebooks/Intro.html b/docs/sphinx_docs/_build/html/notebooks/Intro.html index df81c79..4fde6b0 100644 --- a/docs/sphinx_docs/_build/html/notebooks/Intro.html +++ b/docs/sphinx_docs/_build/html/notebooks/Intro.html @@ -90,7 +90,7 @@ list made from Python tuples.

      -

      Purely Functional Datastructures.

      +

      Purely Functional Datastructures

      Because Joy stacks are made out of Python tuples they are immutable, as are the other Python types we “borrow” for Joy, so all Joy datastructures are purely functional.

      @@ -138,7 +138,7 @@ structure out of the tokens. There’s no Abstract Syntax Tree or anything like that.

      Symbols

      -

      TODO: Symbols are just a string subclass; used by the parser to represent function names and by the interpreter to look up functions in the dictionary. N.B.: Symbols are not looked up at parse-time. You could define recursive functions, er, recusively, without genrec or other recursion combinators foo == ... fooo ... but don’t do that.

      +

      TODO: Symbols are just a string subclass; used by the parser to represent function names and by the interpreter to look up functions in the dictionary. N.B.: Symbols are not looked up at parse-time. You could define recursive functions, er, recusively, without genrec or other recursion combinators foo == ... foo ... but don’t do that.

      Token Regular Expressions

      @@ -300,7 +300,7 @@ developing structured processes.

    • Thun: Joy in Python
      • Read-Eval-Print Loop (REPL)
      • The Stack
      • -
      • Purely Functional Datastructures.
      • +
      • Purely Functional Datastructures
      • The joy() function
        • An Interpreter
        • Continuation-Passing Style
        • diff --git a/docs/sphinx_docs/_build/html/objects.inv b/docs/sphinx_docs/_build/html/objects.inv index 6b116c69a2cd3f85d1b8b410cad147aba6161f40..677395a82c5a5c833470a757c4e14a4e60d0721d 100644 GIT binary patch delta 1275 zcmV@)~`CK3JZl z3xbp&n~t?o4~aXQdj|yL^pJL1K1se`-Bd){F zYAw7pnvFN;6lS4PJK<{m98Af~a=YEbwyn39o$Z~}`17uo%707!x8+p@_JOZ0nTPxf zm`N=IG9e4aog*_xJkO^&%+?Ae_`>9S>$I)zV7-c42ZC>FMBmyZ-D_S%Wo>TEu z0W zu(ZlnM-1%I+QJsn7wmG$!$%o6=svk^i>DmfvHrnVGS3lLI?B z9=~N5AfU`}5stA?>~;GbE4u4J?dthN=X-cY*1?`%+I>7D>tN5XFc0aTk#(@=*L!(> z{XckqvzO;LJ9<{m{0R$>tF_<9+TNbu*wA;`-GexIMVRLaRFoX#Bmd}RUsWZ9^zIdYTMK}=YOWm zqz(?B=+I%BvGYNrgC^a@bHkc`uZ?MQB%LGVeNY&@v-JP&XE-T5^Hmm*q|}n%Ubb7>Dt0m9cfH$ zknlk9Aw!zBg#KAJf0gLvN86Jp(sZLb;eja%T;P lQ&+L8#)fP0V~s-(4_AO!L98{x^Y2(ee*gCG;6E&~E6dWAfYAT| delta 1259 zcmV@)~`CK3JZl z3xX0Mn~JqkFBXaYzHfoW0$9*@W;MDqD^{(}OOw|M*eS#JQQ=GVLu?uT$cBTvh+AW4 zwH96)&Bh%%g;}W7UbtF62U9Y$+-~=Uv|h!ngG7-i_;VY|1EPB^%Syo!0=LJ_ zZipmTk~?rDT2+mS_%kB@1qGjxz?N%KP#B^xQUHmefRiRd7%jLbGDvfl%Zdoksdysc z0k^CviDC_H41YBho>TF(pw6Uqq)DDBV@P>42W>&n7+!iPDUH_0zVH%?fYkvKTnq;x7dZ5m3xq~WC|;mrf>^l8pr5`mPa6)l}Xp{X3&-t9nvAb$v)~phX}=;)a|6U@MZ7BIj(>j^=%8mM@QkdZJ-@Jrct+OIo?l`f(mf;VXwR<>^8D(5@cjB9 z&#(9Ntep7+79Lk?zmJVQs)e0E>O|mzdw-Z4D+O2m3JD-eq>PC*bIVJ-4bKzJOS}px zQ-$@~E7{qjVuI&u$*{h02TWAog9ghz78xzX^{YR{MK8B5I9M`oSPKF6Cs#G@h#mQt zl`_K<_EvNJiz5v`92Y8fmrkhmO;XoevsoXn)dO zJRhv-_u81cqvyOiPcW#H6_y-n2E_Cje&SW(cBRoaCaT7^Z(sj$ES52;rn#+h4DgPK zY|O2aVeNY&@v-JP&XE-T5*u@r=+HA`%Ubb7>BhpYjx?q=NO*AgkReT5LjPMf|2pX9 zN88Sm=Se;A$P|fJ&heFFJTtXVS7g+B3A8nNB9m0RA&Z*CzQGb18JOK+qOUg9pBu#5 za*N+pn=DkOfgf3zflX23fLl>)ANR2>vaX|j!sjrEbzUOh)lclYvEf?$SmV&c!!_W2 V4Qq<<{2Nw^-@g7k_zyn+3VXM4agzW5 diff --git a/docs/sphinx_docs/_build/html/parser.html b/docs/sphinx_docs/_build/html/parser.html index 1644664..98b8ba9 100644 --- a/docs/sphinx_docs/_build/html/parser.html +++ b/docs/sphinx_docs/_build/html/parser.html @@ -72,7 +72,7 @@ Any unbalanced square brackets will raise a ParseError.

          Parameters:text (str) – Text to convert. -Return type:quote +Return type:stack Raises:ParseError – if the parse fails. diff --git a/docs/sphinx_docs/_build/html/pretty.html b/docs/sphinx_docs/_build/html/pretty.html index 9c27e73..c16e007 100644 --- a/docs/sphinx_docs/_build/html/pretty.html +++ b/docs/sphinx_docs/_build/html/pretty.html @@ -36,11 +36,7 @@

          Tracing Joy Execution

          joy.utils.pretty_print

          -

          Pretty printing support.

          -
          -
          -class joy.utils.pretty_print.TracePrinter[source]
          -

          This is what does the formatting, e.g.:

          +

          Pretty printing support, e.g.:

          Joy? 23 18 * 99 +
                  . 23 18 mul 99 add
               23 . 18 mul 99 add
          @@ -48,12 +44,54 @@
              414 . 99 add
           414 99 . add
              513 . 
          +
          +513 <-top
          +
          +joy? 
           
          +

          On each line the stack is printed with the top to the right, then a . to +represent the current locus of processing, then the pending expression to the +left.

          +
          +
          +class joy.utils.pretty_print.TracePrinter[source]
          +

          This is what does the formatting. You instantiate it and pass the viewer() +method to the joy.joy.joy() function, then print it to see the +trace.

          +
          +
          +go()[source]
          +

          Return a list of strings, one for each entry in the history, prefixed +with enough spaces to align all the interpreter dots.

          +

          This method is called internally by the __str__() method.

          + +++ + + + +
          Return type:list(str)
          +
          +
          viewer(stack, expression)[source]
          -

          Pass this method as the viewer to joy() function.

          +

          Record the current stack and expression in the TracePrinter’s history. +Pass this method as the viewer argument to the joy.joy.joy() function.

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

          Stack or Quote or Sequence or List…

          joy.utils.stack

          -

          When talking about Joy we use the terms “stack”, “list”, “sequence”, -“quote” and others to mean the same thing: a simple linear datatype that +

          When talking about Joy we use the terms “stack”, “quote”, “sequence”, +“list”, and others to mean the same thing: a simple linear datatype that permits certain operations such as iterating and pushing and popping values from (at least) one end.

          -

          We use the cons list, a venerable two-tuple recursive sequence datastructure, where the +

          There is no “Stack” Python class, instead we use the cons list, a +venerable two-tuple recursive sequence datastructure, where the empty tuple () is the empty stack and (head, rest) gives the recursive form of a stack with one or more items on it:

          stack := () | (item, stack)
          @@ -66,6 +67,19 @@ in this case “(head, tail)”, and Python takes care of unpacking the
           incoming tuple and assigning values to the names.  (Note that Python
           syntax doesn’t require parentheses around tuples used in expressions
           where they would be redundant.)

          +

          Unfortunately, the Sphinx documentation generator, which is used to generate this +web page, doesn’t handle tuples in the function parameters. And in Python 3, this +syntax was removed entirely. Instead you would have to write:

          +
          def dup(stack):
          +  head, tail = stack
          +  return head, (head, tail)
          +
          +
          +

          We have two very simple functions, one to build up a stack from a Python +iterable and another to iterate through a stack and yield its items +one-by-one in order. There are also two functions to generate string representations +of stacks. They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left. In both functions internal stacks are +printed left-to-right. These functions are written to support Tracing Joy Execution.

          joy.utils.stack.expression_to_string(expression)[source]
          @@ -74,12 +88,32 @@ where they would be redundant.)

          (top, (second, ...)) -> 'top second ...'
           
          + +++ + + + + + +
          Parameters:expression (stack) – A stack.
          Return type:str
          joy.utils.stack.iter_stack(stack)[source]

          Iterate through the items on the stack.

          + +++ + + + + + +
          Parameters:stack (stack) – A stack.
          Return type:iterator
          @@ -89,12 +123,49 @@ where they would be redundant.)

          [1, 2, 3] -> (1, (2, (3, ())))
           
          + +++ + + + + + +
          Parameters:
            +
          • el (list) – A Python list or other sequence (iterators and generators +won’t work because reverse() is called on el.)
          • +
          • stack (stack) – A stack, optional, defaults to the empty stack.
          • +
          +
          Return type:

          stack

          +
          joy.utils.stack.pick(s, n)[source]
          -

          Find the nth item on the stack. (Pick with zero is the same as “dup”.)

          +

          Return the nth item on the stack.

          + +++ + + + + + + + +
          Parameters:
            +
          • s (stack) – A stack.
          • +
          • n (int) – An index into the stack.
          • +
          +
          Raises:
            +
          • ValueError – if n is less than zero.
          • +
          • IndexError – if n is equal to or greater than the length of s.
          • +
          +
          Return type:

          whatever

          +
          @@ -102,6 +173,24 @@ where they would be redundant.)

          joy.utils.stack.pushback(quote, expression)[source]

          Concatinate quote onto expression.

          In joy [1 2] [3 4] would become [1 2 3 4].

          + +++ + + + + + + + +
          Parameters:
            +
          • quote (stack) – A stack.
          • +
          • expression (stack) – A stack.
          • +
          +
          Raises:

          RuntimeError – if quote is larger than sys.getrecursionlimit().

          +
          Return type:

          stack

          +
          @@ -112,6 +201,16 @@ where they would be redundant.)

          (top, (second, ...)) -> '... second top'
           
          + +++ + + + + + +
          Parameters:stack (stack) – A stack.
          Return type:str
          diff --git a/docs/sphinx_docs/notebooks/AlsoNewton.rst b/docs/sphinx_docs/notebooks/AlsoNewton.rst index 4251a23..89b5262 100644 --- a/docs/sphinx_docs/notebooks/AlsoNewton.rst +++ b/docs/sphinx_docs/notebooks/AlsoNewton.rst @@ -1,6 +1,80 @@ -*************** -``within`` -*************** + + + + +A Generator for Approximations +============================== + +In :doc:`Generator Programs` we derive a function ``G`` (called ``make_generator`` in the dictionary) that accepts an initial value and a quoted program and returns a new quoted program that, when driven by the ``x`` combinator (:py:func:`joy.library.x`), acts like a lazy stream. + +To make a generator that generates successive approximations let's start by assuming an initial approximation and then derive the function that computes the next approximation:: + + a F + --------- + a' + + +A Function to Compute the Next Approximation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Looking at the equation again: + +:math:`a_{i+1} = \frac{(a_i+\frac{n}{a_i})}{2}` + +:: + + a n over / + 2 / + a n a / + 2 / + a n/a + 2 / + a+n/a 2 / + (a+n/a)/2 + +The function we want has the argument ``n`` in it:: + + F == n over / + 2 / + + +Make it into a Generator +^^^^^^^^^^^^^^^^^^^^^^^^ + +Our generator would be created by:: + + a [dup F] make_generator + +With ``n`` as part of the function ``F``, but ``n`` is the input to the ``sqrt`` function we're writing. If we let 1 be the initial approximation:: + + 1 n 1 / + 2 / + 1 n/1 + 2 / + 1 n + 2 / + n+1 2 / + (n+1)/2 + +The generator can be written as:: + + 1 swap [over / + 2 /] cons [dup] swoncat make_generator + +Example:: + + 23 1 swap [over / + 2 /] cons [dup] swoncat make_generator + 1 23 [over / + 2 /] cons [dup] swoncat make_generator + 1 [23 over / + 2 /] [dup] swoncat make_generator + 1 [dup 23 over / + 2 /] make_generator + . + . + . + [1 swap [dup 23 over / + 2 /] direco] + + +A Generator of Square Root Approximations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:: + + gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator + + +Finding Consecutive Approximations ``within`` a Tolerance +========================================================= The remainder of a square root finder is a function *within*, which takes a tolerance and a list of approximations and looks down the list for two successive approximations that differ by no more than the given tolerance. @@ -9,21 +83,23 @@ Hughes `__ (And note that by "list" he means a lazily-evaluated list.) -Using a :doc:`generator ` driven by ``x`` and assuming such for square root approximations (or whatever) ``G``, and further assuming that the first term ``a`` has been generated already and epsilon ``ε`` is handy on the stack... +Using the *output* ``[a G]`` of the above :doc:`generator ` for square root approximations, and further assuming that the first term ``a`` has been generated already and epsilon ``ε`` is handy on the stack... :: a [b G] ε within - -------------------- a b - abs ε <= + ---------------------- a b - abs ε <= b +:: + a [b G] ε within - -------------------- a b - abs ε > + ---------------------- a b - abs ε > . [b G] x ε ... b [c G] ε ... . - -------------------- + ---------------------- b [c G] ε within @@ -60,6 +136,7 @@ Base-Case B == roll< popop first + Recur ^^^^^^^^^^^^^ @@ -69,7 +146,7 @@ Recur 1. Discard ``a``. -2. Use ``x`` combinator to generate next term from G. +2. Use ``x`` combinator to generate next term from ``G``. 3. Run ``within`` with ``i`` (it is a ``primrec`` function.) :: @@ -87,38 +164,32 @@ Recur R0 == [popd x] dip + Setting up ^^^^^^^^^^ -:: +The recursive function we have defined so far needs a slight preamble: ``x`` to prime the generator and the epsilon value to use:: - [a G] x ε - a [b G] ε + [a G] x ε ... + a [b G] ε ... + + +``within`` +^^^^^^^^^^ + +Giving us the following definitions:: + + _within_P == [first - abs] dip <= + _within_B == roll< popop first + _within_R == [popd x] dip + within == x ε [_within_P] [_within_B] [_within_R] primrec + + +Finding Square Roots +==================== :: - within == x ε [[first - abs] dip <=] [roll< popop first] [[popd x] dip] primrec - - - - - - - - - - - - - - - - - - - - - - + sqrt == gsra within