From 36b770f0009eda5633c6248261e171b3664eac59 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Wed, 6 Jun 2018 13:07:31 -0700 Subject: [PATCH] Make hates spaces in file names. --- ... This Implementation of Joy in Python.html | 12620 ------------ ...This Implementation of Joy in Python.ipynb | 651 - ...0. This Implementation of Joy in Python.md | 410 - .... This Implementation of Joy in Python.rst | 535 - docs/1. Basic Use of Joy in a Notebook.html | 12079 ----------- docs/1. Basic Use of Joy in a Notebook.ipynb | 240 - docs/1. Basic Use of Joy in a Notebook.md | 137 - docs/1. Basic Use of Joy in a Notebook.rst | 154 - docs/2. Library Examples.html | 16523 ---------------- docs/2. Library Examples.ipynb | 2964 --- docs/2. Library Examples.md | 1395 -- docs/2. Library Examples.rst | 1761 -- docs/3. Developing a Program.html | 13283 ------------- docs/3. Developing a Program.ipynb | 1121 -- docs/3. Developing a Program.md | 694 - docs/3. Developing a Program.rst | 799 - docs/Advent of Code 2017 December 1st.html | 12432 ------------ docs/Advent of Code 2017 December 1st.ipynb | 455 - docs/Advent of Code 2017 December 1st.md | 228 - docs/Advent of Code 2017 December 1st.rst | 288 - docs/Advent of Code 2017 December 2nd.html | 12487 ------------ docs/Advent of Code 2017 December 2nd.ipynb | 554 - docs/Advent of Code 2017 December 2nd.md | 361 - docs/Advent of Code 2017 December 2nd.rst | 432 - docs/Advent of Code 2017 December 3rd.html | 13592 ------------- docs/Advent of Code 2017 December 3rd.ipynb | 1426 -- docs/Advent of Code 2017 December 3rd.md | 843 - docs/Advent of Code 2017 December 3rd.rst | 973 - .../Advent of Code 2017 December 3rd_29_0.png | Bin 677 -> 0 bytes .../Advent of Code 2017 December 3rd_35_1.png | Bin 566 -> 0 bytes .../Advent of Code 2017 December 3rd_36_1.png | Bin 977 -> 0 bytes .../Advent of Code 2017 December 3rd_42_0.png | Bin 655 -> 0 bytes .../Advent of Code 2017 December 3rd_43_0.png | Bin 665 -> 0 bytes .../Advent of Code 2017 December 3rd_45_0.png | Bin 758 -> 0 bytes .../Advent of Code 2017 December 3rd_49_1.png | Bin 566 -> 0 bytes .../Advent of Code 2017 December 3rd_52_1.png | Bin 566 -> 0 bytes .../Advent of Code 2017 December 3rd_56_0.png | Bin 453 -> 0 bytes .../Advent of Code 2017 December 3rd_59_0.png | Bin 239 -> 0 bytes .../Advent of Code 2017 December 3rd_60_0.png | Bin 337 -> 0 bytes .../Advent of Code 2017 December 3rd_61_0.png | Bin 447 -> 0 bytes .../Advent of Code 2017 December 3rd_62_1.png | Bin 784 -> 0 bytes docs/Advent of Code 2017 December 4th.html | 11939 ----------- docs/Advent of Code 2017 December 4th.ipynb | 139 - docs/Advent of Code 2017 December 4th.md | 64 - docs/Advent of Code 2017 December 4th.rst | 77 - docs/Advent of Code 2017 December 5th.html | 12207 ------------ docs/Advent of Code 2017 December 5th.ipynb | 380 - docs/Advent of Code 2017 December 5th.md | 244 - docs/Advent of Code 2017 December 5th.rst | 324 - docs/Advent of Code 2017 December 6th.html | 12415 ------------ docs/Advent of Code 2017 December 6th.ipynb | 457 - docs/Advent of Code 2017 December 6th.md | 267 - docs/Advent of Code 2017 December 6th.rst | 305 - docs/Document.md | 469 - docs/Generator Programs.html | 13245 ------------- docs/Generator Programs.ipynb | 1027 - docs/Generator Programs.md | 508 - docs/Generator Programs.rst | 639 - ...ara-morphisms - Recursion Combinators.html | 15184 -------------- ...ra-morphisms - Recursion Combinators.ipynb | 2987 --- ... Para-morphisms - Recursion Combinators.md | 2449 --- ...Para-morphisms - Recursion Combinators.rst | 2680 --- docs/Library Examples.pdf | Bin 198245 -> 0 bytes docs/README.md | 44 - 64 files changed, 187487 deletions(-) delete mode 100644 docs/0. This Implementation of Joy in Python.html delete mode 100644 docs/0. This Implementation of Joy in Python.ipynb delete mode 100644 docs/0. This Implementation of Joy in Python.md delete mode 100644 docs/0. This Implementation of Joy in Python.rst delete mode 100644 docs/1. Basic Use of Joy in a Notebook.html delete mode 100644 docs/1. Basic Use of Joy in a Notebook.ipynb delete mode 100644 docs/1. Basic Use of Joy in a Notebook.md delete mode 100644 docs/1. Basic Use of Joy in a Notebook.rst delete mode 100644 docs/2. Library Examples.html delete mode 100644 docs/2. Library Examples.ipynb delete mode 100644 docs/2. Library Examples.md delete mode 100644 docs/2. Library Examples.rst delete mode 100644 docs/3. Developing a Program.html delete mode 100644 docs/3. Developing a Program.ipynb delete mode 100644 docs/3. Developing a Program.md delete mode 100644 docs/3. Developing a Program.rst delete mode 100644 docs/Advent of Code 2017 December 1st.html delete mode 100644 docs/Advent of Code 2017 December 1st.ipynb delete mode 100644 docs/Advent of Code 2017 December 1st.md delete mode 100644 docs/Advent of Code 2017 December 1st.rst delete mode 100644 docs/Advent of Code 2017 December 2nd.html delete mode 100644 docs/Advent of Code 2017 December 2nd.ipynb delete mode 100644 docs/Advent of Code 2017 December 2nd.md delete mode 100644 docs/Advent of Code 2017 December 2nd.rst delete mode 100644 docs/Advent of Code 2017 December 3rd.html delete mode 100644 docs/Advent of Code 2017 December 3rd.ipynb delete mode 100644 docs/Advent of Code 2017 December 3rd.md delete mode 100644 docs/Advent of Code 2017 December 3rd.rst delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_29_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_35_1.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_36_1.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_42_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_43_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_45_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_49_1.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_52_1.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_56_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_59_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_60_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_61_0.png delete mode 100644 docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_62_1.png delete mode 100644 docs/Advent of Code 2017 December 4th.html delete mode 100644 docs/Advent of Code 2017 December 4th.ipynb delete mode 100644 docs/Advent of Code 2017 December 4th.md delete mode 100644 docs/Advent of Code 2017 December 4th.rst delete mode 100644 docs/Advent of Code 2017 December 5th.html delete mode 100644 docs/Advent of Code 2017 December 5th.ipynb delete mode 100644 docs/Advent of Code 2017 December 5th.md delete mode 100644 docs/Advent of Code 2017 December 5th.rst delete mode 100644 docs/Advent of Code 2017 December 6th.html delete mode 100644 docs/Advent of Code 2017 December 6th.ipynb delete mode 100644 docs/Advent of Code 2017 December 6th.md delete mode 100644 docs/Advent of Code 2017 December 6th.rst delete mode 100644 docs/Document.md delete mode 100644 docs/Generator Programs.html delete mode 100644 docs/Generator Programs.ipynb delete mode 100644 docs/Generator Programs.md delete mode 100644 docs/Generator Programs.rst delete mode 100644 docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.html delete mode 100644 docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.ipynb delete mode 100644 docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.md delete mode 100644 docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst delete mode 100644 docs/Library Examples.pdf delete mode 100644 docs/README.md diff --git a/docs/0. This Implementation of Joy in Python.html b/docs/0. This Implementation of Joy in Python.html deleted file mode 100644 index 6982023..0000000 --- a/docs/0. This Implementation of Joy in Python.html +++ /dev/null @@ -1,12620 +0,0 @@ - - - -0. This Implementation of Joy in Python - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

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.

- -
-
-
-
-
-
In [1]:
-
-
-
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 utility functions maintain order.

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

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

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

- -
-
-
-
-
-
In [4]:
-
-
-
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]
-
-
-
- -
-
- -
-
-
-
-
-

Purely Functional Datastructures.

Because Joy lists are made out of Python tuples they are immutable, so all Joy datastructures are purely functional.

- -
-
-
-
-
-
-
-

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.)

- -
-
-
-
-
-
In [5]:
-
-
-
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

-
-
-
-
-
-
In [6]:
-
-
-
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.

- -
-
-
-
-
-
In [7]:
-
-
-
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.

- -
-
-
-
-
-
In [8]:
-
-
-
joy.parser.text_to_expression('1 2 3 4 5')  # A simple sequence.
-
- -
-
-
- -
-
- - -
- -
Out[8]:
- - - - -
-
(1, (2, (3, (4, (5, ())))))
-
- -
- -
-
- -
-
-
-
In [9]:
-
-
-
joy.parser.text_to_expression('[1 2 3] 4 5')  # Three items, the first is a list with three items
-
- -
-
-
- -
-
- - -
- -
Out[9]:
- - - - -
-
((1, (2, (3, ()))), (4, (5, ())))
-
- -
- -
-
- -
-
-
-
In [10]:
-
-
-
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.
-
- -
-
-
- -
-
- - -
- -
Out[10]:
- - - - -
-
(1, (23, (('four', ((-5.0, ()), (cons, ()))), (8888, ()))))
-
- -
- -
-
- -
-
-
-
In [11]:
-
-
-
joy.parser.text_to_expression('[][][][][]')  # Five empty lists.
-
- -
-
-
- -
-
- - -
- -
Out[11]:
- - - - -
-
((), ((), ((), ((), ((), ())))))
-
- -
- -
-
- -
-
-
-
In [12]:
-
-
-
joy.parser.text_to_expression('[[[[[]]]]]')  # Five nested lists.
-
- -
-
-
- -
-
- - -
- -
Out[12]:
- - - - -
-
((((((), ()), ()), ()), ()), ())
-
- -
- -
-
- -
-
-
-
-
-

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.

- -
-
-
-
-
-
In [13]:
-
-
-
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:

- -
-
-
-
-
-
In [14]:
-
-
-
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.

- -
-
-
-
-
-
In [15]:
-
-
-
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.)

-

"There should be only one."

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

-

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

-

Literary Code Library

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

-

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

-

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

- -
-
-
-
-
-
In [ ]:
-
-
-
  
-
- -
-
-
- -
-
-
- - - - - - diff --git a/docs/0. This Implementation of Joy in Python.ipynb b/docs/0. This Implementation of Joy in Python.ipynb deleted file mode 100644 index 8b3ce7e..0000000 --- a/docs/0. This Implementation of Joy in Python.ipynb +++ /dev/null @@ -1,651 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Joypy\n", - "\n", - "## Joy in Python\n", - "\n", - "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.\n", - "\n", - "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." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### [Read-Eval-Print Loop (REPL)](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)\n", - "The main way to interact with the Joy interpreter is through a simple [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) that you start by running the package:\n", - "\n", - " $ python -m joy\n", - " Joypy - Copyright © 2017 Simon Forman\n", - " This program comes with ABSOLUTELY NO WARRANTY; for details type \"warranty\".\n", - " This is free software, and you are welcome to redistribute it\n", - " under certain conditions; type \"sharing\" for details.\n", - " Type \"words\" to see a list of all words, and \"[] help\" to print the\n", - " docs for a word.\n", - "\n", - "\n", - " <-top\n", - "\n", - " joy? _\n", - "\n", - "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](#The-TracePrinter.) will be printed followed by the stack and prompt again:\n", - "\n", - " joy? 23 sqr 18 +\n", - " . 23 sqr 18 +\n", - " 23 . sqr 18 +\n", - " 23 . dup mul 18 +\n", - " 23 23 . mul 18 +\n", - " 529 . 18 +\n", - " 529 18 . +\n", - " 547 . \n", - "\n", - " 547 <-top\n", - "\n", - " joy? \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Stacks (aka list, quote, sequence, etc.)\n", - "\n", - "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](https://en.wikipedia.org/wiki/Cons#Lists) made from Python tuples." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "§ Stack\n", - "\n", - "\n", - "When talking about Joy we use the terms \"stack\", \"list\", \"sequence\" and\n", - "\"aggregate\" to mean the same thing: a simple datatype that permits\n", - "certain operations such as iterating and pushing and popping values from\n", - "(at least) one end.\n", - "\n", - "We use the venerable two-tuple recursive form of sequences where the\n", - "empty tuple () is the empty stack and (head, rest) gives the recursive\n", - "form of a stack with one or more items on it.\n", - "\n", - " ()\n", - " (1, ())\n", - " (2, (1, ()))\n", - " (3, (2, (1, ())))\n", - " ...\n", - "\n", - "And so on.\n", - "\n", - "\n", - "We have two very simple functions to build up a stack from a Python\n", - "iterable and also to iterate through a stack and yield its items\n", - "one-by-one in order, and two functions to generate string representations\n", - "of stacks:\n", - "\n", - " list_to_stack()\n", - "\n", - " iter_stack()\n", - "\n", - " expression_to_string() (prints left-to-right)\n", - "\n", - " stack_to_string() (prints right-to-left)\n", - "\n", - "\n", - "A word about the stack data structure.\n", - "\n", - "Python has very nice \"tuple packing and unpacking\" in its syntax which\n", - "means we can directly \"unpack\" the expected arguments to a Joy function.\n", - "\n", - "For example:\n", - "\n", - " def dup(stack):\n", - " head, tail = stack\n", - " return head, (head, tail)\n", - "\n", - "We replace the argument \"stack\" by the expected structure of the stack,\n", - "in this case \"(head, tail)\", and Python takes care of de-structuring the\n", - "incoming argument and assigning values to the names. Note that Python\n", - "syntax doesn't require parentheses around tuples used in expressions\n", - "where they would be redundant.\n" - ] - } - ], - "source": [ - "import inspect\n", - "import joy.utils.stack\n", - "\n", - "\n", - "print inspect.getdoc(joy.utils.stack)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### The utility functions maintain order.\n", - "The 0th item in the list will be on the top of the stack and *vise versa*." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, (2, (3, ())))" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "joy.utils.stack.list_to_stack([1, 2, 3])" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 2, 3]" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "list(joy.utils.stack.iter_stack((1, (2, (3, ())))))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This requires reversing the sequence (or iterating backwards) otherwise:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(3, (2, (1, ())))\n", - "[3, 2, 1]\n" - ] - } - ], - "source": [ - "stack = ()\n", - "\n", - "for n in [1, 2, 3]:\n", - " stack = n, stack\n", - "\n", - "print stack\n", - "print list(joy.utils.stack.iter_stack(stack))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Purely Functional Datastructures.\n", - "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)*." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# The `joy()` function.\n", - "## An Interpreter\n", - "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.\n", - "\n", - "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.)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "def joy(stack, expression, dictionary, viewer=None):\n", - " '''\n", - " Evaluate the Joy expression on the stack.\n", - " '''\n", - " while expression:\n", - "\n", - " if viewer: viewer(stack, expression)\n", - "\n", - " term, expression = expression\n", - " if isinstance(term, Symbol):\n", - " term = dictionary[term]\n", - " stack, expression, dictionary = term(stack, expression, dictionary)\n", - " else:\n", - " stack = term, stack\n", - "\n", - " if viewer: viewer(stack, expression)\n", - " return stack, expression, dictionary\n", - "\n" - ] - } - ], - "source": [ - "import joy.joy\n", - "\n", - "print inspect.getsource(joy.joy.joy)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### View function\n", - "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." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### The `TracePrinter`.\n", - "\n", - "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." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### [Continuation-Passing Style](https://en.wikipedia.org/wiki/Continuation-passing_style)\n", - "One day I thought, What happens if you rewrite Joy to use [CSP](https://en.wikipedia.org/wiki/Continuation-passing_style)? I made all the functions accept and return the expression as well as the stack and found that all the combinators could be rewritten to work by modifying the expression rather than making recursive calls to the `joy()` function." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Parser" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "§ Converting text to a joy expression.\n", - "\n", - "This module exports a single function:\n", - "\n", - " text_to_expression(text)\n", - "\n", - "As well as a single Symbol class and a single Exception type:\n", - "\n", - " ParseError\n", - "\n", - "When supplied with a string this function returns a Python datastructure\n", - "that represents the Joy datastructure described by the text expression.\n", - "Any unbalanced square brackets will raise a ParseError.\n" - ] - } - ], - "source": [ - "import joy.parser\n", - "\n", - "print inspect.getdoc(joy.parser)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "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." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "def _parse(tokens):\n", - " '''\n", - " Return a stack/list expression of the tokens.\n", - " '''\n", - " frame = []\n", - " stack = []\n", - " for tok in tokens:\n", - " if tok == '[':\n", - " stack.append(frame)\n", - " frame = []\n", - " stack[-1].append(frame)\n", - " elif tok == ']':\n", - " try:\n", - " frame = stack.pop()\n", - " except IndexError:\n", - " raise ParseError('One or more extra closing brackets.')\n", - " frame[-1] = list_to_stack(frame[-1])\n", - " else:\n", - " frame.append(tok)\n", - " if stack:\n", - " raise ParseError('One or more unclosed brackets.')\n", - " return list_to_stack(frame)\n", - "\n" - ] - } - ], - "source": [ - "print inspect.getsource(joy.parser._parse)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That's pretty much all there is to it." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, (2, (3, (4, (5, ())))))" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "joy.parser.text_to_expression('1 2 3 4 5') # A simple sequence." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "((1, (2, (3, ()))), (4, (5, ())))" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "joy.parser.text_to_expression('[1 2 3] 4 5') # Three items, the first is a list with three items" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, (23, (('four', ((-5.0, ()), (cons, ()))), (8888, ()))))" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "joy.parser.text_to_expression('1 23 [\"four\" [-5.0] cons] 8888') # A mixed bag. cons is\n", - " # a Symbol, no lookup at\n", - " # parse-time. Haiku docs." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "((), ((), ((), ((), ((), ())))))" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "joy.parser.text_to_expression('[][][][][]') # Five empty lists." - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "((((((), ()), ()), ()), ()), ())" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "joy.parser.text_to_expression('[[[[[]]]]]') # Five nested lists." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Library\n", - "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." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "!= % & * *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 •\n" - ] - } - ], - "source": [ - "import joy.library\n", - "\n", - "print ' '.join(sorted(joy.library.initialize()))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Many of the functions are defined in Python, like `dip`:" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "def dip(stack, expression, dictionary):\n", - " (quote, (x, stack)) = stack\n", - " expression = x, expression\n", - " return stack, pushback(quote, expression), dictionary\n", - "\n" - ] - } - ], - "source": [ - "print inspect.getsource(joy.library.dip)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "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." - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "second == rest first\n", - "third == rest rest first\n", - "product == 1 swap [*] step\n", - "swons == swap cons\n", - "swoncat == swap concat\n", - "flatten == [] swap [concat] step\n", - "unit == [] cons\n", - "quoted == [unit] dip\n", - "unquoted == [i] dip\n", - "enstacken == stack [clear] dip\n", - "disenstacken == ? [uncons ?] loop pop\n", - "? == dup truthy\n", - "dinfrirst == dip infra first\n", - "nullary == [stack] dinfrirst\n", - "unary == [stack [pop] dip] dinfrirst\n", - "binary == [stack [popop] dip] dinfrirst\n", - "ternary == [stack [popop pop] dip] dinfrirst\n", - "pam == [i] map\n", - "run == [] swap infra\n", - "sqr == dup mul\n", - "size == 0 swap [pop ++] step\n", - "cleave == [i] app2 [popd] dip\n", - "average == [sum 1.0 *] [size] cleave /\n", - "gcd == 1 [tuck modulus dup 0 >] loop pop\n", - "least_fraction == dup [gcd] infra [div] concat map\n", - "*fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons\n", - "*fraction0 == concat [[swap] dip * [*] dip] infra\n", - "down_to_zero == [0 >] [dup --] while\n", - "range_to_zero == unit [down_to_zero] infra\n", - "anamorphism == [pop []] swap [dip swons] genrec\n", - "range == [0 <=] [1 - dup] anamorphism\n", - "while == swap [nullary] cons dup dipd concat loop\n", - "dudipd == dup dipd\n", - "primrec == [i] genrec\n", - "\n" - ] - } - ], - "source": [ - "print joy.library.definitions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "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.\n", - "\n", - "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.)\n", - "\n", - "#### \"There should be only one.\"\n", - "\n", - "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.\n", - "\n", - "Code should not burgeon wildly, as it does today. The variety of code should map more-or-less to the well-factored variety of human computably-solvable problems. There shouldn't be dozens of chat apps, JS frameworks, programming languages. It's a waste of time, a [fractal \"thundering herd\" attack](https://en.wikipedia.org/wiki/Thundering_herd_problem) on human mentality.\n", - "\n", - "#### Literary Code Library\n", - "\n", - "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.\n", - "\n", - "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.\n", - "\n", - "There seems to be an elegance and power to the notation.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - " " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/0. This Implementation of Joy in Python.md b/docs/0. This Implementation of Joy in Python.md deleted file mode 100644 index d3871fa..0000000 --- a/docs/0. This Implementation of Joy in Python.md +++ /dev/null @@ -1,410 +0,0 @@ - -# 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)](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) -The main way to interact with the Joy interpreter is through a simple [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) that you start by running the package: - - $ 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 "[] 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](#The-TracePrinter.) 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](https://en.wikipedia.org/wiki/Cons#Lists) made from Python tuples. - - -```python -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 utility functions maintain order. -The 0th item in the list will be on the top of the stack and *vise versa*. - - -```python -joy.utils.stack.list_to_stack([1, 2, 3]) -``` - - - - - (1, (2, (3, ()))) - - - - -```python -list(joy.utils.stack.iter_stack((1, (2, (3, ()))))) -``` - - - - - [1, 2, 3] - - - -This requires reversing the sequence (or iterating backwards) otherwise: - - -```python -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] - - -### Purely Functional Datastructures. -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.) - - -```python -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](https://en.wikipedia.org/wiki/Continuation-passing_style) -One day I thought, What happens if you rewrite Joy to use [CSP](https://en.wikipedia.org/wiki/Continuation-passing_style)? I made all the functions accept and return the expression as well as the stack and found that all the combinators could be rewritten to work by modifying the expression rather than making recursive calls to the `joy()` function. - -# Parser - - -```python -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. - - -```python -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. - - -```python -joy.parser.text_to_expression('1 2 3 4 5') # A simple sequence. -``` - - - - - (1, (2, (3, (4, (5, ()))))) - - - - -```python -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, ()))) - - - - -```python -joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888') # A mixed bag. cons is - # a Symbol, no lookup at - # parse-time. Haiku docs. -``` - - - - - (1, (23, (('four', ((-5.0, ()), (cons, ()))), (8888, ())))) - - - - -```python -joy.parser.text_to_expression('[][][][][]') # Five empty lists. -``` - - - - - ((), ((), ((), ((), ((), ()))))) - - - - -```python -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. - - -```python -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`: - - -```python -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. - - -```python -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.) - -#### "There should be only one." - -Which brings me to talking about one of my hopes and dreams for this notation: "There should be only one." What I mean is that there should be one universal standard dictionary of commands, and all bespoke work done in a UI for purposes takes place by direct interaction and macros. There would be a *Grand Refactoring* biannually (two years, not six months, that's semi-annually) where any new definitions factored out of the usage and macros of the previous time, along with new algorithms and such, were entered into the dictionary and posted to e.g. IPFS. - -Code should not burgeon wildly, as it does today. The variety of code should map more-or-less to the well-factored variety of human computably-solvable problems. There shouldn't be dozens of chat apps, JS frameworks, programming languages. It's a waste of time, a [fractal "thundering herd" attack](https://en.wikipedia.org/wiki/Thundering_herd_problem) on human mentality. - -#### Literary Code Library - -If you read over the other notebooks you'll see that developing code in Joy is a lot like doing simple mathematics, and the descriptions of the code resemble math papers. The code also works the first time, no bugs. If you have any experience programming at all, you are probably skeptical, as I was, but it seems to work: deriving code mathematically seems to lead to fewer errors. - -But my point now is that this great ratio of textual explanation to wind up with code that consists of a few equations and could fit on an index card is highly desirable. Less code has fewer errors. The structure of Joy engenders a kind of thinking that seems to be very effective for developing structured processes. - -There seems to be an elegance and power to the notation. - - - -```python - -``` diff --git a/docs/0. This Implementation of Joy in Python.rst b/docs/0. This Implementation of Joy in Python.rst deleted file mode 100644 index 7515dcc..0000000 --- a/docs/0. This Implementation of Joy in Python.rst +++ /dev/null @@ -1,535 +0,0 @@ - -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 "[] 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 <#The-TracePrinter.>`__ 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. - -.. code:: ipython2 - - import inspect - import joy.utils.stack - - - print inspect.getdoc(joy.utils.stack) - - -.. parsed-literal:: - - § 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 utility functions maintain order. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The 0th item in the list will be on the top of the stack and *vise -versa*. - -.. code:: ipython2 - - joy.utils.stack.list_to_stack([1, 2, 3]) - - - - -.. parsed-literal:: - - (1, (2, (3, ()))) - - - -.. code:: ipython2 - - list(joy.utils.stack.iter_stack((1, (2, (3, ()))))) - - - - -.. parsed-literal:: - - [1, 2, 3] - - - -This requires reversing the sequence (or iterating backwards) otherwise: - -.. code:: ipython2 - - stack = () - - for n in [1, 2, 3]: - stack = n, stack - - print stack - print list(joy.utils.stack.iter_stack(stack)) - - -.. parsed-literal:: - - (3, (2, (1, ()))) - [3, 2, 1] - - -Purely Functional Datastructures. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Because Joy lists are made out of Python tuples they are immutable, so -all Joy datastructures are *`purely -functional `__*. - -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.) - -.. code:: ipython2 - - import joy.joy - - print inspect.getsource(joy.joy.joy) - - -.. parsed-literal:: - - 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 -====== - -.. code:: ipython2 - - import joy.parser - - print inspect.getdoc(joy.parser) - - -.. parsed-literal:: - - § 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. - -.. code:: ipython2 - - print inspect.getsource(joy.parser._parse) - - -.. parsed-literal:: - - 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. - -.. code:: ipython2 - - joy.parser.text_to_expression('1 2 3 4 5') # A simple sequence. - - - - -.. parsed-literal:: - - (1, (2, (3, (4, (5, ()))))) - - - -.. code:: ipython2 - - joy.parser.text_to_expression('[1 2 3] 4 5') # Three items, the first is a list with three items - - - - -.. parsed-literal:: - - ((1, (2, (3, ()))), (4, (5, ()))) - - - -.. code:: ipython2 - - joy.parser.text_to_expression('1 23 ["four" [-5.0] cons] 8888') # A mixed bag. cons is - # a Symbol, no lookup at - # parse-time. Haiku docs. - - - - -.. parsed-literal:: - - (1, (23, (('four', ((-5.0, ()), (cons, ()))), (8888, ())))) - - - -.. code:: ipython2 - - joy.parser.text_to_expression('[][][][][]') # Five empty lists. - - - - -.. parsed-literal:: - - ((), ((), ((), ((), ((), ()))))) - - - -.. code:: ipython2 - - joy.parser.text_to_expression('[[[[[]]]]]') # Five nested lists. - - - - -.. parsed-literal:: - - ((((((), ()), ()), ()), ()), ()) - - - -Library -======= - -The Joy library of functions (aka commands, or "words" after Forth -usage) encapsulates all the actual functionality (no pun intended) of -the Joy system. There are simple functions such as addition ``add`` (or -``+``, the library module supports aliases), and combinators which -provide control-flow and higher-order operations. - -.. code:: ipython2 - - import joy.library - - print ' '.join(sorted(joy.library.initialize())) - - -.. parsed-literal:: - - != % & * *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``: - -.. code:: ipython2 - - print inspect.getsource(joy.library.dip) - - -.. parsed-literal:: - - 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. - -.. code:: ipython2 - - print joy.library.definitions - - -.. parsed-literal:: - - second == rest first - third == rest rest first - product == 1 swap [*] step - swons == swap cons - swoncat == swap concat - flatten == [] swap [concat] step - unit == [] cons - quoted == [unit] dip - unquoted == [i] dip - enstacken == stack [clear] dip - disenstacken == ? [uncons ?] loop pop - ? == dup truthy - dinfrirst == dip infra first - nullary == [stack] dinfrirst - unary == [stack [pop] dip] dinfrirst - binary == [stack [popop] dip] dinfrirst - ternary == [stack [popop pop] dip] dinfrirst - pam == [i] map - run == [] swap infra - sqr == dup mul - size == 0 swap [pop ++] step - cleave == [i] app2 [popd] dip - average == [sum 1.0 *] [size] cleave / - gcd == 1 [tuck modulus dup 0 >] loop pop - least_fraction == dup [gcd] infra [div] concat map - *fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons - *fraction0 == concat [[swap] dip * [*] dip] infra - down_to_zero == [0 >] [dup --] while - range_to_zero == unit [down_to_zero] infra - anamorphism == [pop []] swap [dip swons] genrec - range == [0 <=] [1 - dup] anamorphism - while == swap [nullary] cons dup dipd concat loop - dudipd == dup dipd - primrec == [i] genrec - - - -Currently, there's no function to add new definitions to the dictionary -from "within" Joy code itself. Adding new definitions remains a -meta-interpreter action. You have to do it yourself, in Python, and wash -your hands afterward. - -It would be simple enough to define one, but it would open the door to -*name binding* and break the idea that all state is captured in the -stack and expression. There's an implicit *standard dictionary* that -defines the actual semantics of the syntactic stack and expression -datastructures (which only contain symbols, not the actual functions. -Pickle some and see for yourself.) - -"There should be only one." -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Which brings me to talking about one of my hopes and dreams for this -notation: "There should be only one." What I mean is that there should -be one universal standard dictionary of commands, and all bespoke work -done in a UI for purposes takes place by direct interaction and macros. -There would be a *Grand Refactoring* biannually (two years, not six -months, that's semi-annually) where any new definitions factored out of -the usage and macros of the previous time, along with new algorithms and -such, were entered into the dictionary and posted to e.g. IPFS. - -Code should not burgeon wildly, as it does today. The variety of code -should map more-or-less to the well-factored variety of human -computably-solvable problems. There shouldn't be dozens of chat apps, JS -frameworks, programming languages. It's a waste of time, a `fractal -"thundering herd" -attack `__ on -human mentality. - -Literary Code Library -^^^^^^^^^^^^^^^^^^^^^ - -If you read over the other notebooks you'll see that developing code in -Joy is a lot like doing simple mathematics, and the descriptions of the -code resemble math papers. The code also works the first time, no bugs. -If you have any experience programming at all, you are probably -skeptical, as I was, but it seems to work: deriving code mathematically -seems to lead to fewer errors. - -But my point now is that this great ratio of textual explanation to wind -up with code that consists of a few equations and could fit on an index -card is highly desirable. Less code has fewer errors. The structure of -Joy engenders a kind of thinking that seems to be very effective for -developing structured processes. - -There seems to be an elegance and power to the notation. - diff --git a/docs/1. Basic Use of Joy in a Notebook.html b/docs/1. Basic Use of Joy in a Notebook.html deleted file mode 100644 index ef8d4b3..0000000 --- a/docs/1. Basic Use of Joy in a Notebook.html +++ /dev/null @@ -1,12079 +0,0 @@ - - - -1. Basic Use of Joy in a Notebook - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Preamble

First, import what we need.

- -
-
-
-
-
-
In [1]:
-
-
-
from joy.joy import run
-from joy.library import initialize
-from joy.utils.stack import stack_to_string
-from joy.utils.pretty_print import TracePrinter
-
- -
-
-
- -
-
-
-
-
-

Define a dictionary, an initial stack, and two helper functions to run Joy code and print results for us.

- -
-
-
-
-
-
In [2]:
-
-
-
D = initialize()
-S = ()
-
-
-def J(text):
-    print stack_to_string(run(text, S, D)[0])
-
-
-def V(text):
-    tp = TracePrinter()
-    run(text, S, D, tp.viewer)
-    tp.print_()
-
- -
-
-
- -
-
-
-
-
-

Run some simple programs

-
-
-
-
-
-
In [3]:
-
-
-
J('23 18 +')
-
- -
-
-
- -
-
- - -
- -
- - -
-
41
-
-
-
- -
-
- -
-
-
-
In [4]:
-
-
-
J('45 30 gcd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
15
-
-
-
- -
-
- -
-
-
-
-
-

With Viewer

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. I find these traces beautiful, like a kind of art.

- -
-
-
-
-
-
In [5]:
-
-
-
V('23 18 +')
-
- -
-
-
- -
-
- - -
- -
- - -
-
      . 23 18 +
-   23 . 18 +
-23 18 . +
-   41 . 
-
-
-
- -
-
- -
-
-
-
In [6]:
-
-
-
V('45 30 gcd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                  . 45 30 gcd
-                               45 . 30 gcd
-                            45 30 . gcd
-                            45 30 . 1 [tuck modulus dup 0 >] loop pop
-                          45 30 1 . [tuck modulus dup 0 >] loop pop
-   45 30 1 [tuck modulus dup 0 >] . loop pop
-                            45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                         30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                            30 15 . dup 0 > [tuck modulus dup 0 >] loop pop
-                         30 15 15 . 0 > [tuck modulus dup 0 >] loop pop
-                       30 15 15 0 . > [tuck modulus dup 0 >] loop pop
-                       30 15 True . [tuck modulus dup 0 >] loop pop
-30 15 True [tuck modulus dup 0 >] . loop pop
-                            30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                         15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                             15 0 . dup 0 > [tuck modulus dup 0 >] loop pop
-                           15 0 0 . 0 > [tuck modulus dup 0 >] loop pop
-                         15 0 0 0 . > [tuck modulus dup 0 >] loop pop
-                       15 0 False . [tuck modulus dup 0 >] loop pop
-15 0 False [tuck modulus dup 0 >] . loop pop
-                             15 0 . pop
-                               15 . 
-
-
-
- -
-
- -
-
-
-
-
-

Here's a longer trace.

- -
-
-
-
-
-
In [7]:
-
-
-
V('96 27 gcd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                  . 96 27 gcd
-                               96 . 27 gcd
-                            96 27 . gcd
-                            96 27 . 1 [tuck modulus dup 0 >] loop pop
-                          96 27 1 . [tuck modulus dup 0 >] loop pop
-   96 27 1 [tuck modulus dup 0 >] . loop pop
-                            96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                         27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                            27 15 . dup 0 > [tuck modulus dup 0 >] loop pop
-                         27 15 15 . 0 > [tuck modulus dup 0 >] loop pop
-                       27 15 15 0 . > [tuck modulus dup 0 >] loop pop
-                       27 15 True . [tuck modulus dup 0 >] loop pop
-27 15 True [tuck modulus dup 0 >] . loop pop
-                            27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                         15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                            15 12 . dup 0 > [tuck modulus dup 0 >] loop pop
-                         15 12 12 . 0 > [tuck modulus dup 0 >] loop pop
-                       15 12 12 0 . > [tuck modulus dup 0 >] loop pop
-                       15 12 True . [tuck modulus dup 0 >] loop pop
-15 12 True [tuck modulus dup 0 >] . loop pop
-                            15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                         12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                             12 3 . dup 0 > [tuck modulus dup 0 >] loop pop
-                           12 3 3 . 0 > [tuck modulus dup 0 >] loop pop
-                         12 3 3 0 . > [tuck modulus dup 0 >] loop pop
-                        12 3 True . [tuck modulus dup 0 >] loop pop
- 12 3 True [tuck modulus dup 0 >] . loop pop
-                             12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                           3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop
-                              3 0 . dup 0 > [tuck modulus dup 0 >] loop pop
-                            3 0 0 . 0 > [tuck modulus dup 0 >] loop pop
-                          3 0 0 0 . > [tuck modulus dup 0 >] loop pop
-                        3 0 False . [tuck modulus dup 0 >] loop pop
- 3 0 False [tuck modulus dup 0 >] . loop pop
-                              3 0 . pop
-                                3 . 
-
-
-
- -
-
- -
-
-
- - - - - - diff --git a/docs/1. Basic Use of Joy in a Notebook.ipynb b/docs/1. Basic Use of Joy in a Notebook.ipynb deleted file mode 100644 index 7c8f2a3..0000000 --- a/docs/1. Basic Use of Joy in a Notebook.ipynb +++ /dev/null @@ -1,240 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Preamble\n", - "\n", - "First, import what we need." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from joy.joy import run\n", - "from joy.library import initialize\n", - "from joy.utils.stack import stack_to_string\n", - "from joy.utils.pretty_print import TracePrinter" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Define a dictionary, an initial stack, and two helper functions to run Joy code and print results for us." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "D = initialize()\n", - "S = ()\n", - "\n", - "\n", - "def J(text):\n", - " print stack_to_string(run(text, S, D)[0])\n", - "\n", - "\n", - "def V(text):\n", - " tp = TracePrinter()\n", - " run(text, S, D, tp.viewer)\n", - " tp.print_()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Run some simple programs" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "41\n" - ] - } - ], - "source": [ - "J('23 18 +')" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15\n" - ] - } - ], - "source": [ - "J('45 30 gcd')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### With Viewer\n", - "\n", - "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. I find these traces beautiful, like a kind of art." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 23 18 +\n", - " 23 . 18 +\n", - "23 18 . +\n", - " 41 . \n" - ] - } - ], - "source": [ - "V('23 18 +')" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 45 30 gcd\n", - " 45 . 30 gcd\n", - " 45 30 . gcd\n", - " 45 30 . 1 [tuck modulus dup 0 >] loop pop\n", - " 45 30 1 . [tuck modulus dup 0 >] loop pop\n", - " 45 30 1 [tuck modulus dup 0 >] . loop pop\n", - " 45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 30 15 . dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 30 15 15 . 0 > [tuck modulus dup 0 >] loop pop\n", - " 30 15 15 0 . > [tuck modulus dup 0 >] loop pop\n", - " 30 15 True . [tuck modulus dup 0 >] loop pop\n", - "30 15 True [tuck modulus dup 0 >] . loop pop\n", - " 30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 0 . dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 0 0 . 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 0 0 0 . > [tuck modulus dup 0 >] loop pop\n", - " 15 0 False . [tuck modulus dup 0 >] loop pop\n", - "15 0 False [tuck modulus dup 0 >] . loop pop\n", - " 15 0 . pop\n", - " 15 . \n" - ] - } - ], - "source": [ - "V('45 30 gcd')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's a longer trace." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 96 27 gcd\n", - " 96 . 27 gcd\n", - " 96 27 . gcd\n", - " 96 27 . 1 [tuck modulus dup 0 >] loop pop\n", - " 96 27 1 . [tuck modulus dup 0 >] loop pop\n", - " 96 27 1 [tuck modulus dup 0 >] . loop pop\n", - " 96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 27 15 . dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 27 15 15 . 0 > [tuck modulus dup 0 >] loop pop\n", - " 27 15 15 0 . > [tuck modulus dup 0 >] loop pop\n", - " 27 15 True . [tuck modulus dup 0 >] loop pop\n", - "27 15 True [tuck modulus dup 0 >] . loop pop\n", - " 27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 12 . dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 12 12 . 0 > [tuck modulus dup 0 >] loop pop\n", - " 15 12 12 0 . > [tuck modulus dup 0 >] loop pop\n", - " 15 12 True . [tuck modulus dup 0 >] loop pop\n", - "15 12 True [tuck modulus dup 0 >] . loop pop\n", - " 15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 12 3 . dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 12 3 3 . 0 > [tuck modulus dup 0 >] loop pop\n", - " 12 3 3 0 . > [tuck modulus dup 0 >] loop pop\n", - " 12 3 True . [tuck modulus dup 0 >] loop pop\n", - " 12 3 True [tuck modulus dup 0 >] . loop pop\n", - " 12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 3 0 . dup 0 > [tuck modulus dup 0 >] loop pop\n", - " 3 0 0 . 0 > [tuck modulus dup 0 >] loop pop\n", - " 3 0 0 0 . > [tuck modulus dup 0 >] loop pop\n", - " 3 0 False . [tuck modulus dup 0 >] loop pop\n", - " 3 0 False [tuck modulus dup 0 >] . loop pop\n", - " 3 0 . pop\n", - " 3 . \n" - ] - } - ], - "source": [ - "V('96 27 gcd')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/1. Basic Use of Joy in a Notebook.md b/docs/1. Basic Use of Joy in a Notebook.md deleted file mode 100644 index a46ae6a..0000000 --- a/docs/1. Basic Use of Joy in a Notebook.md +++ /dev/null @@ -1,137 +0,0 @@ - -### Preamble - -First, import what we need. - - -```python -from joy.joy import run -from joy.library import initialize -from joy.utils.stack import stack_to_string -from joy.utils.pretty_print import TracePrinter -``` - -Define a dictionary, an initial stack, and two helper functions to run Joy code and print results for us. - - -```python -D = initialize() -S = () - - -def J(text): - print stack_to_string(run(text, S, D)[0]) - - -def V(text): - tp = TracePrinter() - run(text, S, D, tp.viewer) - tp.print_() -``` - -### Run some simple programs - - -```python -J('23 18 +') -``` - - 41 - - - -```python -J('45 30 gcd') -``` - - 15 - - -### With Viewer - -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. I find these traces beautiful, like a kind of art. - - -```python -V('23 18 +') -``` - - . 23 18 + - 23 . 18 + - 23 18 . + - 41 . - - - -```python -V('45 30 gcd') -``` - - . 45 30 gcd - 45 . 30 gcd - 45 30 . gcd - 45 30 . 1 [tuck modulus dup 0 >] loop pop - 45 30 1 . [tuck modulus dup 0 >] loop pop - 45 30 1 [tuck modulus dup 0 >] . loop pop - 45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 30 15 . dup 0 > [tuck modulus dup 0 >] loop pop - 30 15 15 . 0 > [tuck modulus dup 0 >] loop pop - 30 15 15 0 . > [tuck modulus dup 0 >] loop pop - 30 15 True . [tuck modulus dup 0 >] loop pop - 30 15 True [tuck modulus dup 0 >] . loop pop - 30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 0 . dup 0 > [tuck modulus dup 0 >] loop pop - 15 0 0 . 0 > [tuck modulus dup 0 >] loop pop - 15 0 0 0 . > [tuck modulus dup 0 >] loop pop - 15 0 False . [tuck modulus dup 0 >] loop pop - 15 0 False [tuck modulus dup 0 >] . loop pop - 15 0 . pop - 15 . - - -Here's a longer trace. - - -```python -V('96 27 gcd') -``` - - . 96 27 gcd - 96 . 27 gcd - 96 27 . gcd - 96 27 . 1 [tuck modulus dup 0 >] loop pop - 96 27 1 . [tuck modulus dup 0 >] loop pop - 96 27 1 [tuck modulus dup 0 >] . loop pop - 96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 27 15 . dup 0 > [tuck modulus dup 0 >] loop pop - 27 15 15 . 0 > [tuck modulus dup 0 >] loop pop - 27 15 15 0 . > [tuck modulus dup 0 >] loop pop - 27 15 True . [tuck modulus dup 0 >] loop pop - 27 15 True [tuck modulus dup 0 >] . loop pop - 27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 12 . dup 0 > [tuck modulus dup 0 >] loop pop - 15 12 12 . 0 > [tuck modulus dup 0 >] loop pop - 15 12 12 0 . > [tuck modulus dup 0 >] loop pop - 15 12 True . [tuck modulus dup 0 >] loop pop - 15 12 True [tuck modulus dup 0 >] . loop pop - 15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 12 3 . dup 0 > [tuck modulus dup 0 >] loop pop - 12 3 3 . 0 > [tuck modulus dup 0 >] loop pop - 12 3 3 0 . > [tuck modulus dup 0 >] loop pop - 12 3 True . [tuck modulus dup 0 >] loop pop - 12 3 True [tuck modulus dup 0 >] . loop pop - 12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 3 0 . dup 0 > [tuck modulus dup 0 >] loop pop - 3 0 0 . 0 > [tuck modulus dup 0 >] loop pop - 3 0 0 0 . > [tuck modulus dup 0 >] loop pop - 3 0 False . [tuck modulus dup 0 >] loop pop - 3 0 False [tuck modulus dup 0 >] . loop pop - 3 0 . pop - 3 . - diff --git a/docs/1. Basic Use of Joy in a Notebook.rst b/docs/1. Basic Use of Joy in a Notebook.rst deleted file mode 100644 index 15f23e3..0000000 --- a/docs/1. Basic Use of Joy in a Notebook.rst +++ /dev/null @@ -1,154 +0,0 @@ - -Preamble -~~~~~~~~ - -First, import what we need. - -.. code:: ipython2 - - from joy.joy import run - from joy.library import initialize - from joy.utils.stack import stack_to_string - from joy.utils.pretty_print import TracePrinter - -Define a dictionary, an initial stack, and two helper functions to run -Joy code and print results for us. - -.. code:: ipython2 - - D = initialize() - S = () - - - def J(text): - print stack_to_string(run(text, S, D)[0]) - - - def V(text): - tp = TracePrinter() - run(text, S, D, tp.viewer) - tp.print_() - -Run some simple programs -~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 18 +') - - -.. parsed-literal:: - - 41 - - -.. code:: ipython2 - - J('45 30 gcd') - - -.. parsed-literal:: - - 15 - - -With Viewer -~~~~~~~~~~~ - -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. I find -these traces beautiful, like a kind of art. - -.. code:: ipython2 - - V('23 18 +') - - -.. parsed-literal:: - - . 23 18 + - 23 . 18 + - 23 18 . + - 41 . - - -.. code:: ipython2 - - V('45 30 gcd') - - -.. parsed-literal:: - - . 45 30 gcd - 45 . 30 gcd - 45 30 . gcd - 45 30 . 1 [tuck modulus dup 0 >] loop pop - 45 30 1 . [tuck modulus dup 0 >] loop pop - 45 30 1 [tuck modulus dup 0 >] . loop pop - 45 30 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 30 45 30 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 30 15 . dup 0 > [tuck modulus dup 0 >] loop pop - 30 15 15 . 0 > [tuck modulus dup 0 >] loop pop - 30 15 15 0 . > [tuck modulus dup 0 >] loop pop - 30 15 True . [tuck modulus dup 0 >] loop pop - 30 15 True [tuck modulus dup 0 >] . loop pop - 30 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 30 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 0 . dup 0 > [tuck modulus dup 0 >] loop pop - 15 0 0 . 0 > [tuck modulus dup 0 >] loop pop - 15 0 0 0 . > [tuck modulus dup 0 >] loop pop - 15 0 False . [tuck modulus dup 0 >] loop pop - 15 0 False [tuck modulus dup 0 >] . loop pop - 15 0 . pop - 15 . - - -Here's a longer trace. - -.. code:: ipython2 - - V('96 27 gcd') - - -.. parsed-literal:: - - . 96 27 gcd - 96 . 27 gcd - 96 27 . gcd - 96 27 . 1 [tuck modulus dup 0 >] loop pop - 96 27 1 . [tuck modulus dup 0 >] loop pop - 96 27 1 [tuck modulus dup 0 >] . loop pop - 96 27 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 27 96 27 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 27 15 . dup 0 > [tuck modulus dup 0 >] loop pop - 27 15 15 . 0 > [tuck modulus dup 0 >] loop pop - 27 15 15 0 . > [tuck modulus dup 0 >] loop pop - 27 15 True . [tuck modulus dup 0 >] loop pop - 27 15 True [tuck modulus dup 0 >] . loop pop - 27 15 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 27 15 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 15 12 . dup 0 > [tuck modulus dup 0 >] loop pop - 15 12 12 . 0 > [tuck modulus dup 0 >] loop pop - 15 12 12 0 . > [tuck modulus dup 0 >] loop pop - 15 12 True . [tuck modulus dup 0 >] loop pop - 15 12 True [tuck modulus dup 0 >] . loop pop - 15 12 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 12 15 12 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 12 3 . dup 0 > [tuck modulus dup 0 >] loop pop - 12 3 3 . 0 > [tuck modulus dup 0 >] loop pop - 12 3 3 0 . > [tuck modulus dup 0 >] loop pop - 12 3 True . [tuck modulus dup 0 >] loop pop - 12 3 True [tuck modulus dup 0 >] . loop pop - 12 3 . tuck modulus dup 0 > [tuck modulus dup 0 >] loop pop - 3 12 3 . modulus dup 0 > [tuck modulus dup 0 >] loop pop - 3 0 . dup 0 > [tuck modulus dup 0 >] loop pop - 3 0 0 . 0 > [tuck modulus dup 0 >] loop pop - 3 0 0 0 . > [tuck modulus dup 0 >] loop pop - 3 0 False . [tuck modulus dup 0 >] loop pop - 3 0 False [tuck modulus dup 0 >] . loop pop - 3 0 . pop - 3 . - diff --git a/docs/2. Library Examples.html b/docs/2. Library Examples.html deleted file mode 100644 index 5e4a892..0000000 --- a/docs/2. Library Examples.html +++ /dev/null @@ -1,16523 +0,0 @@ - - - -2. Library Examples - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Examples (and some documentation) for the Words in the Library

-
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import J, V
-
- -
-
-
- -
-
-
-
-
-

Stack Chatter

This is what I like to call the functions that just rearrange things on the stack. (One thing I want to mention is that during a hypothetical compilation phase these "stack chatter" words effectively disappear, because we can map the logical stack locations to registers that remain static for the duration of the computation. This remains to be done but it's "off the shelf" technology.)

- -
-
-
-
-
-
-
-

clear

-
-
-
-
-
-
In [2]:
-
-
-
J('1 2 3 clear')
-
- -
-
-
- -
-
- - -
- -
- - -
-
-
-
-
- -
-
- -
-
-
-
-
-

dup dupd

-
-
-
-
-
-
In [3]:
-
-
-
J('1 2 3 dup')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3 3
-
-
-
- -
-
- -
-
-
-
In [4]:
-
-
-
J('1 2 3 dupd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 2 3
-
-
-
- -
-
- -
-
-
-
-
-

enstacken disenstacken stack unstack

(I may have these paired up wrong. I.e. disenstacken should be unstack and vice versa.)

- -
-
-
-
-
-
In [5]:
-
-
-
J('1 2 3 enstacken') # Replace the stack with a quote of itself.
-
- -
-
-
- -
-
- - -
- -
- - -
-
[3 2 1]
-
-
-
- -
-
- -
-
-
-
In [6]:
-
-
-
J('4 5 6 [3 2 1] disenstacken')  # Unpack a list onto the stack.
-
- -
-
-
- -
-
- - -
- -
- - -
-
4 5 6 3 2 1
-
-
-
- -
-
- -
-
-
-
In [7]:
-
-
-
J('1 2 3 stack')  # Get the stack on the stack.
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3 [3 2 1]
-
-
-
- -
-
- -
-
-
-
In [8]:
-
-
-
J('1 2 3 [4 5 6] unstack')  # Replace the stack with the list on top.
-                            # The items appear reversed but they are not,
-                            # 4 is on the top of both the list and the stack.
-
- -
-
-
- -
-
- - -
- -
- - -
-
6 5 4
-
-
-
- -
-
- -
-
-
-
-
-

pop popd popop

-
-
-
-
-
-
In [9]:
-
-
-
J('1 2 3 pop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2
-
-
-
- -
-
- -
-
-
-
In [10]:
-
-
-
J('1 2 3 popd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 3
-
-
-
- -
-
- -
-
-
-
In [11]:
-
-
-
J('1 2 3 popop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1
-
-
-
- -
-
- -
-
-
-
-
-

roll< rolldown roll> rollup

The "down" and "up" refer to the movement of two of the top three items (displacing the third.)

- -
-
-
-
-
-
In [12]:
-
-
-
J('1 2 3 roll<')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2 3 1
-
-
-
- -
-
- -
-
-
-
In [13]:
-
-
-
J('1 2 3 roll>')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 1 2
-
-
-
- -
-
- -
-
-
-
-
-

swap

-
-
-
-
-
-
In [14]:
-
-
-
J('1 2 3 swap')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 3 2
-
-
-
- -
-
- -
-
-
-
-
-

tuck over

-
-
-
-
-
-
In [15]:
-
-
-
J('1 2 3 tuck')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 3 2 3
-
-
-
- -
-
- -
-
-
-
In [16]:
-
-
-
J('1 2 3 over')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3 2
-
-
-
- -
-
- -
-
-
-
-
-

unit quoted unquoted

-
-
-
-
-
-
In [17]:
-
-
-
J('1 2 3 unit')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 [3]
-
-
-
- -
-
- -
-
-
-
In [18]:
-
-
-
J('1 2 3 quoted')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 [2] 3
-
-
-
- -
-
- -
-
-
-
In [19]:
-
-
-
J('1 [2] 3 unquoted')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3
-
-
-
- -
-
- -
-
-
-
In [20]:
-
-
-
V('1 [dup] 3 unquoted')  # Unquoting evaluates.  Be aware.
-
- -
-
-
- -
-
- - -
- -
- - -
-
              . 1 [dup] 3 unquoted
-            1 . [dup] 3 unquoted
-      1 [dup] . 3 unquoted
-    1 [dup] 3 . unquoted
-    1 [dup] 3 . [i] dip
-1 [dup] 3 [i] . dip
-      1 [dup] . i 3
-            1 . dup 3
-          1 1 . 3
-        1 1 3 . 
-
-
-
- -
-
- -
-
-
-
-
-

List words

-
-
-
-
-
-
-
-

concat swoncat shunt

-
-
-
-
-
-
In [21]:
-
-
-
J('[1 2 3] [4 5 6] concat')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[1 2 3 4 5 6]
-
-
-
- -
-
- -
-
-
-
In [22]:
-
-
-
J('[1 2 3] [4 5 6] swoncat')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[4 5 6 1 2 3]
-
-
-
- -
-
- -
-
-
-
In [23]:
-
-
-
J('[1 2 3] [4 5 6] shunt')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[6 5 4 1 2 3]
-
-
-
- -
-
- -
-
-
-
-
-

cons swons uncons

-
-
-
-
-
-
In [24]:
-
-
-
J('1 [2 3] cons')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[1 2 3]
-
-
-
- -
-
- -
-
-
-
In [25]:
-
-
-
J('[2 3] 1 swons')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[1 2 3]
-
-
-
- -
-
- -
-
-
-
In [26]:
-
-
-
J('[1 2 3] uncons')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 [2 3]
-
-
-
- -
-
- -
-
-
-
-
-

first second third rest

-
-
-
-
-
-
In [27]:
-
-
-
J('[1 2 3 4] first')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1
-
-
-
- -
-
- -
-
-
-
In [28]:
-
-
-
J('[1 2 3 4] second')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
In [29]:
-
-
-
J('[1 2 3 4] third')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3
-
-
-
- -
-
- -
-
-
-
In [30]:
-
-
-
J('[1 2 3 4] rest')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[2 3 4]
-
-
-
- -
-
- -
-
-
-
-
-

flatten

-
-
-
-
-
-
In [31]:
-
-
-
J('[[1] [2 [3] 4] [5 6]] flatten')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[1 2 [3] 4 5 6]
-
-
-
- -
-
- -
-
-
-
-
-

getitem at of drop take

at and getitem are the same function. of == swap at

- -
-
-
-
-
-
In [32]:
-
-
-
J('[10 11 12 13 14] 2 getitem')
-
- -
-
-
- -
-
- - -
- -
- - -
-
12
-
-
-
- -
-
- -
-
-
-
In [33]:
-
-
-
J('[1 2 3 4] 0 at')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1
-
-
-
- -
-
- -
-
-
-
In [34]:
-
-
-
J('2 [1 2 3 4] of')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3
-
-
-
- -
-
- -
-
-
-
In [35]:
-
-
-
J('[1 2 3 4] 2 drop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[3 4]
-
-
-
- -
-
- -
-
-
-
In [36]:
-
-
-
J('[1 2 3 4] 2 take')  # reverses the order
-
- -
-
-
- -
-
- - -
- -
- - -
-
[2 1]
-
-
-
- -
-
- -
-
-
-
-
-

reverse could be defines as reverse == dup size take

- -
-
-
-
-
-
-
-

remove

-
-
-
-
-
-
In [37]:
-
-
-
J('[1 2 3 1 4] 1 remove')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[2 3 1 4]
-
-
-
- -
-
- -
-
-
-
-
-

reverse

-
-
-
-
-
-
In [38]:
-
-
-
J('[1 2 3 4] reverse')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[4 3 2 1]
-
-
-
- -
-
- -
-
-
-
-
-

size

-
-
-
-
-
-
In [39]:
-
-
-
J('[1 1 1 1] size')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4
-
-
-
- -
-
- -
-
-
-
-
-

swaack

"Swap stack" swap the list on the top of the stack for the stack, and put the old stack on top of the new one. Think of it as a context switch. Niether of the lists/stacks change their order.

- -
-
-
-
-
-
In [40]:
-
-
-
J('1 2 3 [4 5 6] swaack')
-
- -
-
-
- -
-
- - -
- -
- - -
-
6 5 4 [3 2 1]
-
-
-
- -
-
- -
-
-
-
-
-

choice select

-
-
-
-
-
-
In [41]:
-
-
-
J('23 9 1 choice')
-
- -
-
-
- -
-
- - -
- -
- - -
-
9
-
-
-
- -
-
- -
-
-
-
In [42]:
-
-
-
J('23 9 0 choice')
-
- -
-
-
- -
-
- - -
- -
- - -
-
23
-
-
-
- -
-
- -
-
-
-
In [43]:
-
-
-
J('[23 9 7] 1 select')  # select is basically getitem, should retire it?
-
- -
-
-
- -
-
- - -
- -
- - -
-
9
-
-
-
- -
-
- -
-
-
-
In [44]:
-
-
-
J('[23 9 7] 0 select')
-
- -
-
-
- -
-
- - -
- -
- - -
-
23
-
-
-
- -
-
- -
-
-
-
-
-

zip

-
-
-
-
-
-
In [45]:
-
-
-
J('[1 2 3] [6 5 4] zip')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[[6 1] [5 2] [4 3]]
-
-
-
- -
-
- -
-
-
-
In [46]:
-
-
-
J('[1 2 3] [6 5 4] zip [sum] map')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[7 7 7]
-
-
-
- -
-
- -
-
-
-
-
-

Math words

-
-
-
-
-
-
-
-

+ add

-
-
-
-
-
-
In [47]:
-
-
-
J('23 9 +')
-
- -
-
-
- -
-
- - -
- -
- - -
-
32
-
-
-
- -
-
- -
-
-
-
-
-

- sub

-
-
-
-
-
-
In [48]:
-
-
-
J('23 9 -')
-
- -
-
-
- -
-
- - -
- -
- - -
-
14
-
-
-
- -
-
- -
-
-
-
-
-

* mul

-
-
-
-
-
-
In [49]:
-
-
-
J('23 9 *')
-
- -
-
-
- -
-
- - -
- -
- - -
-
207
-
-
-
- -
-
- -
-
-
-
-
-

/ div floordiv truediv

-
-
-
-
-
-
In [50]:
-
-
-
J('23 9 /')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2.5555555555555554
-
-
-
- -
-
- -
-
-
-
In [51]:
-
-
-
J('23 -9 truediv')
-
- -
-
-
- -
-
- - -
- -
- - -
-
-2.5555555555555554
-
-
-
- -
-
- -
-
-
-
In [52]:
-
-
-
J('23 9 div')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
In [53]:
-
-
-
J('23 9 floordiv')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
In [54]:
-
-
-
J('23 -9 div')
-
- -
-
-
- -
-
- - -
- -
- - -
-
-3
-
-
-
- -
-
- -
-
-
-
In [55]:
-
-
-
J('23 -9 floordiv')
-
- -
-
-
- -
-
- - -
- -
- - -
-
-3
-
-
-
- -
-
- -
-
-
-
-
-

% mod modulus rem remainder

-
-
-
-
-
-
In [56]:
-
-
-
J('23 9 %')
-
- -
-
-
- -
-
- - -
- -
- - -
-
5
-
-
-
- -
-
- -
-
-
-
-
-

neg

-
-
-
-
-
-
In [57]:
-
-
-
J('23 neg -5 neg')
-
- -
-
-
- -
-
- - -
- -
- - -
-
-23 5
-
-
-
- -
-
- -
-
-
-
-
-

pow

-
-
-
-
-
-
In [58]:
-
-
-
J('2 10 pow')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1024
-
-
-
- -
-
- -
-
-
-
-
-

sqr sqrt

-
-
-
-
-
-
In [59]:
-
-
-
J('23 sqr')
-
- -
-
-
- -
-
- - -
- -
- - -
-
529
-
-
-
- -
-
- -
-
-
-
In [60]:
-
-
-
J('23 sqrt')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4.795831523312719
-
-
-
- -
-
- -
-
-
-
-
-

++ succ -- pred

-
-
-
-
-
-
In [61]:
-
-
-
J('1 ++')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
In [62]:
-
-
-
J('1 --')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0
-
-
-
- -
-
- -
-
-
-
-
-

<< lshift >> rshift

-
-
-
-
-
-
In [63]:
-
-
-
J('8 1 <<')
-
- -
-
-
- -
-
- - -
- -
- - -
-
16
-
-
-
- -
-
- -
-
-
-
In [64]:
-
-
-
J('8 1 >>')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4
-
-
-
- -
-
- -
-
-
-
-
-

average

-
-
-
-
-
-
In [65]:
-
-
-
J('[1 2 3 5] average')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2.75
-
-
-
- -
-
- -
-
-
-
-
-

range range_to_zero down_to_zero

-
-
-
-
-
-
In [66]:
-
-
-
J('5 range')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[4 3 2 1 0]
-
-
-
- -
-
- -
-
-
-
In [67]:
-
-
-
J('5 range_to_zero')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[0 1 2 3 4 5]
-
-
-
- -
-
- -
-
-
-
In [68]:
-
-
-
J('5 down_to_zero')
-
- -
-
-
- -
-
- - -
- -
- - -
-
5 4 3 2 1 0
-
-
-
- -
-
- -
-
-
-
-
-

product

-
-
-
-
-
-
In [69]:
-
-
-
J('[1 2 3 5] product')
-
- -
-
-
- -
-
- - -
- -
- - -
-
30
-
-
-
- -
-
- -
-
-
-
-
-

sum

-
-
-
-
-
-
In [70]:
-
-
-
J('[1 2 3 5] sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
11
-
-
-
- -
-
- -
-
-
-
-
-

min

-
-
-
-
-
-
In [71]:
-
-
-
J('[1 2 3 5] min')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1
-
-
-
- -
-
- -
-
-
-
-
-

gcd

-
-
-
-
-
-
In [72]:
-
-
-
J('45 30 gcd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
15
-
-
-
- -
-
- -
-
-
-
-
-

least_fraction

If we represent fractions as a quoted pair of integers [q d] this word reduces them to their ... least common factors or whatever.

- -
-
-
-
-
-
In [73]:
-
-
-
J('[45 30] least_fraction')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[3 2]
-
-
-
- -
-
- -
-
-
-
In [74]:
-
-
-
J('[23 12] least_fraction')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[23 12]
-
-
-
- -
-
- -
-
-
-
-
-

Logic and Comparison

-
-
-
-
-
-
-
-

? truthy

Get the Boolean value of the item on the top of the stack.

- -
-
-
-
-
-
In [75]:
-
-
-
J('23 truthy')
-
- -
-
-
- -
-
- - -
- -
- - -
-
True
-
-
-
- -
-
- -
-
-
-
In [76]:
-
-
-
J('[] truthy')  # Python semantics.
-
- -
-
-
- -
-
- - -
- -
- - -
-
False
-
-
-
- -
-
- -
-
-
-
In [77]:
-
-
-
J('0 truthy')
-
- -
-
-
- -
-
- - -
- -
- - -
-
False
-
-
-
- -
-
- -
-
-
-
-
- -
? == dup truthy
- -
-
-
-
-
-
In [78]:
-
-
-
V('23 ?')
-
- -
-
-
- -
-
- - -
- -
- - -
-
        . 23 ?
-     23 . ?
-     23 . dup truthy
-  23 23 . truthy
-23 True . 
-
-
-
- -
-
- -
-
-
-
In [79]:
-
-
-
J('[] ?')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[] False
-
-
-
- -
-
- -
-
-
-
In [80]:
-
-
-
J('0 ?')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0 False
-
-
-
- -
-
- -
-
-
-
-
-

& and

-
-
-
-
-
-
In [81]:
-
-
-
J('23 9 &')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1
-
-
-
- -
-
- -
-
-
-
-
-

!= <> ne

-
-
-
-
-
-
In [82]:
-
-
-
J('23 9 !=')
-
- -
-
-
- -
-
- - -
- -
- - -
-
True
-
-
-
- -
-
- -
-
-
-
-
-

The usual suspects:

-
    -
  • < lt
  • -
  • <= le
  • -
  • = eq
  • -
  • > gt
  • -
  • >= ge
  • -
  • not
  • -
  • or
  • -
- -
-
-
-
-
-
-
-

^ xor

-
-
-
-
-
-
In [83]:
-
-
-
J('1 1 ^')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0
-
-
-
- -
-
- -
-
-
-
In [84]:
-
-
-
J('1 0 ^')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1
-
-
-
- -
-
- -
-
-
-
-
-

Miscellaneous

-
-
-
-
-
-
-
-

help

-
-
-
-
-
-
In [85]:
-
-
-
J('[help] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
Accepts a quoted symbol on the top of the stack and prints its docs.
-
-
-
-
- -
-
- -
-
-
-
-
-

parse

-
-
-
-
-
-
In [86]:
-
-
-
J('[parse] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
Parse the string on the stack to a Joy expression.
-
-
-
-
- -
-
- -
-
-
-
In [87]:
-
-
-
J('1 "2 [3] dup" parse')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 [2 [3] dup]
-
-
-
- -
-
- -
-
-
-
-
-

run

Evaluate a quoted Joy sequence.

- -
-
-
-
-
-
In [88]:
-
-
-
J('[1 2 dup + +] run')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[5]
-
-
-
- -
-
- -
-
-
-
-
-

Combinators

-
-
-
-
-
-
-
-

app1 app2 app3

-
-
-
-
-
-
In [89]:
-
-
-
J('[app1] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
Given a quoted program on TOS and anything as the second stack item run
-the program and replace the two args with the first result of the
-program.
-
-            ... x [Q] . app1
-   -----------------------------------
-      ... [x ...] [Q] . infra first
-
-
-
-
- -
-
- -
-
-
-
In [90]:
-
-
-
J('10 4 [sqr *] app1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
10 160
-
-
-
- -
-
- -
-
-
-
In [91]:
-
-
-
J('10 3 4 [sqr *] app2')
-
- -
-
-
- -
-
- - -
- -
- - -
-
10 90 160
-
-
-
- -
-
- -
-
-
-
In [92]:
-
-
-
J('[app2] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
Like app1 with two items.
-
-       ... y x [Q] . app2
------------------------------------
-   ... [y ...] [Q] . infra first
-       [x ...] [Q]   infra first
-
-
-
-
- -
-
- -
-
-
-
In [93]:
-
-
-
J('10 2 3 4 [sqr *] app3')
-
- -
-
-
- -
-
- - -
- -
- - -
-
10 40 90 160
-
-
-
- -
-
- -
-
-
-
-
-

anamorphism

Given an initial value, a predicate function [P], and a generator function [G], the anamorphism combinator creates a sequence.

- -
   n [P] [G] anamorphism
----------------------------
-          [...]
-
-
-

Example, range:

- -
range == [0 <=] [1 - dup] anamorphism
- -
-
-
-
-
-
In [94]:
-
-
-
J('3 [0 <=] [1 - dup] anamorphism')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[2 1 0]
-
-
-
- -
-
- -
-
-
-
-
-

branch

-
-
-
-
-
-
In [95]:
-
-
-
J('3 4 1 [+] [*] branch')
-
- -
-
-
- -
-
- - -
- -
- - -
-
12
-
-
-
- -
-
- -
-
-
-
In [96]:
-
-
-
J('3 4 0 [+] [*] branch')
-
- -
-
-
- -
-
- - -
- -
- - -
-
7
-
-
-
- -
-
- -
-
-
-
-
-

cleave

-
... x [P] [Q] cleave
-
-
-

From the original Joy docs: "The cleave combinator expects two quotations, and below that an item x -It first executes [P], with x on top, and saves the top result element. -Then it executes [Q], again with x, and saves the top result. -Finally it restores the stack to what it was below x and pushes the two -results P(X) and Q(X)."

-

Note that P and Q can use items from the stack freely, since the stack (below x) is restored. cleave is a kind of parallel primitive, and it would make sense to create a version that uses, e.g. Python threads or something, to actually run P and Q concurrently. The current implementation of cleave is a definition in terms of app2:

- -
cleave == [i] app2 [popd] dip
- -
-
-
-
-
-
In [97]:
-
-
-
J('10 2 [+] [-] cleave')
-
- -
-
-
- -
-
- - -
- -
- - -
-
10 12 8
-
-
-
- -
-
- -
-
-
-
-
-

dip dipd dipdd

-
-
-
-
-
-
In [98]:
-
-
-
J('1 2 3 4 5 [+] dip')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 7 5
-
-
-
- -
-
- -
-
-
-
In [99]:
-
-
-
J('1 2 3 4 5 [+] dipd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 5 4 5
-
-
-
- -
-
- -
-
-
-
In [100]:
-
-
-
J('1 2 3 4 5 [+] dipdd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 3 4 5
-
-
-
- -
-
- -
-
-
-
-
-

dupdip

Expects a quoted program [Q] on the stack and some item under it, dup the item and dip the quoted program under it.

- -
n [Q] dupdip == n Q n
- -
-
-
-
-
-
In [101]:
-
-
-
V('23 [++] dupdip *')  # N(N + 1)
-
- -
-
-
- -
-
- - -
- -
- - -
-
        . 23 [++] dupdip *
-     23 . [++] dupdip *
-23 [++] . dupdip *
-     23 . ++ 23 *
-     24 . 23 *
-  24 23 . *
-    552 . 
-
-
-
- -
-
- -
-
-
-
-
-

genrec primrec

-
-
-
-
-
-
In [102]:
-
-
-
J('[genrec] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
General Recursion Combinator.
-
-                        [if] [then] [rec1] [rec2] genrec
-  ---------------------------------------------------------------------
-     [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte
-
-From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun:
-"The genrec combinator takes four program parameters in addition to
-whatever data parameters it needs. Fourth from the top is an if-part,
-followed by a then-part. If the if-part yields true, then the then-part
-is executed and the combinator terminates. The other two parameters are
-the rec1-part and the rec2-part. If the if-part yields false, the
-rec1-part is executed. Following that the four program parameters and
-the combinator are again pushed onto the stack bundled up in a quoted
-form. Then the rec2-part is executed, where it will find the bundled
-form. Typically it will then execute the bundled form, either with i or
-with app2, or some other combinator."
-
-The way to design one of these is to fix your base case [then] and the
-test [if], and then treat rec1 and rec2 as an else-part "sandwiching"
-a quotation of the whole function.
-
-For example, given a (general recursive) function 'F':
-
-    F == [I] [T] [R1] [R2] genrec
-
-If the [I] if-part fails you must derive R1 and R2 from:
-
-    ... R1 [F] R2
-
-Just set the stack arguments in front, and figure out what R1 and R2
-have to do to apply the quoted [F] in the proper way.  In effect, the
-genrec combinator turns into an ifte combinator with a quoted copy of
-the original definition in the else-part:
-
-    F == [I] [T] [R1]   [R2] genrec
-      == [I] [T] [R1 [F] R2] ifte
-
-(Primitive recursive functions are those where R2 == i.
-
-    P == [I] [T] [R] primrec
-      == [I] [T] [R [P] i] ifte
-      == [I] [T] [R P] ifte
-)
-
-
-
-
- -
-
- -
-
-
-
In [103]:
-
-
-
J('3 [1 <=] [] [dup --] [i *] genrec')
-
- -
-
-
- -
-
- - -
- -
- - -
-
6
-
-
-
- -
-
- -
-
-
-
-
-

i

-
-
-
-
-
-
In [104]:
-
-
-
V('1 2 3 [+ +] i')
-
- -
-
-
- -
-
- - -
- -
- - -
-
            . 1 2 3 [+ +] i
-          1 . 2 3 [+ +] i
-        1 2 . 3 [+ +] i
-      1 2 3 . [+ +] i
-1 2 3 [+ +] . i
-      1 2 3 . + +
-        1 5 . +
-          6 . 
-
-
-
- -
-
- -
-
-
-
-
-

ifte

-
[predicate] [then] [else] ifte
- -
-
-
-
-
-
In [105]:
-
-
-
J('1 2 [1] [+] [*] ifte')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3
-
-
-
- -
-
- -
-
-
-
In [106]:
-
-
-
J('1 2 [0] [+] [*] ifte')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
-
-

infra

-
-
-
-
-
-
In [107]:
-
-
-
V('1 2 3 [4 5 6] [* +] infra')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                    . 1 2 3 [4 5 6] [* +] infra
-                  1 . 2 3 [4 5 6] [* +] infra
-                1 2 . 3 [4 5 6] [* +] infra
-              1 2 3 . [4 5 6] [* +] infra
-      1 2 3 [4 5 6] . [* +] infra
-1 2 3 [4 5 6] [* +] . infra
-              6 5 4 . * + [3 2 1] swaack
-               6 20 . + [3 2 1] swaack
-                 26 . [3 2 1] swaack
-         26 [3 2 1] . swaack
-         1 2 3 [26] . 
-
-
-
- -
-
- -
-
-
-
-
-

loop

-
-
-
-
-
-
In [108]:
-
-
-
J('[loop] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
Basic loop combinator.
-
-   ... True [Q] loop
------------------------
-     ... Q [Q] loop
-
-   ... False [Q] loop
-------------------------
-          ...
-
-
-
-
- -
-
- -
-
-
-
In [109]:
-
-
-
V('3 dup [1 - dup] loop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
              . 3 dup [1 - dup] loop
-            3 . dup [1 - dup] loop
-          3 3 . [1 - dup] loop
-3 3 [1 - dup] . loop
-            3 . 1 - dup [1 - dup] loop
-          3 1 . - dup [1 - dup] loop
-            2 . dup [1 - dup] loop
-          2 2 . [1 - dup] loop
-2 2 [1 - dup] . loop
-            2 . 1 - dup [1 - dup] loop
-          2 1 . - dup [1 - dup] loop
-            1 . dup [1 - dup] loop
-          1 1 . [1 - dup] loop
-1 1 [1 - dup] . loop
-            1 . 1 - dup [1 - dup] loop
-          1 1 . - dup [1 - dup] loop
-            0 . dup [1 - dup] loop
-          0 0 . [1 - dup] loop
-0 0 [1 - dup] . loop
-            0 . 
-
-
-
- -
-
- -
-
-
-
-
-

map pam

-
-
-
-
-
-
In [110]:
-
-
-
J('10 [1 2 3] [*] map')
-
- -
-
-
- -
-
- - -
- -
- - -
-
10 [10 20 30]
-
-
-
- -
-
- -
-
-
-
In [111]:
-
-
-
J('10 5 [[*][/][+][-]] pam')
-
- -
-
-
- -
-
- - -
- -
- - -
-
10 5 [50 2.0 15 5]
-
-
-
- -
-
- -
-
-
-
-
-

nullary unary binary ternary

Run a quoted program enforcing arity.

- -
-
-
-
-
-
In [112]:
-
-
-
J('1 2 3 4 5 [+] nullary')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3 4 5 9
-
-
-
- -
-
- -
-
-
-
In [113]:
-
-
-
J('1 2 3 4 5 [+] unary')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3 4 9
-
-
-
- -
-
- -
-
-
-
In [114]:
-
-
-
J('1 2 3 4 5 [+] binary')  # + has arity 2 so this is technically pointless...
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3 9
-
-
-
- -
-
- -
-
-
-
In [115]:
-
-
-
J('1 2 3 4 5 [+] ternary')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 9
-
-
-
- -
-
- -
-
-
-
-
-

step

-
-
-
-
-
-
In [116]:
-
-
-
J('[step] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
Run a quoted program on each item in a sequence.
-
-        ... [] [Q] . step
-     -----------------------
-               ... .
-
-
-       ... [a] [Q] . step
-    ------------------------
-             ... a . Q
-
-
-   ... [a b c] [Q] . step
-----------------------------------------
-             ... a . Q [b c] [Q] step
-
-The step combinator executes the quotation on each member of the list
-on top of the stack.
-
-
-
-
- -
-
- -
-
-
-
In [117]:
-
-
-
V('0 [1 2 3] [+] step')
-
- -
-
-
- -
-
- - -
- -
- - -
-
              . 0 [1 2 3] [+] step
-            0 . [1 2 3] [+] step
-    0 [1 2 3] . [+] step
-0 [1 2 3] [+] . step
-      0 1 [+] . i [2 3] [+] step
-          0 1 . + [2 3] [+] step
-            1 . [2 3] [+] step
-      1 [2 3] . [+] step
-  1 [2 3] [+] . step
-      1 2 [+] . i [3] [+] step
-          1 2 . + [3] [+] step
-            3 . [3] [+] step
-        3 [3] . [+] step
-    3 [3] [+] . step
-      3 3 [+] . i
-          3 3 . +
-            6 . 
-
-
-
- -
-
- -
-
-
-
-
-

times

-
-
-
-
-
-
In [118]:
-
-
-
V('3 2 1 2 [+] times')
-
- -
-
-
- -
-
- - -
- -
- - -
-
            . 3 2 1 2 [+] times
-          3 . 2 1 2 [+] times
-        3 2 . 1 2 [+] times
-      3 2 1 . 2 [+] times
-    3 2 1 2 . [+] times
-3 2 1 2 [+] . times
-      3 2 1 . + 1 [+] times
-        3 3 . 1 [+] times
-      3 3 1 . [+] times
-  3 3 1 [+] . times
-        3 3 . +
-          6 . 
-
-
-
- -
-
- -
-
-
-
-
-

b

-
-
-
-
-
-
In [119]:
-
-
-
J('[b] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
b == [i] dip i
-
-... [P] [Q] b == ... [P] i [Q] i
-... [P] [Q] b == ... P Q
-
-
-
-
- -
-
- -
-
-
-
In [120]:
-
-
-
V('1 2 [3] [4] b')
-
- -
-
-
- -
-
- - -
- -
- - -
-
            . 1 2 [3] [4] b
-          1 . 2 [3] [4] b
-        1 2 . [3] [4] b
-    1 2 [3] . [4] b
-1 2 [3] [4] . b
-        1 2 . 3 4
-      1 2 3 . 4
-    1 2 3 4 . 
-
-
-
- -
-
- -
-
-
-
-
-

while

-
[predicate] [body] while
- -
-
-
-
-
-
In [121]:
-
-
-
J('3 [0 >] [dup --] while')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 2 1 0
-
-
-
- -
-
- -
-
-
-
-
-

x

-
-
-
-
-
-
In [122]:
-
-
-
J('[x] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
x == dup i
-
-... [Q] x = ... [Q] dup i
-... [Q] x = ... [Q] [Q] i
-... [Q] x = ... [Q]  Q
-
-
-
-
- -
-
- -
-
-
-
In [123]:
-
-
-
V('1 [2] [i 3] x')  # Kind of a pointless example.
-
- -
-
-
- -
-
- - -
- -
- - -
-
            . 1 [2] [i 3] x
-          1 . [2] [i 3] x
-      1 [2] . [i 3] x
-1 [2] [i 3] . x
-1 [2] [i 3] . i 3
-      1 [2] . i 3 3
-          1 . 2 3 3
-        1 2 . 3 3
-      1 2 3 . 3
-    1 2 3 3 . 
-
-
-
- -
-
- -
-
-
-
-
-

void

Implements Laws of Form arithmetic over quote-only datastructures (that is, datastructures that consist soley of containers, without strings or numbers or anything else.)

- -
-
-
-
-
-
In [124]:
-
-
-
J('[] void')
-
- -
-
-
- -
-
- - -
- -
- - -
-
False
-
-
-
- -
-
- -
-
-
-
In [125]:
-
-
-
J('[[]] void')
-
- -
-
-
- -
-
- - -
- -
- - -
-
True
-
-
-
- -
-
- -
-
-
-
In [126]:
-
-
-
J('[[][[]]] void')
-
- -
-
-
- -
-
- - -
- -
- - -
-
True
-
-
-
- -
-
- -
-
-
-
In [127]:
-
-
-
J('[[[]][[][]]] void')
-
- -
-
-
- -
-
- - -
- -
- - -
-
False
-
-
-
- -
-
- -
-
-
- - - - - - diff --git a/docs/2. Library Examples.ipynb b/docs/2. Library Examples.ipynb deleted file mode 100644 index 1349eb4..0000000 --- a/docs/2. Library Examples.ipynb +++ /dev/null @@ -1,2964 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Examples (and some documentation) for the Words in the Library" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import J, V" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Stack Chatter\n", - "This is what I like to call the functions that just rearrange things on the stack. (One thing I want to mention is that during a hypothetical compilation phase these \"stack chatter\" words effectively disappear, because we can map the logical stack locations to registers that remain static for the duration of the computation. This remains to be done but it's \"off the shelf\" technology.)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `clear`" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n" - ] - } - ], - "source": [ - "J('1 2 3 clear')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `dup` `dupd`" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 3\n" - ] - } - ], - "source": [ - "J('1 2 3 dup')" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 2 3\n" - ] - } - ], - "source": [ - "J('1 2 3 dupd')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `enstacken` `disenstacken` `stack` `unstack`\n", - "(I may have these paired up wrong. I.e. `disenstacken` should be `unstack` and vice versa.)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 2 1]\n" - ] - } - ], - "source": [ - "J('1 2 3 enstacken') # Replace the stack with a quote of itself." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4 5 6 3 2 1\n" - ] - } - ], - "source": [ - "J('4 5 6 [3 2 1] disenstacken') # Unpack a list onto the stack." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 [3 2 1]\n" - ] - } - ], - "source": [ - "J('1 2 3 stack') # Get the stack on the stack." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6 5 4\n" - ] - } - ], - "source": [ - "J('1 2 3 [4 5 6] unstack') # Replace the stack with the list on top.\n", - " # The items appear reversed but they are not,\n", - " # 4 is on the top of both the list and the stack." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `pop` `popd` `popop`" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2\n" - ] - } - ], - "source": [ - "J('1 2 3 pop')" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 3\n" - ] - } - ], - "source": [ - "J('1 2 3 popd')" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n" - ] - } - ], - "source": [ - "J('1 2 3 popop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `roll<` `rolldown` `roll>` `rollup`\n", - "The \"down\" and \"up\" refer to the movement of two of the top three items (displacing the third.)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 3 1\n" - ] - } - ], - "source": [ - "J('1 2 3 roll<')" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 1 2\n" - ] - } - ], - "source": [ - "J('1 2 3 roll>')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `swap`" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 3 2\n" - ] - } - ], - "source": [ - "J('1 2 3 swap')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `tuck` `over`" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 3 2 3\n" - ] - } - ], - "source": [ - "J('1 2 3 tuck')" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 2\n" - ] - } - ], - "source": [ - "J('1 2 3 over')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `unit` `quoted` `unquoted`" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 [3]\n" - ] - } - ], - "source": [ - "J('1 2 3 unit')" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 [2] 3\n" - ] - } - ], - "source": [ - "J('1 2 3 quoted')" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3\n" - ] - } - ], - "source": [ - "J('1 [2] 3 unquoted')" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 1 [dup] 3 unquoted\n", - " 1 . [dup] 3 unquoted\n", - " 1 [dup] . 3 unquoted\n", - " 1 [dup] 3 . unquoted\n", - " 1 [dup] 3 . [i] dip\n", - "1 [dup] 3 [i] . dip\n", - " 1 [dup] . i 3\n", - " 1 . dup 3\n", - " 1 1 . 3\n", - " 1 1 3 . \n" - ] - } - ], - "source": [ - "V('1 [dup] 3 unquoted') # Unquoting evaluates. Be aware." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# List words" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `concat` `swoncat` `shunt`" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 2 3 4 5 6]\n" - ] - } - ], - "source": [ - "J('[1 2 3] [4 5 6] concat')" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 5 6 1 2 3]\n" - ] - } - ], - "source": [ - "J('[1 2 3] [4 5 6] swoncat')" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[6 5 4 1 2 3]\n" - ] - } - ], - "source": [ - "J('[1 2 3] [4 5 6] shunt')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `cons` `swons` `uncons`" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 2 3]\n" - ] - } - ], - "source": [ - "J('1 [2 3] cons')" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 2 3]\n" - ] - } - ], - "source": [ - "J('[2 3] 1 swons')" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 [2 3]\n" - ] - } - ], - "source": [ - "J('[1 2 3] uncons')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `first` `second` `third` `rest`" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] first')" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] second')" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] third')" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 3 4]\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] rest')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `flatten`" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 2 [3] 4 5 6]\n" - ] - } - ], - "source": [ - "J('[[1] [2 [3] 4] [5 6]] flatten')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `getitem` `at` `of` `drop` `take`\n", - "\n", - "`at` and `getitem` are the same function. `of == swap at`" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "12\n" - ] - } - ], - "source": [ - "J('[10 11 12 13 14] 2 getitem')" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] 0 at')" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "J('2 [1 2 3 4] of')" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 4]\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] 2 drop')" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 1]\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] 2 take') # reverses the order" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`reverse` could be defines as `reverse == dup size take`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `remove`" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 3 1 4]\n" - ] - } - ], - "source": [ - "J('[1 2 3 1 4] 1 remove')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `reverse`" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 3 2 1]\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] reverse')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `size`" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n" - ] - } - ], - "source": [ - "J('[1 1 1 1] size')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `swaack`\n", - "\"Swap stack\" swap the list on the top of the stack for the stack, and put the old stack on top of the new one. Think of it as a context switch. Niether of the lists/stacks change their order." - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6 5 4 [3 2 1]\n" - ] - } - ], - "source": [ - "J('1 2 3 [4 5 6] swaack')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `choice` `select`" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9\n" - ] - } - ], - "source": [ - "J('23 9 1 choice')" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "23\n" - ] - } - ], - "source": [ - "J('23 9 0 choice')" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9\n" - ] - } - ], - "source": [ - "J('[23 9 7] 1 select') # select is basically getitem, should retire it?" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "23\n" - ] - } - ], - "source": [ - "J('[23 9 7] 0 select')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `zip`" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[6 1] [5 2] [4 3]]\n" - ] - } - ], - "source": [ - "J('[1 2 3] [6 5 4] zip')" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[7 7 7]\n" - ] - } - ], - "source": [ - "J('[1 2 3] [6 5 4] zip [sum] map')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Math words" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `+` `add`" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "32\n" - ] - } - ], - "source": [ - "J('23 9 +')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `-` `sub`" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "14\n" - ] - } - ], - "source": [ - "J('23 9 -')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `*` `mul`" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "207\n" - ] - } - ], - "source": [ - "J('23 9 *')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `/` `div` `floordiv` `truediv`" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2.5555555555555554\n" - ] - } - ], - "source": [ - "J('23 9 /')" - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-2.5555555555555554\n" - ] - } - ], - "source": [ - "J('23 -9 truediv')" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('23 9 div')" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('23 9 floordiv')" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-3\n" - ] - } - ], - "source": [ - "J('23 -9 div')" - ] - }, - { - "cell_type": "code", - "execution_count": 55, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-3\n" - ] - } - ], - "source": [ - "J('23 -9 floordiv')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `%` `mod` `modulus` `rem` `remainder`" - ] - }, - { - "cell_type": "code", - "execution_count": 56, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5\n" - ] - } - ], - "source": [ - "J('23 9 %')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `neg`" - ] - }, - { - "cell_type": "code", - "execution_count": 57, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-23 5\n" - ] - } - ], - "source": [ - "J('23 neg -5 neg')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### pow" - ] - }, - { - "cell_type": "code", - "execution_count": 58, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1024\n" - ] - } - ], - "source": [ - "J('2 10 pow')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `sqr` `sqrt`" - ] - }, - { - "cell_type": "code", - "execution_count": 59, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "529\n" - ] - } - ], - "source": [ - "J('23 sqr')" - ] - }, - { - "cell_type": "code", - "execution_count": 60, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4.795831523312719\n" - ] - } - ], - "source": [ - "J('23 sqrt')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `++` `succ` `--` `pred`" - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('1 ++')" - ] - }, - { - "cell_type": "code", - "execution_count": 62, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], - "source": [ - "J('1 --')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `<<` `lshift` `>>` `rshift`" - ] - }, - { - "cell_type": "code", - "execution_count": 63, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "16\n" - ] - } - ], - "source": [ - "J('8 1 <<')" - ] - }, - { - "cell_type": "code", - "execution_count": 64, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n" - ] - } - ], - "source": [ - "J('8 1 >>')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `average`" - ] - }, - { - "cell_type": "code", - "execution_count": 65, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2.75\n" - ] - } - ], - "source": [ - "J('[1 2 3 5] average')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `range` `range_to_zero` `down_to_zero`" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 3 2 1 0]\n" - ] - } - ], - "source": [ - "J('5 range')" - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 1 2 3 4 5]\n" - ] - } - ], - "source": [ - "J('5 range_to_zero')" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5 4 3 2 1 0\n" - ] - } - ], - "source": [ - "J('5 down_to_zero')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `product`" - ] - }, - { - "cell_type": "code", - "execution_count": 69, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "30\n" - ] - } - ], - "source": [ - "J('[1 2 3 5] product')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `sum`" - ] - }, - { - "cell_type": "code", - "execution_count": 70, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "11\n" - ] - } - ], - "source": [ - "J('[1 2 3 5] sum')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `min`" - ] - }, - { - "cell_type": "code", - "execution_count": 71, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n" - ] - } - ], - "source": [ - "J('[1 2 3 5] min')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `gcd`" - ] - }, - { - "cell_type": "code", - "execution_count": 72, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15\n" - ] - } - ], - "source": [ - "J('45 30 gcd')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `least_fraction`\n", - "If we represent fractions as a quoted pair of integers [q d] this word reduces them to their ... least common factors or whatever." - ] - }, - { - "cell_type": "code", - "execution_count": 73, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 2]\n" - ] - } - ], - "source": [ - "J('[45 30] least_fraction')" - ] - }, - { - "cell_type": "code", - "execution_count": 74, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[23 12]\n" - ] - } - ], - "source": [ - "J('[23 12] least_fraction')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Logic and Comparison" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `?` `truthy`\n", - "Get the Boolean value of the item on the top of the stack." - ] - }, - { - "cell_type": "code", - "execution_count": 75, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "J('23 truthy')" - ] - }, - { - "cell_type": "code", - "execution_count": 76, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "False\n" - ] - } - ], - "source": [ - "J('[] truthy') # Python semantics." - ] - }, - { - "cell_type": "code", - "execution_count": 77, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "False\n" - ] - } - ], - "source": [ - "J('0 truthy')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " ? == dup truthy" - ] - }, - { - "cell_type": "code", - "execution_count": 78, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 23 ?\n", - " 23 . ?\n", - " 23 . dup truthy\n", - " 23 23 . truthy\n", - "23 True . \n" - ] - } - ], - "source": [ - "V('23 ?')" - ] - }, - { - "cell_type": "code", - "execution_count": 79, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[] False\n" - ] - } - ], - "source": [ - "J('[] ?')" - ] - }, - { - "cell_type": "code", - "execution_count": 80, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 False\n" - ] - } - ], - "source": [ - "J('0 ?')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `&` `and` " - ] - }, - { - "cell_type": "code", - "execution_count": 81, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n" - ] - } - ], - "source": [ - "J('23 9 &')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `!=` `<>` `ne`" - ] - }, - { - "cell_type": "code", - "execution_count": 82, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "J('23 9 !=')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The usual suspects:\n", - "- `<` `lt`\n", - "- `<=` `le` \n", - "- `=` `eq`\n", - "- `>` `gt`\n", - "- `>=` `ge`\n", - "- `not`\n", - "- `or`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `^` `xor`" - ] - }, - { - "cell_type": "code", - "execution_count": 83, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], - "source": [ - "J('1 1 ^')" - ] - }, - { - "cell_type": "code", - "execution_count": 84, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n" - ] - } - ], - "source": [ - "J('1 0 ^')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Miscellaneous" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `help`" - ] - }, - { - "cell_type": "code", - "execution_count": 85, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accepts a quoted symbol on the top of the stack and prints its docs.\n", - "\n" - ] - } - ], - "source": [ - "J('[help] help')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `parse`" - ] - }, - { - "cell_type": "code", - "execution_count": 86, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Parse the string on the stack to a Joy expression.\n", - "\n" - ] - } - ], - "source": [ - "J('[parse] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 87, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 [2 [3] dup]\n" - ] - } - ], - "source": [ - "J('1 \"2 [3] dup\" parse')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `run`\n", - "Evaluate a quoted Joy sequence." - ] - }, - { - "cell_type": "code", - "execution_count": 88, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[5]\n" - ] - } - ], - "source": [ - "J('[1 2 dup + +] run')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Combinators" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `app1` `app2` `app3`" - ] - }, - { - "cell_type": "code", - "execution_count": 89, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Given a quoted program on TOS and anything as the second stack item run\n", - "the program and replace the two args with the first result of the\n", - "program.\n", - "\n", - " ... x [Q] . app1\n", - " -----------------------------------\n", - " ... [x ...] [Q] . infra first\n", - "\n" - ] - } - ], - "source": [ - "J('[app1] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 90, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10 160\n" - ] - } - ], - "source": [ - "J('10 4 [sqr *] app1')" - ] - }, - { - "cell_type": "code", - "execution_count": 91, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10 90 160\n" - ] - } - ], - "source": [ - "J('10 3 4 [sqr *] app2')" - ] - }, - { - "cell_type": "code", - "execution_count": 92, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Like app1 with two items.\n", - "\n", - " ... y x [Q] . app2\n", - "-----------------------------------\n", - " ... [y ...] [Q] . infra first\n", - " [x ...] [Q] infra first\n", - "\n" - ] - } - ], - "source": [ - "J('[app2] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 93, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10 40 90 160\n" - ] - } - ], - "source": [ - "J('10 2 3 4 [sqr *] app3')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `anamorphism`\n", - "Given an initial value, a predicate function `[P]`, and a generator function `[G]`, the `anamorphism` combinator creates a sequence.\n", - "\n", - " n [P] [G] anamorphism\n", - " ---------------------------\n", - " [...]\n", - "\n", - "Example, `range`:\n", - "\n", - " range == [0 <=] [1 - dup] anamorphism" - ] - }, - { - "cell_type": "code", - "execution_count": 94, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 1 0]\n" - ] - } - ], - "source": [ - "J('3 [0 <=] [1 - dup] anamorphism')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `branch`" - ] - }, - { - "cell_type": "code", - "execution_count": 95, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "12\n" - ] - } - ], - "source": [ - "J('3 4 1 [+] [*] branch')" - ] - }, - { - "cell_type": "code", - "execution_count": 96, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7\n" - ] - } - ], - "source": [ - "J('3 4 0 [+] [*] branch')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `cleave`\n", - " ... x [P] [Q] cleave\n", - "\n", - "From the original Joy docs: \"The cleave combinator expects two quotations, and below that an item `x`\n", - "It first executes `[P]`, with `x` on top, and saves the top result element.\n", - "Then it executes `[Q]`, again with `x`, and saves the top result.\n", - "Finally it restores the stack to what it was below `x` and pushes the two\n", - "results P(X) and Q(X).\"\n", - "\n", - "Note that `P` and `Q` can use items from the stack freely, since the stack (below `x`) is restored. `cleave` is a kind of *parallel* primitive, and it would make sense to create a version that uses, e.g. Python threads or something, to actually run `P` and `Q` concurrently. The current implementation of `cleave` is a definition in terms of `app2`:\n", - "\n", - " cleave == [i] app2 [popd] dip" - ] - }, - { - "cell_type": "code", - "execution_count": 97, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10 12 8\n" - ] - } - ], - "source": [ - "J('10 2 [+] [-] cleave')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `dip` `dipd` `dipdd`" - ] - }, - { - "cell_type": "code", - "execution_count": 98, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 7 5\n" - ] - } - ], - "source": [ - "J('1 2 3 4 5 [+] dip')" - ] - }, - { - "cell_type": "code", - "execution_count": 99, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 5 4 5\n" - ] - } - ], - "source": [ - "J('1 2 3 4 5 [+] dipd')" - ] - }, - { - "cell_type": "code", - "execution_count": 100, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 3 4 5\n" - ] - } - ], - "source": [ - "J('1 2 3 4 5 [+] dipdd')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `dupdip`\n", - "Expects a quoted program `[Q]` on the stack and some item under it, `dup` the item and `dip` the quoted program under it.\n", - "\n", - " n [Q] dupdip == n Q n" - ] - }, - { - "cell_type": "code", - "execution_count": 101, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 23 [++] dupdip *\n", - " 23 . [++] dupdip *\n", - "23 [++] . dupdip *\n", - " 23 . ++ 23 *\n", - " 24 . 23 *\n", - " 24 23 . *\n", - " 552 . \n" - ] - } - ], - "source": [ - "V('23 [++] dupdip *') # N(N + 1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `genrec` `primrec`" - ] - }, - { - "cell_type": "code", - "execution_count": 102, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "General Recursion Combinator.\n", - "\n", - " [if] [then] [rec1] [rec2] genrec\n", - " ---------------------------------------------------------------------\n", - " [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte\n", - "\n", - "From \"Recursion Theory and Joy\" (j05cmp.html) by Manfred von Thun:\n", - "\"The genrec combinator takes four program parameters in addition to\n", - "whatever data parameters it needs. Fourth from the top is an if-part,\n", - "followed by a then-part. If the if-part yields true, then the then-part\n", - "is executed and the combinator terminates. The other two parameters are\n", - "the rec1-part and the rec2-part. If the if-part yields false, the\n", - "rec1-part is executed. Following that the four program parameters and\n", - "the combinator are again pushed onto the stack bundled up in a quoted\n", - "form. Then the rec2-part is executed, where it will find the bundled\n", - "form. Typically it will then execute the bundled form, either with i or\n", - "with app2, or some other combinator.\"\n", - "\n", - "The way to design one of these is to fix your base case [then] and the\n", - "test [if], and then treat rec1 and rec2 as an else-part \"sandwiching\"\n", - "a quotation of the whole function.\n", - "\n", - "For example, given a (general recursive) function 'F':\n", - "\n", - " F == [I] [T] [R1] [R2] genrec\n", - "\n", - "If the [I] if-part fails you must derive R1 and R2 from:\n", - "\n", - " ... R1 [F] R2\n", - "\n", - "Just set the stack arguments in front, and figure out what R1 and R2\n", - "have to do to apply the quoted [F] in the proper way. In effect, the\n", - "genrec combinator turns into an ifte combinator with a quoted copy of\n", - "the original definition in the else-part:\n", - "\n", - " F == [I] [T] [R1] [R2] genrec\n", - " == [I] [T] [R1 [F] R2] ifte\n", - "\n", - "(Primitive recursive functions are those where R2 == i.\n", - "\n", - " P == [I] [T] [R] primrec\n", - " == [I] [T] [R [P] i] ifte\n", - " == [I] [T] [R P] ifte\n", - ")\n", - "\n" - ] - } - ], - "source": [ - "J('[genrec] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 103, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6\n" - ] - } - ], - "source": [ - "J('3 [1 <=] [] [dup --] [i *] genrec')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `i`" - ] - }, - { - "cell_type": "code", - "execution_count": 104, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 1 2 3 [+ +] i\n", - " 1 . 2 3 [+ +] i\n", - " 1 2 . 3 [+ +] i\n", - " 1 2 3 . [+ +] i\n", - "1 2 3 [+ +] . i\n", - " 1 2 3 . + +\n", - " 1 5 . +\n", - " 6 . \n" - ] - } - ], - "source": [ - "V('1 2 3 [+ +] i')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `ifte`\n", - " [predicate] [then] [else] ifte" - ] - }, - { - "cell_type": "code", - "execution_count": 105, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "J('1 2 [1] [+] [*] ifte')" - ] - }, - { - "cell_type": "code", - "execution_count": 106, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('1 2 [0] [+] [*] ifte')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `infra`" - ] - }, - { - "cell_type": "code", - "execution_count": 107, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 1 2 3 [4 5 6] [* +] infra\n", - " 1 . 2 3 [4 5 6] [* +] infra\n", - " 1 2 . 3 [4 5 6] [* +] infra\n", - " 1 2 3 . [4 5 6] [* +] infra\n", - " 1 2 3 [4 5 6] . [* +] infra\n", - "1 2 3 [4 5 6] [* +] . infra\n", - " 6 5 4 . * + [3 2 1] swaack\n", - " 6 20 . + [3 2 1] swaack\n", - " 26 . [3 2 1] swaack\n", - " 26 [3 2 1] . swaack\n", - " 1 2 3 [26] . \n" - ] - } - ], - "source": [ - "V('1 2 3 [4 5 6] [* +] infra')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `loop`" - ] - }, - { - "cell_type": "code", - "execution_count": 108, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Basic loop combinator.\n", - "\n", - " ... True [Q] loop\n", - "-----------------------\n", - " ... Q [Q] loop\n", - "\n", - " ... False [Q] loop\n", - "------------------------\n", - " ...\n", - "\n" - ] - } - ], - "source": [ - "J('[loop] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 109, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 3 dup [1 - dup] loop\n", - " 3 . dup [1 - dup] loop\n", - " 3 3 . [1 - dup] loop\n", - "3 3 [1 - dup] . loop\n", - " 3 . 1 - dup [1 - dup] loop\n", - " 3 1 . - dup [1 - dup] loop\n", - " 2 . dup [1 - dup] loop\n", - " 2 2 . [1 - dup] loop\n", - "2 2 [1 - dup] . loop\n", - " 2 . 1 - dup [1 - dup] loop\n", - " 2 1 . - dup [1 - dup] loop\n", - " 1 . dup [1 - dup] loop\n", - " 1 1 . [1 - dup] loop\n", - "1 1 [1 - dup] . loop\n", - " 1 . 1 - dup [1 - dup] loop\n", - " 1 1 . - dup [1 - dup] loop\n", - " 0 . dup [1 - dup] loop\n", - " 0 0 . [1 - dup] loop\n", - "0 0 [1 - dup] . loop\n", - " 0 . \n" - ] - } - ], - "source": [ - "V('3 dup [1 - dup] loop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `map` `pam`" - ] - }, - { - "cell_type": "code", - "execution_count": 110, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10 [10 20 30]\n" - ] - } - ], - "source": [ - "J('10 [1 2 3] [*] map')" - ] - }, - { - "cell_type": "code", - "execution_count": 111, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10 5 [50 2.0 15 5]\n" - ] - } - ], - "source": [ - "J('10 5 [[*][/][+][-]] pam')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `nullary` `unary` `binary` `ternary`\n", - "Run a quoted program enforcing [arity](https://en.wikipedia.org/wiki/Arity)." - ] - }, - { - "cell_type": "code", - "execution_count": 112, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 4 5 9\n" - ] - } - ], - "source": [ - "J('1 2 3 4 5 [+] nullary')" - ] - }, - { - "cell_type": "code", - "execution_count": 113, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 4 9\n" - ] - } - ], - "source": [ - "J('1 2 3 4 5 [+] unary')" - ] - }, - { - "cell_type": "code", - "execution_count": 114, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 9\n" - ] - } - ], - "source": [ - "J('1 2 3 4 5 [+] binary') # + has arity 2 so this is technically pointless..." - ] - }, - { - "cell_type": "code", - "execution_count": 115, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 9\n" - ] - } - ], - "source": [ - "J('1 2 3 4 5 [+] ternary')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `step`" - ] - }, - { - "cell_type": "code", - "execution_count": 116, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Run a quoted program on each item in a sequence.\n", - "\n", - " ... [] [Q] . step\n", - " -----------------------\n", - " ... .\n", - "\n", - "\n", - " ... [a] [Q] . step\n", - " ------------------------\n", - " ... a . Q\n", - "\n", - "\n", - " ... [a b c] [Q] . step\n", - "----------------------------------------\n", - " ... a . Q [b c] [Q] step\n", - "\n", - "The step combinator executes the quotation on each member of the list\n", - "on top of the stack.\n", - "\n" - ] - } - ], - "source": [ - "J('[step] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 117, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 0 [1 2 3] [+] step\n", - " 0 . [1 2 3] [+] step\n", - " 0 [1 2 3] . [+] step\n", - "0 [1 2 3] [+] . step\n", - " 0 1 [+] . i [2 3] [+] step\n", - " 0 1 . + [2 3] [+] step\n", - " 1 . [2 3] [+] step\n", - " 1 [2 3] . [+] step\n", - " 1 [2 3] [+] . step\n", - " 1 2 [+] . i [3] [+] step\n", - " 1 2 . + [3] [+] step\n", - " 3 . [3] [+] step\n", - " 3 [3] . [+] step\n", - " 3 [3] [+] . step\n", - " 3 3 [+] . i\n", - " 3 3 . +\n", - " 6 . \n" - ] - } - ], - "source": [ - "V('0 [1 2 3] [+] step')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `times`" - ] - }, - { - "cell_type": "code", - "execution_count": 118, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 3 2 1 2 [+] times\n", - " 3 . 2 1 2 [+] times\n", - " 3 2 . 1 2 [+] times\n", - " 3 2 1 . 2 [+] times\n", - " 3 2 1 2 . [+] times\n", - "3 2 1 2 [+] . times\n", - " 3 2 1 . + 1 [+] times\n", - " 3 3 . 1 [+] times\n", - " 3 3 1 . [+] times\n", - " 3 3 1 [+] . times\n", - " 3 3 . +\n", - " 6 . \n" - ] - } - ], - "source": [ - "V('3 2 1 2 [+] times')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `b`" - ] - }, - { - "cell_type": "code", - "execution_count": 119, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "b == [i] dip i\n", - "\n", - "... [P] [Q] b == ... [P] i [Q] i\n", - "... [P] [Q] b == ... P Q\n", - "\n" - ] - } - ], - "source": [ - "J('[b] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 120, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 1 2 [3] [4] b\n", - " 1 . 2 [3] [4] b\n", - " 1 2 . [3] [4] b\n", - " 1 2 [3] . [4] b\n", - "1 2 [3] [4] . b\n", - " 1 2 . 3 4\n", - " 1 2 3 . 4\n", - " 1 2 3 4 . \n" - ] - } - ], - "source": [ - "V('1 2 [3] [4] b')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `while`\n", - " [predicate] [body] while" - ] - }, - { - "cell_type": "code", - "execution_count": 121, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 2 1 0\n" - ] - } - ], - "source": [ - "J('3 [0 >] [dup --] while')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `x`" - ] - }, - { - "cell_type": "code", - "execution_count": 122, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x == dup i\n", - "\n", - "... [Q] x = ... [Q] dup i\n", - "... [Q] x = ... [Q] [Q] i\n", - "... [Q] x = ... [Q] Q\n", - "\n" - ] - } - ], - "source": [ - "J('[x] help')" - ] - }, - { - "cell_type": "code", - "execution_count": 123, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 1 [2] [i 3] x\n", - " 1 . [2] [i 3] x\n", - " 1 [2] . [i 3] x\n", - "1 [2] [i 3] . x\n", - "1 [2] [i 3] . i 3\n", - " 1 [2] . i 3 3\n", - " 1 . 2 3 3\n", - " 1 2 . 3 3\n", - " 1 2 3 . 3\n", - " 1 2 3 3 . \n" - ] - } - ], - "source": [ - "V('1 [2] [i 3] x') # Kind of a pointless example." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# `void`\n", - "Implements [**Laws of Form** *arithmetic*](https://en.wikipedia.org/wiki/Laws_of_Form#The_primary_arithmetic_.28Chapter_4.29) over quote-only datastructures (that is, datastructures that consist soley of containers, without strings or numbers or anything else.)" - ] - }, - { - "cell_type": "code", - "execution_count": 124, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "False\n" - ] - } - ], - "source": [ - "J('[] void')" - ] - }, - { - "cell_type": "code", - "execution_count": 125, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "J('[[]] void')" - ] - }, - { - "cell_type": "code", - "execution_count": 126, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "J('[[][[]]] void')" - ] - }, - { - "cell_type": "code", - "execution_count": 127, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "False\n" - ] - } - ], - "source": [ - "J('[[[]][[][]]] void')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/2. Library Examples.md b/docs/2. Library Examples.md deleted file mode 100644 index fd70ce7..0000000 --- a/docs/2. Library Examples.md +++ /dev/null @@ -1,1395 +0,0 @@ - -# Examples (and some documentation) for the Words in the Library - - -```python -from notebook_preamble import J, V -``` - -# Stack Chatter -This is what I like to call the functions that just rearrange things on the stack. (One thing I want to mention is that during a hypothetical compilation phase these "stack chatter" words effectively disappear, because we can map the logical stack locations to registers that remain static for the duration of the computation. This remains to be done but it's "off the shelf" technology.) - -### `clear` - - -```python -J('1 2 3 clear') -``` - - - - -### `dup` `dupd` - - -```python -J('1 2 3 dup') -``` - - 1 2 3 3 - - - -```python -J('1 2 3 dupd') -``` - - 1 2 2 3 - - -### `enstacken` `disenstacken` `stack` `unstack` -(I may have these paired up wrong. I.e. `disenstacken` should be `unstack` and vice versa.) - - -```python -J('1 2 3 enstacken') # Replace the stack with a quote of itself. -``` - - [3 2 1] - - - -```python -J('4 5 6 [3 2 1] disenstacken') # Unpack a list onto the stack. -``` - - 4 5 6 3 2 1 - - - -```python -J('1 2 3 stack') # Get the stack on the stack. -``` - - 1 2 3 [3 2 1] - - - -```python -J('1 2 3 [4 5 6] unstack') # Replace the stack with the list on top. - # The items appear reversed but they are not, - # 4 is on the top of both the list and the stack. -``` - - 6 5 4 - - -### `pop` `popd` `popop` - - -```python -J('1 2 3 pop') -``` - - 1 2 - - - -```python -J('1 2 3 popd') -``` - - 1 3 - - - -```python -J('1 2 3 popop') -``` - - 1 - - -### `roll<` `rolldown` `roll>` `rollup` -The "down" and "up" refer to the movement of two of the top three items (displacing the third.) - - -```python -J('1 2 3 roll<') -``` - - 2 3 1 - - - -```python -J('1 2 3 roll>') -``` - - 3 1 2 - - -### `swap` - - -```python -J('1 2 3 swap') -``` - - 1 3 2 - - -### `tuck` `over` - - -```python -J('1 2 3 tuck') -``` - - 1 3 2 3 - - - -```python -J('1 2 3 over') -``` - - 1 2 3 2 - - -### `unit` `quoted` `unquoted` - - -```python -J('1 2 3 unit') -``` - - 1 2 [3] - - - -```python -J('1 2 3 quoted') -``` - - 1 [2] 3 - - - -```python -J('1 [2] 3 unquoted') -``` - - 1 2 3 - - - -```python -V('1 [dup] 3 unquoted') # Unquoting evaluates. Be aware. -``` - - . 1 [dup] 3 unquoted - 1 . [dup] 3 unquoted - 1 [dup] . 3 unquoted - 1 [dup] 3 . unquoted - 1 [dup] 3 . [i] dip - 1 [dup] 3 [i] . dip - 1 [dup] . i 3 - 1 . dup 3 - 1 1 . 3 - 1 1 3 . - - -# List words - -### `concat` `swoncat` `shunt` - - -```python -J('[1 2 3] [4 5 6] concat') -``` - - [1 2 3 4 5 6] - - - -```python -J('[1 2 3] [4 5 6] swoncat') -``` - - [4 5 6 1 2 3] - - - -```python -J('[1 2 3] [4 5 6] shunt') -``` - - [6 5 4 1 2 3] - - -### `cons` `swons` `uncons` - - -```python -J('1 [2 3] cons') -``` - - [1 2 3] - - - -```python -J('[2 3] 1 swons') -``` - - [1 2 3] - - - -```python -J('[1 2 3] uncons') -``` - - 1 [2 3] - - -### `first` `second` `third` `rest` - - -```python -J('[1 2 3 4] first') -``` - - 1 - - - -```python -J('[1 2 3 4] second') -``` - - 2 - - - -```python -J('[1 2 3 4] third') -``` - - 3 - - - -```python -J('[1 2 3 4] rest') -``` - - [2 3 4] - - -### `flatten` - - -```python -J('[[1] [2 [3] 4] [5 6]] flatten') -``` - - [1 2 [3] 4 5 6] - - -### `getitem` `at` `of` `drop` `take` - -`at` and `getitem` are the same function. `of == swap at` - - -```python -J('[10 11 12 13 14] 2 getitem') -``` - - 12 - - - -```python -J('[1 2 3 4] 0 at') -``` - - 1 - - - -```python -J('2 [1 2 3 4] of') -``` - - 3 - - - -```python -J('[1 2 3 4] 2 drop') -``` - - [3 4] - - - -```python -J('[1 2 3 4] 2 take') # reverses the order -``` - - [2 1] - - -`reverse` could be defines as `reverse == dup size take` - -### `remove` - - -```python -J('[1 2 3 1 4] 1 remove') -``` - - [2 3 1 4] - - -### `reverse` - - -```python -J('[1 2 3 4] reverse') -``` - - [4 3 2 1] - - -### `size` - - -```python -J('[1 1 1 1] size') -``` - - 4 - - -### `swaack` -"Swap stack" swap the list on the top of the stack for the stack, and put the old stack on top of the new one. Think of it as a context switch. Niether of the lists/stacks change their order. - - -```python -J('1 2 3 [4 5 6] swaack') -``` - - 6 5 4 [3 2 1] - - -### `choice` `select` - - -```python -J('23 9 1 choice') -``` - - 9 - - - -```python -J('23 9 0 choice') -``` - - 23 - - - -```python -J('[23 9 7] 1 select') # select is basically getitem, should retire it? -``` - - 9 - - - -```python -J('[23 9 7] 0 select') -``` - - 23 - - -### `zip` - - -```python -J('[1 2 3] [6 5 4] zip') -``` - - [[6 1] [5 2] [4 3]] - - - -```python -J('[1 2 3] [6 5 4] zip [sum] map') -``` - - [7 7 7] - - -# Math words - -### `+` `add` - - -```python -J('23 9 +') -``` - - 32 - - -### `-` `sub` - - -```python -J('23 9 -') -``` - - 14 - - -### `*` `mul` - - -```python -J('23 9 *') -``` - - 207 - - -### `/` `div` `floordiv` `truediv` - - -```python -J('23 9 /') -``` - - 2.5555555555555554 - - - -```python -J('23 -9 truediv') -``` - - -2.5555555555555554 - - - -```python -J('23 9 div') -``` - - 2 - - - -```python -J('23 9 floordiv') -``` - - 2 - - - -```python -J('23 -9 div') -``` - - -3 - - - -```python -J('23 -9 floordiv') -``` - - -3 - - -### `%` `mod` `modulus` `rem` `remainder` - - -```python -J('23 9 %') -``` - - 5 - - -### `neg` - - -```python -J('23 neg -5 neg') -``` - - -23 5 - - -### pow - - -```python -J('2 10 pow') -``` - - 1024 - - -### `sqr` `sqrt` - - -```python -J('23 sqr') -``` - - 529 - - - -```python -J('23 sqrt') -``` - - 4.795831523312719 - - -### `++` `succ` `--` `pred` - - -```python -J('1 ++') -``` - - 2 - - - -```python -J('1 --') -``` - - 0 - - -### `<<` `lshift` `>>` `rshift` - - -```python -J('8 1 <<') -``` - - 16 - - - -```python -J('8 1 >>') -``` - - 4 - - -### `average` - - -```python -J('[1 2 3 5] average') -``` - - 2.75 - - -### `range` `range_to_zero` `down_to_zero` - - -```python -J('5 range') -``` - - [4 3 2 1 0] - - - -```python -J('5 range_to_zero') -``` - - [0 1 2 3 4 5] - - - -```python -J('5 down_to_zero') -``` - - 5 4 3 2 1 0 - - -### `product` - - -```python -J('[1 2 3 5] product') -``` - - 30 - - -### `sum` - - -```python -J('[1 2 3 5] sum') -``` - - 11 - - -### `min` - - -```python -J('[1 2 3 5] min') -``` - - 1 - - -### `gcd` - - -```python -J('45 30 gcd') -``` - - 15 - - -### `least_fraction` -If we represent fractions as a quoted pair of integers [q d] this word reduces them to their ... least common factors or whatever. - - -```python -J('[45 30] least_fraction') -``` - - [3 2] - - - -```python -J('[23 12] least_fraction') -``` - - [23 12] - - -# Logic and Comparison - -### `?` `truthy` -Get the Boolean value of the item on the top of the stack. - - -```python -J('23 truthy') -``` - - True - - - -```python -J('[] truthy') # Python semantics. -``` - - False - - - -```python -J('0 truthy') -``` - - False - - - ? == dup truthy - - -```python -V('23 ?') -``` - - . 23 ? - 23 . ? - 23 . dup truthy - 23 23 . truthy - 23 True . - - - -```python -J('[] ?') -``` - - [] False - - - -```python -J('0 ?') -``` - - 0 False - - -### `&` `and` - - -```python -J('23 9 &') -``` - - 1 - - -### `!=` `<>` `ne` - - -```python -J('23 9 !=') -``` - - True - - -The usual suspects: -- `<` `lt` -- `<=` `le` -- `=` `eq` -- `>` `gt` -- `>=` `ge` -- `not` -- `or` - -### `^` `xor` - - -```python -J('1 1 ^') -``` - - 0 - - - -```python -J('1 0 ^') -``` - - 1 - - -# Miscellaneous - -### `help` - - -```python -J('[help] help') -``` - - Accepts a quoted symbol on the top of the stack and prints its docs. - - - -### `parse` - - -```python -J('[parse] help') -``` - - Parse the string on the stack to a Joy expression. - - - - -```python -J('1 "2 [3] dup" parse') -``` - - 1 [2 [3] dup] - - -### `run` -Evaluate a quoted Joy sequence. - - -```python -J('[1 2 dup + +] run') -``` - - [5] - - -# Combinators - -### `app1` `app2` `app3` - - -```python -J('[app1] help') -``` - - Given a quoted program on TOS and anything as the second stack item run - the program and replace the two args with the first result of the - program. - - ... x [Q] . app1 - ----------------------------------- - ... [x ...] [Q] . infra first - - - - -```python -J('10 4 [sqr *] app1') -``` - - 10 160 - - - -```python -J('10 3 4 [sqr *] app2') -``` - - 10 90 160 - - - -```python -J('[app2] help') -``` - - Like app1 with two items. - - ... y x [Q] . app2 - ----------------------------------- - ... [y ...] [Q] . infra first - [x ...] [Q] infra first - - - - -```python -J('10 2 3 4 [sqr *] app3') -``` - - 10 40 90 160 - - -### `anamorphism` -Given an initial value, a predicate function `[P]`, and a generator function `[G]`, the `anamorphism` combinator creates a sequence. - - n [P] [G] anamorphism - --------------------------- - [...] - -Example, `range`: - - range == [0 <=] [1 - dup] anamorphism - - -```python -J('3 [0 <=] [1 - dup] anamorphism') -``` - - [2 1 0] - - -### `branch` - - -```python -J('3 4 1 [+] [*] branch') -``` - - 12 - - - -```python -J('3 4 0 [+] [*] branch') -``` - - 7 - - -### `cleave` - ... x [P] [Q] cleave - -From the original Joy docs: "The cleave combinator expects two quotations, and below that an item `x` -It first executes `[P]`, with `x` on top, and saves the top result element. -Then it executes `[Q]`, again with `x`, and saves the top result. -Finally it restores the stack to what it was below `x` and pushes the two -results P(X) and Q(X)." - -Note that `P` and `Q` can use items from the stack freely, since the stack (below `x`) is restored. `cleave` is a kind of *parallel* primitive, and it would make sense to create a version that uses, e.g. Python threads or something, to actually run `P` and `Q` concurrently. The current implementation of `cleave` is a definition in terms of `app2`: - - cleave == [i] app2 [popd] dip - - -```python -J('10 2 [+] [-] cleave') -``` - - 10 12 8 - - -### `dip` `dipd` `dipdd` - - -```python -J('1 2 3 4 5 [+] dip') -``` - - 1 2 7 5 - - - -```python -J('1 2 3 4 5 [+] dipd') -``` - - 1 5 4 5 - - - -```python -J('1 2 3 4 5 [+] dipdd') -``` - - 3 3 4 5 - - -### `dupdip` -Expects a quoted program `[Q]` on the stack and some item under it, `dup` the item and `dip` the quoted program under it. - - n [Q] dupdip == n Q n - - -```python -V('23 [++] dupdip *') # N(N + 1) -``` - - . 23 [++] dupdip * - 23 . [++] dupdip * - 23 [++] . dupdip * - 23 . ++ 23 * - 24 . 23 * - 24 23 . * - 552 . - - -### `genrec` `primrec` - - -```python -J('[genrec] help') -``` - - General Recursion Combinator. - - [if] [then] [rec1] [rec2] genrec - --------------------------------------------------------------------- - [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte - - From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun: - "The genrec combinator takes four program parameters in addition to - whatever data parameters it needs. Fourth from the top is an if-part, - followed by a then-part. If the if-part yields true, then the then-part - is executed and the combinator terminates. The other two parameters are - the rec1-part and the rec2-part. If the if-part yields false, the - rec1-part is executed. Following that the four program parameters and - the combinator are again pushed onto the stack bundled up in a quoted - form. Then the rec2-part is executed, where it will find the bundled - form. Typically it will then execute the bundled form, either with i or - with app2, or some other combinator." - - The way to design one of these is to fix your base case [then] and the - test [if], and then treat rec1 and rec2 as an else-part "sandwiching" - a quotation of the whole function. - - For example, given a (general recursive) function 'F': - - F == [I] [T] [R1] [R2] genrec - - If the [I] if-part fails you must derive R1 and R2 from: - - ... R1 [F] R2 - - Just set the stack arguments in front, and figure out what R1 and R2 - have to do to apply the quoted [F] in the proper way. In effect, the - genrec combinator turns into an ifte combinator with a quoted copy of - the original definition in the else-part: - - F == [I] [T] [R1] [R2] genrec - == [I] [T] [R1 [F] R2] ifte - - (Primitive recursive functions are those where R2 == i. - - P == [I] [T] [R] primrec - == [I] [T] [R [P] i] ifte - == [I] [T] [R P] ifte - ) - - - - -```python -J('3 [1 <=] [] [dup --] [i *] genrec') -``` - - 6 - - -### `i` - - -```python -V('1 2 3 [+ +] i') -``` - - . 1 2 3 [+ +] i - 1 . 2 3 [+ +] i - 1 2 . 3 [+ +] i - 1 2 3 . [+ +] i - 1 2 3 [+ +] . i - 1 2 3 . + + - 1 5 . + - 6 . - - -### `ifte` - [predicate] [then] [else] ifte - - -```python -J('1 2 [1] [+] [*] ifte') -``` - - 3 - - - -```python -J('1 2 [0] [+] [*] ifte') -``` - - 2 - - -### `infra` - - -```python -V('1 2 3 [4 5 6] [* +] infra') -``` - - . 1 2 3 [4 5 6] [* +] infra - 1 . 2 3 [4 5 6] [* +] infra - 1 2 . 3 [4 5 6] [* +] infra - 1 2 3 . [4 5 6] [* +] infra - 1 2 3 [4 5 6] . [* +] infra - 1 2 3 [4 5 6] [* +] . infra - 6 5 4 . * + [3 2 1] swaack - 6 20 . + [3 2 1] swaack - 26 . [3 2 1] swaack - 26 [3 2 1] . swaack - 1 2 3 [26] . - - -### `loop` - - -```python -J('[loop] help') -``` - - Basic loop combinator. - - ... True [Q] loop - ----------------------- - ... Q [Q] loop - - ... False [Q] loop - ------------------------ - ... - - - - -```python -V('3 dup [1 - dup] loop') -``` - - . 3 dup [1 - dup] loop - 3 . dup [1 - dup] loop - 3 3 . [1 - dup] loop - 3 3 [1 - dup] . loop - 3 . 1 - dup [1 - dup] loop - 3 1 . - dup [1 - dup] loop - 2 . dup [1 - dup] loop - 2 2 . [1 - dup] loop - 2 2 [1 - dup] . loop - 2 . 1 - dup [1 - dup] loop - 2 1 . - dup [1 - dup] loop - 1 . dup [1 - dup] loop - 1 1 . [1 - dup] loop - 1 1 [1 - dup] . loop - 1 . 1 - dup [1 - dup] loop - 1 1 . - dup [1 - dup] loop - 0 . dup [1 - dup] loop - 0 0 . [1 - dup] loop - 0 0 [1 - dup] . loop - 0 . - - -### `map` `pam` - - -```python -J('10 [1 2 3] [*] map') -``` - - 10 [10 20 30] - - - -```python -J('10 5 [[*][/][+][-]] pam') -``` - - 10 5 [50 2.0 15 5] - - -### `nullary` `unary` `binary` `ternary` -Run a quoted program enforcing [arity](https://en.wikipedia.org/wiki/Arity). - - -```python -J('1 2 3 4 5 [+] nullary') -``` - - 1 2 3 4 5 9 - - - -```python -J('1 2 3 4 5 [+] unary') -``` - - 1 2 3 4 9 - - - -```python -J('1 2 3 4 5 [+] binary') # + has arity 2 so this is technically pointless... -``` - - 1 2 3 9 - - - -```python -J('1 2 3 4 5 [+] ternary') -``` - - 1 2 9 - - -### `step` - - -```python -J('[step] help') -``` - - Run a quoted program on each item in a sequence. - - ... [] [Q] . step - ----------------------- - ... . - - - ... [a] [Q] . step - ------------------------ - ... a . Q - - - ... [a b c] [Q] . step - ---------------------------------------- - ... a . Q [b c] [Q] step - - The step combinator executes the quotation on each member of the list - on top of the stack. - - - - -```python -V('0 [1 2 3] [+] step') -``` - - . 0 [1 2 3] [+] step - 0 . [1 2 3] [+] step - 0 [1 2 3] . [+] step - 0 [1 2 3] [+] . step - 0 1 [+] . i [2 3] [+] step - 0 1 . + [2 3] [+] step - 1 . [2 3] [+] step - 1 [2 3] . [+] step - 1 [2 3] [+] . step - 1 2 [+] . i [3] [+] step - 1 2 . + [3] [+] step - 3 . [3] [+] step - 3 [3] . [+] step - 3 [3] [+] . step - 3 3 [+] . i - 3 3 . + - 6 . - - -### `times` - - -```python -V('3 2 1 2 [+] times') -``` - - . 3 2 1 2 [+] times - 3 . 2 1 2 [+] times - 3 2 . 1 2 [+] times - 3 2 1 . 2 [+] times - 3 2 1 2 . [+] times - 3 2 1 2 [+] . times - 3 2 1 . + 1 [+] times - 3 3 . 1 [+] times - 3 3 1 . [+] times - 3 3 1 [+] . times - 3 3 . + - 6 . - - -### `b` - - -```python -J('[b] help') -``` - - b == [i] dip i - - ... [P] [Q] b == ... [P] i [Q] i - ... [P] [Q] b == ... P Q - - - - -```python -V('1 2 [3] [4] b') -``` - - . 1 2 [3] [4] b - 1 . 2 [3] [4] b - 1 2 . [3] [4] b - 1 2 [3] . [4] b - 1 2 [3] [4] . b - 1 2 . 3 4 - 1 2 3 . 4 - 1 2 3 4 . - - -### `while` - [predicate] [body] while - - -```python -J('3 [0 >] [dup --] while') -``` - - 3 2 1 0 - - -### `x` - - -```python -J('[x] help') -``` - - x == dup i - - ... [Q] x = ... [Q] dup i - ... [Q] x = ... [Q] [Q] i - ... [Q] x = ... [Q] Q - - - - -```python -V('1 [2] [i 3] x') # Kind of a pointless example. -``` - - . 1 [2] [i 3] x - 1 . [2] [i 3] x - 1 [2] . [i 3] x - 1 [2] [i 3] . x - 1 [2] [i 3] . i 3 - 1 [2] . i 3 3 - 1 . 2 3 3 - 1 2 . 3 3 - 1 2 3 . 3 - 1 2 3 3 . - - -# `void` -Implements [**Laws of Form** *arithmetic*](https://en.wikipedia.org/wiki/Laws_of_Form#The_primary_arithmetic_.28Chapter_4.29) over quote-only datastructures (that is, datastructures that consist soley of containers, without strings or numbers or anything else.) - - -```python -J('[] void') -``` - - False - - - -```python -J('[[]] void') -``` - - True - - - -```python -J('[[][[]]] void') -``` - - True - - - -```python -J('[[[]][[][]]] void') -``` - - False - diff --git a/docs/2. Library Examples.rst b/docs/2. Library Examples.rst deleted file mode 100644 index fe7bbb4..0000000 --- a/docs/2. Library Examples.rst +++ /dev/null @@ -1,1761 +0,0 @@ - -Examples (and some documentation) for the Words in the Library -============================================================== - -.. code:: ipython2 - - from notebook_preamble import J, V - -Stack Chatter -============= - -This is what I like to call the functions that just rearrange things on -the stack. (One thing I want to mention is that during a hypothetical -compilation phase these "stack chatter" words effectively disappear, -because we can map the logical stack locations to registers that remain -static for the duration of the computation. This remains to be done but -it's "off the shelf" technology.) - -``clear`` -~~~~~~~~~ - -.. code:: ipython2 - - J('1 2 3 clear') - - -.. parsed-literal:: - - - - -``dup`` ``dupd`` -~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 2 3 dup') - - -.. parsed-literal:: - - 1 2 3 3 - - -.. code:: ipython2 - - J('1 2 3 dupd') - - -.. parsed-literal:: - - 1 2 2 3 - - -``enstacken`` ``disenstacken`` ``stack`` ``unstack`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -(I may have these paired up wrong. I.e. ``disenstacken`` should be -``unstack`` and vice versa.) - -.. code:: ipython2 - - J('1 2 3 enstacken') # Replace the stack with a quote of itself. - - -.. parsed-literal:: - - [3 2 1] - - -.. code:: ipython2 - - J('4 5 6 [3 2 1] disenstacken') # Unpack a list onto the stack. - - -.. parsed-literal:: - - 4 5 6 3 2 1 - - -.. code:: ipython2 - - J('1 2 3 stack') # Get the stack on the stack. - - -.. parsed-literal:: - - 1 2 3 [3 2 1] - - -.. code:: ipython2 - - J('1 2 3 [4 5 6] unstack') # Replace the stack with the list on top. - # The items appear reversed but they are not, - # 4 is on the top of both the list and the stack. - - -.. parsed-literal:: - - 6 5 4 - - -``pop`` ``popd`` ``popop`` -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 2 3 pop') - - -.. parsed-literal:: - - 1 2 - - -.. code:: ipython2 - - J('1 2 3 popd') - - -.. parsed-literal:: - - 1 3 - - -.. code:: ipython2 - - J('1 2 3 popop') - - -.. parsed-literal:: - - 1 - - -``roll<`` ``rolldown`` ``roll>`` ``rollup`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The "down" and "up" refer to the movement of two of the top three items -(displacing the third.) - -.. code:: ipython2 - - J('1 2 3 roll<') - - -.. parsed-literal:: - - 2 3 1 - - -.. code:: ipython2 - - J('1 2 3 roll>') - - -.. parsed-literal:: - - 3 1 2 - - -``swap`` -~~~~~~~~ - -.. code:: ipython2 - - J('1 2 3 swap') - - -.. parsed-literal:: - - 1 3 2 - - -``tuck`` ``over`` -~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 2 3 tuck') - - -.. parsed-literal:: - - 1 3 2 3 - - -.. code:: ipython2 - - J('1 2 3 over') - - -.. parsed-literal:: - - 1 2 3 2 - - -``unit`` ``quoted`` ``unquoted`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 2 3 unit') - - -.. parsed-literal:: - - 1 2 [3] - - -.. code:: ipython2 - - J('1 2 3 quoted') - - -.. parsed-literal:: - - 1 [2] 3 - - -.. code:: ipython2 - - J('1 [2] 3 unquoted') - - -.. parsed-literal:: - - 1 2 3 - - -.. code:: ipython2 - - V('1 [dup] 3 unquoted') # Unquoting evaluates. Be aware. - - -.. parsed-literal:: - - . 1 [dup] 3 unquoted - 1 . [dup] 3 unquoted - 1 [dup] . 3 unquoted - 1 [dup] 3 . unquoted - 1 [dup] 3 . [i] dip - 1 [dup] 3 [i] . dip - 1 [dup] . i 3 - 1 . dup 3 - 1 1 . 3 - 1 1 3 . - - -List words -========== - -``concat`` ``swoncat`` ``shunt`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3] [4 5 6] concat') - - -.. parsed-literal:: - - [1 2 3 4 5 6] - - -.. code:: ipython2 - - J('[1 2 3] [4 5 6] swoncat') - - -.. parsed-literal:: - - [4 5 6 1 2 3] - - -.. code:: ipython2 - - J('[1 2 3] [4 5 6] shunt') - - -.. parsed-literal:: - - [6 5 4 1 2 3] - - -``cons`` ``swons`` ``uncons`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 [2 3] cons') - - -.. parsed-literal:: - - [1 2 3] - - -.. code:: ipython2 - - J('[2 3] 1 swons') - - -.. parsed-literal:: - - [1 2 3] - - -.. code:: ipython2 - - J('[1 2 3] uncons') - - -.. parsed-literal:: - - 1 [2 3] - - -``first`` ``second`` ``third`` ``rest`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3 4] first') - - -.. parsed-literal:: - - 1 - - -.. code:: ipython2 - - J('[1 2 3 4] second') - - -.. parsed-literal:: - - 2 - - -.. code:: ipython2 - - J('[1 2 3 4] third') - - -.. parsed-literal:: - - 3 - - -.. code:: ipython2 - - J('[1 2 3 4] rest') - - -.. parsed-literal:: - - [2 3 4] - - -``flatten`` -~~~~~~~~~~~ - -.. code:: ipython2 - - J('[[1] [2 [3] 4] [5 6]] flatten') - - -.. parsed-literal:: - - [1 2 [3] 4 5 6] - - -``getitem`` ``at`` ``of`` ``drop`` ``take`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -``at`` and ``getitem`` are the same function. ``of == swap at`` - -.. code:: ipython2 - - J('[10 11 12 13 14] 2 getitem') - - -.. parsed-literal:: - - 12 - - -.. code:: ipython2 - - J('[1 2 3 4] 0 at') - - -.. parsed-literal:: - - 1 - - -.. code:: ipython2 - - J('2 [1 2 3 4] of') - - -.. parsed-literal:: - - 3 - - -.. code:: ipython2 - - J('[1 2 3 4] 2 drop') - - -.. parsed-literal:: - - [3 4] - - -.. code:: ipython2 - - J('[1 2 3 4] 2 take') # reverses the order - - -.. parsed-literal:: - - [2 1] - - -``reverse`` could be defines as ``reverse == dup size take`` - -``remove`` -~~~~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3 1 4] 1 remove') - - -.. parsed-literal:: - - [2 3 1 4] - - -``reverse`` -~~~~~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3 4] reverse') - - -.. parsed-literal:: - - [4 3 2 1] - - -``size`` -~~~~~~~~ - -.. code:: ipython2 - - J('[1 1 1 1] size') - - -.. parsed-literal:: - - 4 - - -``swaack`` -~~~~~~~~~~ - -"Swap stack" swap the list on the top of the stack for the stack, and -put the old stack on top of the new one. Think of it as a context -switch. Niether of the lists/stacks change their order. - -.. code:: ipython2 - - J('1 2 3 [4 5 6] swaack') - - -.. parsed-literal:: - - 6 5 4 [3 2 1] - - -``choice`` ``select`` -~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 1 choice') - - -.. parsed-literal:: - - 9 - - -.. code:: ipython2 - - J('23 9 0 choice') - - -.. parsed-literal:: - - 23 - - -.. code:: ipython2 - - J('[23 9 7] 1 select') # select is basically getitem, should retire it? - - -.. parsed-literal:: - - 9 - - -.. code:: ipython2 - - J('[23 9 7] 0 select') - - -.. parsed-literal:: - - 23 - - -``zip`` -~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3] [6 5 4] zip') - - -.. parsed-literal:: - - [[6 1] [5 2] [4 3]] - - -.. code:: ipython2 - - J('[1 2 3] [6 5 4] zip [sum] map') - - -.. parsed-literal:: - - [7 7 7] - - -Math words -========== - -``+`` ``add`` -~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 +') - - -.. parsed-literal:: - - 32 - - -``-`` ``sub`` -~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 -') - - -.. parsed-literal:: - - 14 - - -``*`` ``mul`` -~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 *') - - -.. parsed-literal:: - - 207 - - -``/`` ``div`` ``floordiv`` ``truediv`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 /') - - -.. parsed-literal:: - - 2.5555555555555554 - - -.. code:: ipython2 - - J('23 -9 truediv') - - -.. parsed-literal:: - - -2.5555555555555554 - - -.. code:: ipython2 - - J('23 9 div') - - -.. parsed-literal:: - - 2 - - -.. code:: ipython2 - - J('23 9 floordiv') - - -.. parsed-literal:: - - 2 - - -.. code:: ipython2 - - J('23 -9 div') - - -.. parsed-literal:: - - -3 - - -.. code:: ipython2 - - J('23 -9 floordiv') - - -.. parsed-literal:: - - -3 - - -``%`` ``mod`` ``modulus`` ``rem`` ``remainder`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 %') - - -.. parsed-literal:: - - 5 - - -``neg`` -~~~~~~~ - -.. code:: ipython2 - - J('23 neg -5 neg') - - -.. parsed-literal:: - - -23 5 - - -pow -~~~ - -.. code:: ipython2 - - J('2 10 pow') - - -.. parsed-literal:: - - 1024 - - -``sqr`` ``sqrt`` -~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 sqr') - - -.. parsed-literal:: - - 529 - - -.. code:: ipython2 - - J('23 sqrt') - - -.. parsed-literal:: - - 4.795831523312719 - - -``++`` ``succ`` ``--`` ``pred`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 ++') - - -.. parsed-literal:: - - 2 - - -.. code:: ipython2 - - J('1 --') - - -.. parsed-literal:: - - 0 - - -``<<`` ``lshift`` ``>>`` ``rshift`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('8 1 <<') - - -.. parsed-literal:: - - 16 - - -.. code:: ipython2 - - J('8 1 >>') - - -.. parsed-literal:: - - 4 - - -``average`` -~~~~~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3 5] average') - - -.. parsed-literal:: - - 2.75 - - -``range`` ``range_to_zero`` ``down_to_zero`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('5 range') - - -.. parsed-literal:: - - [4 3 2 1 0] - - -.. code:: ipython2 - - J('5 range_to_zero') - - -.. parsed-literal:: - - [0 1 2 3 4 5] - - -.. code:: ipython2 - - J('5 down_to_zero') - - -.. parsed-literal:: - - 5 4 3 2 1 0 - - -``product`` -~~~~~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3 5] product') - - -.. parsed-literal:: - - 30 - - -``sum`` -~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3 5] sum') - - -.. parsed-literal:: - - 11 - - -``min`` -~~~~~~~ - -.. code:: ipython2 - - J('[1 2 3 5] min') - - -.. parsed-literal:: - - 1 - - -``gcd`` -~~~~~~~ - -.. code:: ipython2 - - J('45 30 gcd') - - -.. parsed-literal:: - - 15 - - -``least_fraction`` -~~~~~~~~~~~~~~~~~~ - -If we represent fractions as a quoted pair of integers [q d] this word -reduces them to their ... least common factors or whatever. - -.. code:: ipython2 - - J('[45 30] least_fraction') - - -.. parsed-literal:: - - [3 2] - - -.. code:: ipython2 - - J('[23 12] least_fraction') - - -.. parsed-literal:: - - [23 12] - - -Logic and Comparison -==================== - -``?`` ``truthy`` -~~~~~~~~~~~~~~~~ - -Get the Boolean value of the item on the top of the stack. - -.. code:: ipython2 - - J('23 truthy') - - -.. parsed-literal:: - - True - - -.. code:: ipython2 - - J('[] truthy') # Python semantics. - - -.. parsed-literal:: - - False - - -.. code:: ipython2 - - J('0 truthy') - - -.. parsed-literal:: - - False - - -:: - - ? == dup truthy - -.. code:: ipython2 - - V('23 ?') - - -.. parsed-literal:: - - . 23 ? - 23 . ? - 23 . dup truthy - 23 23 . truthy - 23 True . - - -.. code:: ipython2 - - J('[] ?') - - -.. parsed-literal:: - - [] False - - -.. code:: ipython2 - - J('0 ?') - - -.. parsed-literal:: - - 0 False - - -``&`` ``and`` -~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 &') - - -.. parsed-literal:: - - 1 - - -``!=`` ``<>`` ``ne`` -~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('23 9 !=') - - -.. parsed-literal:: - - True - - -| The usual suspects: - ``<`` ``lt`` - ``<=`` ``le`` -| - ``=`` ``eq`` - ``>`` ``gt`` - ``>=`` ``ge`` - ``not`` - ``or`` - -``^`` ``xor`` -~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 1 ^') - - -.. parsed-literal:: - - 0 - - -.. code:: ipython2 - - J('1 0 ^') - - -.. parsed-literal:: - - 1 - - -Miscellaneous -============= - -``help`` -~~~~~~~~ - -.. code:: ipython2 - - J('[help] help') - - -.. parsed-literal:: - - Accepts a quoted symbol on the top of the stack and prints its docs. - - - -``parse`` -~~~~~~~~~ - -.. code:: ipython2 - - J('[parse] help') - - -.. parsed-literal:: - - Parse the string on the stack to a Joy expression. - - - -.. code:: ipython2 - - J('1 "2 [3] dup" parse') - - -.. parsed-literal:: - - 1 [2 [3] dup] - - -``run`` -~~~~~~~ - -Evaluate a quoted Joy sequence. - -.. code:: ipython2 - - J('[1 2 dup + +] run') - - -.. parsed-literal:: - - [5] - - -Combinators -=========== - -``app1`` ``app2`` ``app3`` -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('[app1] help') - - -.. parsed-literal:: - - Given a quoted program on TOS and anything as the second stack item run - the program and replace the two args with the first result of the - program. - - ... x [Q] . app1 - ----------------------------------- - ... [x ...] [Q] . infra first - - - -.. code:: ipython2 - - J('10 4 [sqr *] app1') - - -.. parsed-literal:: - - 10 160 - - -.. code:: ipython2 - - J('10 3 4 [sqr *] app2') - - -.. parsed-literal:: - - 10 90 160 - - -.. code:: ipython2 - - J('[app2] help') - - -.. parsed-literal:: - - Like app1 with two items. - - ... y x [Q] . app2 - ----------------------------------- - ... [y ...] [Q] . infra first - [x ...] [Q] infra first - - - -.. code:: ipython2 - - J('10 2 3 4 [sqr *] app3') - - -.. parsed-literal:: - - 10 40 90 160 - - -``anamorphism`` -~~~~~~~~~~~~~~~ - -Given an initial value, a predicate function ``[P]``, and a generator -function ``[G]``, the ``anamorphism`` combinator creates a sequence. - -:: - - n [P] [G] anamorphism - --------------------------- - [...] - -Example, ``range``: - -:: - - range == [0 <=] [1 - dup] anamorphism - -.. code:: ipython2 - - J('3 [0 <=] [1 - dup] anamorphism') - - -.. parsed-literal:: - - [2 1 0] - - -``branch`` -~~~~~~~~~~ - -.. code:: ipython2 - - J('3 4 1 [+] [*] branch') - - -.. parsed-literal:: - - 12 - - -.. code:: ipython2 - - J('3 4 0 [+] [*] branch') - - -.. parsed-literal:: - - 7 - - -``cleave`` -~~~~~~~~~~ - -:: - - ... x [P] [Q] cleave - -From the original Joy docs: "The cleave combinator expects two -quotations, and below that an item ``x`` It first executes ``[P]``, with -``x`` on top, and saves the top result element. Then it executes -``[Q]``, again with ``x``, and saves the top result. Finally it restores -the stack to what it was below ``x`` and pushes the two results P(X) and -Q(X)." - -Note that ``P`` and ``Q`` can use items from the stack freely, since the -stack (below ``x``) is restored. ``cleave`` is a kind of *parallel* -primitive, and it would make sense to create a version that uses, e.g. -Python threads or something, to actually run ``P`` and ``Q`` -concurrently. The current implementation of ``cleave`` is a definition -in terms of ``app2``: - -:: - - cleave == [i] app2 [popd] dip - -.. code:: ipython2 - - J('10 2 [+] [-] cleave') - - -.. parsed-literal:: - - 10 12 8 - - -``dip`` ``dipd`` ``dipdd`` -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 2 3 4 5 [+] dip') - - -.. parsed-literal:: - - 1 2 7 5 - - -.. code:: ipython2 - - J('1 2 3 4 5 [+] dipd') - - -.. parsed-literal:: - - 1 5 4 5 - - -.. code:: ipython2 - - J('1 2 3 4 5 [+] dipdd') - - -.. parsed-literal:: - - 3 3 4 5 - - -``dupdip`` -~~~~~~~~~~ - -Expects a quoted program ``[Q]`` on the stack and some item under it, -``dup`` the item and ``dip`` the quoted program under it. - -:: - - n [Q] dupdip == n Q n - -.. code:: ipython2 - - V('23 [++] dupdip *') # N(N + 1) - - -.. parsed-literal:: - - . 23 [++] dupdip * - 23 . [++] dupdip * - 23 [++] . dupdip * - 23 . ++ 23 * - 24 . 23 * - 24 23 . * - 552 . - - -``genrec`` ``primrec`` -~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('[genrec] help') - - -.. parsed-literal:: - - General Recursion Combinator. - - [if] [then] [rec1] [rec2] genrec - --------------------------------------------------------------------- - [if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte - - From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun: - "The genrec combinator takes four program parameters in addition to - whatever data parameters it needs. Fourth from the top is an if-part, - followed by a then-part. If the if-part yields true, then the then-part - is executed and the combinator terminates. The other two parameters are - the rec1-part and the rec2-part. If the if-part yields false, the - rec1-part is executed. Following that the four program parameters and - the combinator are again pushed onto the stack bundled up in a quoted - form. Then the rec2-part is executed, where it will find the bundled - form. Typically it will then execute the bundled form, either with i or - with app2, or some other combinator." - - The way to design one of these is to fix your base case [then] and the - test [if], and then treat rec1 and rec2 as an else-part "sandwiching" - a quotation of the whole function. - - For example, given a (general recursive) function 'F': - - F == [I] [T] [R1] [R2] genrec - - If the [I] if-part fails you must derive R1 and R2 from: - - ... R1 [F] R2 - - Just set the stack arguments in front, and figure out what R1 and R2 - have to do to apply the quoted [F] in the proper way. In effect, the - genrec combinator turns into an ifte combinator with a quoted copy of - the original definition in the else-part: - - F == [I] [T] [R1] [R2] genrec - == [I] [T] [R1 [F] R2] ifte - - (Primitive recursive functions are those where R2 == i. - - P == [I] [T] [R] primrec - == [I] [T] [R [P] i] ifte - == [I] [T] [R P] ifte - ) - - - -.. code:: ipython2 - - J('3 [1 <=] [] [dup --] [i *] genrec') - - -.. parsed-literal:: - - 6 - - -``i`` -~~~~~ - -.. code:: ipython2 - - V('1 2 3 [+ +] i') - - -.. parsed-literal:: - - . 1 2 3 [+ +] i - 1 . 2 3 [+ +] i - 1 2 . 3 [+ +] i - 1 2 3 . [+ +] i - 1 2 3 [+ +] . i - 1 2 3 . + + - 1 5 . + - 6 . - - -``ifte`` -~~~~~~~~ - -:: - - [predicate] [then] [else] ifte - -.. code:: ipython2 - - J('1 2 [1] [+] [*] ifte') - - -.. parsed-literal:: - - 3 - - -.. code:: ipython2 - - J('1 2 [0] [+] [*] ifte') - - -.. parsed-literal:: - - 2 - - -``infra`` -~~~~~~~~~ - -.. code:: ipython2 - - V('1 2 3 [4 5 6] [* +] infra') - - -.. parsed-literal:: - - . 1 2 3 [4 5 6] [* +] infra - 1 . 2 3 [4 5 6] [* +] infra - 1 2 . 3 [4 5 6] [* +] infra - 1 2 3 . [4 5 6] [* +] infra - 1 2 3 [4 5 6] . [* +] infra - 1 2 3 [4 5 6] [* +] . infra - 6 5 4 . * + [3 2 1] swaack - 6 20 . + [3 2 1] swaack - 26 . [3 2 1] swaack - 26 [3 2 1] . swaack - 1 2 3 [26] . - - -``loop`` -~~~~~~~~ - -.. code:: ipython2 - - J('[loop] help') - - -.. parsed-literal:: - - Basic loop combinator. - - ... True [Q] loop - ----------------------- - ... Q [Q] loop - - ... False [Q] loop - ------------------------ - ... - - - -.. code:: ipython2 - - V('3 dup [1 - dup] loop') - - -.. parsed-literal:: - - . 3 dup [1 - dup] loop - 3 . dup [1 - dup] loop - 3 3 . [1 - dup] loop - 3 3 [1 - dup] . loop - 3 . 1 - dup [1 - dup] loop - 3 1 . - dup [1 - dup] loop - 2 . dup [1 - dup] loop - 2 2 . [1 - dup] loop - 2 2 [1 - dup] . loop - 2 . 1 - dup [1 - dup] loop - 2 1 . - dup [1 - dup] loop - 1 . dup [1 - dup] loop - 1 1 . [1 - dup] loop - 1 1 [1 - dup] . loop - 1 . 1 - dup [1 - dup] loop - 1 1 . - dup [1 - dup] loop - 0 . dup [1 - dup] loop - 0 0 . [1 - dup] loop - 0 0 [1 - dup] . loop - 0 . - - -``map`` ``pam`` -~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('10 [1 2 3] [*] map') - - -.. parsed-literal:: - - 10 [10 20 30] - - -.. code:: ipython2 - - J('10 5 [[*][/][+][-]] pam') - - -.. parsed-literal:: - - 10 5 [50 2.0 15 5] - - -``nullary`` ``unary`` ``binary`` ``ternary`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Run a quoted program enforcing -`arity `__. - -.. code:: ipython2 - - J('1 2 3 4 5 [+] nullary') - - -.. parsed-literal:: - - 1 2 3 4 5 9 - - -.. code:: ipython2 - - J('1 2 3 4 5 [+] unary') - - -.. parsed-literal:: - - 1 2 3 4 9 - - -.. code:: ipython2 - - J('1 2 3 4 5 [+] binary') # + has arity 2 so this is technically pointless... - - -.. parsed-literal:: - - 1 2 3 9 - - -.. code:: ipython2 - - J('1 2 3 4 5 [+] ternary') - - -.. parsed-literal:: - - 1 2 9 - - -``step`` -~~~~~~~~ - -.. code:: ipython2 - - J('[step] help') - - -.. parsed-literal:: - - Run a quoted program on each item in a sequence. - - ... [] [Q] . step - ----------------------- - ... . - - - ... [a] [Q] . step - ------------------------ - ... a . Q - - - ... [a b c] [Q] . step - ---------------------------------------- - ... a . Q [b c] [Q] step - - The step combinator executes the quotation on each member of the list - on top of the stack. - - - -.. code:: ipython2 - - V('0 [1 2 3] [+] step') - - -.. parsed-literal:: - - . 0 [1 2 3] [+] step - 0 . [1 2 3] [+] step - 0 [1 2 3] . [+] step - 0 [1 2 3] [+] . step - 0 1 [+] . i [2 3] [+] step - 0 1 . + [2 3] [+] step - 1 . [2 3] [+] step - 1 [2 3] . [+] step - 1 [2 3] [+] . step - 1 2 [+] . i [3] [+] step - 1 2 . + [3] [+] step - 3 . [3] [+] step - 3 [3] . [+] step - 3 [3] [+] . step - 3 3 [+] . i - 3 3 . + - 6 . - - -``times`` -~~~~~~~~~ - -.. code:: ipython2 - - V('3 2 1 2 [+] times') - - -.. parsed-literal:: - - . 3 2 1 2 [+] times - 3 . 2 1 2 [+] times - 3 2 . 1 2 [+] times - 3 2 1 . 2 [+] times - 3 2 1 2 . [+] times - 3 2 1 2 [+] . times - 3 2 1 . + 1 [+] times - 3 3 . 1 [+] times - 3 3 1 . [+] times - 3 3 1 [+] . times - 3 3 . + - 6 . - - -``b`` -~~~~~ - -.. code:: ipython2 - - J('[b] help') - - -.. parsed-literal:: - - b == [i] dip i - - ... [P] [Q] b == ... [P] i [Q] i - ... [P] [Q] b == ... P Q - - - -.. code:: ipython2 - - V('1 2 [3] [4] b') - - -.. parsed-literal:: - - . 1 2 [3] [4] b - 1 . 2 [3] [4] b - 1 2 . [3] [4] b - 1 2 [3] . [4] b - 1 2 [3] [4] . b - 1 2 . 3 4 - 1 2 3 . 4 - 1 2 3 4 . - - -``while`` -~~~~~~~~~ - -:: - - [predicate] [body] while - -.. code:: ipython2 - - J('3 [0 >] [dup --] while') - - -.. parsed-literal:: - - 3 2 1 0 - - -``x`` -~~~~~ - -.. code:: ipython2 - - J('[x] help') - - -.. parsed-literal:: - - x == dup i - - ... [Q] x = ... [Q] dup i - ... [Q] x = ... [Q] [Q] i - ... [Q] x = ... [Q] Q - - - -.. code:: ipython2 - - V('1 [2] [i 3] x') # Kind of a pointless example. - - -.. parsed-literal:: - - . 1 [2] [i 3] x - 1 . [2] [i 3] x - 1 [2] . [i 3] x - 1 [2] [i 3] . x - 1 [2] [i 3] . i 3 - 1 [2] . i 3 3 - 1 . 2 3 3 - 1 2 . 3 3 - 1 2 3 . 3 - 1 2 3 3 . - - -``void`` -======== - -Implements `**Laws of Form** -*arithmetic* `__ -over quote-only datastructures (that is, datastructures that consist -soley of containers, without strings or numbers or anything else.) - -.. code:: ipython2 - - J('[] void') - - -.. parsed-literal:: - - False - - -.. code:: ipython2 - - J('[[]] void') - - -.. parsed-literal:: - - True - - -.. code:: ipython2 - - J('[[][[]]] void') - - -.. parsed-literal:: - - True - - -.. code:: ipython2 - - J('[[[]][[][]]] void') - - -.. parsed-literal:: - - False - diff --git a/docs/3. Developing a Program.html b/docs/3. Developing a Program.html deleted file mode 100644 index 4a6e724..0000000 --- a/docs/3. Developing a Program.html +++ /dev/null @@ -1,13283 +0,0 @@ - - - -3. Developing a Program - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Project Euler, first problem: "Multiples of 3 and 5"

-
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
-
-Find the sum of all the multiples of 3 or 5 below 1000.
- -
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import J, V, define
-
- -
-
-
- -
-
-
-
-
-

Let's create a predicate that returns True if a number is a multiple of 3 or 5 and False otherwise.

- -
-
-
-
-
-
In [2]:
-
-
-
define('P == [3 % not] dupdip 5 % not or')
-
- -
-
-
- -
-
-
-
In [3]:
-
-
-
V('80 P')
-
- -
-
-
- -
-
- - -
- -
- - -
-
             . 80 P
-          80 . P
-          80 . [3 % not] dupdip 5 % not or
-80 [3 % not] . dupdip 5 % not or
-          80 . 3 % not 80 5 % not or
-        80 3 . % not 80 5 % not or
-           2 . not 80 5 % not or
-       False . 80 5 % not or
-    False 80 . 5 % not or
-  False 80 5 . % not or
-     False 0 . not or
-  False True . or
-        True . 
-
-
-
- -
-
- -
-
-
-
-
-

Given the predicate function P a suitable program is:

- -
PE1 == 1000 range [P] filter sum
-
-
-

This function generates a list of the integers from 0 to 999, filters -that list by P, and then sums the result.

-

Logically this is fine, but pragmatically we are doing more work than we -should be; we generate one thousand integers but actually use less than -half of them. A better solution would be to generate just the multiples -we want to sum, and to add them as we go rather than storing them and -adding summing them at the end.

-

At first I had the idea to use two counters and increase them by three -and five, respectively. This way we only generate the terms that we -actually want to sum. We have to proceed by incrementing the counter -that is lower, or if they are equal, the three counter, and we have to -take care not to double add numbers like 15 that are multiples of both -three and five.

-

This seemed a little clunky, so I tried a different approach.

-

Consider the first few terms in the series:

- -
3 5 6 9 10 12 15 18 20 21 ...
-
-
-

Subtract each number from the one after it (subtracting 0 from 3):

- -
3 5 6 9 10 12 15 18 20 21 24 25 27 30 ...
-0 3 5 6  9 10 12 15 18 20 21 24 25 27 ...
--------------------------------------------
-3 2 1 3  1  2  3  3  2  1  3  1  2  3 ...
-
-
-

You get this lovely repeating palindromic sequence:

- -
3 2 1 3 1 2 3
-
-
-

To make a counter that increments by factors of 3 and 5 you just add -these differences to the counter one-by-one in a loop.

-

To make use of this sequence to increment a counter and sum terms as we -go we need a function that will accept the sum, the counter, and the next -term to add, and that adds the term to the counter and a copy of the -counter to the running sum. This function will do that:

- -
PE1.1 == + [+] dupdip
- -
-
-
-
-
-
In [4]:
-
-
-
define('PE1.1 == + [+] dupdip')
-
- -
-
-
- -
-
-
-
In [5]:
-
-
-
V('0 0 3 PE1.1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
        . 0 0 3 PE1.1
-      0 . 0 3 PE1.1
-    0 0 . 3 PE1.1
-  0 0 3 . PE1.1
-  0 0 3 . + [+] dupdip
-    0 3 . [+] dupdip
-0 3 [+] . dupdip
-    0 3 . + 3
-      3 . 3
-    3 3 . 
-
-
-
- -
-
- -
-
-
-
In [6]:
-
-
-
V('0 0 [3 2 1 3 1 2 3] [PE1.1] step')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                            . 0 0 [3 2 1 3 1 2 3] [PE1.1] step
-                          0 . 0 [3 2 1 3 1 2 3] [PE1.1] step
-                        0 0 . [3 2 1 3 1 2 3] [PE1.1] step
-        0 0 [3 2 1 3 1 2 3] . [PE1.1] step
-0 0 [3 2 1 3 1 2 3] [PE1.1] . step
-              0 0 3 [PE1.1] . i [2 1 3 1 2 3] [PE1.1] step
-                      0 0 3 . PE1.1 [2 1 3 1 2 3] [PE1.1] step
-                      0 0 3 . + [+] dupdip [2 1 3 1 2 3] [PE1.1] step
-                        0 3 . [+] dupdip [2 1 3 1 2 3] [PE1.1] step
-                    0 3 [+] . dupdip [2 1 3 1 2 3] [PE1.1] step
-                        0 3 . + 3 [2 1 3 1 2 3] [PE1.1] step
-                          3 . 3 [2 1 3 1 2 3] [PE1.1] step
-                        3 3 . [2 1 3 1 2 3] [PE1.1] step
-          3 3 [2 1 3 1 2 3] . [PE1.1] step
-  3 3 [2 1 3 1 2 3] [PE1.1] . step
-              3 3 2 [PE1.1] . i [1 3 1 2 3] [PE1.1] step
-                      3 3 2 . PE1.1 [1 3 1 2 3] [PE1.1] step
-                      3 3 2 . + [+] dupdip [1 3 1 2 3] [PE1.1] step
-                        3 5 . [+] dupdip [1 3 1 2 3] [PE1.1] step
-                    3 5 [+] . dupdip [1 3 1 2 3] [PE1.1] step
-                        3 5 . + 5 [1 3 1 2 3] [PE1.1] step
-                          8 . 5 [1 3 1 2 3] [PE1.1] step
-                        8 5 . [1 3 1 2 3] [PE1.1] step
-            8 5 [1 3 1 2 3] . [PE1.1] step
-    8 5 [1 3 1 2 3] [PE1.1] . step
-              8 5 1 [PE1.1] . i [3 1 2 3] [PE1.1] step
-                      8 5 1 . PE1.1 [3 1 2 3] [PE1.1] step
-                      8 5 1 . + [+] dupdip [3 1 2 3] [PE1.1] step
-                        8 6 . [+] dupdip [3 1 2 3] [PE1.1] step
-                    8 6 [+] . dupdip [3 1 2 3] [PE1.1] step
-                        8 6 . + 6 [3 1 2 3] [PE1.1] step
-                         14 . 6 [3 1 2 3] [PE1.1] step
-                       14 6 . [3 1 2 3] [PE1.1] step
-             14 6 [3 1 2 3] . [PE1.1] step
-     14 6 [3 1 2 3] [PE1.1] . step
-             14 6 3 [PE1.1] . i [1 2 3] [PE1.1] step
-                     14 6 3 . PE1.1 [1 2 3] [PE1.1] step
-                     14 6 3 . + [+] dupdip [1 2 3] [PE1.1] step
-                       14 9 . [+] dupdip [1 2 3] [PE1.1] step
-                   14 9 [+] . dupdip [1 2 3] [PE1.1] step
-                       14 9 . + 9 [1 2 3] [PE1.1] step
-                         23 . 9 [1 2 3] [PE1.1] step
-                       23 9 . [1 2 3] [PE1.1] step
-               23 9 [1 2 3] . [PE1.1] step
-       23 9 [1 2 3] [PE1.1] . step
-             23 9 1 [PE1.1] . i [2 3] [PE1.1] step
-                     23 9 1 . PE1.1 [2 3] [PE1.1] step
-                     23 9 1 . + [+] dupdip [2 3] [PE1.1] step
-                      23 10 . [+] dupdip [2 3] [PE1.1] step
-                  23 10 [+] . dupdip [2 3] [PE1.1] step
-                      23 10 . + 10 [2 3] [PE1.1] step
-                         33 . 10 [2 3] [PE1.1] step
-                      33 10 . [2 3] [PE1.1] step
-                33 10 [2 3] . [PE1.1] step
-        33 10 [2 3] [PE1.1] . step
-            33 10 2 [PE1.1] . i [3] [PE1.1] step
-                    33 10 2 . PE1.1 [3] [PE1.1] step
-                    33 10 2 . + [+] dupdip [3] [PE1.1] step
-                      33 12 . [+] dupdip [3] [PE1.1] step
-                  33 12 [+] . dupdip [3] [PE1.1] step
-                      33 12 . + 12 [3] [PE1.1] step
-                         45 . 12 [3] [PE1.1] step
-                      45 12 . [3] [PE1.1] step
-                  45 12 [3] . [PE1.1] step
-          45 12 [3] [PE1.1] . step
-            45 12 3 [PE1.1] . i
-                    45 12 3 . PE1.1
-                    45 12 3 . + [+] dupdip
-                      45 15 . [+] dupdip
-                  45 15 [+] . dupdip
-                      45 15 . + 15
-                         60 . 15
-                      60 15 . 
-
-
-
- -
-
- -
-
-
-
-
-

So one step through all seven terms brings the counter to 15 and the total to 60.

- -
-
-
-
-
-
In [7]:
-
-
-
1000 / 15
-
- -
-
-
- -
-
- - -
- -
Out[7]:
- - - - -
-
66
-
- -
- -
-
- -
-
-
-
In [8]:
-
-
-
66 * 15
-
- -
-
-
- -
-
- - -
- -
Out[8]:
- - - - -
-
990
-
- -
- -
-
- -
-
-
-
In [9]:
-
-
-
1000 - 990
-
- -
-
-
- -
-
- - -
- -
Out[9]:
- - - - -
-
10
-
- -
- -
-
- -
-
-
-
-
-

We only want the terms less than 1000.

- -
-
-
-
-
-
In [10]:
-
-
-
999 - 990
-
- -
-
-
- -
-
- - -
- -
Out[10]:
- - - - -
-
9
-
- -
- -
-
- -
-
-
-
-
-

That means we want to run the full list of numbers sixty-six times to get to 990 and then the first four numbers 3 2 1 3 to get to 999.

- -
-
-
-
-
-
In [11]:
-
-
-
define('PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop')
-
- -
-
-
- -
-
-
-
In [12]:
-
-
-
J('PE1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
233168
-
-
-
- -
-
- -
-
-
-
-
-

This form uses no extra storage and produces no unused summands. It's -good but there's one more trick we can apply. The list of seven terms -takes up at least seven bytes. But notice that all of the terms are less -than four, and so each can fit in just two bits. We could store all -seven terms in just fourteen bits and use masking and shifts to pick out -each term as we go. This will use less space and save time loading whole -integer terms from the list.

- -
    3  2  1  3  1  2  3
-0b 11 10 01 11 01 10 11 == 14811
- -
-
-
-
-
-
In [13]:
-
-
-
0b11100111011011
-
- -
-
-
- -
-
- - -
- -
Out[13]:
- - - - -
-
14811
-
- -
- -
-
- -
-
-
-
In [14]:
-
-
-
define('PE1.2 == [3 & PE1.1] dupdip 2 >>')
-
- -
-
-
- -
-
-
-
In [15]:
-
-
-
V('0 0 14811 PE1.2')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                      . 0 0 14811 PE1.2
-                    0 . 0 14811 PE1.2
-                  0 0 . 14811 PE1.2
-            0 0 14811 . PE1.2
-            0 0 14811 . [3 & PE1.1] dupdip 2 >>
-0 0 14811 [3 & PE1.1] . dupdip 2 >>
-            0 0 14811 . 3 & PE1.1 14811 2 >>
-          0 0 14811 3 . & PE1.1 14811 2 >>
-                0 0 3 . PE1.1 14811 2 >>
-                0 0 3 . + [+] dupdip 14811 2 >>
-                  0 3 . [+] dupdip 14811 2 >>
-              0 3 [+] . dupdip 14811 2 >>
-                  0 3 . + 3 14811 2 >>
-                    3 . 3 14811 2 >>
-                  3 3 . 14811 2 >>
-            3 3 14811 . 2 >>
-          3 3 14811 2 . >>
-             3 3 3702 . 
-
-
-
- -
-
- -
-
-
-
In [16]:
-
-
-
V('3 3 3702 PE1.2')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                     . 3 3 3702 PE1.2
-                   3 . 3 3702 PE1.2
-                 3 3 . 3702 PE1.2
-            3 3 3702 . PE1.2
-            3 3 3702 . [3 & PE1.1] dupdip 2 >>
-3 3 3702 [3 & PE1.1] . dupdip 2 >>
-            3 3 3702 . 3 & PE1.1 3702 2 >>
-          3 3 3702 3 . & PE1.1 3702 2 >>
-               3 3 2 . PE1.1 3702 2 >>
-               3 3 2 . + [+] dupdip 3702 2 >>
-                 3 5 . [+] dupdip 3702 2 >>
-             3 5 [+] . dupdip 3702 2 >>
-                 3 5 . + 5 3702 2 >>
-                   8 . 5 3702 2 >>
-                 8 5 . 3702 2 >>
-            8 5 3702 . 2 >>
-          8 5 3702 2 . >>
-             8 5 925 . 
-
-
-
- -
-
- -
-
-
-
In [17]:
-
-
-
V('0 0 14811 7 [PE1.2] times pop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                      . 0 0 14811 7 [PE1.2] times pop
-                    0 . 0 14811 7 [PE1.2] times pop
-                  0 0 . 14811 7 [PE1.2] times pop
-            0 0 14811 . 7 [PE1.2] times pop
-          0 0 14811 7 . [PE1.2] times pop
-  0 0 14811 7 [PE1.2] . times pop
-    0 0 14811 [PE1.2] . i 6 [PE1.2] times pop
-            0 0 14811 . PE1.2 6 [PE1.2] times pop
-            0 0 14811 . [3 & PE1.1] dupdip 2 >> 6 [PE1.2] times pop
-0 0 14811 [3 & PE1.1] . dupdip 2 >> 6 [PE1.2] times pop
-            0 0 14811 . 3 & PE1.1 14811 2 >> 6 [PE1.2] times pop
-          0 0 14811 3 . & PE1.1 14811 2 >> 6 [PE1.2] times pop
-                0 0 3 . PE1.1 14811 2 >> 6 [PE1.2] times pop
-                0 0 3 . + [+] dupdip 14811 2 >> 6 [PE1.2] times pop
-                  0 3 . [+] dupdip 14811 2 >> 6 [PE1.2] times pop
-              0 3 [+] . dupdip 14811 2 >> 6 [PE1.2] times pop
-                  0 3 . + 3 14811 2 >> 6 [PE1.2] times pop
-                    3 . 3 14811 2 >> 6 [PE1.2] times pop
-                  3 3 . 14811 2 >> 6 [PE1.2] times pop
-            3 3 14811 . 2 >> 6 [PE1.2] times pop
-          3 3 14811 2 . >> 6 [PE1.2] times pop
-             3 3 3702 . 6 [PE1.2] times pop
-           3 3 3702 6 . [PE1.2] times pop
-   3 3 3702 6 [PE1.2] . times pop
-     3 3 3702 [PE1.2] . i 5 [PE1.2] times pop
-             3 3 3702 . PE1.2 5 [PE1.2] times pop
-             3 3 3702 . [3 & PE1.1] dupdip 2 >> 5 [PE1.2] times pop
- 3 3 3702 [3 & PE1.1] . dupdip 2 >> 5 [PE1.2] times pop
-             3 3 3702 . 3 & PE1.1 3702 2 >> 5 [PE1.2] times pop
-           3 3 3702 3 . & PE1.1 3702 2 >> 5 [PE1.2] times pop
-                3 3 2 . PE1.1 3702 2 >> 5 [PE1.2] times pop
-                3 3 2 . + [+] dupdip 3702 2 >> 5 [PE1.2] times pop
-                  3 5 . [+] dupdip 3702 2 >> 5 [PE1.2] times pop
-              3 5 [+] . dupdip 3702 2 >> 5 [PE1.2] times pop
-                  3 5 . + 5 3702 2 >> 5 [PE1.2] times pop
-                    8 . 5 3702 2 >> 5 [PE1.2] times pop
-                  8 5 . 3702 2 >> 5 [PE1.2] times pop
-             8 5 3702 . 2 >> 5 [PE1.2] times pop
-           8 5 3702 2 . >> 5 [PE1.2] times pop
-              8 5 925 . 5 [PE1.2] times pop
-            8 5 925 5 . [PE1.2] times pop
-    8 5 925 5 [PE1.2] . times pop
-      8 5 925 [PE1.2] . i 4 [PE1.2] times pop
-              8 5 925 . PE1.2 4 [PE1.2] times pop
-              8 5 925 . [3 & PE1.1] dupdip 2 >> 4 [PE1.2] times pop
-  8 5 925 [3 & PE1.1] . dupdip 2 >> 4 [PE1.2] times pop
-              8 5 925 . 3 & PE1.1 925 2 >> 4 [PE1.2] times pop
-            8 5 925 3 . & PE1.1 925 2 >> 4 [PE1.2] times pop
-                8 5 1 . PE1.1 925 2 >> 4 [PE1.2] times pop
-                8 5 1 . + [+] dupdip 925 2 >> 4 [PE1.2] times pop
-                  8 6 . [+] dupdip 925 2 >> 4 [PE1.2] times pop
-              8 6 [+] . dupdip 925 2 >> 4 [PE1.2] times pop
-                  8 6 . + 6 925 2 >> 4 [PE1.2] times pop
-                   14 . 6 925 2 >> 4 [PE1.2] times pop
-                 14 6 . 925 2 >> 4 [PE1.2] times pop
-             14 6 925 . 2 >> 4 [PE1.2] times pop
-           14 6 925 2 . >> 4 [PE1.2] times pop
-             14 6 231 . 4 [PE1.2] times pop
-           14 6 231 4 . [PE1.2] times pop
-   14 6 231 4 [PE1.2] . times pop
-     14 6 231 [PE1.2] . i 3 [PE1.2] times pop
-             14 6 231 . PE1.2 3 [PE1.2] times pop
-             14 6 231 . [3 & PE1.1] dupdip 2 >> 3 [PE1.2] times pop
- 14 6 231 [3 & PE1.1] . dupdip 2 >> 3 [PE1.2] times pop
-             14 6 231 . 3 & PE1.1 231 2 >> 3 [PE1.2] times pop
-           14 6 231 3 . & PE1.1 231 2 >> 3 [PE1.2] times pop
-               14 6 3 . PE1.1 231 2 >> 3 [PE1.2] times pop
-               14 6 3 . + [+] dupdip 231 2 >> 3 [PE1.2] times pop
-                 14 9 . [+] dupdip 231 2 >> 3 [PE1.2] times pop
-             14 9 [+] . dupdip 231 2 >> 3 [PE1.2] times pop
-                 14 9 . + 9 231 2 >> 3 [PE1.2] times pop
-                   23 . 9 231 2 >> 3 [PE1.2] times pop
-                 23 9 . 231 2 >> 3 [PE1.2] times pop
-             23 9 231 . 2 >> 3 [PE1.2] times pop
-           23 9 231 2 . >> 3 [PE1.2] times pop
-              23 9 57 . 3 [PE1.2] times pop
-            23 9 57 3 . [PE1.2] times pop
-    23 9 57 3 [PE1.2] . times pop
-      23 9 57 [PE1.2] . i 2 [PE1.2] times pop
-              23 9 57 . PE1.2 2 [PE1.2] times pop
-              23 9 57 . [3 & PE1.1] dupdip 2 >> 2 [PE1.2] times pop
-  23 9 57 [3 & PE1.1] . dupdip 2 >> 2 [PE1.2] times pop
-              23 9 57 . 3 & PE1.1 57 2 >> 2 [PE1.2] times pop
-            23 9 57 3 . & PE1.1 57 2 >> 2 [PE1.2] times pop
-               23 9 1 . PE1.1 57 2 >> 2 [PE1.2] times pop
-               23 9 1 . + [+] dupdip 57 2 >> 2 [PE1.2] times pop
-                23 10 . [+] dupdip 57 2 >> 2 [PE1.2] times pop
-            23 10 [+] . dupdip 57 2 >> 2 [PE1.2] times pop
-                23 10 . + 10 57 2 >> 2 [PE1.2] times pop
-                   33 . 10 57 2 >> 2 [PE1.2] times pop
-                33 10 . 57 2 >> 2 [PE1.2] times pop
-             33 10 57 . 2 >> 2 [PE1.2] times pop
-           33 10 57 2 . >> 2 [PE1.2] times pop
-             33 10 14 . 2 [PE1.2] times pop
-           33 10 14 2 . [PE1.2] times pop
-   33 10 14 2 [PE1.2] . times pop
-     33 10 14 [PE1.2] . i 1 [PE1.2] times pop
-             33 10 14 . PE1.2 1 [PE1.2] times pop
-             33 10 14 . [3 & PE1.1] dupdip 2 >> 1 [PE1.2] times pop
- 33 10 14 [3 & PE1.1] . dupdip 2 >> 1 [PE1.2] times pop
-             33 10 14 . 3 & PE1.1 14 2 >> 1 [PE1.2] times pop
-           33 10 14 3 . & PE1.1 14 2 >> 1 [PE1.2] times pop
-              33 10 2 . PE1.1 14 2 >> 1 [PE1.2] times pop
-              33 10 2 . + [+] dupdip 14 2 >> 1 [PE1.2] times pop
-                33 12 . [+] dupdip 14 2 >> 1 [PE1.2] times pop
-            33 12 [+] . dupdip 14 2 >> 1 [PE1.2] times pop
-                33 12 . + 12 14 2 >> 1 [PE1.2] times pop
-                   45 . 12 14 2 >> 1 [PE1.2] times pop
-                45 12 . 14 2 >> 1 [PE1.2] times pop
-             45 12 14 . 2 >> 1 [PE1.2] times pop
-           45 12 14 2 . >> 1 [PE1.2] times pop
-              45 12 3 . 1 [PE1.2] times pop
-            45 12 3 1 . [PE1.2] times pop
-    45 12 3 1 [PE1.2] . times pop
-      45 12 3 [PE1.2] . i pop
-              45 12 3 . PE1.2 pop
-              45 12 3 . [3 & PE1.1] dupdip 2 >> pop
-  45 12 3 [3 & PE1.1] . dupdip 2 >> pop
-              45 12 3 . 3 & PE1.1 3 2 >> pop
-            45 12 3 3 . & PE1.1 3 2 >> pop
-              45 12 3 . PE1.1 3 2 >> pop
-              45 12 3 . + [+] dupdip 3 2 >> pop
-                45 15 . [+] dupdip 3 2 >> pop
-            45 15 [+] . dupdip 3 2 >> pop
-                45 15 . + 15 3 2 >> pop
-                   60 . 15 3 2 >> pop
-                60 15 . 3 2 >> pop
-              60 15 3 . 2 >> pop
-            60 15 3 2 . >> pop
-              60 15 0 . pop
-                60 15 . 
-
-
-
- -
-
- -
-
-
-
-
-

And so we have at last:

- -
-
-
-
-
-
In [18]:
-
-
-
define('PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop')
-
- -
-
-
- -
-
-
-
In [19]:
-
-
-
J('PE1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
233168
-
-
-
- -
-
- -
-
-
-
-
-

Let's refactor.

- -
  14811 7 [PE1.2] times pop
-  14811 4 [PE1.2] times pop
-  14811 n [PE1.2] times pop
-n 14811 swap [PE1.2] times pop
- -
-
-
-
-
-
In [20]:
-
-
-
define('PE1.3 == 14811 swap [PE1.2] times pop')
-
- -
-
-
- -
-
-
-
-
-

Now we can simplify the definition above:

- -
-
-
-
-
-
In [21]:
-
-
-
define('PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop')
-
- -
-
-
- -
-
-
-
In [22]:
-
-
-
J('PE1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
233168
-
-
-
- -
-
- -
-
-
-
-
-

Here's our joy program all in one place. It doesn't make so much sense, but if you have read through the above description of how it was derived I hope it's clear.

- -
PE1.1 == + [+] dupdip
-PE1.2 == [3 & PE1.1] dupdip 2 >>
-PE1.3 == 14811 swap [PE1.2] times pop
-PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop
- -
-
-
-
-
-
-
-

Generator Version

It's a little clunky iterating sixty-six times though the seven numbers then four more. In the Generator Programs notebook we derive a generator that can be repeatedly driven by the x combinator to produce a stream of the seven numbers repeating over and over again.

- -
-
-
-
-
-
In [23]:
-
-
-
define('PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]')
-
- -
-
-
- -
-
-
-
In [24]:
-
-
-
J('PE1.terms 21 [x] times')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]
-
-
-
- -
-
- -
-
-
-
-
-

We know from above that we need sixty-six times seven then four more terms to reach up to but not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2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3
-
-
-
- -
-
- -
-
-
-
-
-

...and they do sum to 999.

-
-
-
-
-
-
In [27]:
-
-
-
J('[PE1.terms 466 [x] times pop] run sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
999
-
-
-
- -
-
- -
-
-
-
-
-

Now we can use PE1.1 to accumulate the terms as we go, and then pop the generator and the counter from the stack when we're done, leaving just the sum.

- -
-
-
-
-
-
In [28]:
-
-
-
J('0 0 PE1.terms 466 [x [PE1.1] dip] times popop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
233168
-
-
-
- -
-
- -
-
-
-
-
-

A little further analysis renders iteration unnecessary.

Consider finding the sum of the positive integers less than or equal to ten.

- -
-
-
-
-
-
In [29]:
-
-
-
J('[10 9 8 7 6 5 4 3 2 1] sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
55
-
-
-
- -
-
- -
-
-
-
-
-

Instead of summing them, observe:

- -
  10  9  8  7  6
-+  1  2  3  4  5
----- -- -- -- --
-  11 11 11 11 11
-
-  11 * 5 = 55
-
-
-

From the above example we can deduce that the sum of the first N positive integers is:

- -
(N + 1) * N / 2 
-
-
-

(The formula also works for odd values of N, I'll leave that to you if you want to work it out or you can take my word for it.)

- -
-
-
-
-
-
In [30]:
-
-
-
define('F == dup ++ * 2 floordiv')
-
- -
-
-
- -
-
-
-
In [31]:
-
-
-
V('10 F')
-
- -
-
-
- -
-
- - -
- -
- - -
-
      . 10 F
-   10 . F
-   10 . dup ++ * 2 floordiv
-10 10 . ++ * 2 floordiv
-10 11 . * 2 floordiv
-  110 . 2 floordiv
-110 2 . floordiv
-   55 . 
-
-
-
- -
-
- -
-
-
-
-
-

Generalizing to Blocks of Terms

We can apply the same reasoning to the PE1 problem.

-

Between 0 and 990 inclusive there are sixty-six "blocks" of seven terms each, starting with:

- -
[3 5 6 9 10 12 15]
-
-
-

And ending with:

- -
[978 980 981 984 985 987 990]
-
-
-

If we reverse one of these two blocks and sum pairs...

- -
-
-
-
-
-
In [32]:
-
-
-
J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[[978 15] [980 12] [981 10] [984 9] [985 6] [987 5] [990 3]]
-
-
-
- -
-
- -
-
-
-
In [33]:
-
-
-
J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[993 992 991 993 991 992 993]
-
-
-
- -
-
- -
-
-
-
-
-

(Interesting that the sequence of seven numbers appears again in the rightmost digit of each term.)

- -
-
-
-
-
-
In [34]:
-
-
-
J('[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
6945
-
-
-
- -
-
- -
-
-
-
-
-

Since there are sixty-six blocks and we are pairing them up, there must be thirty-three pairs, each of which sums to 6945. We also have these additional unpaired terms between 990 and 1000:

- -
993 995 996 999
-
-
-

So we can give the "sum of all the multiples of 3 or 5 below 1000" like so:

- -
-
-
-
-
-
In [35]:
-
-
-
J('6945 33 * [993 995 996 999] cons sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
233168
-
-
-
- -
-
- -
-
-
-
-
-

It's worth noting, I think, that this same reasoning holds for any two numbers $n$ and $m$ the multiples of which we hope to sum. The multiples would have a cycle of differences of length $k$ and so we could compute the sum of $Nk$ multiples as above.

-

The sequence of differences will always be a palidrome. Consider an interval spanning the least common multiple of $n$ and $m$:

- -
|   |   |   |   |   |   |   |
-|      |      |      |      |
-
-
-

Here we have 4 and 7, and you can read off the sequence of differences directly from the diagram: 4 3 1 4 2 2 4 1 3 4.

-

Geometrically, the actual values of $n$ and $m$ and their lcm don't matter, the pattern they make will always be symmetrical around its midpoint. The same reasoning holds for multiples of more than two numbers.

- -
-
-
-
-
-
-
-

The Simplest Program

-
-
-
-
-
-
-
-

Of course, the simplest joy program for the first Project Euler problem is just:

- -
PE1 == 233168
-
-
-

Fin.

- -
-
-
-
-
- - - - - - diff --git a/docs/3. Developing a Program.ipynb b/docs/3. Developing a Program.ipynb deleted file mode 100644 index 0cb1730..0000000 --- a/docs/3. Developing a Program.ipynb +++ /dev/null @@ -1,1121 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# [Project Euler, first problem: \"Multiples of 3 and 5\"](https://projecteuler.net/problem=1)\n", - "\n", - " If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.\n", - "\n", - " Find the sum of all the multiples of 3 or 5 below 1000." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import J, V, define" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's create a predicate that returns `True` if a number is a multiple of 3 or 5 and `False` otherwise." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "define('P == [3 % not] dupdip 5 % not or')" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 80 P\n", - " 80 . P\n", - " 80 . [3 % not] dupdip 5 % not or\n", - "80 [3 % not] . dupdip 5 % not or\n", - " 80 . 3 % not 80 5 % not or\n", - " 80 3 . % not 80 5 % not or\n", - " 2 . not 80 5 % not or\n", - " False . 80 5 % not or\n", - " False 80 . 5 % not or\n", - " False 80 5 . % not or\n", - " False 0 . not or\n", - " False True . or\n", - " True . \n" - ] - } - ], - "source": [ - "V('80 P')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Given the predicate function `P` a suitable program is:\n", - "\n", - " PE1 == 1000 range [P] filter sum\n", - "\n", - "This function generates a list of the integers from 0 to 999, filters\n", - "that list by `P`, and then sums the result.\n", - "\n", - "Logically this is fine, but pragmatically we are doing more work than we\n", - "should be; we generate one thousand integers but actually use less than\n", - "half of them. A better solution would be to generate just the multiples\n", - "we want to sum, and to add them as we go rather than storing them and\n", - "adding summing them at the end.\n", - "\n", - "At first I had the idea to use two counters and increase them by three\n", - "and five, respectively. This way we only generate the terms that we\n", - "actually want to sum. We have to proceed by incrementing the counter\n", - "that is lower, or if they are equal, the three counter, and we have to\n", - "take care not to double add numbers like 15 that are multiples of both\n", - "three and five.\n", - "\n", - "This seemed a little clunky, so I tried a different approach.\n", - "\n", - "Consider the first few terms in the series:\n", - "\n", - " 3 5 6 9 10 12 15 18 20 21 ...\n", - "\n", - "Subtract each number from the one after it (subtracting 0 from 3):\n", - "\n", - " 3 5 6 9 10 12 15 18 20 21 24 25 27 30 ...\n", - " 0 3 5 6 9 10 12 15 18 20 21 24 25 27 ...\n", - " -------------------------------------------\n", - " 3 2 1 3 1 2 3 3 2 1 3 1 2 3 ...\n", - "\n", - "You get this lovely repeating palindromic sequence:\n", - "\n", - " 3 2 1 3 1 2 3\n", - "\n", - "To make a counter that increments by factors of 3 and 5 you just add\n", - "these differences to the counter one-by-one in a loop.\n", - "\n", - "\n", - "To make use of this sequence to increment a counter and sum terms as we\n", - "go we need a function that will accept the sum, the counter, and the next\n", - "term to add, and that adds the term to the counter and a copy of the\n", - "counter to the running sum. This function will do that:\n", - "\n", - " PE1.1 == + [+] dupdip" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1.1 == + [+] dupdip')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 0 0 3 PE1.1\n", - " 0 . 0 3 PE1.1\n", - " 0 0 . 3 PE1.1\n", - " 0 0 3 . PE1.1\n", - " 0 0 3 . + [+] dupdip\n", - " 0 3 . [+] dupdip\n", - "0 3 [+] . dupdip\n", - " 0 3 . + 3\n", - " 3 . 3\n", - " 3 3 . \n" - ] - } - ], - "source": [ - "V('0 0 3 PE1.1')" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 0 0 [3 2 1 3 1 2 3] [PE1.1] step\n", - " 0 . 0 [3 2 1 3 1 2 3] [PE1.1] step\n", - " 0 0 . [3 2 1 3 1 2 3] [PE1.1] step\n", - " 0 0 [3 2 1 3 1 2 3] . [PE1.1] step\n", - "0 0 [3 2 1 3 1 2 3] [PE1.1] . step\n", - " 0 0 3 [PE1.1] . i [2 1 3 1 2 3] [PE1.1] step\n", - " 0 0 3 . PE1.1 [2 1 3 1 2 3] [PE1.1] step\n", - " 0 0 3 . + [+] dupdip [2 1 3 1 2 3] [PE1.1] step\n", - " 0 3 . [+] dupdip [2 1 3 1 2 3] [PE1.1] step\n", - " 0 3 [+] . dupdip [2 1 3 1 2 3] [PE1.1] step\n", - " 0 3 . + 3 [2 1 3 1 2 3] [PE1.1] step\n", - " 3 . 3 [2 1 3 1 2 3] [PE1.1] step\n", - " 3 3 . [2 1 3 1 2 3] [PE1.1] step\n", - " 3 3 [2 1 3 1 2 3] . [PE1.1] step\n", - " 3 3 [2 1 3 1 2 3] [PE1.1] . step\n", - " 3 3 2 [PE1.1] . i [1 3 1 2 3] [PE1.1] step\n", - " 3 3 2 . PE1.1 [1 3 1 2 3] [PE1.1] step\n", - " 3 3 2 . + [+] dupdip [1 3 1 2 3] [PE1.1] step\n", - " 3 5 . [+] dupdip [1 3 1 2 3] [PE1.1] step\n", - " 3 5 [+] . dupdip [1 3 1 2 3] [PE1.1] step\n", - " 3 5 . + 5 [1 3 1 2 3] [PE1.1] step\n", - " 8 . 5 [1 3 1 2 3] [PE1.1] step\n", - " 8 5 . [1 3 1 2 3] [PE1.1] step\n", - " 8 5 [1 3 1 2 3] . [PE1.1] step\n", - " 8 5 [1 3 1 2 3] [PE1.1] . step\n", - " 8 5 1 [PE1.1] . i [3 1 2 3] [PE1.1] step\n", - " 8 5 1 . PE1.1 [3 1 2 3] [PE1.1] step\n", - " 8 5 1 . + [+] dupdip [3 1 2 3] [PE1.1] step\n", - " 8 6 . [+] dupdip [3 1 2 3] [PE1.1] step\n", - " 8 6 [+] . dupdip [3 1 2 3] [PE1.1] step\n", - " 8 6 . + 6 [3 1 2 3] [PE1.1] step\n", - " 14 . 6 [3 1 2 3] [PE1.1] step\n", - " 14 6 . [3 1 2 3] [PE1.1] step\n", - " 14 6 [3 1 2 3] . [PE1.1] step\n", - " 14 6 [3 1 2 3] [PE1.1] . step\n", - " 14 6 3 [PE1.1] . i [1 2 3] [PE1.1] step\n", - " 14 6 3 . PE1.1 [1 2 3] [PE1.1] step\n", - " 14 6 3 . + [+] dupdip [1 2 3] [PE1.1] step\n", - " 14 9 . [+] dupdip [1 2 3] [PE1.1] step\n", - " 14 9 [+] . dupdip [1 2 3] [PE1.1] step\n", - " 14 9 . + 9 [1 2 3] [PE1.1] step\n", - " 23 . 9 [1 2 3] [PE1.1] step\n", - " 23 9 . [1 2 3] [PE1.1] step\n", - " 23 9 [1 2 3] . [PE1.1] step\n", - " 23 9 [1 2 3] [PE1.1] . step\n", - " 23 9 1 [PE1.1] . i [2 3] [PE1.1] step\n", - " 23 9 1 . PE1.1 [2 3] [PE1.1] step\n", - " 23 9 1 . + [+] dupdip [2 3] [PE1.1] step\n", - " 23 10 . [+] dupdip [2 3] [PE1.1] step\n", - " 23 10 [+] . dupdip [2 3] [PE1.1] step\n", - " 23 10 . + 10 [2 3] [PE1.1] step\n", - " 33 . 10 [2 3] [PE1.1] step\n", - " 33 10 . [2 3] [PE1.1] step\n", - " 33 10 [2 3] . [PE1.1] step\n", - " 33 10 [2 3] [PE1.1] . step\n", - " 33 10 2 [PE1.1] . i [3] [PE1.1] step\n", - " 33 10 2 . PE1.1 [3] [PE1.1] step\n", - " 33 10 2 . + [+] dupdip [3] [PE1.1] step\n", - " 33 12 . [+] dupdip [3] [PE1.1] step\n", - " 33 12 [+] . dupdip [3] [PE1.1] step\n", - " 33 12 . + 12 [3] [PE1.1] step\n", - " 45 . 12 [3] [PE1.1] step\n", - " 45 12 . [3] [PE1.1] step\n", - " 45 12 [3] . [PE1.1] step\n", - " 45 12 [3] [PE1.1] . step\n", - " 45 12 3 [PE1.1] . i\n", - " 45 12 3 . PE1.1\n", - " 45 12 3 . + [+] dupdip\n", - " 45 15 . [+] dupdip\n", - " 45 15 [+] . dupdip\n", - " 45 15 . + 15\n", - " 60 . 15\n", - " 60 15 . \n" - ] - } - ], - "source": [ - "V('0 0 [3 2 1 3 1 2 3] [PE1.1] step')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "So one `step` through all seven terms brings the counter to 15 and the total to 60." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "66" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "1000 / 15" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "990" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "66 * 15" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "10" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "1000 - 990" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We only want the terms *less than* 1000." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "9" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "999 - 990" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That means we want to run the full list of numbers sixty-six times to get to 990 and then the first four numbers 3 2 1 3 to get to 999." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop')" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "233168\n" - ] - } - ], - "source": [ - "J('PE1')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This form uses no extra storage and produces no unused summands. It's\n", - "good but there's one more trick we can apply. The list of seven terms\n", - "takes up at least seven bytes. But notice that all of the terms are less\n", - "than four, and so each can fit in just two bits. We could store all\n", - "seven terms in just fourteen bits and use masking and shifts to pick out\n", - "each term as we go. This will use less space and save time loading whole\n", - "integer terms from the list.\n", - "\n", - " 3 2 1 3 1 2 3\n", - " 0b 11 10 01 11 01 10 11 == 14811" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "14811" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "0b11100111011011" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1.2 == [3 & PE1.1] dupdip 2 >>')" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 0 0 14811 PE1.2\n", - " 0 . 0 14811 PE1.2\n", - " 0 0 . 14811 PE1.2\n", - " 0 0 14811 . PE1.2\n", - " 0 0 14811 . [3 & PE1.1] dupdip 2 >>\n", - "0 0 14811 [3 & PE1.1] . dupdip 2 >>\n", - " 0 0 14811 . 3 & PE1.1 14811 2 >>\n", - " 0 0 14811 3 . & PE1.1 14811 2 >>\n", - " 0 0 3 . PE1.1 14811 2 >>\n", - " 0 0 3 . + [+] dupdip 14811 2 >>\n", - " 0 3 . [+] dupdip 14811 2 >>\n", - " 0 3 [+] . dupdip 14811 2 >>\n", - " 0 3 . + 3 14811 2 >>\n", - " 3 . 3 14811 2 >>\n", - " 3 3 . 14811 2 >>\n", - " 3 3 14811 . 2 >>\n", - " 3 3 14811 2 . >>\n", - " 3 3 3702 . \n" - ] - } - ], - "source": [ - "V('0 0 14811 PE1.2')" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 3 3 3702 PE1.2\n", - " 3 . 3 3702 PE1.2\n", - " 3 3 . 3702 PE1.2\n", - " 3 3 3702 . PE1.2\n", - " 3 3 3702 . [3 & PE1.1] dupdip 2 >>\n", - "3 3 3702 [3 & PE1.1] . dupdip 2 >>\n", - " 3 3 3702 . 3 & PE1.1 3702 2 >>\n", - " 3 3 3702 3 . & PE1.1 3702 2 >>\n", - " 3 3 2 . PE1.1 3702 2 >>\n", - " 3 3 2 . + [+] dupdip 3702 2 >>\n", - " 3 5 . [+] dupdip 3702 2 >>\n", - " 3 5 [+] . dupdip 3702 2 >>\n", - " 3 5 . + 5 3702 2 >>\n", - " 8 . 5 3702 2 >>\n", - " 8 5 . 3702 2 >>\n", - " 8 5 3702 . 2 >>\n", - " 8 5 3702 2 . >>\n", - " 8 5 925 . \n" - ] - } - ], - "source": [ - "V('3 3 3702 PE1.2')" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 0 0 14811 7 [PE1.2] times pop\n", - " 0 . 0 14811 7 [PE1.2] times pop\n", - " 0 0 . 14811 7 [PE1.2] times pop\n", - " 0 0 14811 . 7 [PE1.2] times pop\n", - " 0 0 14811 7 . [PE1.2] times pop\n", - " 0 0 14811 7 [PE1.2] . times pop\n", - " 0 0 14811 [PE1.2] . i 6 [PE1.2] times pop\n", - " 0 0 14811 . PE1.2 6 [PE1.2] times pop\n", - " 0 0 14811 . [3 & PE1.1] dupdip 2 >> 6 [PE1.2] times pop\n", - "0 0 14811 [3 & PE1.1] . dupdip 2 >> 6 [PE1.2] times pop\n", - " 0 0 14811 . 3 & PE1.1 14811 2 >> 6 [PE1.2] times pop\n", - " 0 0 14811 3 . & PE1.1 14811 2 >> 6 [PE1.2] times pop\n", - " 0 0 3 . PE1.1 14811 2 >> 6 [PE1.2] times pop\n", - " 0 0 3 . + [+] dupdip 14811 2 >> 6 [PE1.2] times pop\n", - " 0 3 . [+] dupdip 14811 2 >> 6 [PE1.2] times pop\n", - " 0 3 [+] . dupdip 14811 2 >> 6 [PE1.2] times pop\n", - " 0 3 . + 3 14811 2 >> 6 [PE1.2] times pop\n", - " 3 . 3 14811 2 >> 6 [PE1.2] times pop\n", - " 3 3 . 14811 2 >> 6 [PE1.2] times pop\n", - " 3 3 14811 . 2 >> 6 [PE1.2] times pop\n", - " 3 3 14811 2 . >> 6 [PE1.2] times pop\n", - " 3 3 3702 . 6 [PE1.2] times pop\n", - " 3 3 3702 6 . [PE1.2] times pop\n", - " 3 3 3702 6 [PE1.2] . times pop\n", - " 3 3 3702 [PE1.2] . i 5 [PE1.2] times pop\n", - " 3 3 3702 . PE1.2 5 [PE1.2] times pop\n", - " 3 3 3702 . [3 & PE1.1] dupdip 2 >> 5 [PE1.2] times pop\n", - " 3 3 3702 [3 & PE1.1] . dupdip 2 >> 5 [PE1.2] times pop\n", - " 3 3 3702 . 3 & PE1.1 3702 2 >> 5 [PE1.2] times pop\n", - " 3 3 3702 3 . & PE1.1 3702 2 >> 5 [PE1.2] times pop\n", - " 3 3 2 . PE1.1 3702 2 >> 5 [PE1.2] times pop\n", - " 3 3 2 . + [+] dupdip 3702 2 >> 5 [PE1.2] times pop\n", - " 3 5 . [+] dupdip 3702 2 >> 5 [PE1.2] times pop\n", - " 3 5 [+] . dupdip 3702 2 >> 5 [PE1.2] times pop\n", - " 3 5 . + 5 3702 2 >> 5 [PE1.2] times pop\n", - " 8 . 5 3702 2 >> 5 [PE1.2] times pop\n", - " 8 5 . 3702 2 >> 5 [PE1.2] times pop\n", - " 8 5 3702 . 2 >> 5 [PE1.2] times pop\n", - " 8 5 3702 2 . >> 5 [PE1.2] times pop\n", - " 8 5 925 . 5 [PE1.2] times pop\n", - " 8 5 925 5 . [PE1.2] times pop\n", - " 8 5 925 5 [PE1.2] . times pop\n", - " 8 5 925 [PE1.2] . i 4 [PE1.2] times pop\n", - " 8 5 925 . PE1.2 4 [PE1.2] times pop\n", - " 8 5 925 . [3 & PE1.1] dupdip 2 >> 4 [PE1.2] times pop\n", - " 8 5 925 [3 & PE1.1] . dupdip 2 >> 4 [PE1.2] times pop\n", - " 8 5 925 . 3 & PE1.1 925 2 >> 4 [PE1.2] times pop\n", - " 8 5 925 3 . & PE1.1 925 2 >> 4 [PE1.2] times pop\n", - " 8 5 1 . PE1.1 925 2 >> 4 [PE1.2] times pop\n", - " 8 5 1 . + [+] dupdip 925 2 >> 4 [PE1.2] times pop\n", - " 8 6 . [+] dupdip 925 2 >> 4 [PE1.2] times pop\n", - " 8 6 [+] . dupdip 925 2 >> 4 [PE1.2] times pop\n", - " 8 6 . + 6 925 2 >> 4 [PE1.2] times pop\n", - " 14 . 6 925 2 >> 4 [PE1.2] times pop\n", - " 14 6 . 925 2 >> 4 [PE1.2] times pop\n", - " 14 6 925 . 2 >> 4 [PE1.2] times pop\n", - " 14 6 925 2 . >> 4 [PE1.2] times pop\n", - " 14 6 231 . 4 [PE1.2] times pop\n", - " 14 6 231 4 . [PE1.2] times pop\n", - " 14 6 231 4 [PE1.2] . times pop\n", - " 14 6 231 [PE1.2] . i 3 [PE1.2] times pop\n", - " 14 6 231 . PE1.2 3 [PE1.2] times pop\n", - " 14 6 231 . [3 & PE1.1] dupdip 2 >> 3 [PE1.2] times pop\n", - " 14 6 231 [3 & PE1.1] . dupdip 2 >> 3 [PE1.2] times pop\n", - " 14 6 231 . 3 & PE1.1 231 2 >> 3 [PE1.2] times pop\n", - " 14 6 231 3 . & PE1.1 231 2 >> 3 [PE1.2] times pop\n", - " 14 6 3 . PE1.1 231 2 >> 3 [PE1.2] times pop\n", - " 14 6 3 . + [+] dupdip 231 2 >> 3 [PE1.2] times pop\n", - " 14 9 . [+] dupdip 231 2 >> 3 [PE1.2] times pop\n", - " 14 9 [+] . dupdip 231 2 >> 3 [PE1.2] times pop\n", - " 14 9 . + 9 231 2 >> 3 [PE1.2] times pop\n", - " 23 . 9 231 2 >> 3 [PE1.2] times pop\n", - " 23 9 . 231 2 >> 3 [PE1.2] times pop\n", - " 23 9 231 . 2 >> 3 [PE1.2] times pop\n", - " 23 9 231 2 . >> 3 [PE1.2] times pop\n", - " 23 9 57 . 3 [PE1.2] times pop\n", - " 23 9 57 3 . [PE1.2] times pop\n", - " 23 9 57 3 [PE1.2] . times pop\n", - " 23 9 57 [PE1.2] . i 2 [PE1.2] times pop\n", - " 23 9 57 . PE1.2 2 [PE1.2] times pop\n", - " 23 9 57 . [3 & PE1.1] dupdip 2 >> 2 [PE1.2] times pop\n", - " 23 9 57 [3 & PE1.1] . dupdip 2 >> 2 [PE1.2] times pop\n", - " 23 9 57 . 3 & PE1.1 57 2 >> 2 [PE1.2] times pop\n", - " 23 9 57 3 . & PE1.1 57 2 >> 2 [PE1.2] times pop\n", - " 23 9 1 . PE1.1 57 2 >> 2 [PE1.2] times pop\n", - " 23 9 1 . + [+] dupdip 57 2 >> 2 [PE1.2] times pop\n", - " 23 10 . [+] dupdip 57 2 >> 2 [PE1.2] times pop\n", - " 23 10 [+] . dupdip 57 2 >> 2 [PE1.2] times pop\n", - " 23 10 . + 10 57 2 >> 2 [PE1.2] times pop\n", - " 33 . 10 57 2 >> 2 [PE1.2] times pop\n", - " 33 10 . 57 2 >> 2 [PE1.2] times pop\n", - " 33 10 57 . 2 >> 2 [PE1.2] times pop\n", - " 33 10 57 2 . >> 2 [PE1.2] times pop\n", - " 33 10 14 . 2 [PE1.2] times pop\n", - " 33 10 14 2 . [PE1.2] times pop\n", - " 33 10 14 2 [PE1.2] . times pop\n", - " 33 10 14 [PE1.2] . i 1 [PE1.2] times pop\n", - " 33 10 14 . PE1.2 1 [PE1.2] times pop\n", - " 33 10 14 . [3 & PE1.1] dupdip 2 >> 1 [PE1.2] times pop\n", - " 33 10 14 [3 & PE1.1] . dupdip 2 >> 1 [PE1.2] times pop\n", - " 33 10 14 . 3 & PE1.1 14 2 >> 1 [PE1.2] times pop\n", - " 33 10 14 3 . & PE1.1 14 2 >> 1 [PE1.2] times pop\n", - " 33 10 2 . PE1.1 14 2 >> 1 [PE1.2] times pop\n", - " 33 10 2 . + [+] dupdip 14 2 >> 1 [PE1.2] times pop\n", - " 33 12 . [+] dupdip 14 2 >> 1 [PE1.2] times pop\n", - " 33 12 [+] . dupdip 14 2 >> 1 [PE1.2] times pop\n", - " 33 12 . + 12 14 2 >> 1 [PE1.2] times pop\n", - " 45 . 12 14 2 >> 1 [PE1.2] times pop\n", - " 45 12 . 14 2 >> 1 [PE1.2] times pop\n", - " 45 12 14 . 2 >> 1 [PE1.2] times pop\n", - " 45 12 14 2 . >> 1 [PE1.2] times pop\n", - " 45 12 3 . 1 [PE1.2] times pop\n", - " 45 12 3 1 . [PE1.2] times pop\n", - " 45 12 3 1 [PE1.2] . times pop\n", - " 45 12 3 [PE1.2] . i pop\n", - " 45 12 3 . PE1.2 pop\n", - " 45 12 3 . [3 & PE1.1] dupdip 2 >> pop\n", - " 45 12 3 [3 & PE1.1] . dupdip 2 >> pop\n", - " 45 12 3 . 3 & PE1.1 3 2 >> pop\n", - " 45 12 3 3 . & PE1.1 3 2 >> pop\n", - " 45 12 3 . PE1.1 3 2 >> pop\n", - " 45 12 3 . + [+] dupdip 3 2 >> pop\n", - " 45 15 . [+] dupdip 3 2 >> pop\n", - " 45 15 [+] . dupdip 3 2 >> pop\n", - " 45 15 . + 15 3 2 >> pop\n", - " 60 . 15 3 2 >> pop\n", - " 60 15 . 3 2 >> pop\n", - " 60 15 3 . 2 >> pop\n", - " 60 15 3 2 . >> pop\n", - " 60 15 0 . pop\n", - " 60 15 . \n" - ] - } - ], - "source": [ - "V('0 0 14811 7 [PE1.2] times pop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And so we have at last:" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop')" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "233168\n" - ] - } - ], - "source": [ - "J('PE1')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's refactor.\n", - "\n", - " 14811 7 [PE1.2] times pop\n", - " 14811 4 [PE1.2] times pop\n", - " 14811 n [PE1.2] times pop\n", - " n 14811 swap [PE1.2] times pop" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1.3 == 14811 swap [PE1.2] times pop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can simplify the definition above:" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop')" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "233168\n" - ] - } - ], - "source": [ - "J('PE1')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's our joy program all in one place. It doesn't make so much sense, but if you have read through the above description of how it was derived I hope it's clear.\n", - "\n", - " PE1.1 == + [+] dupdip\n", - " PE1.2 == [3 & PE1.1] dupdip 2 >>\n", - " PE1.3 == 14811 swap [PE1.2] times pop\n", - " PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Generator Version\n", - "It's a little clunky iterating sixty-six times though the seven numbers then four more. In the _Generator Programs_ notebook we derive a generator that can be repeatedly driven by the `x` combinator to produce a stream of the seven numbers repeating over and over again." - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]')" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]\n" - ] - } - ], - "source": [ - "J('PE1.terms 21 [x] times')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We know from above that we need sixty-six times seven then four more terms to reach up to but not over one thousand." - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "466\n" - ] - } - ], - "source": [ - "J('7 66 * 4 +')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Here they are..." - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3\n" - ] - } - ], - "source": [ - "J('PE1.terms 466 [x] times pop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### ...and they do sum to 999." - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "999\n" - ] - } - ], - "source": [ - "J('[PE1.terms 466 [x] times pop] run sum')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can use `PE1.1` to accumulate the terms as we go, and then `pop` the generator and the counter from the stack when we're done, leaving just the sum." - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "233168\n" - ] - } - ], - "source": [ - "J('0 0 PE1.terms 466 [x [PE1.1] dip] times popop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A little further analysis renders iteration unnecessary.\n", - "Consider finding the sum of the positive integers less than or equal to ten." - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "55\n" - ] - } - ], - "source": [ - "J('[10 9 8 7 6 5 4 3 2 1] sum')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Instead of summing them, [observe](https://en.wikipedia.org/wiki/File:Animated_proof_for_the_formula_giving_the_sum_of_the_first_integers_1%2B2%2B...%2Bn.gif):\n", - "\n", - " 10 9 8 7 6\n", - " + 1 2 3 4 5\n", - " ---- -- -- -- --\n", - " 11 11 11 11 11\n", - " \n", - " 11 * 5 = 55\n", - "\n", - "From the above example we can deduce that the sum of the first N positive integers is:\n", - "\n", - " (N + 1) * N / 2 \n", - "\n", - "(The formula also works for odd values of N, I'll leave that to you if you want to work it out or you can take my word for it.)" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [], - "source": [ - "define('F == dup ++ * 2 floordiv')" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 10 F\n", - " 10 . F\n", - " 10 . dup ++ * 2 floordiv\n", - "10 10 . ++ * 2 floordiv\n", - "10 11 . * 2 floordiv\n", - " 110 . 2 floordiv\n", - "110 2 . floordiv\n", - " 55 . \n" - ] - } - ], - "source": [ - "V('10 F')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Generalizing to Blocks of Terms\n", - "We can apply the same reasoning to the PE1 problem.\n", - "\n", - "Between 0 and 990 inclusive there are sixty-six \"blocks\" of seven terms each, starting with:\n", - "\n", - " [3 5 6 9 10 12 15]\n", - " \n", - "And ending with:\n", - "\n", - " [978 980 981 984 985 987 990]\n", - " \n", - "If we reverse one of these two blocks and sum pairs..." - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[978 15] [980 12] [981 10] [984 9] [985 6] [987 5] [990 3]]\n" - ] - } - ], - "source": [ - "J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip')" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[993 992 991 993 991 992 993]\n" - ] - } - ], - "source": [ - "J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "(Interesting that the sequence of seven numbers appears again in the rightmost digit of each term.)" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6945\n" - ] - } - ], - "source": [ - "J('[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Since there are sixty-six blocks and we are pairing them up, there must be thirty-three pairs, each of which sums to 6945. We also have these additional unpaired terms between 990 and 1000:\n", - "\n", - " 993 995 996 999\n", - " \n", - "So we can give the \"sum of all the multiples of 3 or 5 below 1000\" like so:" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "233168\n" - ] - } - ], - "source": [ - "J('6945 33 * [993 995 996 999] cons sum')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It's worth noting, I think, that this same reasoning holds for any two numbers $n$ and $m$ the multiples of which we hope to sum. The multiples would have a cycle of differences of length $k$ and so we could compute the sum of $Nk$ multiples as above.\n", - "\n", - "The sequence of differences will always be a palidrome. Consider an interval spanning the least common multiple of $n$ and $m$:\n", - "\n", - " | | | | | | | |\n", - " | | | | |\n", - " \n", - "Here we have 4 and 7, and you can read off the sequence of differences directly from the diagram: 4 3 1 4 2 2 4 1 3 4.\n", - " \n", - "Geometrically, the actual values of $n$ and $m$ and their *lcm* don't matter, the pattern they make will always be symmetrical around its midpoint. The same reasoning holds for multiples of more than two numbers." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# The Simplest Program" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Of course, the simplest joy program for the first Project Euler problem is just:\n", - "\n", - " PE1 == 233168\n", - "\n", - "Fin." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/3. Developing a Program.md b/docs/3. Developing a Program.md deleted file mode 100644 index f68f30a..0000000 --- a/docs/3. Developing a Program.md +++ /dev/null @@ -1,694 +0,0 @@ - -# [Project Euler, first problem: "Multiples of 3 and 5"](https://projecteuler.net/problem=1) - - If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. - - Find the sum of all the multiples of 3 or 5 below 1000. - - -```python -from notebook_preamble import J, V, define -``` - -Let's create a predicate that returns `True` if a number is a multiple of 3 or 5 and `False` otherwise. - - -```python -define('P == [3 % not] dupdip 5 % not or') -``` - - -```python -V('80 P') -``` - - . 80 P - 80 . P - 80 . [3 % not] dupdip 5 % not or - 80 [3 % not] . dupdip 5 % not or - 80 . 3 % not 80 5 % not or - 80 3 . % not 80 5 % not or - 2 . not 80 5 % not or - False . 80 5 % not or - False 80 . 5 % not or - False 80 5 . % not or - False 0 . not or - False True . or - True . - - -Given the predicate function `P` a suitable program is: - - PE1 == 1000 range [P] filter sum - -This function generates a list of the integers from 0 to 999, filters -that list by `P`, and then sums the result. - -Logically this is fine, but pragmatically we are doing more work than we -should be; we generate one thousand integers but actually use less than -half of them. A better solution would be to generate just the multiples -we want to sum, and to add them as we go rather than storing them and -adding summing them at the end. - -At first I had the idea to use two counters and increase them by three -and five, respectively. This way we only generate the terms that we -actually want to sum. We have to proceed by incrementing the counter -that is lower, or if they are equal, the three counter, and we have to -take care not to double add numbers like 15 that are multiples of both -three and five. - -This seemed a little clunky, so I tried a different approach. - -Consider the first few terms in the series: - - 3 5 6 9 10 12 15 18 20 21 ... - -Subtract each number from the one after it (subtracting 0 from 3): - - 3 5 6 9 10 12 15 18 20 21 24 25 27 30 ... - 0 3 5 6 9 10 12 15 18 20 21 24 25 27 ... - ------------------------------------------- - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 ... - -You get this lovely repeating palindromic sequence: - - 3 2 1 3 1 2 3 - -To make a counter that increments by factors of 3 and 5 you just add -these differences to the counter one-by-one in a loop. - - -To make use of this sequence to increment a counter and sum terms as we -go we need a function that will accept the sum, the counter, and the next -term to add, and that adds the term to the counter and a copy of the -counter to the running sum. This function will do that: - - PE1.1 == + [+] dupdip - - -```python -define('PE1.1 == + [+] dupdip') -``` - - -```python -V('0 0 3 PE1.1') -``` - - . 0 0 3 PE1.1 - 0 . 0 3 PE1.1 - 0 0 . 3 PE1.1 - 0 0 3 . PE1.1 - 0 0 3 . + [+] dupdip - 0 3 . [+] dupdip - 0 3 [+] . dupdip - 0 3 . + 3 - 3 . 3 - 3 3 . - - - -```python -V('0 0 [3 2 1 3 1 2 3] [PE1.1] step') -``` - - . 0 0 [3 2 1 3 1 2 3] [PE1.1] step - 0 . 0 [3 2 1 3 1 2 3] [PE1.1] step - 0 0 . [3 2 1 3 1 2 3] [PE1.1] step - 0 0 [3 2 1 3 1 2 3] . [PE1.1] step - 0 0 [3 2 1 3 1 2 3] [PE1.1] . step - 0 0 3 [PE1.1] . i [2 1 3 1 2 3] [PE1.1] step - 0 0 3 . PE1.1 [2 1 3 1 2 3] [PE1.1] step - 0 0 3 . + [+] dupdip [2 1 3 1 2 3] [PE1.1] step - 0 3 . [+] dupdip [2 1 3 1 2 3] [PE1.1] step - 0 3 [+] . dupdip [2 1 3 1 2 3] [PE1.1] step - 0 3 . + 3 [2 1 3 1 2 3] [PE1.1] step - 3 . 3 [2 1 3 1 2 3] [PE1.1] step - 3 3 . [2 1 3 1 2 3] [PE1.1] step - 3 3 [2 1 3 1 2 3] . [PE1.1] step - 3 3 [2 1 3 1 2 3] [PE1.1] . step - 3 3 2 [PE1.1] . i [1 3 1 2 3] [PE1.1] step - 3 3 2 . PE1.1 [1 3 1 2 3] [PE1.1] step - 3 3 2 . + [+] dupdip [1 3 1 2 3] [PE1.1] step - 3 5 . [+] dupdip [1 3 1 2 3] [PE1.1] step - 3 5 [+] . dupdip [1 3 1 2 3] [PE1.1] step - 3 5 . + 5 [1 3 1 2 3] [PE1.1] step - 8 . 5 [1 3 1 2 3] [PE1.1] step - 8 5 . [1 3 1 2 3] [PE1.1] step - 8 5 [1 3 1 2 3] . [PE1.1] step - 8 5 [1 3 1 2 3] [PE1.1] . step - 8 5 1 [PE1.1] . i [3 1 2 3] [PE1.1] step - 8 5 1 . PE1.1 [3 1 2 3] [PE1.1] step - 8 5 1 . + [+] dupdip [3 1 2 3] [PE1.1] step - 8 6 . [+] dupdip [3 1 2 3] [PE1.1] step - 8 6 [+] . dupdip [3 1 2 3] [PE1.1] step - 8 6 . + 6 [3 1 2 3] [PE1.1] step - 14 . 6 [3 1 2 3] [PE1.1] step - 14 6 . [3 1 2 3] [PE1.1] step - 14 6 [3 1 2 3] . [PE1.1] step - 14 6 [3 1 2 3] [PE1.1] . step - 14 6 3 [PE1.1] . i [1 2 3] [PE1.1] step - 14 6 3 . PE1.1 [1 2 3] [PE1.1] step - 14 6 3 . + [+] dupdip [1 2 3] [PE1.1] step - 14 9 . [+] dupdip [1 2 3] [PE1.1] step - 14 9 [+] . dupdip [1 2 3] [PE1.1] step - 14 9 . + 9 [1 2 3] [PE1.1] step - 23 . 9 [1 2 3] [PE1.1] step - 23 9 . [1 2 3] [PE1.1] step - 23 9 [1 2 3] . [PE1.1] step - 23 9 [1 2 3] [PE1.1] . step - 23 9 1 [PE1.1] . i [2 3] [PE1.1] step - 23 9 1 . PE1.1 [2 3] [PE1.1] step - 23 9 1 . + [+] dupdip [2 3] [PE1.1] step - 23 10 . [+] dupdip [2 3] [PE1.1] step - 23 10 [+] . dupdip [2 3] [PE1.1] step - 23 10 . + 10 [2 3] [PE1.1] step - 33 . 10 [2 3] [PE1.1] step - 33 10 . [2 3] [PE1.1] step - 33 10 [2 3] . [PE1.1] step - 33 10 [2 3] [PE1.1] . step - 33 10 2 [PE1.1] . i [3] [PE1.1] step - 33 10 2 . PE1.1 [3] [PE1.1] step - 33 10 2 . + [+] dupdip [3] [PE1.1] step - 33 12 . [+] dupdip [3] [PE1.1] step - 33 12 [+] . dupdip [3] [PE1.1] step - 33 12 . + 12 [3] [PE1.1] step - 45 . 12 [3] [PE1.1] step - 45 12 . [3] [PE1.1] step - 45 12 [3] . [PE1.1] step - 45 12 [3] [PE1.1] . step - 45 12 3 [PE1.1] . i - 45 12 3 . PE1.1 - 45 12 3 . + [+] dupdip - 45 15 . [+] dupdip - 45 15 [+] . dupdip - 45 15 . + 15 - 60 . 15 - 60 15 . - - -So one `step` through all seven terms brings the counter to 15 and the total to 60. - - -```python -1000 / 15 -``` - - - - - 66 - - - - -```python -66 * 15 -``` - - - - - 990 - - - - -```python -1000 - 990 -``` - - - - - 10 - - - -We only want the terms *less than* 1000. - - -```python -999 - 990 -``` - - - - - 9 - - - -That means we want to run the full list of numbers sixty-six times to get to 990 and then the first four numbers 3 2 1 3 to get to 999. - - -```python -define('PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop') -``` - - -```python -J('PE1') -``` - - 233168 - - -This form uses no extra storage and produces no unused summands. It's -good but there's one more trick we can apply. The list of seven terms -takes up at least seven bytes. But notice that all of the terms are less -than four, and so each can fit in just two bits. We could store all -seven terms in just fourteen bits and use masking and shifts to pick out -each term as we go. This will use less space and save time loading whole -integer terms from the list. - - 3 2 1 3 1 2 3 - 0b 11 10 01 11 01 10 11 == 14811 - - -```python -0b11100111011011 -``` - - - - - 14811 - - - - -```python -define('PE1.2 == [3 & PE1.1] dupdip 2 >>') -``` - - -```python -V('0 0 14811 PE1.2') -``` - - . 0 0 14811 PE1.2 - 0 . 0 14811 PE1.2 - 0 0 . 14811 PE1.2 - 0 0 14811 . PE1.2 - 0 0 14811 . [3 & PE1.1] dupdip 2 >> - 0 0 14811 [3 & PE1.1] . dupdip 2 >> - 0 0 14811 . 3 & PE1.1 14811 2 >> - 0 0 14811 3 . & PE1.1 14811 2 >> - 0 0 3 . PE1.1 14811 2 >> - 0 0 3 . + [+] dupdip 14811 2 >> - 0 3 . [+] dupdip 14811 2 >> - 0 3 [+] . dupdip 14811 2 >> - 0 3 . + 3 14811 2 >> - 3 . 3 14811 2 >> - 3 3 . 14811 2 >> - 3 3 14811 . 2 >> - 3 3 14811 2 . >> - 3 3 3702 . - - - -```python -V('3 3 3702 PE1.2') -``` - - . 3 3 3702 PE1.2 - 3 . 3 3702 PE1.2 - 3 3 . 3702 PE1.2 - 3 3 3702 . PE1.2 - 3 3 3702 . [3 & PE1.1] dupdip 2 >> - 3 3 3702 [3 & PE1.1] . dupdip 2 >> - 3 3 3702 . 3 & PE1.1 3702 2 >> - 3 3 3702 3 . & PE1.1 3702 2 >> - 3 3 2 . PE1.1 3702 2 >> - 3 3 2 . + [+] dupdip 3702 2 >> - 3 5 . [+] dupdip 3702 2 >> - 3 5 [+] . dupdip 3702 2 >> - 3 5 . + 5 3702 2 >> - 8 . 5 3702 2 >> - 8 5 . 3702 2 >> - 8 5 3702 . 2 >> - 8 5 3702 2 . >> - 8 5 925 . - - - -```python -V('0 0 14811 7 [PE1.2] times pop') -``` - - . 0 0 14811 7 [PE1.2] times pop - 0 . 0 14811 7 [PE1.2] times pop - 0 0 . 14811 7 [PE1.2] times pop - 0 0 14811 . 7 [PE1.2] times pop - 0 0 14811 7 . [PE1.2] times pop - 0 0 14811 7 [PE1.2] . times pop - 0 0 14811 [PE1.2] . i 6 [PE1.2] times pop - 0 0 14811 . PE1.2 6 [PE1.2] times pop - 0 0 14811 . [3 & PE1.1] dupdip 2 >> 6 [PE1.2] times pop - 0 0 14811 [3 & PE1.1] . dupdip 2 >> 6 [PE1.2] times pop - 0 0 14811 . 3 & PE1.1 14811 2 >> 6 [PE1.2] times pop - 0 0 14811 3 . & PE1.1 14811 2 >> 6 [PE1.2] times pop - 0 0 3 . PE1.1 14811 2 >> 6 [PE1.2] times pop - 0 0 3 . + [+] dupdip 14811 2 >> 6 [PE1.2] times pop - 0 3 . [+] dupdip 14811 2 >> 6 [PE1.2] times pop - 0 3 [+] . dupdip 14811 2 >> 6 [PE1.2] times pop - 0 3 . + 3 14811 2 >> 6 [PE1.2] times pop - 3 . 3 14811 2 >> 6 [PE1.2] times pop - 3 3 . 14811 2 >> 6 [PE1.2] times pop - 3 3 14811 . 2 >> 6 [PE1.2] times pop - 3 3 14811 2 . >> 6 [PE1.2] times pop - 3 3 3702 . 6 [PE1.2] times pop - 3 3 3702 6 . [PE1.2] times pop - 3 3 3702 6 [PE1.2] . times pop - 3 3 3702 [PE1.2] . i 5 [PE1.2] times pop - 3 3 3702 . PE1.2 5 [PE1.2] times pop - 3 3 3702 . [3 & PE1.1] dupdip 2 >> 5 [PE1.2] times pop - 3 3 3702 [3 & PE1.1] . dupdip 2 >> 5 [PE1.2] times pop - 3 3 3702 . 3 & PE1.1 3702 2 >> 5 [PE1.2] times pop - 3 3 3702 3 . & PE1.1 3702 2 >> 5 [PE1.2] times pop - 3 3 2 . PE1.1 3702 2 >> 5 [PE1.2] times pop - 3 3 2 . + [+] dupdip 3702 2 >> 5 [PE1.2] times pop - 3 5 . [+] dupdip 3702 2 >> 5 [PE1.2] times pop - 3 5 [+] . dupdip 3702 2 >> 5 [PE1.2] times pop - 3 5 . + 5 3702 2 >> 5 [PE1.2] times pop - 8 . 5 3702 2 >> 5 [PE1.2] times pop - 8 5 . 3702 2 >> 5 [PE1.2] times pop - 8 5 3702 . 2 >> 5 [PE1.2] times pop - 8 5 3702 2 . >> 5 [PE1.2] times pop - 8 5 925 . 5 [PE1.2] times pop - 8 5 925 5 . [PE1.2] times pop - 8 5 925 5 [PE1.2] . times pop - 8 5 925 [PE1.2] . i 4 [PE1.2] times pop - 8 5 925 . PE1.2 4 [PE1.2] times pop - 8 5 925 . [3 & PE1.1] dupdip 2 >> 4 [PE1.2] times pop - 8 5 925 [3 & PE1.1] . dupdip 2 >> 4 [PE1.2] times pop - 8 5 925 . 3 & PE1.1 925 2 >> 4 [PE1.2] times pop - 8 5 925 3 . & PE1.1 925 2 >> 4 [PE1.2] times pop - 8 5 1 . PE1.1 925 2 >> 4 [PE1.2] times pop - 8 5 1 . + [+] dupdip 925 2 >> 4 [PE1.2] times pop - 8 6 . [+] dupdip 925 2 >> 4 [PE1.2] times pop - 8 6 [+] . dupdip 925 2 >> 4 [PE1.2] times pop - 8 6 . + 6 925 2 >> 4 [PE1.2] times pop - 14 . 6 925 2 >> 4 [PE1.2] times pop - 14 6 . 925 2 >> 4 [PE1.2] times pop - 14 6 925 . 2 >> 4 [PE1.2] times pop - 14 6 925 2 . >> 4 [PE1.2] times pop - 14 6 231 . 4 [PE1.2] times pop - 14 6 231 4 . [PE1.2] times pop - 14 6 231 4 [PE1.2] . times pop - 14 6 231 [PE1.2] . i 3 [PE1.2] times pop - 14 6 231 . PE1.2 3 [PE1.2] times pop - 14 6 231 . [3 & PE1.1] dupdip 2 >> 3 [PE1.2] times pop - 14 6 231 [3 & PE1.1] . dupdip 2 >> 3 [PE1.2] times pop - 14 6 231 . 3 & PE1.1 231 2 >> 3 [PE1.2] times pop - 14 6 231 3 . & PE1.1 231 2 >> 3 [PE1.2] times pop - 14 6 3 . PE1.1 231 2 >> 3 [PE1.2] times pop - 14 6 3 . + [+] dupdip 231 2 >> 3 [PE1.2] times pop - 14 9 . [+] dupdip 231 2 >> 3 [PE1.2] times pop - 14 9 [+] . dupdip 231 2 >> 3 [PE1.2] times pop - 14 9 . + 9 231 2 >> 3 [PE1.2] times pop - 23 . 9 231 2 >> 3 [PE1.2] times pop - 23 9 . 231 2 >> 3 [PE1.2] times pop - 23 9 231 . 2 >> 3 [PE1.2] times pop - 23 9 231 2 . >> 3 [PE1.2] times pop - 23 9 57 . 3 [PE1.2] times pop - 23 9 57 3 . [PE1.2] times pop - 23 9 57 3 [PE1.2] . times pop - 23 9 57 [PE1.2] . i 2 [PE1.2] times pop - 23 9 57 . PE1.2 2 [PE1.2] times pop - 23 9 57 . [3 & PE1.1] dupdip 2 >> 2 [PE1.2] times pop - 23 9 57 [3 & PE1.1] . dupdip 2 >> 2 [PE1.2] times pop - 23 9 57 . 3 & PE1.1 57 2 >> 2 [PE1.2] times pop - 23 9 57 3 . & PE1.1 57 2 >> 2 [PE1.2] times pop - 23 9 1 . PE1.1 57 2 >> 2 [PE1.2] times pop - 23 9 1 . + [+] dupdip 57 2 >> 2 [PE1.2] times pop - 23 10 . [+] dupdip 57 2 >> 2 [PE1.2] times pop - 23 10 [+] . dupdip 57 2 >> 2 [PE1.2] times pop - 23 10 . + 10 57 2 >> 2 [PE1.2] times pop - 33 . 10 57 2 >> 2 [PE1.2] times pop - 33 10 . 57 2 >> 2 [PE1.2] times pop - 33 10 57 . 2 >> 2 [PE1.2] times pop - 33 10 57 2 . >> 2 [PE1.2] times pop - 33 10 14 . 2 [PE1.2] times pop - 33 10 14 2 . [PE1.2] times pop - 33 10 14 2 [PE1.2] . times pop - 33 10 14 [PE1.2] . i 1 [PE1.2] times pop - 33 10 14 . PE1.2 1 [PE1.2] times pop - 33 10 14 . [3 & PE1.1] dupdip 2 >> 1 [PE1.2] times pop - 33 10 14 [3 & PE1.1] . dupdip 2 >> 1 [PE1.2] times pop - 33 10 14 . 3 & PE1.1 14 2 >> 1 [PE1.2] times pop - 33 10 14 3 . & PE1.1 14 2 >> 1 [PE1.2] times pop - 33 10 2 . PE1.1 14 2 >> 1 [PE1.2] times pop - 33 10 2 . + [+] dupdip 14 2 >> 1 [PE1.2] times pop - 33 12 . [+] dupdip 14 2 >> 1 [PE1.2] times pop - 33 12 [+] . dupdip 14 2 >> 1 [PE1.2] times pop - 33 12 . + 12 14 2 >> 1 [PE1.2] times pop - 45 . 12 14 2 >> 1 [PE1.2] times pop - 45 12 . 14 2 >> 1 [PE1.2] times pop - 45 12 14 . 2 >> 1 [PE1.2] times pop - 45 12 14 2 . >> 1 [PE1.2] times pop - 45 12 3 . 1 [PE1.2] times pop - 45 12 3 1 . [PE1.2] times pop - 45 12 3 1 [PE1.2] . times pop - 45 12 3 [PE1.2] . i pop - 45 12 3 . PE1.2 pop - 45 12 3 . [3 & PE1.1] dupdip 2 >> pop - 45 12 3 [3 & PE1.1] . dupdip 2 >> pop - 45 12 3 . 3 & PE1.1 3 2 >> pop - 45 12 3 3 . & PE1.1 3 2 >> pop - 45 12 3 . PE1.1 3 2 >> pop - 45 12 3 . + [+] dupdip 3 2 >> pop - 45 15 . [+] dupdip 3 2 >> pop - 45 15 [+] . dupdip 3 2 >> pop - 45 15 . + 15 3 2 >> pop - 60 . 15 3 2 >> pop - 60 15 . 3 2 >> pop - 60 15 3 . 2 >> pop - 60 15 3 2 . >> pop - 60 15 0 . pop - 60 15 . - - -And so we have at last: - - -```python -define('PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop') -``` - - -```python -J('PE1') -``` - - 233168 - - -Let's refactor. - - 14811 7 [PE1.2] times pop - 14811 4 [PE1.2] times pop - 14811 n [PE1.2] times pop - n 14811 swap [PE1.2] times pop - - -```python -define('PE1.3 == 14811 swap [PE1.2] times pop') -``` - -Now we can simplify the definition above: - - -```python -define('PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop') -``` - - -```python -J('PE1') -``` - - 233168 - - -Here's our joy program all in one place. It doesn't make so much sense, but if you have read through the above description of how it was derived I hope it's clear. - - PE1.1 == + [+] dupdip - PE1.2 == [3 & PE1.1] dupdip 2 >> - PE1.3 == 14811 swap [PE1.2] times pop - PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop - -# Generator Version -It's a little clunky iterating sixty-six times though the seven numbers then four more. In the _Generator Programs_ notebook we derive a generator that can be repeatedly driven by the `x` combinator to produce a stream of the seven numbers repeating over and over again. - - -```python -define('PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]') -``` - - -```python -J('PE1.terms 21 [x] times') -``` - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons] - - -We know from above that we need sixty-six times seven then four more terms to reach up to but not over one thousand. - - -```python -J('7 66 * 4 +') -``` - - 466 - - -### Here they are... - - -```python -J('PE1.terms 466 [x] times pop') -``` - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 - - -### ...and they do sum to 999. - - -```python -J('[PE1.terms 466 [x] times pop] run sum') -``` - - 999 - - -Now we can use `PE1.1` to accumulate the terms as we go, and then `pop` the generator and the counter from the stack when we're done, leaving just the sum. - - -```python -J('0 0 PE1.terms 466 [x [PE1.1] dip] times popop') -``` - - 233168 - - -# A little further analysis renders iteration unnecessary. -Consider finding the sum of the positive integers less than or equal to ten. - - -```python -J('[10 9 8 7 6 5 4 3 2 1] sum') -``` - - 55 - - -Instead of summing them, [observe](https://en.wikipedia.org/wiki/File:Animated_proof_for_the_formula_giving_the_sum_of_the_first_integers_1%2B2%2B...%2Bn.gif): - - 10 9 8 7 6 - + 1 2 3 4 5 - ---- -- -- -- -- - 11 11 11 11 11 - - 11 * 5 = 55 - -From the above example we can deduce that the sum of the first N positive integers is: - - (N + 1) * N / 2 - -(The formula also works for odd values of N, I'll leave that to you if you want to work it out or you can take my word for it.) - - -```python -define('F == dup ++ * 2 floordiv') -``` - - -```python -V('10 F') -``` - - . 10 F - 10 . F - 10 . dup ++ * 2 floordiv - 10 10 . ++ * 2 floordiv - 10 11 . * 2 floordiv - 110 . 2 floordiv - 110 2 . floordiv - 55 . - - -## Generalizing to Blocks of Terms -We can apply the same reasoning to the PE1 problem. - -Between 0 and 990 inclusive there are sixty-six "blocks" of seven terms each, starting with: - - [3 5 6 9 10 12 15] - -And ending with: - - [978 980 981 984 985 987 990] - -If we reverse one of these two blocks and sum pairs... - - -```python -J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip') -``` - - [[978 15] [980 12] [981 10] [984 9] [985 6] [987 5] [990 3]] - - - -```python -J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map') -``` - - [993 992 991 993 991 992 993] - - -(Interesting that the sequence of seven numbers appears again in the rightmost digit of each term.) - - -```python -J('[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum') -``` - - 6945 - - -Since there are sixty-six blocks and we are pairing them up, there must be thirty-three pairs, each of which sums to 6945. We also have these additional unpaired terms between 990 and 1000: - - 993 995 996 999 - -So we can give the "sum of all the multiples of 3 or 5 below 1000" like so: - - -```python -J('6945 33 * [993 995 996 999] cons sum') -``` - - 233168 - - -It's worth noting, I think, that this same reasoning holds for any two numbers $n$ and $m$ the multiples of which we hope to sum. The multiples would have a cycle of differences of length $k$ and so we could compute the sum of $Nk$ multiples as above. - -The sequence of differences will always be a palidrome. Consider an interval spanning the least common multiple of $n$ and $m$: - - | | | | | | | | - | | | | | - -Here we have 4 and 7, and you can read off the sequence of differences directly from the diagram: 4 3 1 4 2 2 4 1 3 4. - -Geometrically, the actual values of $n$ and $m$ and their *lcm* don't matter, the pattern they make will always be symmetrical around its midpoint. The same reasoning holds for multiples of more than two numbers. - -# The Simplest Program - -Of course, the simplest joy program for the first Project Euler problem is just: - - PE1 == 233168 - -Fin. diff --git a/docs/3. Developing a Program.rst b/docs/3. Developing a Program.rst deleted file mode 100644 index 29da686..0000000 --- a/docs/3. Developing a Program.rst +++ /dev/null @@ -1,799 +0,0 @@ - -`Project Euler, first problem: "Multiples of 3 and 5" `__ -============================================================================================= - -:: - - If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. - - Find the sum of all the multiples of 3 or 5 below 1000. - -.. code:: ipython2 - - from notebook_preamble import J, V, define - -Let's create a predicate that returns ``True`` if a number is a multiple -of 3 or 5 and ``False`` otherwise. - -.. code:: ipython2 - - define('P == [3 % not] dupdip 5 % not or') - -.. code:: ipython2 - - V('80 P') - - -.. parsed-literal:: - - . 80 P - 80 . P - 80 . [3 % not] dupdip 5 % not or - 80 [3 % not] . dupdip 5 % not or - 80 . 3 % not 80 5 % not or - 80 3 . % not 80 5 % not or - 2 . not 80 5 % not or - False . 80 5 % not or - False 80 . 5 % not or - False 80 5 . % not or - False 0 . not or - False True . or - True . - - -Given the predicate function ``P`` a suitable program is: - -:: - - PE1 == 1000 range [P] filter sum - -This function generates a list of the integers from 0 to 999, filters -that list by ``P``, and then sums the result. - -Logically this is fine, but pragmatically we are doing more work than we -should be; we generate one thousand integers but actually use less than -half of them. A better solution would be to generate just the multiples -we want to sum, and to add them as we go rather than storing them and -adding summing them at the end. - -At first I had the idea to use two counters and increase them by three -and five, respectively. This way we only generate the terms that we -actually want to sum. We have to proceed by incrementing the counter -that is lower, or if they are equal, the three counter, and we have to -take care not to double add numbers like 15 that are multiples of both -three and five. - -This seemed a little clunky, so I tried a different approach. - -Consider the first few terms in the series: - -:: - - 3 5 6 9 10 12 15 18 20 21 ... - -Subtract each number from the one after it (subtracting 0 from 3): - -:: - - 3 5 6 9 10 12 15 18 20 21 24 25 27 30 ... - 0 3 5 6 9 10 12 15 18 20 21 24 25 27 ... - ------------------------------------------- - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 ... - -You get this lovely repeating palindromic sequence: - -:: - - 3 2 1 3 1 2 3 - -To make a counter that increments by factors of 3 and 5 you just add -these differences to the counter one-by-one in a loop. - -To make use of this sequence to increment a counter and sum terms as we -go we need a function that will accept the sum, the counter, and the -next term to add, and that adds the term to the counter and a copy of -the counter to the running sum. This function will do that: - -:: - - PE1.1 == + [+] dupdip - -.. code:: ipython2 - - define('PE1.1 == + [+] dupdip') - -.. code:: ipython2 - - V('0 0 3 PE1.1') - - -.. parsed-literal:: - - . 0 0 3 PE1.1 - 0 . 0 3 PE1.1 - 0 0 . 3 PE1.1 - 0 0 3 . PE1.1 - 0 0 3 . + [+] dupdip - 0 3 . [+] dupdip - 0 3 [+] . dupdip - 0 3 . + 3 - 3 . 3 - 3 3 . - - -.. code:: ipython2 - - V('0 0 [3 2 1 3 1 2 3] [PE1.1] step') - - -.. parsed-literal:: - - . 0 0 [3 2 1 3 1 2 3] [PE1.1] step - 0 . 0 [3 2 1 3 1 2 3] [PE1.1] step - 0 0 . [3 2 1 3 1 2 3] [PE1.1] step - 0 0 [3 2 1 3 1 2 3] . [PE1.1] step - 0 0 [3 2 1 3 1 2 3] [PE1.1] . step - 0 0 3 [PE1.1] . i [2 1 3 1 2 3] [PE1.1] step - 0 0 3 . PE1.1 [2 1 3 1 2 3] [PE1.1] step - 0 0 3 . + [+] dupdip [2 1 3 1 2 3] [PE1.1] step - 0 3 . [+] dupdip [2 1 3 1 2 3] [PE1.1] step - 0 3 [+] . dupdip [2 1 3 1 2 3] [PE1.1] step - 0 3 . + 3 [2 1 3 1 2 3] [PE1.1] step - 3 . 3 [2 1 3 1 2 3] [PE1.1] step - 3 3 . [2 1 3 1 2 3] [PE1.1] step - 3 3 [2 1 3 1 2 3] . [PE1.1] step - 3 3 [2 1 3 1 2 3] [PE1.1] . step - 3 3 2 [PE1.1] . i [1 3 1 2 3] [PE1.1] step - 3 3 2 . PE1.1 [1 3 1 2 3] [PE1.1] step - 3 3 2 . + [+] dupdip [1 3 1 2 3] [PE1.1] step - 3 5 . [+] dupdip [1 3 1 2 3] [PE1.1] step - 3 5 [+] . dupdip [1 3 1 2 3] [PE1.1] step - 3 5 . + 5 [1 3 1 2 3] [PE1.1] step - 8 . 5 [1 3 1 2 3] [PE1.1] step - 8 5 . [1 3 1 2 3] [PE1.1] step - 8 5 [1 3 1 2 3] . [PE1.1] step - 8 5 [1 3 1 2 3] [PE1.1] . step - 8 5 1 [PE1.1] . i [3 1 2 3] [PE1.1] step - 8 5 1 . PE1.1 [3 1 2 3] [PE1.1] step - 8 5 1 . + [+] dupdip [3 1 2 3] [PE1.1] step - 8 6 . [+] dupdip [3 1 2 3] [PE1.1] step - 8 6 [+] . dupdip [3 1 2 3] [PE1.1] step - 8 6 . + 6 [3 1 2 3] [PE1.1] step - 14 . 6 [3 1 2 3] [PE1.1] step - 14 6 . [3 1 2 3] [PE1.1] step - 14 6 [3 1 2 3] . [PE1.1] step - 14 6 [3 1 2 3] [PE1.1] . step - 14 6 3 [PE1.1] . i [1 2 3] [PE1.1] step - 14 6 3 . PE1.1 [1 2 3] [PE1.1] step - 14 6 3 . + [+] dupdip [1 2 3] [PE1.1] step - 14 9 . [+] dupdip [1 2 3] [PE1.1] step - 14 9 [+] . dupdip [1 2 3] [PE1.1] step - 14 9 . + 9 [1 2 3] [PE1.1] step - 23 . 9 [1 2 3] [PE1.1] step - 23 9 . [1 2 3] [PE1.1] step - 23 9 [1 2 3] . [PE1.1] step - 23 9 [1 2 3] [PE1.1] . step - 23 9 1 [PE1.1] . i [2 3] [PE1.1] step - 23 9 1 . PE1.1 [2 3] [PE1.1] step - 23 9 1 . + [+] dupdip [2 3] [PE1.1] step - 23 10 . [+] dupdip [2 3] [PE1.1] step - 23 10 [+] . dupdip [2 3] [PE1.1] step - 23 10 . + 10 [2 3] [PE1.1] step - 33 . 10 [2 3] [PE1.1] step - 33 10 . [2 3] [PE1.1] step - 33 10 [2 3] . [PE1.1] step - 33 10 [2 3] [PE1.1] . step - 33 10 2 [PE1.1] . i [3] [PE1.1] step - 33 10 2 . PE1.1 [3] [PE1.1] step - 33 10 2 . + [+] dupdip [3] [PE1.1] step - 33 12 . [+] dupdip [3] [PE1.1] step - 33 12 [+] . dupdip [3] [PE1.1] step - 33 12 . + 12 [3] [PE1.1] step - 45 . 12 [3] [PE1.1] step - 45 12 . [3] [PE1.1] step - 45 12 [3] . [PE1.1] step - 45 12 [3] [PE1.1] . step - 45 12 3 [PE1.1] . i - 45 12 3 . PE1.1 - 45 12 3 . + [+] dupdip - 45 15 . [+] dupdip - 45 15 [+] . dupdip - 45 15 . + 15 - 60 . 15 - 60 15 . - - -So one ``step`` through all seven terms brings the counter to 15 and the -total to 60. - -.. code:: ipython2 - - 1000 / 15 - - - - -.. parsed-literal:: - - 66 - - - -.. code:: ipython2 - - 66 * 15 - - - - -.. parsed-literal:: - - 990 - - - -.. code:: ipython2 - - 1000 - 990 - - - - -.. parsed-literal:: - - 10 - - - -We only want the terms *less than* 1000. - -.. code:: ipython2 - - 999 - 990 - - - - -.. parsed-literal:: - - 9 - - - -That means we want to run the full list of numbers sixty-six times to -get to 990 and then the first four numbers 3 2 1 3 to get to 999. - -.. code:: ipython2 - - define('PE1 == 0 0 66 [[3 2 1 3 1 2 3] [PE1.1] step] times [3 2 1 3] [PE1.1] step pop') - -.. code:: ipython2 - - J('PE1') - - -.. parsed-literal:: - - 233168 - - -This form uses no extra storage and produces no unused summands. It's -good but there's one more trick we can apply. The list of seven terms -takes up at least seven bytes. But notice that all of the terms are less -than four, and so each can fit in just two bits. We could store all -seven terms in just fourteen bits and use masking and shifts to pick out -each term as we go. This will use less space and save time loading whole -integer terms from the list. - -:: - - 3 2 1 3 1 2 3 - 0b 11 10 01 11 01 10 11 == 14811 - -.. code:: ipython2 - - 0b11100111011011 - - - - -.. parsed-literal:: - - 14811 - - - -.. code:: ipython2 - - define('PE1.2 == [3 & PE1.1] dupdip 2 >>') - -.. code:: ipython2 - - V('0 0 14811 PE1.2') - - -.. parsed-literal:: - - . 0 0 14811 PE1.2 - 0 . 0 14811 PE1.2 - 0 0 . 14811 PE1.2 - 0 0 14811 . PE1.2 - 0 0 14811 . [3 & PE1.1] dupdip 2 >> - 0 0 14811 [3 & PE1.1] . dupdip 2 >> - 0 0 14811 . 3 & PE1.1 14811 2 >> - 0 0 14811 3 . & PE1.1 14811 2 >> - 0 0 3 . PE1.1 14811 2 >> - 0 0 3 . + [+] dupdip 14811 2 >> - 0 3 . [+] dupdip 14811 2 >> - 0 3 [+] . dupdip 14811 2 >> - 0 3 . + 3 14811 2 >> - 3 . 3 14811 2 >> - 3 3 . 14811 2 >> - 3 3 14811 . 2 >> - 3 3 14811 2 . >> - 3 3 3702 . - - -.. code:: ipython2 - - V('3 3 3702 PE1.2') - - -.. parsed-literal:: - - . 3 3 3702 PE1.2 - 3 . 3 3702 PE1.2 - 3 3 . 3702 PE1.2 - 3 3 3702 . PE1.2 - 3 3 3702 . [3 & PE1.1] dupdip 2 >> - 3 3 3702 [3 & PE1.1] . dupdip 2 >> - 3 3 3702 . 3 & PE1.1 3702 2 >> - 3 3 3702 3 . & PE1.1 3702 2 >> - 3 3 2 . PE1.1 3702 2 >> - 3 3 2 . + [+] dupdip 3702 2 >> - 3 5 . [+] dupdip 3702 2 >> - 3 5 [+] . dupdip 3702 2 >> - 3 5 . + 5 3702 2 >> - 8 . 5 3702 2 >> - 8 5 . 3702 2 >> - 8 5 3702 . 2 >> - 8 5 3702 2 . >> - 8 5 925 . - - -.. code:: ipython2 - - V('0 0 14811 7 [PE1.2] times pop') - - -.. parsed-literal:: - - . 0 0 14811 7 [PE1.2] times pop - 0 . 0 14811 7 [PE1.2] times pop - 0 0 . 14811 7 [PE1.2] times pop - 0 0 14811 . 7 [PE1.2] times pop - 0 0 14811 7 . [PE1.2] times pop - 0 0 14811 7 [PE1.2] . times pop - 0 0 14811 [PE1.2] . i 6 [PE1.2] times pop - 0 0 14811 . PE1.2 6 [PE1.2] times pop - 0 0 14811 . [3 & PE1.1] dupdip 2 >> 6 [PE1.2] times pop - 0 0 14811 [3 & PE1.1] . dupdip 2 >> 6 [PE1.2] times pop - 0 0 14811 . 3 & PE1.1 14811 2 >> 6 [PE1.2] times pop - 0 0 14811 3 . & PE1.1 14811 2 >> 6 [PE1.2] times pop - 0 0 3 . PE1.1 14811 2 >> 6 [PE1.2] times pop - 0 0 3 . + [+] dupdip 14811 2 >> 6 [PE1.2] times pop - 0 3 . [+] dupdip 14811 2 >> 6 [PE1.2] times pop - 0 3 [+] . dupdip 14811 2 >> 6 [PE1.2] times pop - 0 3 . + 3 14811 2 >> 6 [PE1.2] times pop - 3 . 3 14811 2 >> 6 [PE1.2] times pop - 3 3 . 14811 2 >> 6 [PE1.2] times pop - 3 3 14811 . 2 >> 6 [PE1.2] times pop - 3 3 14811 2 . >> 6 [PE1.2] times pop - 3 3 3702 . 6 [PE1.2] times pop - 3 3 3702 6 . [PE1.2] times pop - 3 3 3702 6 [PE1.2] . times pop - 3 3 3702 [PE1.2] . i 5 [PE1.2] times pop - 3 3 3702 . PE1.2 5 [PE1.2] times pop - 3 3 3702 . [3 & PE1.1] dupdip 2 >> 5 [PE1.2] times pop - 3 3 3702 [3 & PE1.1] . dupdip 2 >> 5 [PE1.2] times pop - 3 3 3702 . 3 & PE1.1 3702 2 >> 5 [PE1.2] times pop - 3 3 3702 3 . & PE1.1 3702 2 >> 5 [PE1.2] times pop - 3 3 2 . PE1.1 3702 2 >> 5 [PE1.2] times pop - 3 3 2 . + [+] dupdip 3702 2 >> 5 [PE1.2] times pop - 3 5 . [+] dupdip 3702 2 >> 5 [PE1.2] times pop - 3 5 [+] . dupdip 3702 2 >> 5 [PE1.2] times pop - 3 5 . + 5 3702 2 >> 5 [PE1.2] times pop - 8 . 5 3702 2 >> 5 [PE1.2] times pop - 8 5 . 3702 2 >> 5 [PE1.2] times pop - 8 5 3702 . 2 >> 5 [PE1.2] times pop - 8 5 3702 2 . >> 5 [PE1.2] times pop - 8 5 925 . 5 [PE1.2] times pop - 8 5 925 5 . [PE1.2] times pop - 8 5 925 5 [PE1.2] . times pop - 8 5 925 [PE1.2] . i 4 [PE1.2] times pop - 8 5 925 . PE1.2 4 [PE1.2] times pop - 8 5 925 . [3 & PE1.1] dupdip 2 >> 4 [PE1.2] times pop - 8 5 925 [3 & PE1.1] . dupdip 2 >> 4 [PE1.2] times pop - 8 5 925 . 3 & PE1.1 925 2 >> 4 [PE1.2] times pop - 8 5 925 3 . & PE1.1 925 2 >> 4 [PE1.2] times pop - 8 5 1 . PE1.1 925 2 >> 4 [PE1.2] times pop - 8 5 1 . + [+] dupdip 925 2 >> 4 [PE1.2] times pop - 8 6 . [+] dupdip 925 2 >> 4 [PE1.2] times pop - 8 6 [+] . dupdip 925 2 >> 4 [PE1.2] times pop - 8 6 . + 6 925 2 >> 4 [PE1.2] times pop - 14 . 6 925 2 >> 4 [PE1.2] times pop - 14 6 . 925 2 >> 4 [PE1.2] times pop - 14 6 925 . 2 >> 4 [PE1.2] times pop - 14 6 925 2 . >> 4 [PE1.2] times pop - 14 6 231 . 4 [PE1.2] times pop - 14 6 231 4 . [PE1.2] times pop - 14 6 231 4 [PE1.2] . times pop - 14 6 231 [PE1.2] . i 3 [PE1.2] times pop - 14 6 231 . PE1.2 3 [PE1.2] times pop - 14 6 231 . [3 & PE1.1] dupdip 2 >> 3 [PE1.2] times pop - 14 6 231 [3 & PE1.1] . dupdip 2 >> 3 [PE1.2] times pop - 14 6 231 . 3 & PE1.1 231 2 >> 3 [PE1.2] times pop - 14 6 231 3 . & PE1.1 231 2 >> 3 [PE1.2] times pop - 14 6 3 . PE1.1 231 2 >> 3 [PE1.2] times pop - 14 6 3 . + [+] dupdip 231 2 >> 3 [PE1.2] times pop - 14 9 . [+] dupdip 231 2 >> 3 [PE1.2] times pop - 14 9 [+] . dupdip 231 2 >> 3 [PE1.2] times pop - 14 9 . + 9 231 2 >> 3 [PE1.2] times pop - 23 . 9 231 2 >> 3 [PE1.2] times pop - 23 9 . 231 2 >> 3 [PE1.2] times pop - 23 9 231 . 2 >> 3 [PE1.2] times pop - 23 9 231 2 . >> 3 [PE1.2] times pop - 23 9 57 . 3 [PE1.2] times pop - 23 9 57 3 . [PE1.2] times pop - 23 9 57 3 [PE1.2] . times pop - 23 9 57 [PE1.2] . i 2 [PE1.2] times pop - 23 9 57 . PE1.2 2 [PE1.2] times pop - 23 9 57 . [3 & PE1.1] dupdip 2 >> 2 [PE1.2] times pop - 23 9 57 [3 & PE1.1] . dupdip 2 >> 2 [PE1.2] times pop - 23 9 57 . 3 & PE1.1 57 2 >> 2 [PE1.2] times pop - 23 9 57 3 . & PE1.1 57 2 >> 2 [PE1.2] times pop - 23 9 1 . PE1.1 57 2 >> 2 [PE1.2] times pop - 23 9 1 . + [+] dupdip 57 2 >> 2 [PE1.2] times pop - 23 10 . [+] dupdip 57 2 >> 2 [PE1.2] times pop - 23 10 [+] . dupdip 57 2 >> 2 [PE1.2] times pop - 23 10 . + 10 57 2 >> 2 [PE1.2] times pop - 33 . 10 57 2 >> 2 [PE1.2] times pop - 33 10 . 57 2 >> 2 [PE1.2] times pop - 33 10 57 . 2 >> 2 [PE1.2] times pop - 33 10 57 2 . >> 2 [PE1.2] times pop - 33 10 14 . 2 [PE1.2] times pop - 33 10 14 2 . [PE1.2] times pop - 33 10 14 2 [PE1.2] . times pop - 33 10 14 [PE1.2] . i 1 [PE1.2] times pop - 33 10 14 . PE1.2 1 [PE1.2] times pop - 33 10 14 . [3 & PE1.1] dupdip 2 >> 1 [PE1.2] times pop - 33 10 14 [3 & PE1.1] . dupdip 2 >> 1 [PE1.2] times pop - 33 10 14 . 3 & PE1.1 14 2 >> 1 [PE1.2] times pop - 33 10 14 3 . & PE1.1 14 2 >> 1 [PE1.2] times pop - 33 10 2 . PE1.1 14 2 >> 1 [PE1.2] times pop - 33 10 2 . + [+] dupdip 14 2 >> 1 [PE1.2] times pop - 33 12 . [+] dupdip 14 2 >> 1 [PE1.2] times pop - 33 12 [+] . dupdip 14 2 >> 1 [PE1.2] times pop - 33 12 . + 12 14 2 >> 1 [PE1.2] times pop - 45 . 12 14 2 >> 1 [PE1.2] times pop - 45 12 . 14 2 >> 1 [PE1.2] times pop - 45 12 14 . 2 >> 1 [PE1.2] times pop - 45 12 14 2 . >> 1 [PE1.2] times pop - 45 12 3 . 1 [PE1.2] times pop - 45 12 3 1 . [PE1.2] times pop - 45 12 3 1 [PE1.2] . times pop - 45 12 3 [PE1.2] . i pop - 45 12 3 . PE1.2 pop - 45 12 3 . [3 & PE1.1] dupdip 2 >> pop - 45 12 3 [3 & PE1.1] . dupdip 2 >> pop - 45 12 3 . 3 & PE1.1 3 2 >> pop - 45 12 3 3 . & PE1.1 3 2 >> pop - 45 12 3 . PE1.1 3 2 >> pop - 45 12 3 . + [+] dupdip 3 2 >> pop - 45 15 . [+] dupdip 3 2 >> pop - 45 15 [+] . dupdip 3 2 >> pop - 45 15 . + 15 3 2 >> pop - 60 . 15 3 2 >> pop - 60 15 . 3 2 >> pop - 60 15 3 . 2 >> pop - 60 15 3 2 . >> pop - 60 15 0 . pop - 60 15 . - - -And so we have at last: - -.. code:: ipython2 - - define('PE1 == 0 0 66 [14811 7 [PE1.2] times pop] times 14811 4 [PE1.2] times popop') - -.. code:: ipython2 - - J('PE1') - - -.. parsed-literal:: - - 233168 - - -Let's refactor. - -:: - - 14811 7 [PE1.2] times pop - 14811 4 [PE1.2] times pop - 14811 n [PE1.2] times pop - n 14811 swap [PE1.2] times pop - -.. code:: ipython2 - - define('PE1.3 == 14811 swap [PE1.2] times pop') - -Now we can simplify the definition above: - -.. code:: ipython2 - - define('PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop') - -.. code:: ipython2 - - J('PE1') - - -.. parsed-literal:: - - 233168 - - -Here's our joy program all in one place. It doesn't make so much sense, -but if you have read through the above description of how it was derived -I hope it's clear. - -:: - - PE1.1 == + [+] dupdip - PE1.2 == [3 & PE1.1] dupdip 2 >> - PE1.3 == 14811 swap [PE1.2] times pop - PE1 == 0 0 66 [7 PE1.3] times 4 PE1.3 pop - -Generator Version -================= - -It's a little clunky iterating sixty-six times though the seven numbers -then four more. In the *Generator Programs* notebook we derive a -generator that can be repeatedly driven by the ``x`` combinator to -produce a stream of the seven numbers repeating over and over again. - -.. code:: ipython2 - - define('PE1.terms == [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons]') - -.. code:: ipython2 - - J('PE1.terms 21 [x] times') - - -.. parsed-literal:: - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [dup [pop 14811] [] branch [3 &] dupdip 2 >>] dip rest cons] - - -We know from above that we need sixty-six times seven then four more -terms to reach up to but not over one thousand. - -.. code:: ipython2 - - J('7 66 * 4 +') - - -.. parsed-literal:: - - 466 - - -Here they are... -~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('PE1.terms 466 [x] times pop') - - -.. parsed-literal:: - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 - - -...and they do sum to 999. -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - J('[PE1.terms 466 [x] times pop] run sum') - - -.. parsed-literal:: - - 999 - - -Now we can use ``PE1.1`` to accumulate the terms as we go, and then -``pop`` the generator and the counter from the stack when we're done, -leaving just the sum. - -.. code:: ipython2 - - J('0 0 PE1.terms 466 [x [PE1.1] dip] times popop') - - -.. parsed-literal:: - - 233168 - - -A little further analysis renders iteration unnecessary. -======================================================== - -Consider finding the sum of the positive integers less than or equal to -ten. - -.. code:: ipython2 - - J('[10 9 8 7 6 5 4 3 2 1] sum') - - -.. parsed-literal:: - - 55 - - -Instead of summing them, -`observe `__: - -:: - - 10 9 8 7 6 - + 1 2 3 4 5 - ---- -- -- -- -- - 11 11 11 11 11 - - 11 * 5 = 55 - -From the above example we can deduce that the sum of the first N -positive integers is: - -:: - - (N + 1) * N / 2 - -(The formula also works for odd values of N, I'll leave that to you if -you want to work it out or you can take my word for it.) - -.. code:: ipython2 - - define('F == dup ++ * 2 floordiv') - -.. code:: ipython2 - - V('10 F') - - -.. parsed-literal:: - - . 10 F - 10 . F - 10 . dup ++ * 2 floordiv - 10 10 . ++ * 2 floordiv - 10 11 . * 2 floordiv - 110 . 2 floordiv - 110 2 . floordiv - 55 . - - -Generalizing to Blocks of Terms -------------------------------- - -We can apply the same reasoning to the PE1 problem. - -Between 0 and 990 inclusive there are sixty-six "blocks" of seven terms -each, starting with: - -:: - - [3 5 6 9 10 12 15] - -And ending with: - -:: - - [978 980 981 984 985 987 990] - -If we reverse one of these two blocks and sum pairs... - -.. code:: ipython2 - - J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip') - - -.. parsed-literal:: - - [[978 15] [980 12] [981 10] [984 9] [985 6] [987 5] [990 3]] - - -.. code:: ipython2 - - J('[3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map') - - -.. parsed-literal:: - - [993 992 991 993 991 992 993] - - -(Interesting that the sequence of seven numbers appears again in the -rightmost digit of each term.) - -.. code:: ipython2 - - J('[ 3 5 6 9 10 12 15] reverse [978 980 981 984 985 987 990] zip [sum] map sum') - - -.. parsed-literal:: - - 6945 - - -Since there are sixty-six blocks and we are pairing them up, there must -be thirty-three pairs, each of which sums to 6945. We also have these -additional unpaired terms between 990 and 1000: - -:: - - 993 995 996 999 - -So we can give the "sum of all the multiples of 3 or 5 below 1000" like -so: - -.. code:: ipython2 - - J('6945 33 * [993 995 996 999] cons sum') - - -.. parsed-literal:: - - 233168 - - -It's worth noting, I think, that this same reasoning holds for any two -numbers :math:`n` and :math:`m` the multiples of which we hope to sum. -The multiples would have a cycle of differences of length :math:`k` and -so we could compute the sum of :math:`Nk` multiples as above. - -The sequence of differences will always be a palidrome. Consider an -interval spanning the least common multiple of :math:`n` and :math:`m`: - -:: - - | | | | | | | | - | | | | | - -Here we have 4 and 7, and you can read off the sequence of differences -directly from the diagram: 4 3 1 4 2 2 4 1 3 4. - -Geometrically, the actual values of :math:`n` and :math:`m` and their -*lcm* don't matter, the pattern they make will always be symmetrical -around its midpoint. The same reasoning holds for multiples of more than -two numbers. - -The Simplest Program -==================== - -Of course, the simplest joy program for the first Project Euler problem -is just: - -:: - - PE1 == 233168 - -Fin. diff --git a/docs/Advent of Code 2017 December 1st.html b/docs/Advent of Code 2017 December 1st.html deleted file mode 100644 index b085073..0000000 --- a/docs/Advent of Code 2017 December 1st.html +++ /dev/null @@ -1,12432 +0,0 @@ - - - -Advent of Code 2017 December 1st - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Advent of Code 2017

December 1st

[Given] a sequence of digits (your puzzle input) and find the sum of all digits that match the next digit in the list. The list is circular, so the digit after the last digit is the first digit in the list.

-

For example:

-
    -
  • 1122 produces a sum of 3 (1 + 2) because the first digit (1) matches the second digit and the third digit (2) matches the fourth digit.
  • -
  • 1111 produces 4 because each digit (all 1) matches the next.
  • -
  • 1234 produces 0 because no digit matches the next.
  • -
  • 91212129 produces 9 because the only digit that matches the next one is the last digit, 9.
  • -
- -
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import J, V, define
-
- -
-
-
- -
-
-
-
-
-

I'll assume the input is a Joy sequence of integers (as opposed to a string or something else.)

-

We might proceed by creating a word that makes a copy of the sequence with the first item moved to the last, and zips it with the original to make a list of pairs, and a another word that adds (one of) each pair to a total if the pair matches.

- -
AoC2017.1 == pair_up total_matches
-
-
-

Let's derive pair_up:

- -
     [a b c] pair_up
--------------------------
-   [[a b] [b c] [c a]]
- -
-
-
-
-
-
-
-

Straightforward (although the order of each pair is reversed, due to the way zip works, but it doesn't matter for this program):

- -
[a b c] dup
-[a b c] [a b c] uncons swap
-[a b c] [b c] a unit concat
-[a b c] [b c a] zip
-[[b a] [c b] [a c]]
- -
-
-
-
-
-
In [2]:
-
-
-
define('pair_up == dup uncons swap unit concat zip')
-
- -
-
-
- -
-
-
-
In [3]:
-
-
-
J('[1 2 3] pair_up')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[[2 1] [3 2] [1 3]]
-
-
-
- -
-
- -
-
-
-
In [4]:
-
-
-
J('[1 2 2 3] pair_up')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[[2 1] [2 2] [3 2] [1 3]]
-
-
-
- -
-
- -
-
-
-
-
-

Now we need to derive total_matches. It will be a step function:

- -
total_matches == 0 swap [F] step
-
-
-

Where F will have the pair to work with, and it will basically be a branch or ifte.

- -
total [n m] F
-
-
-

It will probably be easier to write if we dequote the pair:

- -
   total [n m] i F′
-----------------------
-     total n m F′
-
-
-

Now F′ becomes just:

- -
total n m [=] [pop +] [popop] ifte
-
-
-

So:

- -
F == i [=] [pop +] [popop] ifte
-
-
-

And thus:

- -
total_matches == 0 swap [i [=] [pop +] [popop] ifte] step
- -
-
-
-
-
-
In [5]:
-
-
-
define('total_matches == 0 swap [i [=] [pop +] [popop] ifte] step')
-
- -
-
-
- -
-
-
-
In [6]:
-
-
-
J('[1 2 3] pair_up total_matches')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0
-
-
-
- -
-
- -
-
-
-
In [7]:
-
-
-
J('[1 2 2 3] pair_up total_matches')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
-
-

Now we can define our main program and evaluate it on the examples.

- -
-
-
-
-
-
In [8]:
-
-
-
define('AoC2017.1 == pair_up total_matches')
-
- -
-
-
- -
-
-
-
In [9]:
-
-
-
J('[1 1 2 2] AoC2017.1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3
-
-
-
- -
-
- -
-
-
-
In [10]:
-
-
-
J('[1 1 1 1] AoC2017.1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4
-
-
-
- -
-
- -
-
-
-
In [11]:
-
-
-
J('[1 2 3 4] AoC2017.1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0
-
-
-
- -
-
- -
-
-
-
In [12]:
-
-
-
J('[9 1 2 1 2 1 2 9] AoC2017.1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
9
-
-
-
- -
-
- -
-
-
-
In [13]:
-
-
-
J('[9 1 2 1 2 1 2 9] AoC2017.1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
9
-
-
-
- -
-
- -
-
-
-
-
- -
      pair_up == dup uncons swap unit concat zip
-total_matches == 0 swap [i [=] [pop +] [popop] ifte] step
-
-    AoC2017.1 == pair_up total_matches
- -
-
-
-
-
-
-
-

Now the paired digit is "halfway" round.

- -
[a b c d] dup size 2 / [drop] [take reverse] cleave concat zip
- -
-
-
-
-
-
In [14]:
-
-
-
J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave concat zip')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[[3 1] [4 2] [1 3] [2 4]]
-
-
-
- -
-
- -
-
-
-
-
-

I realized that each pair is repeated...

- -
-
-
-
-
-
In [15]:
-
-
-
J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave  zip')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[1 2 3 4] [[1 3] [2 4]]
-
-
-
- -
-
- -
-
-
-
In [16]:
-
-
-
define('AoC2017.1.extra == dup size 2 / [drop] [take reverse] cleave  zip swap pop total_matches 2 *')
-
- -
-
-
- -
-
-
-
In [17]:
-
-
-
J('[1 2 1 2] AoC2017.1.extra')
-
- -
-
-
- -
-
- - -
- -
- - -
-
6
-
-
-
- -
-
- -
-
-
-
In [18]:
-
-
-
J('[1 2 2 1] AoC2017.1.extra')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0
-
-
-
- -
-
- -
-
-
-
In [19]:
-
-
-
J('[1 2 3 4 2 5] AoC2017.1.extra')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4
-
-
-
- -
-
- -
-
-
-
-
-

Refactor FTW

With Joy a great deal of the heuristics from Forth programming carry over nicely. For example, refactoring into small, well-scoped commands with mnemonic names...

- -
         rotate_seq == uncons swap unit concat
-            pair_up == dup rotate_seq zip
-       add_if_match == [=] [pop +] [popop] ifte
-      total_matches == [i add_if_match] step_zero
-
-          AoC2017.1 == pair_up total_matches
-
-       half_of_size == dup size 2 /
-           split_at == [drop] [take reverse] cleave
-      pair_up.extra == half_of_size split_at zip swap pop
-
-    AoC2017.1.extra == pair_up.extra total_matches 2 *
- -
-
-
-
-
- - - - - - diff --git a/docs/Advent of Code 2017 December 1st.ipynb b/docs/Advent of Code 2017 December 1st.ipynb deleted file mode 100644 index c83a62d..0000000 --- a/docs/Advent of Code 2017 December 1st.ipynb +++ /dev/null @@ -1,455 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Advent of Code 2017\n", - "\n", - "## December 1st\n", - "\n", - "\\[Given\\] a sequence of digits (your puzzle input) and find the sum of all digits that match the next digit in the list. The list is circular, so the digit after the last digit is the first digit in the list.\n", - "\n", - "For example:\n", - "\n", - "* 1122 produces a sum of 3 (1 + 2) because the first digit (1) matches the second digit and the third digit (2) matches the fourth digit.\n", - "* 1111 produces 4 because each digit (all 1) matches the next.\n", - "* 1234 produces 0 because no digit matches the next.\n", - "* 91212129 produces 9 because the only digit that matches the next one is the last digit, 9." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import J, V, define" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "I'll assume the input is a Joy sequence of integers (as opposed to a string or something else.)\n", - "\n", - "We might proceed by creating a word that makes a copy of the sequence with the first item moved to the last, and zips it with the original to make a list of pairs, and a another word that adds (one of) each pair to a total if the pair matches.\n", - "\n", - " AoC2017.1 == pair_up total_matches\n", - "\n", - "Let's derive `pair_up`:\n", - "\n", - " [a b c] pair_up\n", - " -------------------------\n", - " [[a b] [b c] [c a]]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Straightforward (although the order of each pair is reversed, due to the way `zip` works, but it doesn't matter for this program):\n", - "\n", - " [a b c] dup\n", - " [a b c] [a b c] uncons swap\n", - " [a b c] [b c] a unit concat\n", - " [a b c] [b c a] zip\n", - " [[b a] [c b] [a c]]" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "define('pair_up == dup uncons swap unit concat zip')" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[2 1] [3 2] [1 3]]\n" - ] - } - ], - "source": [ - "J('[1 2 3] pair_up')" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[2 1] [2 2] [3 2] [1 3]]\n" - ] - } - ], - "source": [ - "J('[1 2 2 3] pair_up')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we need to derive `total_matches`. It will be a `step` function:\n", - "\n", - " total_matches == 0 swap [F] step\n", - "\n", - "Where `F` will have the pair to work with, and it will basically be a `branch` or `ifte`.\n", - "\n", - " total [n m] F\n", - "\n", - "It will probably be easier to write if we dequote the pair:\n", - "\n", - " total [n m] i F′\n", - " ----------------------\n", - " total n m F′\n", - "\n", - "Now `F′` becomes just:\n", - "\n", - " total n m [=] [pop +] [popop] ifte\n", - "\n", - "So:\n", - "\n", - " F == i [=] [pop +] [popop] ifte\n", - "\n", - "And thus:\n", - "\n", - " total_matches == 0 swap [i [=] [pop +] [popop] ifte] step" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "define('total_matches == 0 swap [i [=] [pop +] [popop] ifte] step')" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], - "source": [ - "J('[1 2 3] pair_up total_matches')" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('[1 2 2 3] pair_up total_matches')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can define our main program and evaluate it on the examples." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "define('AoC2017.1 == pair_up total_matches')" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "J('[1 1 2 2] AoC2017.1')" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n" - ] - } - ], - "source": [ - "J('[1 1 1 1] AoC2017.1')" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] AoC2017.1')" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9\n" - ] - } - ], - "source": [ - "J('[9 1 2 1 2 1 2 9] AoC2017.1')" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9\n" - ] - } - ], - "source": [ - "J('[9 1 2 1 2 1 2 9] AoC2017.1')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " pair_up == dup uncons swap unit concat zip\n", - " total_matches == 0 swap [i [=] [pop +] [popop] ifte] step\n", - "\n", - " AoC2017.1 == pair_up total_matches" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now the paired digit is \"halfway\" round.\n", - "\n", - " [a b c d] dup size 2 / [drop] [take reverse] cleave concat zip" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[3 1] [4 2] [1 3] [2 4]]\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave concat zip')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "I realized that each pair is repeated..." - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 2 3 4] [[1 3] [2 4]]\n" - ] - } - ], - "source": [ - "J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave zip')" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [], - "source": [ - "define('AoC2017.1.extra == dup size 2 / [drop] [take reverse] cleave zip swap pop total_matches 2 *')" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6\n" - ] - } - ], - "source": [ - "J('[1 2 1 2] AoC2017.1.extra')" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], - "source": [ - "J('[1 2 2 1] AoC2017.1.extra')" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n" - ] - } - ], - "source": [ - "J('[1 2 3 4 2 5] AoC2017.1.extra')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Refactor FTW\n", - "\n", - "With Joy a great deal of the heuristics from Forth programming carry over nicely. For example, refactoring into small, well-scoped commands with mnemonic names...\n", - "\n", - " rotate_seq == uncons swap unit concat\n", - " pair_up == dup rotate_seq zip\n", - " add_if_match == [=] [pop +] [popop] ifte\n", - " total_matches == [i add_if_match] step_zero\n", - "\n", - " AoC2017.1 == pair_up total_matches\n", - "\n", - " half_of_size == dup size 2 /\n", - " split_at == [drop] [take reverse] cleave\n", - " pair_up.extra == half_of_size split_at zip swap pop\n", - "\n", - " AoC2017.1.extra == pair_up.extra total_matches 2 *\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Advent of Code 2017 December 1st.md b/docs/Advent of Code 2017 December 1st.md deleted file mode 100644 index c08b171..0000000 --- a/docs/Advent of Code 2017 December 1st.md +++ /dev/null @@ -1,228 +0,0 @@ - -# Advent of Code 2017 - -## December 1st - -\[Given\] a sequence of digits (your puzzle input) and find the sum of all digits that match the next digit in the list. The list is circular, so the digit after the last digit is the first digit in the list. - -For example: - -* 1122 produces a sum of 3 (1 + 2) because the first digit (1) matches the second digit and the third digit (2) matches the fourth digit. -* 1111 produces 4 because each digit (all 1) matches the next. -* 1234 produces 0 because no digit matches the next. -* 91212129 produces 9 because the only digit that matches the next one is the last digit, 9. - - -```python -from notebook_preamble import J, V, define -``` - -I'll assume the input is a Joy sequence of integers (as opposed to a string or something else.) - -We might proceed by creating a word that makes a copy of the sequence with the first item moved to the last, and zips it with the original to make a list of pairs, and a another word that adds (one of) each pair to a total if the pair matches. - - AoC2017.1 == pair_up total_matches - -Let's derive `pair_up`: - - [a b c] pair_up - ------------------------- - [[a b] [b c] [c a]] - - -Straightforward (although the order of each pair is reversed, due to the way `zip` works, but it doesn't matter for this program): - - [a b c] dup - [a b c] [a b c] uncons swap - [a b c] [b c] a unit concat - [a b c] [b c a] zip - [[b a] [c b] [a c]] - - -```python -define('pair_up == dup uncons swap unit concat zip') -``` - - -```python -J('[1 2 3] pair_up') -``` - - [[2 1] [3 2] [1 3]] - - - -```python -J('[1 2 2 3] pair_up') -``` - - [[2 1] [2 2] [3 2] [1 3]] - - -Now we need to derive `total_matches`. It will be a `step` function: - - total_matches == 0 swap [F] step - -Where `F` will have the pair to work with, and it will basically be a `branch` or `ifte`. - - total [n m] F - -It will probably be easier to write if we dequote the pair: - - total [n m] i F′ - ---------------------- - total n m F′ - -Now `F′` becomes just: - - total n m [=] [pop +] [popop] ifte - -So: - - F == i [=] [pop +] [popop] ifte - -And thus: - - total_matches == 0 swap [i [=] [pop +] [popop] ifte] step - - -```python -define('total_matches == 0 swap [i [=] [pop +] [popop] ifte] step') -``` - - -```python -J('[1 2 3] pair_up total_matches') -``` - - 0 - - - -```python -J('[1 2 2 3] pair_up total_matches') -``` - - 2 - - -Now we can define our main program and evaluate it on the examples. - - -```python -define('AoC2017.1 == pair_up total_matches') -``` - - -```python -J('[1 1 2 2] AoC2017.1') -``` - - 3 - - - -```python -J('[1 1 1 1] AoC2017.1') -``` - - 4 - - - -```python -J('[1 2 3 4] AoC2017.1') -``` - - 0 - - - -```python -J('[9 1 2 1 2 1 2 9] AoC2017.1') -``` - - 9 - - - -```python -J('[9 1 2 1 2 1 2 9] AoC2017.1') -``` - - 9 - - - pair_up == dup uncons swap unit concat zip - total_matches == 0 swap [i [=] [pop +] [popop] ifte] step - - AoC2017.1 == pair_up total_matches - -Now the paired digit is "halfway" round. - - [a b c d] dup size 2 / [drop] [take reverse] cleave concat zip - - -```python -J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave concat zip') -``` - - [[3 1] [4 2] [1 3] [2 4]] - - -I realized that each pair is repeated... - - -```python -J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave zip') -``` - - [1 2 3 4] [[1 3] [2 4]] - - - -```python -define('AoC2017.1.extra == dup size 2 / [drop] [take reverse] cleave zip swap pop total_matches 2 *') -``` - - -```python -J('[1 2 1 2] AoC2017.1.extra') -``` - - 6 - - - -```python -J('[1 2 2 1] AoC2017.1.extra') -``` - - 0 - - - -```python -J('[1 2 3 4 2 5] AoC2017.1.extra') -``` - - 4 - - -# Refactor FTW - -With Joy a great deal of the heuristics from Forth programming carry over nicely. For example, refactoring into small, well-scoped commands with mnemonic names... - - rotate_seq == uncons swap unit concat - pair_up == dup rotate_seq zip - add_if_match == [=] [pop +] [popop] ifte - total_matches == [i add_if_match] step_zero - - AoC2017.1 == pair_up total_matches - - half_of_size == dup size 2 / - split_at == [drop] [take reverse] cleave - pair_up.extra == half_of_size split_at zip swap pop - - AoC2017.1.extra == pair_up.extra total_matches 2 * - diff --git a/docs/Advent of Code 2017 December 1st.rst b/docs/Advent of Code 2017 December 1st.rst deleted file mode 100644 index d5bb543..0000000 --- a/docs/Advent of Code 2017 December 1st.rst +++ /dev/null @@ -1,288 +0,0 @@ - -Advent of Code 2017 -=================== - -December 1st ------------- - -[Given] a sequence of digits (your puzzle input) and find the sum of all -digits that match the next digit in the list. The list is circular, so -the digit after the last digit is the first digit in the list. - -For example: - -- 1122 produces a sum of 3 (1 + 2) because the first digit (1) matches - the second digit and the third digit (2) matches the fourth digit. -- 1111 produces 4 because each digit (all 1) matches the next. -- 1234 produces 0 because no digit matches the next. -- 91212129 produces 9 because the only digit that matches the next one - is the last digit, 9. - -.. code:: ipython2 - - from notebook_preamble import J, V, define - -I'll assume the input is a Joy sequence of integers (as opposed to a -string or something else.) - -We might proceed by creating a word that makes a copy of the sequence -with the first item moved to the last, and zips it with the original to -make a list of pairs, and a another word that adds (one of) each pair to -a total if the pair matches. - -:: - - AoC2017.1 == pair_up total_matches - -Let's derive ``pair_up``: - -:: - - [a b c] pair_up - ------------------------- - [[a b] [b c] [c a]] - -Straightforward (although the order of each pair is reversed, due to the -way ``zip`` works, but it doesn't matter for this program): - -:: - - [a b c] dup - [a b c] [a b c] uncons swap - [a b c] [b c] a unit concat - [a b c] [b c a] zip - [[b a] [c b] [a c]] - -.. code:: ipython2 - - define('pair_up == dup uncons swap unit concat zip') - -.. code:: ipython2 - - J('[1 2 3] pair_up') - - -.. parsed-literal:: - - [[2 1] [3 2] [1 3]] - - -.. code:: ipython2 - - J('[1 2 2 3] pair_up') - - -.. parsed-literal:: - - [[2 1] [2 2] [3 2] [1 3]] - - -Now we need to derive ``total_matches``. It will be a ``step`` function: - -:: - - total_matches == 0 swap [F] step - -Where ``F`` will have the pair to work with, and it will basically be a -``branch`` or ``ifte``. - -:: - - total [n m] F - -It will probably be easier to write if we dequote the pair: - -:: - - total [n m] i F′ - ---------------------- - total n m F′ - -Now ``F′`` becomes just: - -:: - - total n m [=] [pop +] [popop] ifte - -So: - -:: - - F == i [=] [pop +] [popop] ifte - -And thus: - -:: - - total_matches == 0 swap [i [=] [pop +] [popop] ifte] step - -.. code:: ipython2 - - define('total_matches == 0 swap [i [=] [pop +] [popop] ifte] step') - -.. code:: ipython2 - - J('[1 2 3] pair_up total_matches') - - -.. parsed-literal:: - - 0 - - -.. code:: ipython2 - - J('[1 2 2 3] pair_up total_matches') - - -.. parsed-literal:: - - 2 - - -Now we can define our main program and evaluate it on the examples. - -.. code:: ipython2 - - define('AoC2017.1 == pair_up total_matches') - -.. code:: ipython2 - - J('[1 1 2 2] AoC2017.1') - - -.. parsed-literal:: - - 3 - - -.. code:: ipython2 - - J('[1 1 1 1] AoC2017.1') - - -.. parsed-literal:: - - 4 - - -.. code:: ipython2 - - J('[1 2 3 4] AoC2017.1') - - -.. parsed-literal:: - - 0 - - -.. code:: ipython2 - - J('[9 1 2 1 2 1 2 9] AoC2017.1') - - -.. parsed-literal:: - - 9 - - -.. code:: ipython2 - - J('[9 1 2 1 2 1 2 9] AoC2017.1') - - -.. parsed-literal:: - - 9 - - -:: - - pair_up == dup uncons swap unit concat zip - total_matches == 0 swap [i [=] [pop +] [popop] ifte] step - - AoC2017.1 == pair_up total_matches - -Now the paired digit is "halfway" round. - -:: - - [a b c d] dup size 2 / [drop] [take reverse] cleave concat zip - -.. code:: ipython2 - - J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave concat zip') - - -.. parsed-literal:: - - [[3 1] [4 2] [1 3] [2 4]] - - -I realized that each pair is repeated... - -.. code:: ipython2 - - J('[1 2 3 4] dup size 2 / [drop] [take reverse] cleave zip') - - -.. parsed-literal:: - - [1 2 3 4] [[1 3] [2 4]] - - -.. code:: ipython2 - - define('AoC2017.1.extra == dup size 2 / [drop] [take reverse] cleave zip swap pop total_matches 2 *') - -.. code:: ipython2 - - J('[1 2 1 2] AoC2017.1.extra') - - -.. parsed-literal:: - - 6 - - -.. code:: ipython2 - - J('[1 2 2 1] AoC2017.1.extra') - - -.. parsed-literal:: - - 0 - - -.. code:: ipython2 - - J('[1 2 3 4 2 5] AoC2017.1.extra') - - -.. parsed-literal:: - - 4 - - -Refactor FTW -============ - -With Joy a great deal of the heuristics from Forth programming carry -over nicely. For example, refactoring into small, well-scoped commands -with mnemonic names... - -:: - - rotate_seq == uncons swap unit concat - pair_up == dup rotate_seq zip - add_if_match == [=] [pop +] [popop] ifte - total_matches == [i add_if_match] step_zero - - AoC2017.1 == pair_up total_matches - - half_of_size == dup size 2 / - split_at == [drop] [take reverse] cleave - pair_up.extra == half_of_size split_at zip swap pop - - AoC2017.1.extra == pair_up.extra total_matches 2 * diff --git a/docs/Advent of Code 2017 December 2nd.html b/docs/Advent of Code 2017 December 2nd.html deleted file mode 100644 index 6f72cc2..0000000 --- a/docs/Advent of Code 2017 December 2nd.html +++ /dev/null @@ -1,12487 +0,0 @@ - - - -Advent of Code 2017 December 2nd - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Advent of Code 2017

December 2nd

For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences.

-

For example, given the following spreadsheet:

- -
5 1 9 5
-7 5 3
-2 4 6 8
-
-
-
    -
  • The first row's largest and smallest values are 9 and 1, and their difference is 8.
  • -
  • The second row's largest and smallest values are 7 and 3, and their difference is 4.
  • -
  • The third row's difference is 6.
  • -
-

In this example, the spreadsheet's checksum would be 8 + 4 + 6 = 18.

- -
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import J, V, define
-
- -
-
-
- -
-
-
-
-
-

I'll assume the input is a Joy sequence of sequences of integers.

- -
[[5 1 9 5]
- [7 5 3]
- [2 4 6 8]]
-
-
-

So, obviously, the initial form will be a step function:

- -
AoC2017.2 == 0 swap [F +] step
- -
-
-
-
-
-
-
-

This function F must get the max and min of a row of numbers and subtract. We can define a helper function maxmin which does this:

- -
-
-
-
-
-
In [2]:
-
-
-
define('maxmin == [max] [min] cleave')
-
- -
-
-
- -
-
-
-
In [3]:
-
-
-
J('[1 2 3] maxmin')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 1
-
-
-
- -
-
- -
-
-
-
-
-

Then F just does that then subtracts the min from the max:

- -
F == maxmin -
-
-
-

So:

- -
-
-
-
-
-
In [4]:
-
-
-
define('AoC2017.2 == [maxmin - +] step_zero')
-
- -
-
-
- -
-
-
-
In [5]:
-
-
-
J('''
-
-[[5 1 9 5]
- [7 5 3]
- [2 4 6 8]] AoC2017.2
-
-''')
-
- -
-
-
- -
-
- - -
- -
- - -
-
18
-
-
-
- -
-
- -
-
-
-
-
-

...find the only two numbers in each row where one evenly divides the other - that is, where the result of the division operation is a whole number. They would like you to find those numbers on each line, divide them, and add up each line's result.

-

For example, given the following spreadsheet:

- -
5 9 2 8
-9 4 7 3
-3 8 6 5
-
-
-
    -
  • In the first row, the only two numbers that evenly divide are 8 and 2; the result of this division is 4.
  • -
  • In the second row, the two numbers are 9 and 3; the result is 3.
  • -
  • In the third row, the result is 2.
  • -
-

In this example, the sum of the results would be 4 + 3 + 2 = 9.

-

What is the sum of each row's result in your puzzle input?

- -
-
-
-
-
-
In [6]:
-
-
-
J('[5 9 2 8] sort reverse')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[9 8 5 2]
-
-
-
- -
-
- -
-
-
-
In [7]:
-
-
-
J('[9 8 5 2] uncons [swap [divmod] cons] dupdip')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[8 5 2] [9 divmod] [8 5 2]
-
-
-
- -
-
- -
-
-
-
-
- -
[9 8 5 2] uncons [swap [divmod] cons F] dupdip G
-  [8 5 2]            [9 divmod]      F [8 5 2] G
- -
-
-
-
-
-
In [8]:
-
-
-
V('[8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                      . [8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip
-                              [8 5 2] . [9 divmod] [uncons swap] dip dup [i not] dip
-                   [8 5 2] [9 divmod] . [uncons swap] dip dup [i not] dip
-     [8 5 2] [9 divmod] [uncons swap] . dip dup [i not] dip
-                              [8 5 2] . uncons swap [9 divmod] dup [i not] dip
-                              8 [5 2] . swap [9 divmod] dup [i not] dip
-                              [5 2] 8 . [9 divmod] dup [i not] dip
-                   [5 2] 8 [9 divmod] . dup [i not] dip
-        [5 2] 8 [9 divmod] [9 divmod] . [i not] dip
-[5 2] 8 [9 divmod] [9 divmod] [i not] . dip
-                   [5 2] 8 [9 divmod] . i not [9 divmod]
-                              [5 2] 8 . 9 divmod not [9 divmod]
-                            [5 2] 8 9 . divmod not [9 divmod]
-                            [5 2] 1 1 . not [9 divmod]
-                        [5 2] 1 False . [9 divmod]
-             [5 2] 1 False [9 divmod] . 
-
-
-
- -
-
- -
-
-
-
-
-

Tricky

Let's think.

-

Given a sorted sequence (from highest to lowest) we want to

-
    -
  • for head, tail in sequence
      -
    • for term in tail:
        -
      • check if the head % term == 0
          -
        • if so compute head / term and terminate loop
        • -
        • else continue
        • -
        -
      • -
      -
    • -
    -
  • -
- -
-
-
-
-
-
-
-

So we want a loop I think

-
[a b c d] True [Q] loop
-[a b c d] Q    [Q] loop
-
-
-

Q should either leave the result and False, or the rest and True.

- -
   [a b c d] Q
------------------
-    result 0
-
-   [a b c d] Q
------------------
-    [b c d] 1
- -
-
-
-
-
-
-
-

This suggests that Q should start with:

- -
[a b c d] uncons dup roll<
-[b c d] [b c d] a
-
-
-

Now we just have to pop it if we don't need it.

- -
[b c d] [b c d] a [P] [T] [cons] app2 popdd [E] primrec
-[b c d] [b c d] [a P] [a T]                 [E] primrec
-
-
-
- -
w/ Q == [% not] [T] [F] primrec
-
-        [a b c d] uncons
-        a [b c d] tuck
-[b c d] a [b c d] uncons
-[b c d] a b [c d] roll>
-[b c d] [c d] a b Q
-[b c d] [c d] a b [% not] [T] [F] primrec
-
-[b c d] [c d] a b T
-[b c d] [c d] a b / roll> popop 0
-
-[b c d] [c d] a b F                   Q
-[b c d] [c d] a b pop swap uncons ... Q
-[b c d] [c d] a       swap uncons ... Q
-[b c d] a [c d]            uncons ... Q
-[b c d] a c [d]                   roll> Q
-[b c d] [d] a c Q
-
-Q == [% not] [/ roll> popop 0] [pop swap uncons roll>] primrec
-
-uncons tuck uncons roll> Q
- -
-
-
-
-
-
In [9]:
-
-
-
J('[8 5 3 2] 9 [swap] [% not] [cons] app2 popdd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[8 5 3 2] [9 swap] [9 % not]
-
-
-
- -
-
- -
-
-
-
-
-
- -
        [a b c d] uncons
-        a [b c d] tuck
-[b c d] a [b c d] [not] [popop 1] [Q] ifte
-
-[b c d] a [] popop 1
-[b c d] 1
-
-[b c d] a [b c d] Q 
-
-
-   a [...] Q
----------------
-   result 0
-
-   a [...] Q
----------------
-       1
-
-
-w/ Q == [first % not] [first / 0] [rest [not] [popop 1]] [ifte]
-
-
-
-a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte]
-a [b c d]  first % not
-a b % not
-a%b not
-bool(a%b)
-
-a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte]
-a [b c d]                first / 0
-a b / 0
-a/b 0
-
-a [b c d] [first % not] [first / 0] [rest [not] [popop 1]]   [ifte]
-a [b c d]                            rest [not] [popop 1] [Q] ifte
-a [c d]                                   [not] [popop 1] [Q] ifte
-a [c d]                                   [not] [popop 1] [Q] ifte
-
-a [c d] [not] [popop 1] [Q] ifte
-a [c d]  not
-
-a [] popop 1
-1
-
-a [c d] Q
-
-
-uncons tuck [first % not] [first / 0] [rest [not] [popop 1]] [ifte]
- -
-
-
-
-
-
-
-

I finally sat down with a piece of paper and blocked it out.

First, I made a function G that expects a number and a sequence of candidates and return the result or zero:

- -
   n [...] G
----------------
-    result
-
-   n [...] G
----------------
-       0
-
-
-

It's a recursive function that conditionally executes the recursive part of its recursive branch

- -
[Pg] [E] [R1 [Pi] [T]] [ifte] genrec
-
-
-

The recursive branch is the else-part of the inner ifte:

- -
G == [Pg] [E] [R1 [Pi] [T]]   [ifte] genrec
-  == [Pg] [E] [R1 [Pi] [T] [G] ifte] ifte
-
-
-

But this is in hindsight. Going forward I derived:

- -
G == [first % not]
-     [first /]
-     [rest [not] [popop 0]]
-     [ifte] genrec
-
-
-

The predicate detects if the n can be evenly divided by the first item in the list. If so, the then-part returns the result. Otherwise, we have:

- -
n [m ...] rest [not] [popop 0] [G] ifte
-n [...]        [not] [popop 0] [G] ifte
-
-
-

This ifte guards against empty sequences and returns zero in that case, otherwise it executes G.

- -
-
-
-
-
-
In [10]:
-
-
-
define('G == [first % not] [first /] [rest [not] [popop 0]] [ifte] genrec')
-
- -
-
-
- -
-
-
-
-
-

Now we need a word that uses G on each (head, tail) pair of a sequence until it finds a (non-zero) result. It's going to be designed to work on a stack that has some candidate n, a sequence of possible divisors, and a result that is zero to signal to continue (a non-zero value implies that it is the discovered result):

- -
   n [...] p find-result
----------------------------
-          result
-
-
-

It applies G using nullary because if it fails with one candidate it needs the list to get the next one (the list is otherwise consumed by G.)

- -
find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec
-
-n [...] p [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec
-
-
-

The base-case is trivial, return the (non-zero) result. The recursive branch...

- -
n [...] p roll< popop uncons [G] nullary find-result
-[...] p n       popop uncons [G] nullary find-result
-[...]                 uncons [G] nullary find-result
-m [..]                       [G] nullary find-result
-m [..] p                                 find-result
-
-
-

The puzzle states that the input is well-formed, meaning that we can expect a result before the row sequence empties and so do not need to guard the uncons.

- -
-
-
-
-
-
In [11]:
-
-
-
define('find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec')
-
- -
-
-
- -
-
-
-
In [14]:
-
-
-
J('[11 9 8 7 3 2] 0 tuck find-result')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3.0
-
-
-
- -
-
- -
-
-
-
-
-

In order to get the thing started, we need to sort the list in descending order, then prime the find-result function with a dummy candidate value and zero ("continue") flag.

- -
-
-
-
-
-
In [12]:
-
-
-
define('prep-row == sort reverse 0 tuck')
-
- -
-
-
- -
-
-
-
-
-

Now we can define our program.

- -
-
-
-
-
-
In [13]:
-
-
-
define('AoC20017.2.extra == [prep-row find-result +] step_zero')
-
- -
-
-
- -
-
-
-
In [15]:
-
-
-
J('''
-
-[[5 9 2 8]
- [9 4 7 3]
- [3 8 6 5]] AoC20017.2.extra
-
-''')
-
- -
-
-
- -
-
- - -
- -
- - -
-
9.0
-
-
-
- -
-
- -
-
-
- - - - - - diff --git a/docs/Advent of Code 2017 December 2nd.ipynb b/docs/Advent of Code 2017 December 2nd.ipynb deleted file mode 100644 index 871349d..0000000 --- a/docs/Advent of Code 2017 December 2nd.ipynb +++ /dev/null @@ -1,554 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Advent of Code 2017\n", - "\n", - "## December 2nd\n", - "\n", - "For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences.\n", - "\n", - "For example, given the following spreadsheet:\n", - "\n", - " 5 1 9 5\n", - " 7 5 3\n", - " 2 4 6 8\n", - "\n", - "* The first row's largest and smallest values are 9 and 1, and their difference is 8.\n", - "* The second row's largest and smallest values are 7 and 3, and their difference is 4.\n", - "* The third row's difference is 6.\n", - "\n", - "In this example, the spreadsheet's checksum would be 8 + 4 + 6 = 18." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import J, V, define" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "I'll assume the input is a Joy sequence of sequences of integers.\n", - "\n", - " [[5 1 9 5]\n", - " [7 5 3]\n", - " [2 4 6 8]]\n", - "\n", - "So, obviously, the initial form will be a `step` function:\n", - "\n", - " AoC2017.2 == 0 swap [F +] step" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This function `F` must get the `max` and `min` of a row of numbers and subtract. We can define a helper function `maxmin` which does this:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "define('maxmin == [max] [min] cleave')" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 1\n" - ] - } - ], - "source": [ - "J('[1 2 3] maxmin')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Then `F` just does that then subtracts the min from the max:\n", - "\n", - " F == maxmin -\n", - "\n", - "So:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "define('AoC2017.2 == [maxmin - +] step_zero')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "18\n" - ] - } - ], - "source": [ - "J('''\n", - "\n", - "[[5 1 9 5]\n", - " [7 5 3]\n", - " [2 4 6 8]] AoC2017.2\n", - "\n", - "''')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "...find the only two numbers in each row where one evenly divides the other - that is, where the result of the division operation is a whole number. They would like you to find those numbers on each line, divide them, and add up each line's result.\n", - "\n", - "For example, given the following spreadsheet:\n", - "\n", - " 5 9 2 8\n", - " 9 4 7 3\n", - " 3 8 6 5\n", - "\n", - "* In the first row, the only two numbers that evenly divide are 8 and 2; the result of this division is 4.\n", - "* In the second row, the two numbers are 9 and 3; the result is 3.\n", - "* In the third row, the result is 2.\n", - "\n", - "In this example, the sum of the results would be 4 + 3 + 2 = 9.\n", - "\n", - "What is the sum of each row's result in your puzzle input?" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 8 5 2]\n" - ] - } - ], - "source": [ - "J('[5 9 2 8] sort reverse')" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[8 5 2] [9 divmod] [8 5 2]\n" - ] - } - ], - "source": [ - "J('[9 8 5 2] uncons [swap [divmod] cons] dupdip')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " [9 8 5 2] uncons [swap [divmod] cons F] dupdip G\n", - " [8 5 2] [9 divmod] F [8 5 2] G\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip\n", - " [8 5 2] . [9 divmod] [uncons swap] dip dup [i not] dip\n", - " [8 5 2] [9 divmod] . [uncons swap] dip dup [i not] dip\n", - " [8 5 2] [9 divmod] [uncons swap] . dip dup [i not] dip\n", - " [8 5 2] . uncons swap [9 divmod] dup [i not] dip\n", - " 8 [5 2] . swap [9 divmod] dup [i not] dip\n", - " [5 2] 8 . [9 divmod] dup [i not] dip\n", - " [5 2] 8 [9 divmod] . dup [i not] dip\n", - " [5 2] 8 [9 divmod] [9 divmod] . [i not] dip\n", - "[5 2] 8 [9 divmod] [9 divmod] [i not] . dip\n", - " [5 2] 8 [9 divmod] . i not [9 divmod]\n", - " [5 2] 8 . 9 divmod not [9 divmod]\n", - " [5 2] 8 9 . divmod not [9 divmod]\n", - " [5 2] 1 1 . not [9 divmod]\n", - " [5 2] 1 False . [9 divmod]\n", - " [5 2] 1 False [9 divmod] . \n" - ] - } - ], - "source": [ - "V('[8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tricky\n", - "\n", - "Let's think.\n", - "\n", - "Given a *sorted* sequence (from highest to lowest) we want to \n", - "* for head, tail in sequence\n", - " * for term in tail:\n", - " * check if the head % term == 0\n", - " * if so compute head / term and terminate loop\n", - " * else continue" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### So we want a `loop` I think\n", - "\n", - " [a b c d] True [Q] loop\n", - " [a b c d] Q [Q] loop\n", - "\n", - "`Q` should either leave the result and False, or the `rest` and True.\n", - "\n", - " [a b c d] Q\n", - " -----------------\n", - " result 0\n", - "\n", - " [a b c d] Q\n", - " -----------------\n", - " [b c d] 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This suggests that `Q` should start with:\n", - "\n", - " [a b c d] uncons dup roll<\n", - " [b c d] [b c d] a\n", - "\n", - "Now we just have to `pop` it if we don't need it.\n", - "\n", - " [b c d] [b c d] a [P] [T] [cons] app2 popdd [E] primrec\n", - " [b c d] [b c d] [a P] [a T] [E] primrec\n", - "\n", - "-------------------\n", - "\n", - " w/ Q == [% not] [T] [F] primrec\n", - "\n", - " [a b c d] uncons\n", - " a [b c d] tuck\n", - " [b c d] a [b c d] uncons\n", - " [b c d] a b [c d] roll>\n", - " [b c d] [c d] a b Q\n", - " [b c d] [c d] a b [% not] [T] [F] primrec\n", - "\n", - " [b c d] [c d] a b T\n", - " [b c d] [c d] a b / roll> popop 0\n", - "\n", - " [b c d] [c d] a b F Q\n", - " [b c d] [c d] a b pop swap uncons ... Q\n", - " [b c d] [c d] a swap uncons ... Q\n", - " [b c d] a [c d] uncons ... Q\n", - " [b c d] a c [d] roll> Q\n", - " [b c d] [d] a c Q\n", - "\n", - " Q == [% not] [/ roll> popop 0] [pop swap uncons roll>] primrec\n", - " \n", - " uncons tuck uncons roll> Q" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[8 5 3 2] [9 swap] [9 % not]\n" - ] - } - ], - "source": [ - "J('[8 5 3 2] 9 [swap] [% not] [cons] app2 popdd')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "-------------------\n", - "\n", - " [a b c d] uncons\n", - " a [b c d] tuck\n", - " [b c d] a [b c d] [not] [popop 1] [Q] ifte\n", - "\n", - " [b c d] a [] popop 1\n", - " [b c d] 1\n", - "\n", - " [b c d] a [b c d] Q \n", - "\n", - "\n", - " a [...] Q\n", - " ---------------\n", - " result 0\n", - "\n", - " a [...] Q\n", - " ---------------\n", - " 1\n", - "\n", - "\n", - " w/ Q == [first % not] [first / 0] [rest [not] [popop 1]] [ifte]\n", - "\n", - "\n", - "\n", - " a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte]\n", - " a [b c d] first % not\n", - " a b % not\n", - " a%b not\n", - " bool(a%b)\n", - "\n", - " a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte]\n", - " a [b c d] first / 0\n", - " a b / 0\n", - " a/b 0\n", - "\n", - " a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte]\n", - " a [b c d] rest [not] [popop 1] [Q] ifte\n", - " a [c d] [not] [popop 1] [Q] ifte\n", - " a [c d] [not] [popop 1] [Q] ifte\n", - "\n", - " a [c d] [not] [popop 1] [Q] ifte\n", - " a [c d] not\n", - "\n", - " a [] popop 1\n", - " 1\n", - "\n", - " a [c d] Q\n", - "\n", - "\n", - " uncons tuck [first % not] [first / 0] [rest [not] [popop 1]] [ifte]\n", - " \n", - " \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### I finally sat down with a piece of paper and blocked it out.\n", - "\n", - "First, I made a function `G` that expects a number and a sequence of candidates and return the result or zero:\n", - "\n", - " n [...] G\n", - " ---------------\n", - " result\n", - "\n", - " n [...] G\n", - " ---------------\n", - " 0\n", - "\n", - "It's a recursive function that conditionally executes the recursive part of its recursive branch\n", - "\n", - " [Pg] [E] [R1 [Pi] [T]] [ifte] genrec\n", - "\n", - "The recursive branch is the else-part of the inner `ifte`:\n", - "\n", - " G == [Pg] [E] [R1 [Pi] [T]] [ifte] genrec\n", - " == [Pg] [E] [R1 [Pi] [T] [G] ifte] ifte\n", - "\n", - "But this is in hindsight. Going forward I derived:\n", - "\n", - " G == [first % not]\n", - " [first /]\n", - " [rest [not] [popop 0]]\n", - " [ifte] genrec\n", - "\n", - "The predicate detects if the `n` can be evenly divided by the `first` item in the list. If so, the then-part returns the result. Otherwise, we have:\n", - "\n", - " n [m ...] rest [not] [popop 0] [G] ifte\n", - " n [...] [not] [popop 0] [G] ifte\n", - "\n", - "This `ifte` guards against empty sequences and returns zero in that case, otherwise it executes `G`." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "define('G == [first % not] [first /] [rest [not] [popop 0]] [ifte] genrec')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we need a word that uses `G` on each (head, tail) pair of a sequence until it finds a (non-zero) result. It's going to be designed to work on a stack that has some candidate `n`, a sequence of possible divisors, and a result that is zero to signal to continue (a non-zero value implies that it is the discovered result):\n", - "\n", - " n [...] p find-result\n", - " ---------------------------\n", - " result\n", - "\n", - "It applies `G` using `nullary` because if it fails with one candidate it needs the list to get the next one (the list is otherwise consumed by `G`.)\n", - "\n", - " find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec\n", - "\n", - " n [...] p [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec\n", - "\n", - "The base-case is trivial, return the (non-zero) result. The recursive branch...\n", - "\n", - " n [...] p roll< popop uncons [G] nullary find-result\n", - " [...] p n popop uncons [G] nullary find-result\n", - " [...] uncons [G] nullary find-result\n", - " m [..] [G] nullary find-result\n", - " m [..] p find-result\n", - "\n", - "The puzzle states that the input is well-formed, meaning that we can expect a result before the row sequence empties and so do not need to guard the `uncons`." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "define('find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec')" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3.0\n" - ] - } - ], - "source": [ - "J('[11 9 8 7 3 2] 0 tuck find-result')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In order to get the thing started, we need to `sort` the list in descending order, then prime the `find-result` function with a dummy candidate value and zero (\"continue\") flag." - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "define('prep-row == sort reverse 0 tuck')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can define our program." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "define('AoC20017.2.extra == [prep-row find-result +] step_zero')" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9.0\n" - ] - } - ], - "source": [ - "J('''\n", - "\n", - "[[5 9 2 8]\n", - " [9 4 7 3]\n", - " [3 8 6 5]] AoC20017.2.extra\n", - "\n", - "''')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Advent of Code 2017 December 2nd.md b/docs/Advent of Code 2017 December 2nd.md deleted file mode 100644 index 28b6908..0000000 --- a/docs/Advent of Code 2017 December 2nd.md +++ /dev/null @@ -1,361 +0,0 @@ - -# Advent of Code 2017 - -## December 2nd - -For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences. - -For example, given the following spreadsheet: - - 5 1 9 5 - 7 5 3 - 2 4 6 8 - -* The first row's largest and smallest values are 9 and 1, and their difference is 8. -* The second row's largest and smallest values are 7 and 3, and their difference is 4. -* The third row's difference is 6. - -In this example, the spreadsheet's checksum would be 8 + 4 + 6 = 18. - - -```python -from notebook_preamble import J, V, define -``` - -I'll assume the input is a Joy sequence of sequences of integers. - - [[5 1 9 5] - [7 5 3] - [2 4 6 8]] - -So, obviously, the initial form will be a `step` function: - - AoC2017.2 == 0 swap [F +] step - -This function `F` must get the `max` and `min` of a row of numbers and subtract. We can define a helper function `maxmin` which does this: - - -```python -define('maxmin == [max] [min] cleave') -``` - - -```python -J('[1 2 3] maxmin') -``` - - 3 1 - - -Then `F` just does that then subtracts the min from the max: - - F == maxmin - - -So: - - -```python -define('AoC2017.2 == [maxmin - +] step_zero') -``` - - -```python -J(''' - -[[5 1 9 5] - [7 5 3] - [2 4 6 8]] AoC2017.2 - -''') -``` - - 18 - - -...find the only two numbers in each row where one evenly divides the other - that is, where the result of the division operation is a whole number. They would like you to find those numbers on each line, divide them, and add up each line's result. - -For example, given the following spreadsheet: - - 5 9 2 8 - 9 4 7 3 - 3 8 6 5 - -* In the first row, the only two numbers that evenly divide are 8 and 2; the result of this division is 4. -* In the second row, the two numbers are 9 and 3; the result is 3. -* In the third row, the result is 2. - -In this example, the sum of the results would be 4 + 3 + 2 = 9. - -What is the sum of each row's result in your puzzle input? - - -```python -J('[5 9 2 8] sort reverse') -``` - - [9 8 5 2] - - - -```python -J('[9 8 5 2] uncons [swap [divmod] cons] dupdip') -``` - - [8 5 2] [9 divmod] [8 5 2] - - - - [9 8 5 2] uncons [swap [divmod] cons F] dupdip G - [8 5 2] [9 divmod] F [8 5 2] G - - - - -```python -V('[8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip') -``` - - . [8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip - [8 5 2] . [9 divmod] [uncons swap] dip dup [i not] dip - [8 5 2] [9 divmod] . [uncons swap] dip dup [i not] dip - [8 5 2] [9 divmod] [uncons swap] . dip dup [i not] dip - [8 5 2] . uncons swap [9 divmod] dup [i not] dip - 8 [5 2] . swap [9 divmod] dup [i not] dip - [5 2] 8 . [9 divmod] dup [i not] dip - [5 2] 8 [9 divmod] . dup [i not] dip - [5 2] 8 [9 divmod] [9 divmod] . [i not] dip - [5 2] 8 [9 divmod] [9 divmod] [i not] . dip - [5 2] 8 [9 divmod] . i not [9 divmod] - [5 2] 8 . 9 divmod not [9 divmod] - [5 2] 8 9 . divmod not [9 divmod] - [5 2] 1 1 . not [9 divmod] - [5 2] 1 False . [9 divmod] - [5 2] 1 False [9 divmod] . - - -## Tricky - -Let's think. - -Given a *sorted* sequence (from highest to lowest) we want to -* for head, tail in sequence - * for term in tail: - * check if the head % term == 0 - * if so compute head / term and terminate loop - * else continue - -### So we want a `loop` I think - - [a b c d] True [Q] loop - [a b c d] Q [Q] loop - -`Q` should either leave the result and False, or the `rest` and True. - - [a b c d] Q - ----------------- - result 0 - - [a b c d] Q - ----------------- - [b c d] 1 - -This suggests that `Q` should start with: - - [a b c d] uncons dup roll< - [b c d] [b c d] a - -Now we just have to `pop` it if we don't need it. - - [b c d] [b c d] a [P] [T] [cons] app2 popdd [E] primrec - [b c d] [b c d] [a P] [a T] [E] primrec - -------------------- - - w/ Q == [% not] [T] [F] primrec - - [a b c d] uncons - a [b c d] tuck - [b c d] a [b c d] uncons - [b c d] a b [c d] roll> - [b c d] [c d] a b Q - [b c d] [c d] a b [% not] [T] [F] primrec - - [b c d] [c d] a b T - [b c d] [c d] a b / roll> popop 0 - - [b c d] [c d] a b F Q - [b c d] [c d] a b pop swap uncons ... Q - [b c d] [c d] a swap uncons ... Q - [b c d] a [c d] uncons ... Q - [b c d] a c [d] roll> Q - [b c d] [d] a c Q - - Q == [% not] [/ roll> popop 0] [pop swap uncons roll>] primrec - - uncons tuck uncons roll> Q - - -```python -J('[8 5 3 2] 9 [swap] [% not] [cons] app2 popdd') -``` - - [8 5 3 2] [9 swap] [9 % not] - - -------------------- - - [a b c d] uncons - a [b c d] tuck - [b c d] a [b c d] [not] [popop 1] [Q] ifte - - [b c d] a [] popop 1 - [b c d] 1 - - [b c d] a [b c d] Q - - - a [...] Q - --------------- - result 0 - - a [...] Q - --------------- - 1 - - - w/ Q == [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - - - - a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - a [b c d] first % not - a b % not - a%b not - bool(a%b) - - a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - a [b c d] first / 0 - a b / 0 - a/b 0 - - a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - a [b c d] rest [not] [popop 1] [Q] ifte - a [c d] [not] [popop 1] [Q] ifte - a [c d] [not] [popop 1] [Q] ifte - - a [c d] [not] [popop 1] [Q] ifte - a [c d] not - - a [] popop 1 - 1 - - a [c d] Q - - - uncons tuck [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - - - - -### I finally sat down with a piece of paper and blocked it out. - -First, I made a function `G` that expects a number and a sequence of candidates and return the result or zero: - - n [...] G - --------------- - result - - n [...] G - --------------- - 0 - -It's a recursive function that conditionally executes the recursive part of its recursive branch - - [Pg] [E] [R1 [Pi] [T]] [ifte] genrec - -The recursive branch is the else-part of the inner `ifte`: - - G == [Pg] [E] [R1 [Pi] [T]] [ifte] genrec - == [Pg] [E] [R1 [Pi] [T] [G] ifte] ifte - -But this is in hindsight. Going forward I derived: - - G == [first % not] - [first /] - [rest [not] [popop 0]] - [ifte] genrec - -The predicate detects if the `n` can be evenly divided by the `first` item in the list. If so, the then-part returns the result. Otherwise, we have: - - n [m ...] rest [not] [popop 0] [G] ifte - n [...] [not] [popop 0] [G] ifte - -This `ifte` guards against empty sequences and returns zero in that case, otherwise it executes `G`. - - -```python -define('G == [first % not] [first /] [rest [not] [popop 0]] [ifte] genrec') -``` - -Now we need a word that uses `G` on each (head, tail) pair of a sequence until it finds a (non-zero) result. It's going to be designed to work on a stack that has some candidate `n`, a sequence of possible divisors, and a result that is zero to signal to continue (a non-zero value implies that it is the discovered result): - - n [...] p find-result - --------------------------- - result - -It applies `G` using `nullary` because if it fails with one candidate it needs the list to get the next one (the list is otherwise consumed by `G`.) - - find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec - - n [...] p [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec - -The base-case is trivial, return the (non-zero) result. The recursive branch... - - n [...] p roll< popop uncons [G] nullary find-result - [...] p n popop uncons [G] nullary find-result - [...] uncons [G] nullary find-result - m [..] [G] nullary find-result - m [..] p find-result - -The puzzle states that the input is well-formed, meaning that we can expect a result before the row sequence empties and so do not need to guard the `uncons`. - - -```python -define('find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec') -``` - - -```python -J('[11 9 8 7 3 2] 0 tuck find-result') -``` - - 3.0 - - -In order to get the thing started, we need to `sort` the list in descending order, then prime the `find-result` function with a dummy candidate value and zero ("continue") flag. - - -```python -define('prep-row == sort reverse 0 tuck') -``` - -Now we can define our program. - - -```python -define('AoC20017.2.extra == [prep-row find-result +] step_zero') -``` - - -```python -J(''' - -[[5 9 2 8] - [9 4 7 3] - [3 8 6 5]] AoC20017.2.extra - -''') -``` - - 9.0 - diff --git a/docs/Advent of Code 2017 December 2nd.rst b/docs/Advent of Code 2017 December 2nd.rst deleted file mode 100644 index 7b85b26..0000000 --- a/docs/Advent of Code 2017 December 2nd.rst +++ /dev/null @@ -1,432 +0,0 @@ - -Advent of Code 2017 -=================== - -December 2nd ------------- - -For each row, determine the difference between the largest value and the -smallest value; the checksum is the sum of all of these differences. - -For example, given the following spreadsheet: - -:: - - 5 1 9 5 - 7 5 3 - 2 4 6 8 - -- The first row's largest and smallest values are 9 and 1, and their - difference is 8. -- The second row's largest and smallest values are 7 and 3, and their - difference is 4. -- The third row's difference is 6. - -In this example, the spreadsheet's checksum would be 8 + 4 + 6 = 18. - -.. code:: ipython2 - - from notebook_preamble import J, V, define - -I'll assume the input is a Joy sequence of sequences of integers. - -:: - - [[5 1 9 5] - [7 5 3] - [2 4 6 8]] - -So, obviously, the initial form will be a ``step`` function: - -:: - - AoC2017.2 == 0 swap [F +] step - -This function ``F`` must get the ``max`` and ``min`` of a row of numbers -and subtract. We can define a helper function ``maxmin`` which does -this: - -.. code:: ipython2 - - define('maxmin == [max] [min] cleave') - -.. code:: ipython2 - - J('[1 2 3] maxmin') - - -.. parsed-literal:: - - 3 1 - - -Then ``F`` just does that then subtracts the min from the max: - -:: - - F == maxmin - - -So: - -.. code:: ipython2 - - define('AoC2017.2 == [maxmin - +] step_zero') - -.. code:: ipython2 - - J(''' - - [[5 1 9 5] - [7 5 3] - [2 4 6 8]] AoC2017.2 - - ''') - - -.. parsed-literal:: - - 18 - - -...find the only two numbers in each row where one evenly divides the -other - that is, where the result of the division operation is a whole -number. They would like you to find those numbers on each line, divide -them, and add up each line's result. - -For example, given the following spreadsheet: - -:: - - 5 9 2 8 - 9 4 7 3 - 3 8 6 5 - -- In the first row, the only two numbers that evenly divide are 8 and - 2; the result of this division is 4. -- In the second row, the two numbers are 9 and 3; the result is 3. -- In the third row, the result is 2. - -In this example, the sum of the results would be 4 + 3 + 2 = 9. - -What is the sum of each row's result in your puzzle input? - -.. code:: ipython2 - - J('[5 9 2 8] sort reverse') - - -.. parsed-literal:: - - [9 8 5 2] - - -.. code:: ipython2 - - J('[9 8 5 2] uncons [swap [divmod] cons] dupdip') - - -.. parsed-literal:: - - [8 5 2] [9 divmod] [8 5 2] - - -:: - - [9 8 5 2] uncons [swap [divmod] cons F] dupdip G - [8 5 2] [9 divmod] F [8 5 2] G - -.. code:: ipython2 - - V('[8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip') - - -.. parsed-literal:: - - . [8 5 2] [9 divmod] [uncons swap] dip dup [i not] dip - [8 5 2] . [9 divmod] [uncons swap] dip dup [i not] dip - [8 5 2] [9 divmod] . [uncons swap] dip dup [i not] dip - [8 5 2] [9 divmod] [uncons swap] . dip dup [i not] dip - [8 5 2] . uncons swap [9 divmod] dup [i not] dip - 8 [5 2] . swap [9 divmod] dup [i not] dip - [5 2] 8 . [9 divmod] dup [i not] dip - [5 2] 8 [9 divmod] . dup [i not] dip - [5 2] 8 [9 divmod] [9 divmod] . [i not] dip - [5 2] 8 [9 divmod] [9 divmod] [i not] . dip - [5 2] 8 [9 divmod] . i not [9 divmod] - [5 2] 8 . 9 divmod not [9 divmod] - [5 2] 8 9 . divmod not [9 divmod] - [5 2] 1 1 . not [9 divmod] - [5 2] 1 False . [9 divmod] - [5 2] 1 False [9 divmod] . - - -Tricky ------- - -Let's think. - -Given a *sorted* sequence (from highest to lowest) we want to \* for -head, tail in sequence \* for term in tail: \* check if the head % term -== 0 \* if so compute head / term and terminate loop \* else continue - -So we want a ``loop`` I think -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - [a b c d] True [Q] loop - [a b c d] Q [Q] loop - -``Q`` should either leave the result and False, or the ``rest`` and -True. - -:: - - [a b c d] Q - ----------------- - result 0 - - [a b c d] Q - ----------------- - [b c d] 1 - -This suggests that ``Q`` should start with: - -:: - - [a b c d] uncons dup roll< - [b c d] [b c d] a - -Now we just have to ``pop`` it if we don't need it. - -:: - - [b c d] [b c d] a [P] [T] [cons] app2 popdd [E] primrec - [b c d] [b c d] [a P] [a T] [E] primrec - --------------- - -:: - - w/ Q == [% not] [T] [F] primrec - - [a b c d] uncons - a [b c d] tuck - [b c d] a [b c d] uncons - [b c d] a b [c d] roll> - [b c d] [c d] a b Q - [b c d] [c d] a b [% not] [T] [F] primrec - - [b c d] [c d] a b T - [b c d] [c d] a b / roll> popop 0 - - [b c d] [c d] a b F Q - [b c d] [c d] a b pop swap uncons ... Q - [b c d] [c d] a swap uncons ... Q - [b c d] a [c d] uncons ... Q - [b c d] a c [d] roll> Q - [b c d] [d] a c Q - - Q == [% not] [/ roll> popop 0] [pop swap uncons roll>] primrec - - uncons tuck uncons roll> Q - -.. code:: ipython2 - - J('[8 5 3 2] 9 [swap] [% not] [cons] app2 popdd') - - -.. parsed-literal:: - - [8 5 3 2] [9 swap] [9 % not] - - --------------- - -:: - - [a b c d] uncons - a [b c d] tuck - [b c d] a [b c d] [not] [popop 1] [Q] ifte - - [b c d] a [] popop 1 - [b c d] 1 - - [b c d] a [b c d] Q - - - a [...] Q - --------------- - result 0 - - a [...] Q - --------------- - 1 - - - w/ Q == [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - - - - a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - a [b c d] first % not - a b % not - a%b not - bool(a%b) - - a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - a [b c d] first / 0 - a b / 0 - a/b 0 - - a [b c d] [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - a [b c d] rest [not] [popop 1] [Q] ifte - a [c d] [not] [popop 1] [Q] ifte - a [c d] [not] [popop 1] [Q] ifte - - a [c d] [not] [popop 1] [Q] ifte - a [c d] not - - a [] popop 1 - 1 - - a [c d] Q - - - uncons tuck [first % not] [first / 0] [rest [not] [popop 1]] [ifte] - -I finally sat down with a piece of paper and blocked it out. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -First, I made a function ``G`` that expects a number and a sequence of -candidates and return the result or zero: - -:: - - n [...] G - --------------- - result - - n [...] G - --------------- - 0 - -It's a recursive function that conditionally executes the recursive part -of its recursive branch - -:: - - [Pg] [E] [R1 [Pi] [T]] [ifte] genrec - -The recursive branch is the else-part of the inner ``ifte``: - -:: - - G == [Pg] [E] [R1 [Pi] [T]] [ifte] genrec - == [Pg] [E] [R1 [Pi] [T] [G] ifte] ifte - -But this is in hindsight. Going forward I derived: - -:: - - G == [first % not] - [first /] - [rest [not] [popop 0]] - [ifte] genrec - -The predicate detects if the ``n`` can be evenly divided by the -``first`` item in the list. If so, the then-part returns the result. -Otherwise, we have: - -:: - - n [m ...] rest [not] [popop 0] [G] ifte - n [...] [not] [popop 0] [G] ifte - -This ``ifte`` guards against empty sequences and returns zero in that -case, otherwise it executes ``G``. - -.. code:: ipython2 - - define('G == [first % not] [first /] [rest [not] [popop 0]] [ifte] genrec') - -Now we need a word that uses ``G`` on each (head, tail) pair of a -sequence until it finds a (non-zero) result. It's going to be designed -to work on a stack that has some candidate ``n``, a sequence of possible -divisors, and a result that is zero to signal to continue (a non-zero -value implies that it is the discovered result): - -:: - - n [...] p find-result - --------------------------- - result - -It applies ``G`` using ``nullary`` because if it fails with one -candidate it needs the list to get the next one (the list is otherwise -consumed by ``G``.) - -:: - - find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec - - n [...] p [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec - -The base-case is trivial, return the (non-zero) result. The recursive -branch... - -:: - - n [...] p roll< popop uncons [G] nullary find-result - [...] p n popop uncons [G] nullary find-result - [...] uncons [G] nullary find-result - m [..] [G] nullary find-result - m [..] p find-result - -The puzzle states that the input is well-formed, meaning that we can -expect a result before the row sequence empties and so do not need to -guard the ``uncons``. - -.. code:: ipython2 - - define('find-result == [0 >] [roll> popop] [roll< popop uncons [G] nullary] primrec') - -.. code:: ipython2 - - J('[11 9 8 7 3 2] 0 tuck find-result') - - -.. parsed-literal:: - - 3.0 - - -In order to get the thing started, we need to ``sort`` the list in -descending order, then prime the ``find-result`` function with a dummy -candidate value and zero ("continue") flag. - -.. code:: ipython2 - - define('prep-row == sort reverse 0 tuck') - -Now we can define our program. - -.. code:: ipython2 - - define('AoC20017.2.extra == [prep-row find-result +] step_zero') - -.. code:: ipython2 - - J(''' - - [[5 9 2 8] - [9 4 7 3] - [3 8 6 5]] AoC20017.2.extra - - ''') - - -.. parsed-literal:: - - 9.0 - diff --git a/docs/Advent of Code 2017 December 3rd.html b/docs/Advent of Code 2017 December 3rd.html deleted file mode 100644 index fb13cb1..0000000 --- a/docs/Advent of Code 2017 December 3rd.html +++ /dev/null @@ -1,13592 +0,0 @@ - - - -Advent of Code 2017 December 3rd - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Advent of Code 2017

December 3rd

You come across an experimental new kind of memory stored on an infinite two-dimensional grid.

-

Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up while spiraling outward. For example, the first few squares are allocated like this:

- -
17  16  15  14  13
-18   5   4   3  12
-19   6   1   2  11
-20   7   8   9  10
-21  22  23---> ...
-
-
-

While this is very space-efficient (no squares are skipped), requested data must be carried back to square 1 (the location of the only access port for this memory system) by programs that can only move up, down, left, or right. They always take the shortest path: the Manhattan Distance between the location of the data and square 1.

-

For example:

-
    -
  • Data from square 1 is carried 0 steps, since it's at the access port.
  • -
  • Data from square 12 is carried 3 steps, such as: down, left, left.
  • -
  • Data from square 23 is carried only 2 steps: up twice.
  • -
  • Data from square 1024 must be carried 31 steps.
  • -
-

How many steps are required to carry the data from the square identified in your puzzle input all the way to the access port?

- -
-
-
-
-
-
-
-

Analysis

I freely admit that I worked out the program I wanted to write using graph paper and some Python doodles. There's no point in trying to write a Joy program until I'm sure I understand the problem well enough.

-

The first thing I did was to write a column of numbers from 1 to n (32 as it happens) and next to them the desired output number, to look for patterns directly:

- -
1  0
-2  1
-3  2
-4  1
-5  2
-6  1
-7  2
-8  1
-9  2
-10 3
-11 2
-12 3
-13 4
-14 3
-15 2
-16 3
-17 4
-18 3
-19 2
-20 3
-21 4
-22 3
-23 2
-24 3
-25 4
-26 5
-27 4
-28 3
-29 4
-30 5
-31 6
-32 5
- -
-
-
-
-
-
-
-

There are four groups repeating for a given "rank", then the pattern enlarges and four groups repeat again, etc.

- -
        1 2
-      3 2 3 4
-    5 4 3 4 5 6
-  7 6 5 4 5 6 7 8
-9 8 7 6 5 6 7 8 9 10
-
-
-

Four of this pyramid interlock to tile the plane extending from the initial "1" square.

- -
         2   3   |    4  5   |    6  7   |    8  9
-      10 11 12 13|14 15 16 17|18 19 20 21|22 23 24 25
-
-
-

And so on.

- -
-
-
-
-
-
-
-

We can figure out the pattern for a row of the pyramid at a given "rank" $k$:

-

$2k - 1, 2k - 2, ..., k, k + 1, k + 2, ..., 2k$

-

or

-

$k + (k - 1), k + (k - 2), ..., k, k + 1, k + 2, ..., k + k$

-

This shows that the series consists at each place of $k$ plus some number that begins at $k - 1$, decreases to zero, then increases to $k$. Each row has $2k$ members.

- -
-
-
-
-
-
-
-

Let's figure out how, given an index into a row, we can calculate the value there. The index will be from 0 to $k - 1$.

-

Let's look at an example, with $k = 4$:

- -
0 1 2 3 4 5 6 7
-7 6 5 4 5 6 7 8
- -
-
-
-
-
-
In [1]:
-
-
-
k = 4
-
- -
-
-
- -
-
-
-
-
-

Subtract $k$ from the index and take the absolute value:

- -
-
-
-
-
-
In [2]:
-
-
-
for n in range(2 * k):
-    print abs(n - k),
-
- -
-
-
- -
-
- - -
- -
- - -
-
4 3 2 1 0 1 2 3
-
-
-
- -
-
- -
-
-
-
-
-

Not quite. Subtract $k - 1$ from the index and take the absolute value:

- -
-
-
-
-
-
In [3]:
-
-
-
for n in range(2 * k):
-    print abs(n - (k - 1)),
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 2 1 0 1 2 3 4
-
-
-
- -
-
- -
-
-
-
-
-

Great, now add $k$...

- -
-
-
-
-
-
In [4]:
-
-
-
for n in range(2 * k):
-    print abs(n - (k - 1)) + k,
-
- -
-
-
- -
-
- - -
- -
- - -
-
7 6 5 4 5 6 7 8
-
-
-
- -
-
- -
-
-
-
-
-

So to write a function that can give us the value of a row at a given index:

- -
-
-
-
-
-
In [5]:
-
-
-
def row_value(k, i):
-    i %= (2 * k)  # wrap the index at the row boundary.
-    return abs(i - (k - 1)) + k
-
- -
-
-
- -
-
-
-
In [6]:
-
-
-
k = 5
-for i in range(2 * k):
-    print row_value(k, i),
-
- -
-
-
- -
-
- - -
- -
- - -
-
9 8 7 6 5 6 7 8 9 10
-
-
-
- -
-
- -
-
-
-
-
-

(I'm leaving out details of how I figured this all out and just giving the relevent bits. It took a little while to zero in of the aspects of the pattern that were important for the task.)

- -
-
-
-
-
-
-
-

Finding the rank and offset of a number.

Now that we can compute the desired output value for a given rank and the offset (index) into that rank, we need to determine how to find the rank and offset of a number.

-

The rank is easy to find by iteratively stripping off the amount already covered by previous ranks until you find the one that brackets the target number. Because each row is $2k$ places and there are $4$ per rank each rank contains $8k$ places. Counting the initial square we have:

-

$corner_k = 1 + \sum_{n=1}^k 8n$

-

I'm not mathematically sophisticated enough to turn this directly into a formula (but Sympy is, see below.) I'm going to write a simple Python function to iterate and search:

- -
-
-
-
-
-
In [7]:
-
-
-
def rank_and_offset(n):
-    assert n >= 2  # Guard the domain.
-    n -= 2  # Subtract two,
-            # one for the initial square,
-            # and one because we are counting from 1 instead of 0.
-    k = 1
-    while True:
-        m = 8 * k  # The number of places total in this rank, 4(2k).
-        if n < m:
-            return k, n % (2 * k)
-        n -= m  # Remove this rank's worth.
-        k += 1
-
- -
-
-
- -
-
-
-
In [8]:
-
-
-
for n in range(2, 51):
-    print n, rank_and_offset(n)
-
- -
-
-
- -
-
- - -
- -
- - -
-
2 (1, 0)
-3 (1, 1)
-4 (1, 0)
-5 (1, 1)
-6 (1, 0)
-7 (1, 1)
-8 (1, 0)
-9 (1, 1)
-10 (2, 0)
-11 (2, 1)
-12 (2, 2)
-13 (2, 3)
-14 (2, 0)
-15 (2, 1)
-16 (2, 2)
-17 (2, 3)
-18 (2, 0)
-19 (2, 1)
-20 (2, 2)
-21 (2, 3)
-22 (2, 0)
-23 (2, 1)
-24 (2, 2)
-25 (2, 3)
-26 (3, 0)
-27 (3, 1)
-28 (3, 2)
-29 (3, 3)
-30 (3, 4)
-31 (3, 5)
-32 (3, 0)
-33 (3, 1)
-34 (3, 2)
-35 (3, 3)
-36 (3, 4)
-37 (3, 5)
-38 (3, 0)
-39 (3, 1)
-40 (3, 2)
-41 (3, 3)
-42 (3, 4)
-43 (3, 5)
-44 (3, 0)
-45 (3, 1)
-46 (3, 2)
-47 (3, 3)
-48 (3, 4)
-49 (3, 5)
-50 (4, 0)
-
-
-
- -
-
- -
-
-
-
In [9]:
-
-
-
for n in range(2, 51):
-    k, i = rank_and_offset(n)
-    print n, row_value(k, i)
-
- -
-
-
- -
-
- - -
- -
- - -
-
2 1
-3 2
-4 1
-5 2
-6 1
-7 2
-8 1
-9 2
-10 3
-11 2
-12 3
-13 4
-14 3
-15 2
-16 3
-17 4
-18 3
-19 2
-20 3
-21 4
-22 3
-23 2
-24 3
-25 4
-26 5
-27 4
-28 3
-29 4
-30 5
-31 6
-32 5
-33 4
-34 3
-35 4
-36 5
-37 6
-38 5
-39 4
-40 3
-41 4
-42 5
-43 6
-44 5
-45 4
-46 3
-47 4
-48 5
-49 6
-50 7
-
-
-
- -
-
- -
-
-
-
-
-

Putting it all together

-
-
-
-
-
-
In [10]:
-
-
-
def row_value(k, i):
-    return abs(i - (k - 1)) + k
-
-
-def rank_and_offset(n):
-    n -= 2  # Subtract two,
-            # one for the initial square,
-            # and one because we are counting from 1 instead of 0.
-    k = 1
-    while True:
-        m = 8 * k  # The number of places total in this rank, 4(2k).
-        if n < m:
-            return k, n % (2 * k)
-        n -= m  # Remove this rank's worth.
-        k += 1
-
-
-def aoc20173(n):
-    if n <= 1:
-        return 0
-    k, i = rank_and_offset(n)
-    return row_value(k, i)
-
- -
-
-
- -
-
-
-
In [11]:
-
-
-
aoc20173(23)
-
- -
-
-
- -
-
- - -
- -
Out[11]:
- - - - -
-
2
-
- -
- -
-
- -
-
-
-
In [12]:
-
-
-
aoc20173(23000)
-
- -
-
-
- -
-
- - -
- -
Out[12]:
- - - - -
-
105
-
- -
- -
-
- -
-
-
-
In [13]:
-
-
-
aoc20173(23000000000000)
-
- -
-
-
- -
-
- - -
- -
Out[13]:
- - - - -
-
4572225
-
- -
- -
-
- -
-
-
-
-
-

Sympy to the Rescue

Find the rank for large numbers

Using e.g. Sympy we can find the rank directly by solving for the roots of an equation. For large numbers this will (eventually) be faster than iterating as rank_and_offset() does.

- -
-
-
-
-
-
In [14]:
-
-
-
from sympy import floor, lambdify, solve, symbols
-from sympy import init_printing
-init_printing() 
-
- -
-
-
- -
-
-
-
In [15]:
-
-
-
k = symbols('k')
-
- -
-
-
- -
-
-
-
-
-

Since

-

$1 + 2 + 3 + ... + N = \frac{N(N + 1)}{2}$

-

and

-

$\sum_{n=1}^k 8n = 8(\sum_{n=1}^k n) = 8\frac{k(k + 1)}{2}$

-

We want:

- -
-
-
-
-
-
In [16]:
-
-
-
E = 2 + 8 * k * (k + 1) / 2  # For the reason for adding 2 see above.
-
-E
-
- -
-
-
- -
-
- - -
- -
Out[16]:
- - - - -
-$$4 k \left(k + 1\right) + 2$$ -
- -
- -
-
- -
-
-
-
-
-

We can write a function to solve for $k$ given some $n$...

- -
-
-
-
-
-
In [17]:
-
-
-
def rank_of(n):
-    return floor(max(solve(E - n, k))) + 1
-
- -
-
-
- -
-
-
-
-
-

First solve() for $E - n = 0$ which has two solutions (because the equation is quadratic so it has two roots) and since we only care about the larger one we use max() to select it. It will generally not be a nice integer (unless $n$ is the number of an end-corner of a rank) so we take the floor() and add 1 to get the integer rank of $n$. (Taking the ceiling() gives off-by-one errors on the rank boundaries. I don't know why. I'm basically like a monkey doing math here.) =-D

-

It gives correct answers:

- -
-
-
-
-
-
In [18]:
-
-
-
for n in (9, 10, 25, 26, 49, 50):
-    print n, rank_of(n)
-
- -
-
-
- -
-
- - -
- -
- - -
-
9 1
-10 2
-25 2
-26 3
-49 3
-50 4
-
-
-
- -
-
- -
-
-
-
-
-

And it runs much faster (at least for large numbers):

- -
-
-
-
-
-
In [19]:
-
-
-
%time rank_of(23000000000000)  # Compare runtime with rank_and_offset()!
-
- -
-
-
- -
-
- - -
- -
- - -
-
CPU times: user 68 ms, sys: 8 ms, total: 76 ms
-Wall time: 73.8 ms
-
-
-
- -
- -
Out[19]:
- - - - -
-$$2397916$$ -
- -
- -
-
- -
-
-
-
In [20]:
-
-
-
%time rank_and_offset(23000000000000)
-
- -
-
-
- -
-
- - -
- -
- - -
-
CPU times: user 308 ms, sys: 0 ns, total: 308 ms
-Wall time: 306 ms
-
-
-
- -
- -
Out[20]:
- - - - -
-$$\left ( 2397916, \quad 223606\right )$$ -
- -
- -
-
- -
-
-
-
-
-

After finding the rank you would still have to find the actual value of the rank's first corner and subtract it (plus 2) from the number and compute the offset as above and then the final output, but this overhead is partially shared by the other method, and overshadowed by the time it (the other iterative method) would take for really big inputs.

-

The fun thing to do here would be to graph the actual runtime of both methods against each other to find the trade-off point.

- -
-
-
-
-
-
-
-

It took me a second to realize I could do this...

Sympy is a symbolic math library, and it supports symbolic manipulation of equations. I can put in $y$ (instead of a value) and ask it to solve for $k$.

- -
-
-
-
-
-
In [21]:
-
-
-
y = symbols('y')
-
- -
-
-
- -
-
-
-
In [22]:
-
-
-
g, f = solve(E - y, k)
-
- -
-
-
- -
-
-
-
-
-

The equation is quadratic so there are two roots, we are interested in the greater one...

- -
-
-
-
-
-
In [23]:
-
-
-
g
-
- -
-
-
- -
-
- - -
- -
Out[23]:
- - - - -
-$$- \frac{1}{2} \sqrt{y - 1} - \frac{1}{2}$$ -
- -
- -
-
- -
-
-
-
In [24]:
-
-
-
f
-
- -
-
-
- -
-
- - -
- -
Out[24]:
- - - - -
-$$\frac{1}{2} \sqrt{y - 1} - \frac{1}{2}$$ -
- -
- -
-
- -
-
-
-
-
-

Now we can take the floor(), add 1, and lambdify() the equation to get a Python function that calculates the rank directly.

- -
-
-
-
-
-
In [25]:
-
-
-
floor(f) + 1
-
- -
-
-
- -
-
- - -
- -
Out[25]:
- - - - -
-$$\lfloor{\frac{1}{2} \sqrt{y - 1} - \frac{1}{2}}\rfloor + 1$$ -
- -
- -
-
- -
-
-
-
In [26]:
-
-
-
F = lambdify(y, floor(f) + 1)
-
- -
-
-
- -
-
-
-
In [27]:
-
-
-
for n in (9, 10, 25, 26, 49, 50):
-    print n, int(F(n))
-
- -
-
-
- -
-
- - -
- -
- - -
-
9 1
-10 2
-25 2
-26 3
-49 3
-50 4
-
-
-
- -
-
- -
-
-
-
-
-

It's pretty fast.

- -
-
-
-
-
-
In [28]:
-
-
-
%time int(F(23000000000000))  # The clear winner.
-
- -
-
-
- -
-
- - -
- -
- - -
-
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
-Wall time: 11.9 µs
-
-
-
- -
- -
Out[28]:
- - - - -
-$$2397916$$ -
- -
- -
-
- -
-
-
-
-
-

Knowing the equation we could write our own function manually, but the speed is no better.

- -
-
-
-
-
-
In [29]:
-
-
-
from math import floor as mfloor, sqrt
-
-def mrank_of(n):
-    return int(mfloor(sqrt(23000000000000 - 1) / 2 - 0.5) + 1)
-
- -
-
-
- -
-
-
-
In [30]:
-
-
-
%time mrank_of(23000000000000)
-
- -
-
-
- -
-
- - -
- -
- - -
-
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
-Wall time: 12.9 µs
-
-
-
- -
- -
Out[30]:
- - - - -
-$$2397916$$ -
- -
- -
-
- -
-
-
-
-
-

Given $n$ and a rank, compute the offset.

Now that we have a fast way to get the rank, we still need to use it to compute the offset into a pyramid row.

- -
-
-
-
-
-
In [31]:
-
-
-
def offset_of(n, k):
-    return (n - 2 + 4 * k * (k - 1)) % (2 * k)
-
- -
-
-
- -
-
-
-
-
-

(Note the sneaky way the sign changes from $k(k + 1)$ to $k(k - 1)$. This is because we want to subract the $(k - 1)$th rank's total places (its own and those of lesser rank) from our $n$ of rank $k$. Substituting $k - 1$ for $k$ in $k(k + 1)$ gives $(k - 1)(k - 1 + 1)$, which of course simplifies to $k(k - 1)$.)

- -
-
-
-
-
-
In [32]:
-
-
-
offset_of(23000000000000, 2397916)
-
- -
-
-
- -
-
- - -
- -
Out[32]:
- - - - -
-$$223606$$ -
- -
- -
-
- -
-
-
-
-
-

So, we can compute the rank, then the offset, then the row value.

- -
-
-
-
-
-
In [33]:
-
-
-
def rank_of(n):
-    return int(mfloor(sqrt(n - 1) / 2 - 0.5) + 1)
-
-
-def offset_of(n, k):
-    return (n - 2 + 4 * k * (k - 1)) % (2 * k)
-
-
-def row_value(k, i):
-    return abs(i - (k - 1)) + k
-
-
-def aoc20173(n):
-    k = rank_of(n)
-    i = offset_of(n, k)
-    return row_value(k, i)
-
- -
-
-
- -
-
-
-
In [34]:
-
-
-
aoc20173(23)
-
- -
-
-
- -
-
- - -
- -
Out[34]:
- - - - -
-$$2$$ -
- -
- -
-
- -
-
-
-
In [35]:
-
-
-
aoc20173(23000)
-
- -
-
-
- -
-
- - -
- -
Out[35]:
- - - - -
-$$105$$ -
- -
- -
-
- -
-
-
-
In [36]:
-
-
-
aoc20173(23000000000000)
-
- -
-
-
- -
-
- - -
- -
Out[36]:
- - - - -
-$$4572225$$ -
- -
- -
-
- -
-
-
-
In [37]:
-
-
-
%time aoc20173(23000000000000000000000000)  # Fast for large values.
-
- -
-
-
- -
-
- - -
- -
- - -
-
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
-Wall time: 20 µs
-
-
-
- -
- -
Out[37]:
- - - - -
-$$2690062495969$$ -
- -
- -
-
- -
-
-
-
-
-

A Joy Version

At this point I feel confident that I can implement a concise version of this code in Joy. ;-)

- -
-
-
-
-
-
In [38]:
-
-
-
from notebook_preamble import J, V, define
-
- -
-
-
- -
-
-
-
-
-

rank_of

-
   n rank_of
----------------
-      k
-
-
-

The translation is straightforward.

- -
int(floor(sqrt(n - 1) / 2 - 0.5) + 1)
-
-rank_of == -- sqrt 2 / 0.5 - floor ++
- -
-
-
-
-
-
In [39]:
-
-
-
define('rank_of == -- sqrt 2 / 0.5 - floor ++')
-
- -
-
-
- -
-
-
-
-
-

offset_of

-
   n k offset_of
--------------------
-         i
-
-(n - 2 + 4 * k * (k - 1)) % (2 * k)
-
-
-

A little tricky...

- -
n k dup 2 *
-n k k 2 *
-n k k*2 [Q] dip %
-n k Q k*2 %
-
-n k dup --
-n k k --
-n k k-1 4 * * 2 + -
-n k*k-1*4     2 + -
-n k*k-1*4+2       -
-n-k*k-1*4+2
-
-n-k*k-1*4+2 k*2 %
-n-k*k-1*4+2%k*2
-
-
-

Ergo:

- -
offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %
- -
-
-
-
-
-
In [40]:
-
-
-
define('offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %')
-
- -
-
-
- -
-
-
-
-
-

row_value

-
   k i row_value
--------------------
-        n
-
-abs(i - (k - 1)) + k
-
-k i over -- - abs +
-k i k    -- - abs +
-k i k-1     - abs +
-k i-k-1       abs +
-k |i-k-1|         +
-k+|i-k-1|
- -
-
-
-
-
-
In [41]:
-
-
-
define('row_value == over -- - abs +')
-
- -
-
-
- -
-
-
-
-
-

aoc2017.3

-
   n aoc2017.3
------------------
-        m
-
-n dup rank_of
-n k [offset_of] dupdip
-n k offset_of k
-i             k swap row_value
-k i row_value
-m
- -
-
-
-
-
-
In [42]:
-
-
-
define('aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value')
-
- -
-
-
- -
-
-
-
In [43]:
-
-
-
J('23 aoc2017.3')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
In [44]:
-
-
-
J('23000 aoc2017.3')
-
- -
-
-
- -
-
- - -
- -
- - -
-
105
-
-
-
- -
-
- -
-
-
-
In [45]:
-
-
-
V('23000000000000 aoc2017.3')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                    . 23000000000000 aoc2017.3
-                                     23000000000000 . aoc2017.3
-                                     23000000000000 . dup rank_of [offset_of] dupdip swap row_value
-                      23000000000000 23000000000000 . rank_of [offset_of] dupdip swap row_value
-                      23000000000000 23000000000000 . -- sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value
-                      23000000000000 22999999999999 . sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value
-                   23000000000000 4795831.523312615 . 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value
-                 23000000000000 4795831.523312615 2 . / 0.5 - floor ++ [offset_of] dupdip swap row_value
-                  23000000000000 2397915.7616563076 . 0.5 - floor ++ [offset_of] dupdip swap row_value
-              23000000000000 2397915.7616563076 0.5 . - floor ++ [offset_of] dupdip swap row_value
-                  23000000000000 2397915.2616563076 . floor ++ [offset_of] dupdip swap row_value
-                             23000000000000 2397915 . ++ [offset_of] dupdip swap row_value
-                             23000000000000 2397916 . [offset_of] dupdip swap row_value
-                 23000000000000 2397916 [offset_of] . dupdip swap row_value
-                             23000000000000 2397916 . offset_of 2397916 swap row_value
-                             23000000000000 2397916 . dup 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value
-                     23000000000000 2397916 2397916 . 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value
-                   23000000000000 2397916 2397916 2 . * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value
-                     23000000000000 2397916 4795832 . [dup -- 4 * * 2 + -] dip % 2397916 swap row_value
-23000000000000 2397916 4795832 [dup -- 4 * * 2 + -] . dip % 2397916 swap row_value
-                             23000000000000 2397916 . dup -- 4 * * 2 + - 4795832 % 2397916 swap row_value
-                     23000000000000 2397916 2397916 . -- 4 * * 2 + - 4795832 % 2397916 swap row_value
-                     23000000000000 2397916 2397915 . 4 * * 2 + - 4795832 % 2397916 swap row_value
-                   23000000000000 2397916 2397915 4 . * * 2 + - 4795832 % 2397916 swap row_value
-                     23000000000000 2397916 9591660 . * 2 + - 4795832 % 2397916 swap row_value
-                      23000000000000 22999994980560 . 2 + - 4795832 % 2397916 swap row_value
-                    23000000000000 22999994980560 2 . + - 4795832 % 2397916 swap row_value
-                      23000000000000 22999994980562 . - 4795832 % 2397916 swap row_value
-                                            5019438 . 4795832 % 2397916 swap row_value
-                                    5019438 4795832 . % 2397916 swap row_value
-                                             223606 . 2397916 swap row_value
-                                     223606 2397916 . swap row_value
-                                     2397916 223606 . row_value
-                                     2397916 223606 . over -- - abs +
-                             2397916 223606 2397916 . -- - abs +
-                             2397916 223606 2397915 . - abs +
-                                   2397916 -2174309 . abs +
-                                    2397916 2174309 . +
-                                            4572225 . 
-
-
-
- -
-
- -
-
-
-
-
- -
  rank_of == -- sqrt 2 / 0.5 - floor ++
-offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %
-row_value == over -- - abs +
-
-aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value
- -
-
-
-
-
- - - - - - diff --git a/docs/Advent of Code 2017 December 3rd.ipynb b/docs/Advent of Code 2017 December 3rd.ipynb deleted file mode 100644 index cdb7d80..0000000 --- a/docs/Advent of Code 2017 December 3rd.ipynb +++ /dev/null @@ -1,1426 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Advent of Code 2017\n", - "\n", - "## December 3rd\n", - "\n", - "You come across an experimental new kind of memory stored on an infinite two-dimensional grid.\n", - "\n", - "Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up while spiraling outward. For example, the first few squares are allocated like this:\n", - "\n", - " 17 16 15 14 13\n", - " 18 5 4 3 12\n", - " 19 6 1 2 11\n", - " 20 7 8 9 10\n", - " 21 22 23---> ...\n", - "\n", - "While this is very space-efficient (no squares are skipped), requested data must be carried back to square 1 (the location of the only access port for this memory system) by programs that can only move up, down, left, or right. They always take the shortest path: the Manhattan Distance between the location of the data and square 1.\n", - "\n", - "For example:\n", - "\n", - "* Data from square 1 is carried 0 steps, since it's at the access port.\n", - "* Data from square 12 is carried 3 steps, such as: down, left, left.\n", - "* Data from square 23 is carried only 2 steps: up twice.\n", - "* Data from square 1024 must be carried 31 steps.\n", - "\n", - "How many steps are required to carry the data from the square identified in your puzzle input all the way to the access port?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Analysis\n", - "\n", - "I freely admit that I worked out the program I wanted to write using graph paper and some Python doodles. There's no point in trying to write a Joy program until I'm sure I understand the problem well enough.\n", - "\n", - "The first thing I did was to write a column of numbers from 1 to n (32 as it happens) and next to them the desired output number, to look for patterns directly:\n", - "\n", - " 1 0\n", - " 2 1\n", - " 3 2\n", - " 4 1\n", - " 5 2\n", - " 6 1\n", - " 7 2\n", - " 8 1\n", - " 9 2\n", - " 10 3\n", - " 11 2\n", - " 12 3\n", - " 13 4\n", - " 14 3\n", - " 15 2\n", - " 16 3\n", - " 17 4\n", - " 18 3\n", - " 19 2\n", - " 20 3\n", - " 21 4\n", - " 22 3\n", - " 23 2\n", - " 24 3\n", - " 25 4\n", - " 26 5\n", - " 27 4\n", - " 28 3\n", - " 29 4\n", - " 30 5\n", - " 31 6\n", - " 32 5" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "There are four groups repeating for a given \"rank\", then the pattern enlarges and four groups repeat again, etc.\n", - "\n", - " 1 2\n", - " 3 2 3 4\n", - " 5 4 3 4 5 6\n", - " 7 6 5 4 5 6 7 8\n", - " 9 8 7 6 5 6 7 8 9 10\n", - "\n", - "Four of this pyramid interlock to tile the plane extending from the initial \"1\" square.\n", - "\n", - "\n", - " 2 3 | 4 5 | 6 7 | 8 9\n", - " 10 11 12 13|14 15 16 17|18 19 20 21|22 23 24 25\n", - "\n", - "And so on." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can figure out the pattern for a row of the pyramid at a given \"rank\" $k$:\n", - "\n", - "$2k - 1, 2k - 2, ..., k, k + 1, k + 2, ..., 2k$\n", - "\n", - "or\n", - "\n", - "$k + (k - 1), k + (k - 2), ..., k, k + 1, k + 2, ..., k + k$\n", - "\n", - "This shows that the series consists at each place of $k$ plus some number that begins at $k - 1$, decreases to zero, then increases to $k$. Each row has $2k$ members." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's figure out how, given an index into a row, we can calculate the value there. The index will be from 0 to $k - 1$. \n", - "\n", - " Let's look at an example, with $k = 4$:\n", - "\n", - " 0 1 2 3 4 5 6 7\n", - " 7 6 5 4 5 6 7 8" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "k = 4" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Subtract $k$ from the index and take the absolute value:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4 3 2 1 0 1 2 3\n" - ] - } - ], - "source": [ - "for n in range(2 * k):\n", - " print abs(n - k)," - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Not quite. Subtract $k - 1$ from the index and take the absolute value:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 2 1 0 1 2 3 4\n" - ] - } - ], - "source": [ - "for n in range(2 * k):\n", - " print abs(n - (k - 1))," - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Great, now add $k$..." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7 6 5 4 5 6 7 8\n" - ] - } - ], - "source": [ - "for n in range(2 * k):\n", - " print abs(n - (k - 1)) + k," - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "So to write a function that can give us the value of a row at a given index:" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def row_value(k, i):\n", - " i %= (2 * k) # wrap the index at the row boundary.\n", - " return abs(i - (k - 1)) + k" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9 8 7 6 5 6 7 8 9 10\n" - ] - } - ], - "source": [ - "k = 5\n", - "for i in range(2 * k):\n", - " print row_value(k, i)," - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "(I'm leaving out details of how I figured this all out and just giving the relevent bits. It took a little while to zero in of the aspects of the pattern that were important for the task.)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Finding the rank and offset of a number.\n", - "Now that we can compute the desired output value for a given rank and the offset (index) into that rank, we need to determine how to find the rank and offset of a number.\n", - "\n", - "The rank is easy to find by iteratively stripping off the amount already covered by previous ranks until you find the one that brackets the target number. Because each row is $2k$ places and there are $4$ per rank each rank contains $8k$ places. Counting the initial square we have:\n", - "\n", - "$corner_k = 1 + \\sum_{n=1}^k 8n$\n", - "\n", - "I'm not mathematically sophisticated enough to turn this directly into a formula (but Sympy is, see below.) I'm going to write a simple Python function to iterate and search:" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "def rank_and_offset(n):\n", - " assert n >= 2 # Guard the domain.\n", - " n -= 2 # Subtract two,\n", - " # one for the initial square,\n", - " # and one because we are counting from 1 instead of 0.\n", - " k = 1\n", - " while True:\n", - " m = 8 * k # The number of places total in this rank, 4(2k).\n", - " if n < m:\n", - " return k, n % (2 * k)\n", - " n -= m # Remove this rank's worth.\n", - " k += 1" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 (1, 0)\n", - "3 (1, 1)\n", - "4 (1, 0)\n", - "5 (1, 1)\n", - "6 (1, 0)\n", - "7 (1, 1)\n", - "8 (1, 0)\n", - "9 (1, 1)\n", - "10 (2, 0)\n", - "11 (2, 1)\n", - "12 (2, 2)\n", - "13 (2, 3)\n", - "14 (2, 0)\n", - "15 (2, 1)\n", - "16 (2, 2)\n", - "17 (2, 3)\n", - "18 (2, 0)\n", - "19 (2, 1)\n", - "20 (2, 2)\n", - "21 (2, 3)\n", - "22 (2, 0)\n", - "23 (2, 1)\n", - "24 (2, 2)\n", - "25 (2, 3)\n", - "26 (3, 0)\n", - "27 (3, 1)\n", - "28 (3, 2)\n", - "29 (3, 3)\n", - "30 (3, 4)\n", - "31 (3, 5)\n", - "32 (3, 0)\n", - "33 (3, 1)\n", - "34 (3, 2)\n", - "35 (3, 3)\n", - "36 (3, 4)\n", - "37 (3, 5)\n", - "38 (3, 0)\n", - "39 (3, 1)\n", - "40 (3, 2)\n", - "41 (3, 3)\n", - "42 (3, 4)\n", - "43 (3, 5)\n", - "44 (3, 0)\n", - "45 (3, 1)\n", - "46 (3, 2)\n", - "47 (3, 3)\n", - "48 (3, 4)\n", - "49 (3, 5)\n", - "50 (4, 0)\n" - ] - } - ], - "source": [ - "for n in range(2, 51):\n", - " print n, rank_and_offset(n)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 1\n", - "3 2\n", - "4 1\n", - "5 2\n", - "6 1\n", - "7 2\n", - "8 1\n", - "9 2\n", - "10 3\n", - "11 2\n", - "12 3\n", - "13 4\n", - "14 3\n", - "15 2\n", - "16 3\n", - "17 4\n", - "18 3\n", - "19 2\n", - "20 3\n", - "21 4\n", - "22 3\n", - "23 2\n", - "24 3\n", - "25 4\n", - "26 5\n", - "27 4\n", - "28 3\n", - "29 4\n", - "30 5\n", - "31 6\n", - "32 5\n", - "33 4\n", - "34 3\n", - "35 4\n", - "36 5\n", - "37 6\n", - "38 5\n", - "39 4\n", - "40 3\n", - "41 4\n", - "42 5\n", - "43 6\n", - "44 5\n", - "45 4\n", - "46 3\n", - "47 4\n", - "48 5\n", - "49 6\n", - "50 7\n" - ] - } - ], - "source": [ - "for n in range(2, 51):\n", - " k, i = rank_and_offset(n)\n", - " print n, row_value(k, i)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Putting it all together" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "def row_value(k, i):\n", - " return abs(i - (k - 1)) + k\n", - "\n", - "\n", - "def rank_and_offset(n):\n", - " n -= 2 # Subtract two,\n", - " # one for the initial square,\n", - " # and one because we are counting from 1 instead of 0.\n", - " k = 1\n", - " while True:\n", - " m = 8 * k # The number of places total in this rank, 4(2k).\n", - " if n < m:\n", - " return k, n % (2 * k)\n", - " n -= m # Remove this rank's worth.\n", - " k += 1\n", - "\n", - "\n", - "def aoc20173(n):\n", - " if n <= 1:\n", - " return 0\n", - " k, i = rank_and_offset(n)\n", - " return row_value(k, i)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "2" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "aoc20173(23)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "105" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "aoc20173(23000)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "4572225" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "aoc20173(23000000000000)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Sympy to the Rescue\n", - "### Find the rank for large numbers\n", - "Using e.g. Sympy we can find the rank directly by solving for the roots of an equation. For large numbers this will (eventually) be faster than iterating as `rank_and_offset()` does." - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "from sympy import floor, lambdify, solve, symbols\n", - "from sympy import init_printing\n", - "init_printing() " - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "k = symbols('k')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Since\n", - "\n", - "$1 + 2 + 3 + ... + N = \\frac{N(N + 1)}{2}$\n", - "\n", - "and\n", - "\n", - "$\\sum_{n=1}^k 8n = 8(\\sum_{n=1}^k n) = 8\\frac{k(k + 1)}{2}$\n", - "\n", - "We want:" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHwAAAAUBAMAAAC9l0S6AAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAMpndu3bvImbNiRBU\nq0Qb3U6NAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACAElEQVQ4EW1UzWsTQRx9NB+bzSZt6D/gHvRS\nKOZQWhAK6UHrsRShhyIW2rvBiznp0ltPxdJLDi2h9aIXc7C0emlA6k38wKKXYsA/IFZEhITG95vZ\nj5klD3bmvff7vczsMBvARsOWiSrUE26zSeD1uracGrw7Vbscqm9p99H1BWXNcNzRRZdruL7mxvi+\nDbwxtFDvE151Oec2OAz4EJt8JjrCBGd68r78YLy4pFXkltvIr9Fq7ALjfV2b49Rjr0YYBx7Q8tZs\nN19F+ZJWi/FiVdUcmQ7Dtnh1Hcd+6Ic/6vZVvFBn3PVL9yt8D58tOzj7rDut1XFgx6ky3PMRGD/t\nrPQCIMvHG+Se/IOCHd/SZvTuVL0W9y7xj0ftE+pMByj1V72AnLDj77SZuJhnd0XiN31Vy3eBsd+6\n7UWzOdts7ikhR4drQk13zAfeQuLz95akKPHM+W2hAnt1FTfdZYoPFxd/z70r50r6ZfOn3add4YQd\n/6nN2C35eCzWBgq/vEGRLBsA2zzHFhTseProeNdXpO0PyjVcSrzoA18xUWmRE3Z8SpuR69x6OS3X\n5PnwezbA8irpOPVd5G7ISRFRfPrhXgA8U17susPhUOIm5NImiOLKUTdSmOUmzcLkk0lwnFDjk7Fc\ns4NnV7e1odIfrFGKqVOLaZospo1RujHKFG/0n9V/fdOG1o/ONcUAAAAASUVORK5CYII=\n", - "text/latex": [ - "$$4 k \\left(k + 1\\right) + 2$$" - ], - "text/plain": [ - "4⋅k⋅(k + 1) + 2" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "E = 2 + 8 * k * (k + 1) / 2 # For the reason for adding 2 see above.\n", - "\n", - "E" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can write a function to solve for $k$ given some $n$..." - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "def rank_of(n):\n", - " return floor(max(solve(E - n, k))) + 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "First `solve()` for $E - n = 0$ which has two solutions (because the equation is quadratic so it has two roots) and since we only care about the larger one we use `max()` to select it. It will generally not be a nice integer (unless $n$ is the number of an end-corner of a rank) so we take the `floor()` and add 1 to get the integer rank of $n$. (Taking the `ceiling()` gives off-by-one errors on the rank boundaries. I don't know why. I'm basically like a monkey doing math here.) =-D\n", - "\n", - "It gives correct answers:" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9 1\n", - "10 2\n", - "25 2\n", - "26 3\n", - "49 3\n", - "50 4\n" - ] - } - ], - "source": [ - "for n in (9, 10, 25, 26, 49, 50):\n", - " print n, rank_of(n)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And it runs much faster (at least for large numbers):" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CPU times: user 68 ms, sys: 8 ms, total: 76 ms\n", - "Wall time: 73.8 ms\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEcAAAAPBAMAAABElc8tAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIpm7MhCriUTv3c12\nVGZoascqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABkUlEQVQoFY2QPUscURSGn4l7d4y7q6ONxGqZ\ngEbSCFZWTmfpYCHEFK6CRdIoJmQaYacNBBJJ4wcqKNhYaKNYBFeCnYKLjdhNK4j5NrKbOHlnxx+Q\nAzP33nOf+77nHCy338MKXlUxPW8cMps9QcBIMMF92HOvYRT7lg4KdzyLrHla4zi+Mas8cuDCB7PP\nU5iCRU6r1HgBkzzQZSn7gWzRTE4LairSD0sw7b0NTZ06lLHB9tp2sL/CqaD3egQVXxCyMz+U1o53\njPeR/5lCA0o0YlsvxmZYllKoRB8PpXSbQvWhz0mO5t/Que7Li0oktyjxyt01IFOPWBFDS0k/e4Hc\nYaFchXGdPnH+N4Vin14Z4epTiz5XR2UPjnVoPRm6r6kGX0LIF6EdBiVC0vSGVsj+SmvaEhTBGZYj\n0Qa0p+ndNKBcKYU0PClliuSdj7DtXDqZb5D5Lrd5hp0UGlZN0BXMvuSawh+O/ecSLgjK75oD6SXD\nzM4YdVeJ4xrN7uMQ232iGyvpeNYNoXttL9K221PiP+If4oN7f8ioQFsAAAAASUVORK5CYII=\n", - "text/latex": [ - "$$2397916$$" - ], - "text/plain": [ - "2397916" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%time rank_of(23000000000000) # Compare runtime with rank_and_offset()!" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CPU times: user 308 ms, sys: 0 ns, total: 308 ms\n", - "Wall time: 306 ms\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAALAAAAAUBAMAAADfFKqVAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIma7zZnddlTvRIky\nEKtZsEGBAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADLElEQVQ4Ea2VT2hcVRjFf28yfzNzZ6ZIC9LN\nQwpSXDQahCpiYzdCqWagnYUGw4h/EAo1QkMXin0b3biYqYqkwcJsrLiQBHQMMmJm46qLeUJUumlS\nQaG0UhvHWGrT6bn3PYszuBih3+Lcf+ee993zvncfeD73PBJlSd4HO488Abvb++GH9iUKx2fabczM\nt3bVRfvNTty723jVyQ4RtL8IIL/yjbY8ZHmWfUntU5gNVptehbpv3uf+cqLf79/mgu+dhuxZMdaa\nqSk1A3GR/E0c7CS7iTnEUZKBeTFmr0GiQjEk18jcoFQrNihWUsp0g8vwCxdntyX3KGMTA6oa/AZn\nIjgVsMVYhUn2wpcxOz9HukyuRvHW+CLrU6Up8r/ndbAOPViFjITHrw+ravwRXOs4+KxpeixZ256E\nehixTYNdkNyWsBbq/voEGdv7FPMHnOo44bGGZoZjOpSwA/m1yWN2/TYsBTH7EPNuS1qZmWPklPFN\nTejkHyrjphMuHV553pGG4PVQExZ+XKZ3fr5p/pTwXMxu8YijLy3jffWCfCC5KSd858O074TXD5IL\nHGsAxv/W0MLuV0LT81nw1O8ux+w9vObYxy1+3eRp3rsB6xok57KrQSS8TcoWx1CkNzThIL9o+iHP\nfa+MJRyx32XR8lMVi7mzJE6el8cn7OjBt1Yjj0s1EtafoajasQPOhFuw73MJy4qI3Y2E58ErM6Zk\nKcrtlyKNa6HLOD1FQv4MRcbmYmEHHAhelrCvl1cPYnbXWZGtsKO0HQknNzBi2HhWO/UYFfd/ZPyO\nTcWCXDgQqOr3NScFYcw+517ed/BGboL09cRpumUKOhN7ywXVrxUuyLWGe9K/oFAhU3bwgUqj3JXH\n9gM5+g97Dy25cKw9W0v41Ocyz5iDqksrfCJc8yNhrnAh0EcwELvarV9x8ADZvygumwXSgfkYx4YZ\nzqkAdDnU+KT6OLSqTT1oQRr5qoo3dbn3s+1ehVfDAeHpfn8LB+PVI9rTmu1gVt7uxGwO2096pMiO\nyIvEPNVGZSRddIP8j9AlxMOj8X8ajRaz1tTqoh8l/FFIdzk2W88X3OPQr+kOAx0PXfbg7EwAAAAA\nSUVORK5CYII=\n", - "text/latex": [ - "$$\\left ( 2397916, \\quad 223606\\right )$$" - ], - "text/plain": [ - "(2397916, 223606)" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%time rank_and_offset(23000000000000)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After finding the rank you would still have to find the actual value of the rank's first corner and subtract it (plus 2) from the number and compute the offset as above and then the final output, but this overhead is partially shared by the other method, and overshadowed by the time it (the other iterative method) would take for really big inputs.\n", - "\n", - "The fun thing to do here would be to graph the actual runtime of both methods against each other to find the trade-off point." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### It took me a second to realize I could do this...\n", - "Sympy is a *symbolic* math library, and it supports symbolic manipulation of equations. I can put in $y$ (instead of a value) and ask it to solve for $k$." - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [], - "source": [ - "y = symbols('y')" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [], - "source": [ - "g, f = solve(E - y, k)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The equation is quadratic so there are two roots, we are interested in the greater one..." - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIkAAAAqBAMAAAB1gmW6AAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEM3dMlTvq5l2ZiK7\niUTiBfEGAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB6klEQVRIDe2Uv0vDQBTHv9eiTU2pRQdxsqLo\n4CI6CEKxo5tObqKOThYHEUEUlyKIOklFwf4J4iQ42EEQt86C6Ca62IogqKh3lzQ/nkm8BEdvuL73\nve/ny/WlDfDXayoTJdFNseW1CCk/qaMIKQClaK/2/ShF+/8UYwLuuex8eS86LTdFnpleoXafPjAl\ncedDUTkw5YS6/XqSUlzoL9vWbbsMrNwUsbIsESK12qQX1jTnpfpr7V5HHcW6l+yvXXseJcOlsMG/\nSEmWgc5N6GQOIe8S51epTiFZc19JPYUJcB/QJzeQqiimtA2L1QvI/14Nek6AfCwM82jd5bXlAIy7\nsB6BDOWF0aRE6VyPfbxrqfIt/Y6JvPOokeLWvLuZMhDP8DMtiz1iUZ9L8yAwLehUAZeRU5KfQLeg\ntUr6LXIK+0DTuqDZaundnaItPa+4lZ/d6daFFHeOY8fGKZ/Mr6tBmUZWwO2dqM+r91JaRJfsZeO3\nWZRpSGTQPCvqVG1ASqO4kp+Bm0WZLv5sEi+iTr8WpPRQysvPwM2iTFesbqZgTIFuRNtUQ0HceH0c\nWoJSYVKW96lqlSEKSo2EYG0robR1+0i9olRJHXU4CcV/92eOU8WSUuPAgSLqsBFKz90U+Ush5KJU\njL/8wqcY1Dcp15UsZrvPlwAAAABJRU5ErkJggg==\n", - "text/latex": [ - "$$- \\frac{1}{2} \\sqrt{y - 1} - \\frac{1}{2}$$" - ], - "text/plain": [ - " _______ \n", - " ╲╱ y - 1 1\n", - "- ───────── - ─\n", - " 2 2" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "g" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHgAAAAqBAMAAACKDIIdAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAVO8Qq5l2zWYiuzKJ\nRN0MreaOAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB9ElEQVRIDe2Vu0vDUBTGvzRNSrSNILgX3TVD\nwU2LD3DRVqgIOthF0akdXETQbi4OVXDQoTg46aCLexedCvY/aEHBRVQQfOCj3nOrmCa3ubGuHmjP\nyXe+3z1tb24K/C06rVZ4pYdR6miiFTiWeuAjM63A0P/h322Y8AfTauK4d6wthPccpmaXQni8mduh\ni2Aj6zA1u6zDqb7l3I9DK//UXpU29DTm6ve7lF8Ik0Kvv4OnVgWw34MXzglgwN/BGxCyPuFF9nSY\nT2PbalzE3+QqEFaiyDSy8sk0TE8DW1oWhz5hfgzugUKRASZ7WYE0HllW125ZXJ+w8mtyPwm3qyR0\ncIwqishGlL1vUlnJt79StoXsOyvPzHxJwDT0KGVbyGD0AkqRgAO0xSnbQgpnygjxHZpBJWcDqZTC\ng/vo4kzsfC7fCDcePHtvZ+aIX2ovWPnSp+19cW1MHbJ9UOO4KJPBeIvEKQez6jtl74ghzFxBC4Eo\nNx6H+Kc1c21pb5C6w0A3EKgiWN/WyghnIguzcpb2JnGC0MM3bDpvDa811i2CWZj1Pzx938vt7t1Z\npFWK7o5cibxxz5XcKXCYcRK1pKAll6a4ZV5uFDh0PlJJYlfQlEldMPLAKbAkc7r77UnoeRg3pVTV\n3ZQphdLZBBBiD5QW4PVa7QOfZ0qXehvwRMIAAAAASUVORK5CYII=\n", - "text/latex": [ - "$$\\frac{1}{2} \\sqrt{y - 1} - \\frac{1}{2}$$" - ], - "text/plain": [ - " _______ \n", - "╲╱ y - 1 1\n", - "───────── - ─\n", - " 2 2" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "f" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can take the `floor()`, add 1, and `lambdify()` the equation to get a Python function that calculates the rank directly." - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAK0AAAAqBAMAAAAzNMYQAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEGYiq+/dVJl2zbsy\niUT7WiApAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACUUlEQVRIDe2Uv2/TQBTHv1YgsdMmRCUwdCEz\nElIHCANLqAAx0TLASpEgAwxMSGXrUImqVCJigimRqBgipHZg60D+BEZAQup/EH5ISCBKuPfsc8/2\nw2fHYuOk5L177/v9+Hw+G/ino3J9GrzV1Vz/MgU3g8ubhgu7y66Q7sfusiv+c6Ud8Gv23Ysq3Ik8\nPscuEXXFmjyNKi5IEqEWdQmC2Em8JkmEWhp3jvURRWkgMKRS4PKk3lkqupd/Lh423f3DPC3Trqok\nYm60MR+dWmdZuY9F0sOGWFbFBJekyfU6KwLAubpk5T7yfb40ya21BC7Qz8r1pUnuSRFbnPsMcJ73\ncC62vsLrXQFqlWX0Y8suwqUlej3gvDvAXnHuMf7MAO13ilVWv8bRHn6o6LzqqnFvpNJgf+ep0H1N\nBe3yz9nH4fDucLhNDZYaz61+elkVz1BnvDD7i6IxCuxD5avi3CbWJjy6hjkKcHETqNBe4A1mOiZU\n5UW4/X1UG8R7gnGLojGKcE/tYpVRzQ9PFwymStdvbbeilXCmvw/Be+xL+bmVNvZGJHO/4WUg3wxi\nStCuOJctzG2i9ptmpYN6h+KRgcNzyv8+tEtzj5tS5l4EbnDxbZVvv9ya6ZkiOdcuzY2omKvOwdKI\nyuNL3Ky/2OKY/qddIvdE9w6w0wi45fjbkEb2Xe3u/TTRAz5f3m6aJtnzXcl6WKkfhGmOxO4qd3Lg\nQqndtRFq8yRWl7eWB6e1dtcqSnxwtSNbtLpm1+Dl59pd7U/vr2Rboqmyu3Ymk++mI1ue5voDRu6s\n5n/E50UAAAAASUVORK5CYII=\n", - "text/latex": [ - "$$\\lfloor{\\frac{1}{2} \\sqrt{y - 1} - \\frac{1}{2}}\\rfloor + 1$$" - ], - "text/plain": [ - "⎢ _______ ⎥ \n", - "⎢╲╱ y - 1 1⎥ \n", - "⎢───────── - ─⎥ + 1\n", - "⎣ 2 2⎦ " - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "floor(f) + 1" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [], - "source": [ - "F = lambdify(y, floor(f) + 1)" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9 1\n", - "10 2\n", - "25 2\n", - "26 3\n", - "49 3\n", - "50 4\n" - ] - } - ], - "source": [ - "for n in (9, 10, 25, 26, 49, 50):\n", - " print n, int(F(n))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It's pretty fast." - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", - "Wall time: 11.9 µs\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEcAAAAPBAMAAABElc8tAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIpm7MhCriUTv3c12\nVGZoascqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABkUlEQVQoFY2QPUscURSGn4l7d4y7q6ONxGqZ\ngEbSCFZWTmfpYCHEFK6CRdIoJmQaYacNBBJJ4wcqKNhYaKNYBFeCnYKLjdhNK4j5NrKbOHlnxx+Q\nAzP33nOf+77nHCy338MKXlUxPW8cMps9QcBIMMF92HOvYRT7lg4KdzyLrHla4zi+Mas8cuDCB7PP\nU5iCRU6r1HgBkzzQZSn7gWzRTE4LairSD0sw7b0NTZ06lLHB9tp2sL/CqaD3egQVXxCyMz+U1o53\njPeR/5lCA0o0YlsvxmZYllKoRB8PpXSbQvWhz0mO5t/Que7Li0oktyjxyt01IFOPWBFDS0k/e4Hc\nYaFchXGdPnH+N4Vin14Z4epTiz5XR2UPjnVoPRm6r6kGX0LIF6EdBiVC0vSGVsj+SmvaEhTBGZYj\n0Qa0p+ndNKBcKYU0PClliuSdj7DtXDqZb5D5Lrd5hp0UGlZN0BXMvuSawh+O/ecSLgjK75oD6SXD\nzM4YdVeJ4xrN7uMQ232iGyvpeNYNoXttL9K221PiP+If4oN7f8ioQFsAAAAASUVORK5CYII=\n", - "text/latex": [ - "$$2397916$$" - ], - "text/plain": [ - "2397916" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%time int(F(23000000000000)) # The clear winner." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Knowing the equation we could write our own function manually, but the speed is no better." - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [], - "source": [ - "from math import floor as mfloor, sqrt\n", - "\n", - "def mrank_of(n):\n", - " return int(mfloor(sqrt(23000000000000 - 1) / 2 - 0.5) + 1)" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", - "Wall time: 12.9 µs\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEcAAAAPBAMAAABElc8tAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIpm7MhCriUTv3c12\nVGZoascqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABkUlEQVQoFY2QPUscURSGn4l7d4y7q6ONxGqZ\ngEbSCFZWTmfpYCHEFK6CRdIoJmQaYacNBBJJ4wcqKNhYaKNYBFeCnYKLjdhNK4j5NrKbOHlnxx+Q\nAzP33nOf+77nHCy338MKXlUxPW8cMps9QcBIMMF92HOvYRT7lg4KdzyLrHla4zi+Mas8cuDCB7PP\nU5iCRU6r1HgBkzzQZSn7gWzRTE4LairSD0sw7b0NTZ06lLHB9tp2sL/CqaD3egQVXxCyMz+U1o53\njPeR/5lCA0o0YlsvxmZYllKoRB8PpXSbQvWhz0mO5t/Que7Li0oktyjxyt01IFOPWBFDS0k/e4Hc\nYaFchXGdPnH+N4Vin14Z4epTiz5XR2UPjnVoPRm6r6kGX0LIF6EdBiVC0vSGVsj+SmvaEhTBGZYj\n0Qa0p+ndNKBcKYU0PClliuSdj7DtXDqZb5D5Lrd5hp0UGlZN0BXMvuSawh+O/ecSLgjK75oD6SXD\nzM4YdVeJ4xrN7uMQ232iGyvpeNYNoXttL9K221PiP+If4oN7f8ioQFsAAAAASUVORK5CYII=\n", - "text/latex": [ - "$$2397916$$" - ], - "text/plain": [ - "2397916" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%time mrank_of(23000000000000)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Given $n$ and a rank, compute the offset.\n", - "\n", - "Now that we have a fast way to get the rank, we still need to use it to compute the offset into a pyramid row." - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [], - "source": [ - "def offset_of(n, k):\n", - " return (n - 2 + 4 * k * (k - 1)) % (2 * k)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "(Note the sneaky way the sign changes from $k(k + 1)$ to $k(k - 1)$. This is because we want to subract the $(k - 1)$th rank's total places (its own and those of lesser rank) from our $n$ of rank $k$. Substituting $k - 1$ for $k$ in $k(k + 1)$ gives $(k - 1)(k - 1 + 1)$, which of course simplifies to $k(k - 1)$.)" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAADsAAAAOBAMAAABjvHmeAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIpm7MhCriUTv3c12\nVGZoascqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABIElEQVQYGTWQoU8DMRSHvwuULWNLDgwJ6jIS\nCJlcQoLaOeSKQaAwCDAsg2WCiTMI1AQIRjIBFoHFjSCwNPwDmyMYSBBAdoTjtR2iX76+X/r6WoJy\nNcajfWgg1zlCrbzE3tgi9+0xT+kXdUeFWaOuvLELPY8nw5ipiCqvcOyNSziIHU4TldINgTUYamcM\ntMQO2ObrkvIJXePM7m71BNsN0o2HRH1IfG/NpvmvCRautUpH9AMp1FvWbFzY+UfuQmWa1U05XW9Z\ns23Lsjzo6TG8n7jm1hIoRpJazEHN3EhxJKMNvcEzQegg3Wpmz56pCrQzpiOKocOZvCGsy432Wyo4\nY7Hd3Pd4o/TDTEP1KRh17o1Blo098uUlGaW5HKM6j7G3P7xTb/ft54xWAAAAAElFTkSuQmCC\n", - "text/latex": [ - "$$223606$$" - ], - "text/plain": [ - "223606" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "offset_of(23000000000000, 2397916)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "So, we can compute the rank, then the offset, then the row value." - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [], - "source": [ - "def rank_of(n):\n", - " return int(mfloor(sqrt(n - 1) / 2 - 0.5) + 1)\n", - "\n", - "\n", - "def offset_of(n, k):\n", - " return (n - 2 + 4 * k * (k - 1)) % (2 * k)\n", - "\n", - "\n", - "def row_value(k, i):\n", - " return abs(i - (k - 1)) + k\n", - "\n", - "\n", - "def aoc20173(n):\n", - " k = rank_of(n)\n", - " i = offset_of(n, k)\n", - " return row_value(k, i)" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAkAAAAOBAMAAAAPuiubAAAALVBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAOrOgAAAADnRSTlMAIpm7MhCriUTv3c12VLge\nopIAAAAJcEhZcwAADsQAAA7EAZUrDhsAAABOSURBVAgdY2BUMnZgYAhjYH/BwJDKwDCTgWEWA0Oe\nA8O+ABAJBOsCgATHcxCTKwFEKoEIHgUQeYmBUYCBRYGBR4BBqrwoi4Fh37t3rxgAK5QOlzv7snYA\nAAAASUVORK5CYII=\n", - "text/latex": [ - "$$2$$" - ], - "text/plain": [ - "2" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "aoc20173(23)" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAB0AAAAPBAMAAADqo9msAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAVO8Qq5l2zWaJMt0i\nu0SCRuA9AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAArElEQVQIHWNgAAHmyM4FDOzJXIFANqMyAwO7\nAPMeBqb//ycwMJiEfGZgaGJgmM7APiUHpJYNyL/CwCBvwALiQfhfGBjeCyD4zF+B/ASWjtQFEHme\nnwwM6yfwGvD8g/KB8uuBZjPchvAh6oHs+ANw8+QF3BkY5j+A8O8yMPQbqAPlDSB8oHvCGQIYGLZD\n9DNwCzBrMRxl4NBhYGB1+u7BwDwtZQEDT6QrUDkaAADf+TCFzC1FdQAAAABJRU5ErkJggg==\n", - "text/latex": [ - "$$105$$" - ], - "text/plain": [ - "105" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "aoc20173(23000)" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEgAAAAPBAMAAAC1npSgAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAMpndu3bvImbNiRBU\nq0Qb3U6NAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABGklEQVQoFYWQsUrDUBRAT6I1pVYJ/YLYURcH\nV9HBzS9wtjgJPnRx00XnDLq4tIhTQOjiIojiLghSKEjRxR9QUajU5715hfc2Qzi83HMgjwvQgNNu\n4y5ani8KkuZaGqA00rAEO3ZI1Vo74obab4DSSFNpwVnPEBt45Bm2ApRGov0TlVCTN2UTXlKP0ojs\njCM5vkG7K5HHOKoaifpHc9KwqmClG8CZKyRa5+BV/nYoltlhCGc6GsHkItzqgQm9oIeaeuqi+Bs2\nyqip9EDMNRLN5LodXZhsJAvhzMNg8NWbyol/mB5pdE9iPJyRcYtYLpETvctHlFExHs7I/JMk49hQ\n12ivOH8K4Axc2D67lwuQbEvUtvYjgDMy//f5A0ICeXTNG40LAAAAAElFTkSuQmCC\n", - "text/latex": [ - "$$4572225$$" - ], - "text/plain": [ - "4572225" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "aoc20173(23000000000000)" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", - "Wall time: 20 µs\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIUAAAAPBAMAAAA43xGxAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIpm7MhCriUTv3c12\nVGZoascqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACa0lEQVQoFaXTT0gUYRjH8e/+mZ11d50duhWE\nw9JfvAxJQaeGIDw6eCjMg1uUUUQuInpIci6dXaGCCsvOEe2hfwfTJaKIhLYIOrqeQhLUcl3RdHve\neTfo3h6GnefzPj/e99l3ieQ6PDBHhzAODtvy+C6v3TeGgJH3HpqJO5qZ9k9W6B451+Swh9OYGxiv\naKenGpkgXTEewWvO2vQG0ZJmSLmaedioYzxgd5PDHi7CXWIOHVyG8yzCdawiZokjxFzN8MHVzMur\nNokiCUdz2MM9GPDGbdnbFoxxDOb9WJ7WWnJVapqJ/HA1k5datoS5ojnsYdaXjOMixi/45K3DeCWb\nJ7kdK0pRM2ba1Rxm9Llk1kJuFmXdU3+r803AfdnHzZ+SUe5zSP7OPhs9pFKEWUi7IQdcW9pHi+xj\nQ7PqCWRNsm5sVZmUgzC7UIeuQluBeL1vhpZKyBhlyVBc5ShtgblCekezLsrM80bD57CfLreOfZZ9\nSIajMmpEb0tGKo+JZChWmbEppvm2rflvMQebsByw9Hbs1D9nmcLakB7hrypDsSfv0VWsuc61rGZd\nzDjwWDKq4gO+zHRezbR1O1XC2gFhoxBmKE6oUcjCRK3JqghfiNjyM8s+4IVcE5Z9uRdWTW6B2ofw\n3v7+gTvlkGWc0Zp8S+ebrHrULc7YXTIPFu34qrpj7VhFoqW4zKOoGVpczVGZT8maoMvWHPawZ2Tw\nComCMclHv7dKqmLcgif0eFyip6JZrpWrOeJIVua5MYPmsIfZRkMmOnjAw8zJfTBG33lwZu6C/A9z\n8tBsnlivhsyu4f2yOhc0WRflcP/7+QN1gvGXxRfSRAAAAABJRU5ErkJggg==\n", - "text/latex": [ - "$$2690062495969$$" - ], - "text/plain": [ - "2690062495969" - ] - }, - "execution_count": 37, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%time aoc20173(23000000000000000000000000) # Fast for large values." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A Joy Version\n", - "At this point I feel confident that I can implement a concise version of this code in Joy. ;-)" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import J, V, define" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `rank_of`\n", - "\n", - " n rank_of\n", - " ---------------\n", - " k\n", - "\n", - "The translation is straightforward.\n", - "\n", - " int(floor(sqrt(n - 1) / 2 - 0.5) + 1)\n", - "\n", - " rank_of == -- sqrt 2 / 0.5 - floor ++" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [], - "source": [ - "define('rank_of == -- sqrt 2 / 0.5 - floor ++')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `offset_of`\n", - "\n", - " n k offset_of\n", - " -------------------\n", - " i\n", - "\n", - " (n - 2 + 4 * k * (k - 1)) % (2 * k)\n", - "\n", - "A little tricky...\n", - "\n", - " n k dup 2 *\n", - " n k k 2 *\n", - " n k k*2 [Q] dip %\n", - " n k Q k*2 %\n", - "\n", - " n k dup --\n", - " n k k --\n", - " n k k-1 4 * * 2 + -\n", - " n k*k-1*4 2 + -\n", - " n k*k-1*4+2 -\n", - " n-k*k-1*4+2\n", - "\n", - " n-k*k-1*4+2 k*2 %\n", - " n-k*k-1*4+2%k*2\n", - "\n", - "Ergo:\n", - "\n", - " offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [], - "source": [ - "define('offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `row_value`\n", - "\n", - " k i row_value\n", - " -------------------\n", - " n\n", - "\n", - " abs(i - (k - 1)) + k\n", - "\n", - " k i over -- - abs +\n", - " k i k -- - abs +\n", - " k i k-1 - abs +\n", - " k i-k-1 abs +\n", - " k |i-k-1| +\n", - " k+|i-k-1|" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": {}, - "outputs": [], - "source": [ - "define('row_value == over -- - abs +')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `aoc2017.3`\n", - "\n", - " n aoc2017.3\n", - " -----------------\n", - " m\n", - "\n", - " n dup rank_of\n", - " n k [offset_of] dupdip\n", - " n k offset_of k\n", - " i k swap row_value\n", - " k i row_value\n", - " m" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [], - "source": [ - "define('aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value')" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('23 aoc2017.3')" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "105\n" - ] - } - ], - "source": [ - "J('23000 aoc2017.3')" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 23000000000000 aoc2017.3\n", - " 23000000000000 . aoc2017.3\n", - " 23000000000000 . dup rank_of [offset_of] dupdip swap row_value\n", - " 23000000000000 23000000000000 . rank_of [offset_of] dupdip swap row_value\n", - " 23000000000000 23000000000000 . -- sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 22999999999999 . sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 4795831.523312615 . 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 4795831.523312615 2 . / 0.5 - floor ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 2397915.7616563076 . 0.5 - floor ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 2397915.7616563076 0.5 . - floor ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 2397915.2616563076 . floor ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 2397915 . ++ [offset_of] dupdip swap row_value\n", - " 23000000000000 2397916 . [offset_of] dupdip swap row_value\n", - " 23000000000000 2397916 [offset_of] . dupdip swap row_value\n", - " 23000000000000 2397916 . offset_of 2397916 swap row_value\n", - " 23000000000000 2397916 . dup 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value\n", - " 23000000000000 2397916 2397916 . 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value\n", - " 23000000000000 2397916 2397916 2 . * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value\n", - " 23000000000000 2397916 4795832 . [dup -- 4 * * 2 + -] dip % 2397916 swap row_value\n", - "23000000000000 2397916 4795832 [dup -- 4 * * 2 + -] . dip % 2397916 swap row_value\n", - " 23000000000000 2397916 . dup -- 4 * * 2 + - 4795832 % 2397916 swap row_value\n", - " 23000000000000 2397916 2397916 . -- 4 * * 2 + - 4795832 % 2397916 swap row_value\n", - " 23000000000000 2397916 2397915 . 4 * * 2 + - 4795832 % 2397916 swap row_value\n", - " 23000000000000 2397916 2397915 4 . * * 2 + - 4795832 % 2397916 swap row_value\n", - " 23000000000000 2397916 9591660 . * 2 + - 4795832 % 2397916 swap row_value\n", - " 23000000000000 22999994980560 . 2 + - 4795832 % 2397916 swap row_value\n", - " 23000000000000 22999994980560 2 . + - 4795832 % 2397916 swap row_value\n", - " 23000000000000 22999994980562 . - 4795832 % 2397916 swap row_value\n", - " 5019438 . 4795832 % 2397916 swap row_value\n", - " 5019438 4795832 . % 2397916 swap row_value\n", - " 223606 . 2397916 swap row_value\n", - " 223606 2397916 . swap row_value\n", - " 2397916 223606 . row_value\n", - " 2397916 223606 . over -- - abs +\n", - " 2397916 223606 2397916 . -- - abs +\n", - " 2397916 223606 2397915 . - abs +\n", - " 2397916 -2174309 . abs +\n", - " 2397916 2174309 . +\n", - " 4572225 . \n" - ] - } - ], - "source": [ - "V('23000000000000 aoc2017.3')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " rank_of == -- sqrt 2 / 0.5 - floor ++\n", - " offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %\n", - " row_value == over -- - abs +\n", - "\n", - " aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Advent of Code 2017 December 3rd.md b/docs/Advent of Code 2017 December 3rd.md deleted file mode 100644 index d6de378..0000000 --- a/docs/Advent of Code 2017 December 3rd.md +++ /dev/null @@ -1,843 +0,0 @@ - -# Advent of Code 2017 - -## December 3rd - -You come across an experimental new kind of memory stored on an infinite two-dimensional grid. - -Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up while spiraling outward. For example, the first few squares are allocated like this: - - 17 16 15 14 13 - 18 5 4 3 12 - 19 6 1 2 11 - 20 7 8 9 10 - 21 22 23---> ... - -While this is very space-efficient (no squares are skipped), requested data must be carried back to square 1 (the location of the only access port for this memory system) by programs that can only move up, down, left, or right. They always take the shortest path: the Manhattan Distance between the location of the data and square 1. - -For example: - -* Data from square 1 is carried 0 steps, since it's at the access port. -* Data from square 12 is carried 3 steps, such as: down, left, left. -* Data from square 23 is carried only 2 steps: up twice. -* Data from square 1024 must be carried 31 steps. - -How many steps are required to carry the data from the square identified in your puzzle input all the way to the access port? - -### Analysis - -I freely admit that I worked out the program I wanted to write using graph paper and some Python doodles. There's no point in trying to write a Joy program until I'm sure I understand the problem well enough. - -The first thing I did was to write a column of numbers from 1 to n (32 as it happens) and next to them the desired output number, to look for patterns directly: - - 1 0 - 2 1 - 3 2 - 4 1 - 5 2 - 6 1 - 7 2 - 8 1 - 9 2 - 10 3 - 11 2 - 12 3 - 13 4 - 14 3 - 15 2 - 16 3 - 17 4 - 18 3 - 19 2 - 20 3 - 21 4 - 22 3 - 23 2 - 24 3 - 25 4 - 26 5 - 27 4 - 28 3 - 29 4 - 30 5 - 31 6 - 32 5 - -There are four groups repeating for a given "rank", then the pattern enlarges and four groups repeat again, etc. - - 1 2 - 3 2 3 4 - 5 4 3 4 5 6 - 7 6 5 4 5 6 7 8 - 9 8 7 6 5 6 7 8 9 10 - -Four of this pyramid interlock to tile the plane extending from the initial "1" square. - - - 2 3 | 4 5 | 6 7 | 8 9 - 10 11 12 13|14 15 16 17|18 19 20 21|22 23 24 25 - -And so on. - -We can figure out the pattern for a row of the pyramid at a given "rank" $k$: - -$2k - 1, 2k - 2, ..., k, k + 1, k + 2, ..., 2k$ - -or - -$k + (k - 1), k + (k - 2), ..., k, k + 1, k + 2, ..., k + k$ - -This shows that the series consists at each place of $k$ plus some number that begins at $k - 1$, decreases to zero, then increases to $k$. Each row has $2k$ members. - -Let's figure out how, given an index into a row, we can calculate the value there. The index will be from 0 to $k - 1$. - - Let's look at an example, with $k = 4$: - - 0 1 2 3 4 5 6 7 - 7 6 5 4 5 6 7 8 - - -```python -k = 4 -``` - -Subtract $k$ from the index and take the absolute value: - - -```python -for n in range(2 * k): - print abs(n - k), -``` - - 4 3 2 1 0 1 2 3 - - -Not quite. Subtract $k - 1$ from the index and take the absolute value: - - -```python -for n in range(2 * k): - print abs(n - (k - 1)), -``` - - 3 2 1 0 1 2 3 4 - - -Great, now add $k$... - - -```python -for n in range(2 * k): - print abs(n - (k - 1)) + k, -``` - - 7 6 5 4 5 6 7 8 - - -So to write a function that can give us the value of a row at a given index: - - -```python -def row_value(k, i): - i %= (2 * k) # wrap the index at the row boundary. - return abs(i - (k - 1)) + k -``` - - -```python -k = 5 -for i in range(2 * k): - print row_value(k, i), -``` - - 9 8 7 6 5 6 7 8 9 10 - - -(I'm leaving out details of how I figured this all out and just giving the relevent bits. It took a little while to zero in of the aspects of the pattern that were important for the task.) - -### Finding the rank and offset of a number. -Now that we can compute the desired output value for a given rank and the offset (index) into that rank, we need to determine how to find the rank and offset of a number. - -The rank is easy to find by iteratively stripping off the amount already covered by previous ranks until you find the one that brackets the target number. Because each row is $2k$ places and there are $4$ per rank each rank contains $8k$ places. Counting the initial square we have: - -$corner_k = 1 + \sum_{n=1}^k 8n$ - -I'm not mathematically sophisticated enough to turn this directly into a formula (but Sympy is, see below.) I'm going to write a simple Python function to iterate and search: - - -```python -def rank_and_offset(n): - assert n >= 2 # Guard the domain. - n -= 2 # Subtract two, - # one for the initial square, - # and one because we are counting from 1 instead of 0. - k = 1 - while True: - m = 8 * k # The number of places total in this rank, 4(2k). - if n < m: - return k, n % (2 * k) - n -= m # Remove this rank's worth. - k += 1 -``` - - -```python -for n in range(2, 51): - print n, rank_and_offset(n) -``` - - 2 (1, 0) - 3 (1, 1) - 4 (1, 0) - 5 (1, 1) - 6 (1, 0) - 7 (1, 1) - 8 (1, 0) - 9 (1, 1) - 10 (2, 0) - 11 (2, 1) - 12 (2, 2) - 13 (2, 3) - 14 (2, 0) - 15 (2, 1) - 16 (2, 2) - 17 (2, 3) - 18 (2, 0) - 19 (2, 1) - 20 (2, 2) - 21 (2, 3) - 22 (2, 0) - 23 (2, 1) - 24 (2, 2) - 25 (2, 3) - 26 (3, 0) - 27 (3, 1) - 28 (3, 2) - 29 (3, 3) - 30 (3, 4) - 31 (3, 5) - 32 (3, 0) - 33 (3, 1) - 34 (3, 2) - 35 (3, 3) - 36 (3, 4) - 37 (3, 5) - 38 (3, 0) - 39 (3, 1) - 40 (3, 2) - 41 (3, 3) - 42 (3, 4) - 43 (3, 5) - 44 (3, 0) - 45 (3, 1) - 46 (3, 2) - 47 (3, 3) - 48 (3, 4) - 49 (3, 5) - 50 (4, 0) - - - -```python -for n in range(2, 51): - k, i = rank_and_offset(n) - print n, row_value(k, i) -``` - - 2 1 - 3 2 - 4 1 - 5 2 - 6 1 - 7 2 - 8 1 - 9 2 - 10 3 - 11 2 - 12 3 - 13 4 - 14 3 - 15 2 - 16 3 - 17 4 - 18 3 - 19 2 - 20 3 - 21 4 - 22 3 - 23 2 - 24 3 - 25 4 - 26 5 - 27 4 - 28 3 - 29 4 - 30 5 - 31 6 - 32 5 - 33 4 - 34 3 - 35 4 - 36 5 - 37 6 - 38 5 - 39 4 - 40 3 - 41 4 - 42 5 - 43 6 - 44 5 - 45 4 - 46 3 - 47 4 - 48 5 - 49 6 - 50 7 - - -### Putting it all together - - -```python -def row_value(k, i): - return abs(i - (k - 1)) + k - - -def rank_and_offset(n): - n -= 2 # Subtract two, - # one for the initial square, - # and one because we are counting from 1 instead of 0. - k = 1 - while True: - m = 8 * k # The number of places total in this rank, 4(2k). - if n < m: - return k, n % (2 * k) - n -= m # Remove this rank's worth. - k += 1 - - -def aoc20173(n): - if n <= 1: - return 0 - k, i = rank_and_offset(n) - return row_value(k, i) -``` - - -```python -aoc20173(23) -``` - - - - - 2 - - - - -```python -aoc20173(23000) -``` - - - - - 105 - - - - -```python -aoc20173(23000000000000) -``` - - - - - 4572225 - - - -# Sympy to the Rescue -### Find the rank for large numbers -Using e.g. Sympy we can find the rank directly by solving for the roots of an equation. For large numbers this will (eventually) be faster than iterating as `rank_and_offset()` does. - - -```python -from sympy import floor, lambdify, solve, symbols -from sympy import init_printing -init_printing() -``` - - -```python -k = symbols('k') -``` - -Since - -$1 + 2 + 3 + ... + N = \frac{N(N + 1)}{2}$ - -and - -$\sum_{n=1}^k 8n = 8(\sum_{n=1}^k n) = 8\frac{k(k + 1)}{2}$ - -We want: - - -```python -E = 2 + 8 * k * (k + 1) / 2 # For the reason for adding 2 see above. - -E -``` - - - - -$$4 k \left(k + 1\right) + 2$$ - - - -We can write a function to solve for $k$ given some $n$... - - -```python -def rank_of(n): - return floor(max(solve(E - n, k))) + 1 -``` - -First `solve()` for $E - n = 0$ which has two solutions (because the equation is quadratic so it has two roots) and since we only care about the larger one we use `max()` to select it. It will generally not be a nice integer (unless $n$ is the number of an end-corner of a rank) so we take the `floor()` and add 1 to get the integer rank of $n$. (Taking the `ceiling()` gives off-by-one errors on the rank boundaries. I don't know why. I'm basically like a monkey doing math here.) =-D - -It gives correct answers: - - -```python -for n in (9, 10, 25, 26, 49, 50): - print n, rank_of(n) -``` - - 9 1 - 10 2 - 25 2 - 26 3 - 49 3 - 50 4 - - -And it runs much faster (at least for large numbers): - - -```python -%time rank_of(23000000000000) # Compare runtime with rank_and_offset()! -``` - - CPU times: user 68 ms, sys: 8 ms, total: 76 ms - Wall time: 73.8 ms - - - - - -$$2397916$$ - - - - -```python -%time rank_and_offset(23000000000000) -``` - - CPU times: user 308 ms, sys: 0 ns, total: 308 ms - Wall time: 306 ms - - - - - -$$\left ( 2397916, \quad 223606\right )$$ - - - -After finding the rank you would still have to find the actual value of the rank's first corner and subtract it (plus 2) from the number and compute the offset as above and then the final output, but this overhead is partially shared by the other method, and overshadowed by the time it (the other iterative method) would take for really big inputs. - -The fun thing to do here would be to graph the actual runtime of both methods against each other to find the trade-off point. - -### It took me a second to realize I could do this... -Sympy is a *symbolic* math library, and it supports symbolic manipulation of equations. I can put in $y$ (instead of a value) and ask it to solve for $k$. - - -```python -y = symbols('y') -``` - - -```python -g, f = solve(E - y, k) -``` - -The equation is quadratic so there are two roots, we are interested in the greater one... - - -```python -g -``` - - - - -$$- \frac{1}{2} \sqrt{y - 1} - \frac{1}{2}$$ - - - - -```python -f -``` - - - - -$$\frac{1}{2} \sqrt{y - 1} - \frac{1}{2}$$ - - - -Now we can take the `floor()`, add 1, and `lambdify()` the equation to get a Python function that calculates the rank directly. - - -```python -floor(f) + 1 -``` - - - - -$$\lfloor{\frac{1}{2} \sqrt{y - 1} - \frac{1}{2}}\rfloor + 1$$ - - - - -```python -F = lambdify(y, floor(f) + 1) -``` - - -```python -for n in (9, 10, 25, 26, 49, 50): - print n, int(F(n)) -``` - - 9 1 - 10 2 - 25 2 - 26 3 - 49 3 - 50 4 - - -It's pretty fast. - - -```python -%time int(F(23000000000000)) # The clear winner. -``` - - CPU times: user 0 ns, sys: 0 ns, total: 0 ns - Wall time: 11.9 µs - - - - - -$$2397916$$ - - - -Knowing the equation we could write our own function manually, but the speed is no better. - - -```python -from math import floor as mfloor, sqrt - -def mrank_of(n): - return int(mfloor(sqrt(23000000000000 - 1) / 2 - 0.5) + 1) -``` - - -```python -%time mrank_of(23000000000000) -``` - - CPU times: user 0 ns, sys: 0 ns, total: 0 ns - Wall time: 12.9 µs - - - - - -$$2397916$$ - - - -### Given $n$ and a rank, compute the offset. - -Now that we have a fast way to get the rank, we still need to use it to compute the offset into a pyramid row. - - -```python -def offset_of(n, k): - return (n - 2 + 4 * k * (k - 1)) % (2 * k) -``` - -(Note the sneaky way the sign changes from $k(k + 1)$ to $k(k - 1)$. This is because we want to subract the $(k - 1)$th rank's total places (its own and those of lesser rank) from our $n$ of rank $k$. Substituting $k - 1$ for $k$ in $k(k + 1)$ gives $(k - 1)(k - 1 + 1)$, which of course simplifies to $k(k - 1)$.) - - -```python -offset_of(23000000000000, 2397916) -``` - - - - -$$223606$$ - - - -So, we can compute the rank, then the offset, then the row value. - - -```python -def rank_of(n): - return int(mfloor(sqrt(n - 1) / 2 - 0.5) + 1) - - -def offset_of(n, k): - return (n - 2 + 4 * k * (k - 1)) % (2 * k) - - -def row_value(k, i): - return abs(i - (k - 1)) + k - - -def aoc20173(n): - k = rank_of(n) - i = offset_of(n, k) - return row_value(k, i) -``` - - -```python -aoc20173(23) -``` - - - - -$$2$$ - - - - -```python -aoc20173(23000) -``` - - - - -$$105$$ - - - - -```python -aoc20173(23000000000000) -``` - - - - -$$4572225$$ - - - - -```python -%time aoc20173(23000000000000000000000000) # Fast for large values. -``` - - CPU times: user 0 ns, sys: 0 ns, total: 0 ns - Wall time: 20 µs - - - - - -$$2690062495969$$ - - - -# A Joy Version -At this point I feel confident that I can implement a concise version of this code in Joy. ;-) - - -```python -from notebook_preamble import J, V, define -``` - -### `rank_of` - - n rank_of - --------------- - k - -The translation is straightforward. - - int(floor(sqrt(n - 1) / 2 - 0.5) + 1) - - rank_of == -- sqrt 2 / 0.5 - floor ++ - - -```python -define('rank_of == -- sqrt 2 / 0.5 - floor ++') -``` - -### `offset_of` - - n k offset_of - ------------------- - i - - (n - 2 + 4 * k * (k - 1)) % (2 * k) - -A little tricky... - - n k dup 2 * - n k k 2 * - n k k*2 [Q] dip % - n k Q k*2 % - - n k dup -- - n k k -- - n k k-1 4 * * 2 + - - n k*k-1*4 2 + - - n k*k-1*4+2 - - n-k*k-1*4+2 - - n-k*k-1*4+2 k*2 % - n-k*k-1*4+2%k*2 - -Ergo: - - offset_of == dup 2 * [dup -- 4 * * 2 + -] dip % - - -```python -define('offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %') -``` - -### `row_value` - - k i row_value - ------------------- - n - - abs(i - (k - 1)) + k - - k i over -- - abs + - k i k -- - abs + - k i k-1 - abs + - k i-k-1 abs + - k |i-k-1| + - k+|i-k-1| - - -```python -define('row_value == over -- - abs +') -``` - -### `aoc2017.3` - - n aoc2017.3 - ----------------- - m - - n dup rank_of - n k [offset_of] dupdip - n k offset_of k - i k swap row_value - k i row_value - m - - -```python -define('aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value') -``` - - -```python -J('23 aoc2017.3') -``` - - 2 - - - -```python -J('23000 aoc2017.3') -``` - - 105 - - - -```python -V('23000000000000 aoc2017.3') -``` - - . 23000000000000 aoc2017.3 - 23000000000000 . aoc2017.3 - 23000000000000 . dup rank_of [offset_of] dupdip swap row_value - 23000000000000 23000000000000 . rank_of [offset_of] dupdip swap row_value - 23000000000000 23000000000000 . -- sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 22999999999999 . sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 4795831.523312615 . 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 4795831.523312615 2 . / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915.7616563076 . 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915.7616563076 0.5 . - floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915.2616563076 . floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915 . ++ [offset_of] dupdip swap row_value - 23000000000000 2397916 . [offset_of] dupdip swap row_value - 23000000000000 2397916 [offset_of] . dupdip swap row_value - 23000000000000 2397916 . offset_of 2397916 swap row_value - 23000000000000 2397916 . dup 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 2397916 . 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 2397916 2 . * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 4795832 . [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 4795832 [dup -- 4 * * 2 + -] . dip % 2397916 swap row_value - 23000000000000 2397916 . dup -- 4 * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 2397916 . -- 4 * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 2397915 . 4 * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 2397915 4 . * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 9591660 . * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 22999994980560 . 2 + - 4795832 % 2397916 swap row_value - 23000000000000 22999994980560 2 . + - 4795832 % 2397916 swap row_value - 23000000000000 22999994980562 . - 4795832 % 2397916 swap row_value - 5019438 . 4795832 % 2397916 swap row_value - 5019438 4795832 . % 2397916 swap row_value - 223606 . 2397916 swap row_value - 223606 2397916 . swap row_value - 2397916 223606 . row_value - 2397916 223606 . over -- - abs + - 2397916 223606 2397916 . -- - abs + - 2397916 223606 2397915 . - abs + - 2397916 -2174309 . abs + - 2397916 2174309 . + - 4572225 . - - - rank_of == -- sqrt 2 / 0.5 - floor ++ - offset_of == dup 2 * [dup -- 4 * * 2 + -] dip % - row_value == over -- - abs + - - aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value diff --git a/docs/Advent of Code 2017 December 3rd.rst b/docs/Advent of Code 2017 December 3rd.rst deleted file mode 100644 index 2283c7f..0000000 --- a/docs/Advent of Code 2017 December 3rd.rst +++ /dev/null @@ -1,973 +0,0 @@ - -Advent of Code 2017 -=================== - -December 3rd ------------- - -You come across an experimental new kind of memory stored on an infinite -two-dimensional grid. - -Each square on the grid is allocated in a spiral pattern starting at a -location marked 1 and then counting up while spiraling outward. For -example, the first few squares are allocated like this: - -:: - - 17 16 15 14 13 - 18 5 4 3 12 - 19 6 1 2 11 - 20 7 8 9 10 - 21 22 23---> ... - -While this is very space-efficient (no squares are skipped), requested -data must be carried back to square 1 (the location of the only access -port for this memory system) by programs that can only move up, down, -left, or right. They always take the shortest path: the Manhattan -Distance between the location of the data and square 1. - -For example: - -- Data from square 1 is carried 0 steps, since it's at the access port. -- Data from square 12 is carried 3 steps, such as: down, left, left. -- Data from square 23 is carried only 2 steps: up twice. -- Data from square 1024 must be carried 31 steps. - -How many steps are required to carry the data from the square identified -in your puzzle input all the way to the access port? - -Analysis -~~~~~~~~ - -I freely admit that I worked out the program I wanted to write using -graph paper and some Python doodles. There's no point in trying to write -a Joy program until I'm sure I understand the problem well enough. - -The first thing I did was to write a column of numbers from 1 to n (32 -as it happens) and next to them the desired output number, to look for -patterns directly: - -:: - - 1 0 - 2 1 - 3 2 - 4 1 - 5 2 - 6 1 - 7 2 - 8 1 - 9 2 - 10 3 - 11 2 - 12 3 - 13 4 - 14 3 - 15 2 - 16 3 - 17 4 - 18 3 - 19 2 - 20 3 - 21 4 - 22 3 - 23 2 - 24 3 - 25 4 - 26 5 - 27 4 - 28 3 - 29 4 - 30 5 - 31 6 - 32 5 - -There are four groups repeating for a given "rank", then the pattern -enlarges and four groups repeat again, etc. - -:: - - 1 2 - 3 2 3 4 - 5 4 3 4 5 6 - 7 6 5 4 5 6 7 8 - 9 8 7 6 5 6 7 8 9 10 - -Four of this pyramid interlock to tile the plane extending from the -initial "1" square. - -:: - - 2 3 | 4 5 | 6 7 | 8 9 - 10 11 12 13|14 15 16 17|18 19 20 21|22 23 24 25 - -And so on. - -We can figure out the pattern for a row of the pyramid at a given "rank" -:math:`k`: - -:math:`2k - 1, 2k - 2, ..., k, k + 1, k + 2, ..., 2k` - -or - -:math:`k + (k - 1), k + (k - 2), ..., k, k + 1, k + 2, ..., k + k` - -This shows that the series consists at each place of :math:`k` plus some -number that begins at :math:`k - 1`, decreases to zero, then increases -to :math:`k`. Each row has :math:`2k` members. - -Let's figure out how, given an index into a row, we can calculate the -value there. The index will be from 0 to :math:`k - 1`. - -Let's look at an example, with :math:`k = 4`: - -:: - - 0 1 2 3 4 5 6 7 - 7 6 5 4 5 6 7 8 - -.. code:: ipython2 - - k = 4 - -Subtract :math:`k` from the index and take the absolute value: - -.. code:: ipython2 - - for n in range(2 * k): - print abs(n - k), - - -.. parsed-literal:: - - 4 3 2 1 0 1 2 3 - - -Not quite. Subtract :math:`k - 1` from the index and take the absolute -value: - -.. code:: ipython2 - - for n in range(2 * k): - print abs(n - (k - 1)), - - -.. parsed-literal:: - - 3 2 1 0 1 2 3 4 - - -Great, now add :math:`k`... - -.. code:: ipython2 - - for n in range(2 * k): - print abs(n - (k - 1)) + k, - - -.. parsed-literal:: - - 7 6 5 4 5 6 7 8 - - -So to write a function that can give us the value of a row at a given -index: - -.. code:: ipython2 - - def row_value(k, i): - i %= (2 * k) # wrap the index at the row boundary. - return abs(i - (k - 1)) + k - -.. code:: ipython2 - - k = 5 - for i in range(2 * k): - print row_value(k, i), - - -.. parsed-literal:: - - 9 8 7 6 5 6 7 8 9 10 - - -(I'm leaving out details of how I figured this all out and just giving -the relevent bits. It took a little while to zero in of the aspects of -the pattern that were important for the task.) - -Finding the rank and offset of a number. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Now that we can compute the desired output value for a given rank and -the offset (index) into that rank, we need to determine how to find the -rank and offset of a number. - -The rank is easy to find by iteratively stripping off the amount already -covered by previous ranks until you find the one that brackets the -target number. Because each row is :math:`2k` places and there are -:math:`4` per rank each rank contains :math:`8k` places. Counting the -initial square we have: - -:math:`corner_k = 1 + \sum_{n=1}^k 8n` - -I'm not mathematically sophisticated enough to turn this directly into a -formula (but Sympy is, see below.) I'm going to write a simple Python -function to iterate and search: - -.. code:: ipython2 - - def rank_and_offset(n): - assert n >= 2 # Guard the domain. - n -= 2 # Subtract two, - # one for the initial square, - # and one because we are counting from 1 instead of 0. - k = 1 - while True: - m = 8 * k # The number of places total in this rank, 4(2k). - if n < m: - return k, n % (2 * k) - n -= m # Remove this rank's worth. - k += 1 - -.. code:: ipython2 - - for n in range(2, 51): - print n, rank_and_offset(n) - - -.. parsed-literal:: - - 2 (1, 0) - 3 (1, 1) - 4 (1, 0) - 5 (1, 1) - 6 (1, 0) - 7 (1, 1) - 8 (1, 0) - 9 (1, 1) - 10 (2, 0) - 11 (2, 1) - 12 (2, 2) - 13 (2, 3) - 14 (2, 0) - 15 (2, 1) - 16 (2, 2) - 17 (2, 3) - 18 (2, 0) - 19 (2, 1) - 20 (2, 2) - 21 (2, 3) - 22 (2, 0) - 23 (2, 1) - 24 (2, 2) - 25 (2, 3) - 26 (3, 0) - 27 (3, 1) - 28 (3, 2) - 29 (3, 3) - 30 (3, 4) - 31 (3, 5) - 32 (3, 0) - 33 (3, 1) - 34 (3, 2) - 35 (3, 3) - 36 (3, 4) - 37 (3, 5) - 38 (3, 0) - 39 (3, 1) - 40 (3, 2) - 41 (3, 3) - 42 (3, 4) - 43 (3, 5) - 44 (3, 0) - 45 (3, 1) - 46 (3, 2) - 47 (3, 3) - 48 (3, 4) - 49 (3, 5) - 50 (4, 0) - - -.. code:: ipython2 - - for n in range(2, 51): - k, i = rank_and_offset(n) - print n, row_value(k, i) - - -.. parsed-literal:: - - 2 1 - 3 2 - 4 1 - 5 2 - 6 1 - 7 2 - 8 1 - 9 2 - 10 3 - 11 2 - 12 3 - 13 4 - 14 3 - 15 2 - 16 3 - 17 4 - 18 3 - 19 2 - 20 3 - 21 4 - 22 3 - 23 2 - 24 3 - 25 4 - 26 5 - 27 4 - 28 3 - 29 4 - 30 5 - 31 6 - 32 5 - 33 4 - 34 3 - 35 4 - 36 5 - 37 6 - 38 5 - 39 4 - 40 3 - 41 4 - 42 5 - 43 6 - 44 5 - 45 4 - 46 3 - 47 4 - 48 5 - 49 6 - 50 7 - - -Putting it all together -~~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - def row_value(k, i): - return abs(i - (k - 1)) + k - - - def rank_and_offset(n): - n -= 2 # Subtract two, - # one for the initial square, - # and one because we are counting from 1 instead of 0. - k = 1 - while True: - m = 8 * k # The number of places total in this rank, 4(2k). - if n < m: - return k, n % (2 * k) - n -= m # Remove this rank's worth. - k += 1 - - - def aoc20173(n): - if n <= 1: - return 0 - k, i = rank_and_offset(n) - return row_value(k, i) - -.. code:: ipython2 - - aoc20173(23) - - - - -.. parsed-literal:: - - 2 - - - -.. code:: ipython2 - - aoc20173(23000) - - - - -.. parsed-literal:: - - 105 - - - -.. code:: ipython2 - - aoc20173(23000000000000) - - - - -.. parsed-literal:: - - 4572225 - - - -Sympy to the Rescue -=================== - -Find the rank for large numbers -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Using e.g. Sympy we can find the rank directly by solving for the roots -of an equation. For large numbers this will (eventually) be faster than -iterating as ``rank_and_offset()`` does. - -.. code:: ipython2 - - from sympy import floor, lambdify, solve, symbols - from sympy import init_printing - init_printing() - -.. code:: ipython2 - - k = symbols('k') - -Since - -:math:`1 + 2 + 3 + ... + N = \frac{N(N + 1)}{2}` - -and - -:math:`\sum_{n=1}^k 8n = 8(\sum_{n=1}^k n) = 8\frac{k(k + 1)}{2}` - -We want: - -.. code:: ipython2 - - E = 2 + 8 * k * (k + 1) / 2 # For the reason for adding 2 see above. - - E - - - - -.. math:: - - 4 k \left(k + 1\right) + 2 - - - -We can write a function to solve for :math:`k` given some :math:`n`... - -.. code:: ipython2 - - def rank_of(n): - return floor(max(solve(E - n, k))) + 1 - -First ``solve()`` for :math:`E - n = 0` which has two solutions (because -the equation is quadratic so it has two roots) and since we only care -about the larger one we use ``max()`` to select it. It will generally -not be a nice integer (unless :math:`n` is the number of an end-corner -of a rank) so we take the ``floor()`` and add 1 to get the integer rank -of :math:`n`. (Taking the ``ceiling()`` gives off-by-one errors on the -rank boundaries. I don't know why. I'm basically like a monkey doing -math here.) =-D - -It gives correct answers: - -.. code:: ipython2 - - for n in (9, 10, 25, 26, 49, 50): - print n, rank_of(n) - - -.. parsed-literal:: - - 9 1 - 10 2 - 25 2 - 26 3 - 49 3 - 50 4 - - -And it runs much faster (at least for large numbers): - -.. code:: ipython2 - - %time rank_of(23000000000000) # Compare runtime with rank_and_offset()! - - -.. parsed-literal:: - - CPU times: user 68 ms, sys: 8 ms, total: 76 ms - Wall time: 73.8 ms - - - - -.. math:: - - 2397916 - - - -.. code:: ipython2 - - %time rank_and_offset(23000000000000) - - -.. parsed-literal:: - - CPU times: user 308 ms, sys: 0 ns, total: 308 ms - Wall time: 306 ms - - - - -.. math:: - - \left ( 2397916, \quad 223606\right ) - - - -After finding the rank you would still have to find the actual value of -the rank's first corner and subtract it (plus 2) from the number and -compute the offset as above and then the final output, but this overhead -is partially shared by the other method, and overshadowed by the time it -(the other iterative method) would take for really big inputs. - -The fun thing to do here would be to graph the actual runtime of both -methods against each other to find the trade-off point. - -It took me a second to realize I could do this... -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Sympy is a *symbolic* math library, and it supports symbolic -manipulation of equations. I can put in :math:`y` (instead of a value) -and ask it to solve for :math:`k`. - -.. code:: ipython2 - - y = symbols('y') - -.. code:: ipython2 - - g, f = solve(E - y, k) - -The equation is quadratic so there are two roots, we are interested in -the greater one... - -.. code:: ipython2 - - g - - - - -.. math:: - - - \frac{1}{2} \sqrt{y - 1} - \frac{1}{2} - - - -.. code:: ipython2 - - f - - - - -.. math:: - - \frac{1}{2} \sqrt{y - 1} - \frac{1}{2} - - - -Now we can take the ``floor()``, add 1, and ``lambdify()`` the equation -to get a Python function that calculates the rank directly. - -.. code:: ipython2 - - floor(f) + 1 - - - - -.. math:: - - \lfloor{\frac{1}{2} \sqrt{y - 1} - \frac{1}{2}}\rfloor + 1 - - - -.. code:: ipython2 - - F = lambdify(y, floor(f) + 1) - -.. code:: ipython2 - - for n in (9, 10, 25, 26, 49, 50): - print n, int(F(n)) - - -.. parsed-literal:: - - 9 1 - 10 2 - 25 2 - 26 3 - 49 3 - 50 4 - - -It's pretty fast. - -.. code:: ipython2 - - %time int(F(23000000000000)) # The clear winner. - - -.. parsed-literal:: - - CPU times: user 0 ns, sys: 0 ns, total: 0 ns - Wall time: 11.9 µs - - - - -.. math:: - - 2397916 - - - -Knowing the equation we could write our own function manually, but the -speed is no better. - -.. code:: ipython2 - - from math import floor as mfloor, sqrt - - def mrank_of(n): - return int(mfloor(sqrt(23000000000000 - 1) / 2 - 0.5) + 1) - -.. code:: ipython2 - - %time mrank_of(23000000000000) - - -.. parsed-literal:: - - CPU times: user 0 ns, sys: 0 ns, total: 0 ns - Wall time: 12.9 µs - - - - -.. math:: - - 2397916 - - - -Given :math:`n` and a rank, compute the offset. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Now that we have a fast way to get the rank, we still need to use it to -compute the offset into a pyramid row. - -.. code:: ipython2 - - def offset_of(n, k): - return (n - 2 + 4 * k * (k - 1)) % (2 * k) - -(Note the sneaky way the sign changes from :math:`k(k + 1)` to -:math:`k(k - 1)`. This is because we want to subract the -:math:`(k - 1)`\ th rank's total places (its own and those of lesser -rank) from our :math:`n` of rank :math:`k`. Substituting :math:`k - 1` -for :math:`k` in :math:`k(k + 1)` gives :math:`(k - 1)(k - 1 + 1)`, -which of course simplifies to :math:`k(k - 1)`.) - -.. code:: ipython2 - - offset_of(23000000000000, 2397916) - - - - -.. math:: - - 223606 - - - -So, we can compute the rank, then the offset, then the row value. - -.. code:: ipython2 - - def rank_of(n): - return int(mfloor(sqrt(n - 1) / 2 - 0.5) + 1) - - - def offset_of(n, k): - return (n - 2 + 4 * k * (k - 1)) % (2 * k) - - - def row_value(k, i): - return abs(i - (k - 1)) + k - - - def aoc20173(n): - k = rank_of(n) - i = offset_of(n, k) - return row_value(k, i) - -.. code:: ipython2 - - aoc20173(23) - - - - -.. math:: - - 2 - - - -.. code:: ipython2 - - aoc20173(23000) - - - - -.. math:: - - 105 - - - -.. code:: ipython2 - - aoc20173(23000000000000) - - - - -.. math:: - - 4572225 - - - -.. code:: ipython2 - - %time aoc20173(23000000000000000000000000) # Fast for large values. - - -.. parsed-literal:: - - CPU times: user 0 ns, sys: 0 ns, total: 0 ns - Wall time: 20 µs - - - - -.. math:: - - 2690062495969 - - - -A Joy Version -============= - -At this point I feel confident that I can implement a concise version of -this code in Joy. ;-) - -.. code:: ipython2 - - from notebook_preamble import J, V, define - -``rank_of`` -~~~~~~~~~~~ - -:: - - n rank_of - --------------- - k - -The translation is straightforward. - -:: - - int(floor(sqrt(n - 1) / 2 - 0.5) + 1) - - rank_of == -- sqrt 2 / 0.5 - floor ++ - -.. code:: ipython2 - - define('rank_of == -- sqrt 2 / 0.5 - floor ++') - -``offset_of`` -~~~~~~~~~~~~~ - -:: - - n k offset_of - ------------------- - i - - (n - 2 + 4 * k * (k - 1)) % (2 * k) - -A little tricky... - -:: - - n k dup 2 * - n k k 2 * - n k k*2 [Q] dip % - n k Q k*2 % - - n k dup -- - n k k -- - n k k-1 4 * * 2 + - - n k*k-1*4 2 + - - n k*k-1*4+2 - - n-k*k-1*4+2 - - n-k*k-1*4+2 k*2 % - n-k*k-1*4+2%k*2 - -Ergo: - -:: - - offset_of == dup 2 * [dup -- 4 * * 2 + -] dip % - -.. code:: ipython2 - - define('offset_of == dup 2 * [dup -- 4 * * 2 + -] dip %') - -``row_value`` -~~~~~~~~~~~~~ - -:: - - k i row_value - ------------------- - n - - abs(i - (k - 1)) + k - - k i over -- - abs + - k i k -- - abs + - k i k-1 - abs + - k i-k-1 abs + - k |i-k-1| + - k+|i-k-1| - -.. code:: ipython2 - - define('row_value == over -- - abs +') - -``aoc2017.3`` -~~~~~~~~~~~~~ - -:: - - n aoc2017.3 - ----------------- - m - - n dup rank_of - n k [offset_of] dupdip - n k offset_of k - i k swap row_value - k i row_value - m - -.. code:: ipython2 - - define('aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value') - -.. code:: ipython2 - - J('23 aoc2017.3') - - -.. parsed-literal:: - - 2 - - -.. code:: ipython2 - - J('23000 aoc2017.3') - - -.. parsed-literal:: - - 105 - - -.. code:: ipython2 - - V('23000000000000 aoc2017.3') - - -.. parsed-literal:: - - . 23000000000000 aoc2017.3 - 23000000000000 . aoc2017.3 - 23000000000000 . dup rank_of [offset_of] dupdip swap row_value - 23000000000000 23000000000000 . rank_of [offset_of] dupdip swap row_value - 23000000000000 23000000000000 . -- sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 22999999999999 . sqrt 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 4795831.523312615 . 2 / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 4795831.523312615 2 . / 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915.7616563076 . 0.5 - floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915.7616563076 0.5 . - floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915.2616563076 . floor ++ [offset_of] dupdip swap row_value - 23000000000000 2397915 . ++ [offset_of] dupdip swap row_value - 23000000000000 2397916 . [offset_of] dupdip swap row_value - 23000000000000 2397916 [offset_of] . dupdip swap row_value - 23000000000000 2397916 . offset_of 2397916 swap row_value - 23000000000000 2397916 . dup 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 2397916 . 2 * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 2397916 2 . * [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 4795832 . [dup -- 4 * * 2 + -] dip % 2397916 swap row_value - 23000000000000 2397916 4795832 [dup -- 4 * * 2 + -] . dip % 2397916 swap row_value - 23000000000000 2397916 . dup -- 4 * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 2397916 . -- 4 * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 2397915 . 4 * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 2397915 4 . * * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 2397916 9591660 . * 2 + - 4795832 % 2397916 swap row_value - 23000000000000 22999994980560 . 2 + - 4795832 % 2397916 swap row_value - 23000000000000 22999994980560 2 . + - 4795832 % 2397916 swap row_value - 23000000000000 22999994980562 . - 4795832 % 2397916 swap row_value - 5019438 . 4795832 % 2397916 swap row_value - 5019438 4795832 . % 2397916 swap row_value - 223606 . 2397916 swap row_value - 223606 2397916 . swap row_value - 2397916 223606 . row_value - 2397916 223606 . over -- - abs + - 2397916 223606 2397916 . -- - abs + - 2397916 223606 2397915 . - abs + - 2397916 -2174309 . abs + - 2397916 2174309 . + - 4572225 . - - -:: - - rank_of == -- sqrt 2 / 0.5 - floor ++ - offset_of == dup 2 * [dup -- 4 * * 2 + -] dip % - row_value == over -- - abs + - - aoc2017.3 == dup rank_of [offset_of] dupdip swap row_value diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_29_0.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_29_0.png deleted file mode 100644 index 4e6c0d8105a3e02cc67806fc99c23e123c9b13c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 677 zcmeAS@N?(olHy`uVBq!ia0vp^H9#!F!VDz$PIuV_qznRlLR|m<{|{sm5A^RYs0OO$ zFA4GsW-yw0cX!!)rL?o10wJqir0@Fm0;M<$JR*x382FBWFymBhK4}I9CI(Lz#}Es_ z+>o=`!j3YvCi1h-s^z}0e<1fINaI;RlmORD$JZN07Pc#i-P(Py+w$e5X#b;^y!mt& zeqAJ9ykSdKro$`WKL-{~PdZ?)5a!a-a_sx;oBcCY`OBW|{r-FJnKuT~2iy)%>(sg; zoVVHY!Pi~e=1A?a4&5!YDnIl4#jmWXXAACJbe*2PW8br5KlbtNG29aHUO2AQ^0}D> z&kupwHELFeSkkLL?fa9kXUCGzC(~}9Sbs6=4b$V=*x8S-B(HaqV3)h_=~|9?yz9?N zVcj2-La)lqiu22hJU`UwZ-o>)@!d8CLCXBbmz06 zg#Ft!Uzik5AD4bI?@x1+?EOn=U*3i675lFDvETiz@GBp7jj!Q*8|G|y{C>;K9W&C) zT_2g(hMq2O+<1T2Ti4B&w{zZUD!R94JNcHMVZZ0}==1k!OEf;7`I)|0~bl(EVAVbB&E_{~pJQI?@ccZH|kHys7y0qT+h^ zlDGV)Ok=$EykL$u49uJ;Tvp>Xd*bUmRhGKfpZxq#ZFb<3)=P`8u}|_&cnSvA{CXJ2 zU=tkoX4m0|0gu$4TvF?JbSlt1XvR~uvxlBc_AHna@ObjZn9a@U;oG+^yd=LSuxn*- ocjhdeWxavB3{Q#Vf0=)^zV>q4wf=LaM?opg)78&qol`;+0Q4#{D*ylh diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_35_1.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_35_1.png deleted file mode 100644 index d4b2fdacb40507ac71b4171402ef9933c2f503ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 566 zcmeAS@N?(olHy`uVBq!ia0vp^?m*1X!VDx`rk>XYQU(D&A+G=b{|7RO2l{sxR0CD> zmjw9*Gbqj6Z6vU|)8+l$vt=P^8Cl1*fKr?V9+AZi417mGm~pB$pELsl<3vvv#}EzC z-U+teGJzs(^E<1{dv>p0+WM?}^&xn9yxOOZ-k&dVa?`Iucx z<3>cr;s}=Trnybsy*GTdJARsNnr%^;eq4S6v+?(P#q)pfdoH81{r+LDxKKmed>NzJ zwvGop3=Y=bC|;i^@_QN|SGi61n#!oh7W)iW+Y~)G#J>4_@Qfx`ztvYN7$@6YNY(t^ zm~+v`k2_2262G^>+r7NLbFHRqJoxQa*@pdxRxbEn#UdInu*ukd%C)}op6?U?&vat; zGD(WoKb96TEog;{Jpa;?*-l>`slezsH-o{wX%%AX6Z+m6iToI`--wUE=_C1+( zNWSmyb0IyBQ}1Unzf?VZ=A1-nc;{oOv+o`Y+^$_Dt^Km%8t=mDT>VSiZU;ZIeR#LLL)5^33b6eRCchn1TnL0U(chySY z-7#Zj*OG&Wa@Opaz*53vl$7>(Rd=OR$ga#F$Aw#hq>o2rU4FUqyKT4e4vB^LAKj^c zKJWY8&-=>dE9}182&H=7W4G?NVcdQD_rvyYs$9p@Z{?mjv%T!9>+iFEcXr>dxO$RL zaLaxUh5es;x7nmrPOJ5N8$5$IY<67huKat?{}nB||Nj27ruTE(-b5N+o3&EYl(}%? zA77a_D!V%^j|5I?tTaqp@3_dxQ04lGI}1Xz%{0P-PL(vD{=hAszFqaZMzS#TDyctg z=}H!&8;(Y_dVV`J-O$?JeV5NVw~yC;D7_9|s`+XE^U@7`wh^s8EyvgMug>}-81vfV z$C}J4oygnsTB;;A`ZmW-xHD~o*sFiPSR`-%7WvFR=at37jcsXd$yQS~F#p_oGP&%p znGUPrZ-LKw-cd7WCO?_-(bxCI6M3!2%Y^l0<0|h>Y-Sh0m zaoxJRPcrZAW_&HB@_f^3N0mLkr^Jp2EHO8EsIWidm*V-_^*yRG8}FxH{1hzOy>qjQ z-@NI^)!)20xIIj{-`iB^+WdtpZf#^f*Al(qeKF_hu8zCCEzb{X8!t=IJoR?EQg8Oc z(-yX_PXBmZk3CCDWS8NHo3>&7^l<*9vg?r(*KSz6MV3?D+#u;jMVR$h3DNKMDS!HW zk2b|v2&{PZ-Bg`5@r>Q`xO?Rv-13^fd_9u6E0xPixcW5f)%Bu!C$_d#U)sMQKry)N zL!;N?J5!H;W48RoU(K((vtW&FwD*rI&yCK{XkO*5U85B9SvhfCf#L;s1A*PQ*2Wip zV7R$oLvJ?grN*BU$J->&tz;;%yz*noFN-a!d~GuvrGBpJGB4fvee>J6*6_oO4`0^R zbF)9bs(kD6thWha_ud`J;k)f$wd6$KiS8pdSKU%oVoRF;^j}ata(MB_dZ}Kq&DXBH rS|qRfC(xtZ(k%MC_?^cW*1zOqmgSHA_TY^VC|7#A`njxgN@xNAaBjfq diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_42_0.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_42_0.png deleted file mode 100644 index 02b91a14fc1bb906259233e7a3ca6335a3c190ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 655 zcmeAS@N?(olHy`uVBq!ia0vp^oj|O`!VDx!n^JcHDT4r?5ZC|z{{xxC1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|3<9l&8KI#aqm98Zo<3c?>1@wD_$!5A^Y3iZmm0=Hg?DL1WS+3vgy^*^AK7n zR?69Q!*h?CXG@e+dEZw-*GvV2B|#59Ex8w|wQG94o}Ag;zlUvfFRxprl9ac_P=0Py zdgRW2*Gq@nBEpWcOkZ;HtCcp>ft|Zjp4xq?-Dh%g?N%1O3+GRLUF!MHQ!skYZ=QmA z-wX7%?K|{3mN9E;>X+oxdWV*(R@pw-V|^g5@SWkmGYoIbyF$bEAG;`5x8lW~SE~y1 zmt0Dyf4=fUtuO1_Pv>tQfB4~D!46;EX;SCc)>TD{o)1XhWAM9sks;R`=clV5-BG)y zX0xl!lB=Llc*TXd2fS%kY9UWucl@mlkv>x0R0veqRp9?NX=>nEet&VEWnS0wbGI*= zTCi+C|H0}v-amIvHT&kKQoR3Rs=|GqB(DqWET-$8$zAkqcG}YBs`f_{8xI$s`fsIpQ}g%Vne}p}lI3;1v%M>3tUh<}Qpc&s-gnmQzwv0szvZz?-(9}* zZMe*_!>m3OxaW_?x( zo4$P-`|_=2*R{NA3braoZ`qZ0{lU}cw_@M=zh9pcy=dj8-DPT%-!D^+p7-n*v)j8h U&+3mncLgO~Pgg&ebxsLQ051txiU0rr diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_49_1.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_49_1.png deleted file mode 100644 index d4b2fdacb40507ac71b4171402ef9933c2f503ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 566 zcmeAS@N?(olHy`uVBq!ia0vp^?m*1X!VDx`rk>XYQU(D&A+G=b{|7RO2l{sxR0CD> zmjw9*Gbqj6Z6vU|)8+l$vt=P^8Cl1*fKr?V9+AZi417mGm~pB$pELsl<3vvv#}EzC z-U+teGJzs(^E<1{dv>p0+WM?}^&xn9yxOOZ-k&dVa?`Iucx z<3>cr;s}=Trnybsy*GTdJARsNnr%^;eq4S6v+?(P#q)pfdoH81{r+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RNl|AU&))GUR9Vcs_n@)k3x&H`Y3JvygTe~ HDWM4frKPJP diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_59_0.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_59_0.png deleted file mode 100644 index ed4ba2d85e9c8aac157462ca2c776d3769f66d46..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^oIuRS!VDz&cWKWCQn~>?A+G=b{|7RO1P81(F90g# zD+%%oW>A{B+elz_r_1}hXUjr%$Ss-#l;JG!h%5#wI0C|qQ?>b|fr5UXE{-7_vdIY{ zMr8>J9LWjw2Mm?Ypr|?a;{=KOTXflJRtDnm{r-UW|nLIq~ diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_60_0.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_60_0.png deleted file mode 100644 index 9034b06d391e37f1d37d53d068d241a62fd8a843..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 337 zcmeAS@N?(olHy`uVBq!ia0vp^vOvtw!VDx|Exx%1NErn9gt-3y{~yRC9_Zg)Pz_Yg zUlQaO%n^&v?n35jjaUyKX54YCboQXgDMOh_pG p_3q#S8{Je!X8$GH0hUq>4EKK;w4Tv*Ed{!p!PC{xWt~$(696YZZ|?vA diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_61_0.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_61_0.png deleted file mode 100644 index 5714d79cbea05d35fe616d3dcb9280d4a62c9b72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 447 zcmeAS@N?(olHy`uVBq!ia0vp^9ze{`!VDz0&YQ9TNErn9gt-3y{~yRC9_Zg)Pz_Yg zUlQaO%wRP0?(VYpN@-_11wvN4NZr3a(~UrJ_V9}b&*~R!v*5HVDZK3ZoM+dLEgiuQFCHm%JksL` z((t%=R6ZbZ#g*rKD_g&tIa}@U>eWBrU-ebL}dHP(Fo<&J5FuAmW#k$PnYLxY( zwp;lPmppn&iWa0nI-;7HghHxc1P$<6yAH0cDtu@Pss7UvhAC4gR#;7??0KHm?}%oO80Vu;=t3@&t;ucLK6VP C#Hqgk diff --git a/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_62_1.png b/docs/Advent of Code 2017 December 3rd_files/Advent of Code 2017 December 3rd_62_1.png deleted file mode 100644 index 1a257f5a92e8c02b385645c82e3c98f8dc36971d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 784 zcmeAS@N?(olHy`uVBq!ia0vp^tw7Ar!VDxW?h9@NQU(D&A+G=b{|7RO2l{sxR0CD> zmjw9*Gbqj6Z6vU|)8+l$vt=P^8Cl1*fKr?V9+AZi417mGm~pB$pELslQ?{pzV~B?6 z(#!rHB8d{mKfeDrb8cz*T-jZsEr&0~@8R)uT;8T&V^yJXra5{_po^YTl}C}@+}MRp zT&K?ozFk<)epz)#~9y@1M-dK@rlTbeSu$;MFsySDSSzak>}Z zIBYBN;aKj?+hRS1JkS0{%)1s<6q+@w^G|{4de38}WBNaytUX+z zI$M3GthQI6aoVk`GHG9Srd)H%6HC1tT)+CW?}6Hz$Is566!@;#C?9FeR=5<0M^<+TIQ;pololaHm zoApke`RsQ1`G)y=+xu##)q1ooHp+6z_jc3j?@ZAMo4HYQ+0Sijf94yq&)y)j;Y-<@ zEB5I#58av|_i(+I^G5ae7em+VJhydCTI?B%4-rPI9x?AbQxbP}OR06}p<9fJiv`j& z{8j{>IOMYSs-{oybE vbRlP6#QL@~>mL5yWF>AADgLzJ|L>p7rA;5F9~Hmk0!q}Lu6{1-oD!M - - -Advent of Code 2017 December 4th - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Advent of Code 2017

December 4th

To ensure security, a valid passphrase must contain no duplicate words.

-

For example:

-
    -
  • aa bb cc dd ee is valid.
  • -
  • aa bb cc dd aa is not valid - the word aa appears more than once.
  • -
  • aa bb cc dd aaa is valid - aa and aaa count as different words.
  • -
-

The system's full passphrase list is available as your puzzle input. How many passphrases are valid?

- -
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import J, V, define
-
- -
-
-
- -
-
-
-
-
-

I'll assume the input is a Joy sequence of sequences of integers.

- -
[[5 1 9 5]
- [7 5 4 3]
- [2 4 6 8]]
-
-
-

So, obviously, the initial form will be a step function:

- -
AoC2017.4 == 0 swap [F +] step
- -
-
-
-
-
-
-
- -
F == [size] [unique size] cleave =
- -
-
-
-
-
-
-
-

The step_zero combinator includes the 0 swap that would normally open one of these definitions:

- -
-
-
-
-
-
In [2]:
-
-
-
J('[step_zero] help')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0 roll> step
-
-
-
-
- -
-
- -
-
-
-
-
- -
AoC2017.4 == [F +] step_zero
- -
-
-
-
-
-
In [3]:
-
-
-
define('AoC2017.4 == [[size] [unique size] cleave = +] step_zero')
-
- -
-
-
- -
-
-
-
In [4]:
-
-
-
J('''
-
-[[5 1 9 5]
- [7 5 4 3]
- [2 4 6 8]] AoC2017.4
-
-''')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
- - - - - - diff --git a/docs/Advent of Code 2017 December 4th.ipynb b/docs/Advent of Code 2017 December 4th.ipynb deleted file mode 100644 index cd1bd55..0000000 --- a/docs/Advent of Code 2017 December 4th.ipynb +++ /dev/null @@ -1,139 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Advent of Code 2017\n", - "\n", - "## December 4th\n", - "To ensure security, a valid passphrase must contain no duplicate words.\n", - "\n", - "For example:\n", - "\n", - "* aa bb cc dd ee is valid.\n", - "* aa bb cc dd aa is not valid - the word aa appears more than once.\n", - "* aa bb cc dd aaa is valid - aa and aaa count as different words.\n", - "\n", - "The system's full passphrase list is available as your puzzle input. How many passphrases are valid?" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import J, V, define" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "I'll assume the input is a Joy sequence of sequences of integers.\n", - "\n", - " [[5 1 9 5]\n", - " [7 5 4 3]\n", - " [2 4 6 8]]\n", - "\n", - "So, obviously, the initial form will be a `step` function:\n", - "\n", - " AoC2017.4 == 0 swap [F +] step" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " F == [size] [unique size] cleave =\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `step_zero` combinator includes the `0 swap` that would normally open one of these definitions:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 roll> step\n", - "\n" - ] - } - ], - "source": [ - "J('[step_zero] help')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " AoC2017.4 == [F +] step_zero" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "define('AoC2017.4 == [[size] [unique size] cleave = +] step_zero')" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('''\n", - "\n", - "[[5 1 9 5]\n", - " [7 5 4 3]\n", - " [2 4 6 8]] AoC2017.4\n", - "\n", - "''')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Advent of Code 2017 December 4th.md b/docs/Advent of Code 2017 December 4th.md deleted file mode 100644 index 96f3c29..0000000 --- a/docs/Advent of Code 2017 December 4th.md +++ /dev/null @@ -1,64 +0,0 @@ - -# Advent of Code 2017 - -## December 4th -To ensure security, a valid passphrase must contain no duplicate words. - -For example: - -* aa bb cc dd ee is valid. -* aa bb cc dd aa is not valid - the word aa appears more than once. -* aa bb cc dd aaa is valid - aa and aaa count as different words. - -The system's full passphrase list is available as your puzzle input. How many passphrases are valid? - - -```python -from notebook_preamble import J, V, define -``` - -I'll assume the input is a Joy sequence of sequences of integers. - - [[5 1 9 5] - [7 5 4 3] - [2 4 6 8]] - -So, obviously, the initial form will be a `step` function: - - AoC2017.4 == 0 swap [F +] step - - - F == [size] [unique size] cleave = - - -The `step_zero` combinator includes the `0 swap` that would normally open one of these definitions: - - -```python -J('[step_zero] help') -``` - - 0 roll> step - - - - AoC2017.4 == [F +] step_zero - - -```python -define('AoC2017.4 == [[size] [unique size] cleave = +] step_zero') -``` - - -```python -J(''' - -[[5 1 9 5] - [7 5 4 3] - [2 4 6 8]] AoC2017.4 - -''') -``` - - 2 - diff --git a/docs/Advent of Code 2017 December 4th.rst b/docs/Advent of Code 2017 December 4th.rst deleted file mode 100644 index e51ca12..0000000 --- a/docs/Advent of Code 2017 December 4th.rst +++ /dev/null @@ -1,77 +0,0 @@ - -Advent of Code 2017 -=================== - -December 4th ------------- - -To ensure security, a valid passphrase must contain no duplicate words. - -For example: - -- aa bb cc dd ee is valid. -- aa bb cc dd aa is not valid - the word aa appears more than once. -- aa bb cc dd aaa is valid - aa and aaa count as different words. - -The system's full passphrase list is available as your puzzle input. How -many passphrases are valid? - -.. code:: ipython2 - - from notebook_preamble import J, V, define - -I'll assume the input is a Joy sequence of sequences of integers. - -:: - - [[5 1 9 5] - [7 5 4 3] - [2 4 6 8]] - -So, obviously, the initial form will be a ``step`` function: - -:: - - AoC2017.4 == 0 swap [F +] step - -:: - - F == [size] [unique size] cleave = - -The ``step_zero`` combinator includes the ``0 swap`` that would normally -open one of these definitions: - -.. code:: ipython2 - - J('[step_zero] help') - - -.. parsed-literal:: - - 0 roll> step - - - -:: - - AoC2017.4 == [F +] step_zero - -.. code:: ipython2 - - define('AoC2017.4 == [[size] [unique size] cleave = +] step_zero') - -.. code:: ipython2 - - J(''' - - [[5 1 9 5] - [7 5 4 3] - [2 4 6 8]] AoC2017.4 - - ''') - - -.. parsed-literal:: - - 2 - diff --git a/docs/Advent of Code 2017 December 5th.html b/docs/Advent of Code 2017 December 5th.html deleted file mode 100644 index 3ec5535..0000000 --- a/docs/Advent of Code 2017 December 5th.html +++ /dev/null @@ -1,12207 +0,0 @@ - - - -Advent of Code 2017 December 5th - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Advent of Code 2017

December 5th

...a list of the offsets for each jump. Jumps are relative: -1 moves to the previous instruction, and 2 skips the next one. Start at the first instruction in the list. The goal is to follow the jumps until one leads outside the list.

-

In addition, these instructions are a little strange; after each jump, the offset of that instruction increases by 1. So, if you come across an offset of 3, you would move three instructions forward, but change it to a 4 for the next time it is encountered.

-

For example, consider the following list of jump offsets:

- -
0
-3
-0
-1
--3
-
-
-

Positive jumps ("forward") move downward; negative jumps move upward. For legibility in this example, these offset values will be written all on one line, with the current instruction marked in parentheses. The following steps would be taken before an exit is found:

-
    -
  • (0) 3 0 1 -3 - before we have taken any steps.
  • -
  • (1) 3 0 1 -3 - jump with offset 0 (that is, don't jump at all). Fortunately, the instruction is then incremented to 1.
  • -
  • 2 (3) 0 1 -3 - step forward because of the instruction we just modified. The first instruction is incremented again, now to 2.
  • -
  • 2 4 0 1 (-3) - jump all the way to the end; leave a 4 behind.
  • -
  • 2 (4) 0 1 -2 - go back to where we just were; increment -3 to -2.
  • -
  • 2 5 0 1 -2 - jump 4 steps forward, escaping the maze.
  • -
-

In this example, the exit is reached in 5 steps.

-

How many steps does it take to reach the exit?

- -
-
-
-
-
-
-
-

Breakdown

For now, I'm going to assume a starting state with the size of the sequence pre-computed. We need it to define the exit condition and it is a trivial preamble to generate it. We then need and index and a step-count, which are both initially zero. Then we have the sequence itself, and some recursive function F that does the work.

- -
   size index step-count [...] F
------------------------------------
-            step-count
-
-F == [P] [T] [R1] [R2] genrec
-
-
-

Later on I was thinking about it and the Forth heuristic came to mind, to wit: four things on the stack are kind of much. Immediately I realized that the size properly belongs in the predicate of F! D'oh!

- -
   index step-count [...] F
-------------------------------
-         step-count
- -
-
-
-
-
-
-
-

So, let's start by nailing down the predicate:

- -
F == [P] [T] [R1]   [R2] genrec
-  == [P] [T] [R1 [F] R2] ifte
-
-0 0 [0 3 0 1 -3] popop 5 >=
-
-P == popop 5 >=
- -
-
-
-
-
-
-
-

Now we need the else-part:

- -
index step-count [0 3 0 1 -3] roll< popop
-
-E == roll< popop
- -
-
-
-
-
-
-
-

Last but not least, the recursive branch

- -
0 0 [0 3 0 1 -3] R1 [F] R2
-
-
-

The R1 function has a big job:

- -
R1 == get the value at index
-      increment the value at the index
-      add the value gotten to the index
-      increment the step count
-
-
-

The only tricky thing there is incrementing an integer in the sequence. Joy sequences are not particularly good for random access. We could encode the list of jump offsets in a big integer and use math to do the processing for a good speed-up, but it still wouldn't beat the performance of e.g. a mutable array. This is just one of those places where "plain vanilla" Joypy doesn't shine (in default performance. The legendary Sufficiently-Smart Compiler would of course rewrite this function to use an array "under the hood".)

-

In the meantime, I'm going to write a primitive function that just does what we need.

- -
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import D, J, V, define
-from joy.library import SimpleFunctionWrapper
-from joy.utils.stack import list_to_stack
-
-
-@SimpleFunctionWrapper
-def incr_at(stack):
-    '''Given a index and a sequence of integers, increment the integer at the index.
-
-    E.g.:
-
-       3 [0 1 2 3 4 5] incr_at
-    -----------------------------
-         [0 1 2 4 4 5]
-    
-    '''
-    sequence, (i, stack) = stack
-    mem = []
-    while i >= 0:
-        term, sequence = sequence
-        mem.append(term)
-        i -= 1
-    mem[-1] += 1
-    return list_to_stack(mem, sequence), stack
-
-
-D['incr_at'] = incr_at
-
- -
-
-
- -
-
-
-
In [2]:
-
-
-
J('3 [0 1 2 3 4 5] incr_at')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[0 1 2 4 4 5]
-
-
-
- -
-
- -
-
-
-
-
-

get the value at index

-
3 0 [0 1 2 3 4] [roll< at] nullary
-3 0 [0 1 2 n 4] n
- -
-
-
-
-
-
-
-

increment the value at the index

-
3 0 [0 1 2 n 4] n [Q] dip
-3 0 [0 1 2 n 4] Q n
-3 0 [0 1 2 n 4] [popd incr_at] unary n
-3 0 [0 1 2 n+1 4] n
- -
-
-
-
-
-
-
-

add the value gotten to the index

-
3 0 [0 1 2 n+1 4] n [+] cons dipd
-3 0 [0 1 2 n+1 4] [n +]      dipd
-3 n + 0 [0 1 2 n+1 4]
-3+n   0 [0 1 2 n+1 4]
- -
-
-
-
-
-
-
-

increment the step count

-
3+n 0 [0 1 2 n+1 4] [++] dip
-3+n 1 [0 1 2 n+1 4]
- -
-
-
-
-
-
-
-

All together now...

-
get_value == [roll< at] nullary
-incr_value == [[popd incr_at] unary] dip
-add_value == [+] cons dipd
-incr_step_count == [++] dip
-
-R1 == get_value incr_value add_value incr_step_count
-
-F == [P] [T] [R1] primrec
-
-F == [popop !size! >=] [roll< pop] [get_value incr_value add_value incr_step_count] primrec
- -
-
-
-
-
-
In [3]:
-
-
-
from joy.library import DefinitionWrapper
-
-
-DefinitionWrapper.add_definitions('''
-
-      get_value == [roll< at] nullary
-     incr_value == [[popd incr_at] unary] dip
-      add_value == [+] cons dipd
-incr_step_count == [++] dip
-
-     AoC2017.5.0 == get_value incr_value add_value incr_step_count
-
-''', D)
-
- -
-
-
- -
-
-
-
In [4]:
-
-
-
define('F == [popop 5 >=] [roll< popop] [AoC2017.5.0] primrec')
-
- -
-
-
- -
-
-
-
In [5]:
-
-
-
J('0 0 [0 3 0 1 -3] F')
-
- -
-
-
- -
-
- - -
- -
- - -
-
5
-
-
-
- -
-
- -
-
-
-
-
-

Preamble for setting up predicate, index, and step-count

We want to go from this to this:

- -
   [...] AoC2017.5.preamble
-------------------------------
-    0 0 [...] [popop n >=]
-
-
-

Where n is the size of the sequence.

-

The first part is obviously 0 0 roll<, then dup size:

- -
[...] 0 0 roll< dup size
-0 0 [...] n
-
-
-

Then:

- -
0 0 [...] n [>=] cons [popop] swoncat
-
-
-

So:

- -
init-index-and-step-count == 0 0 roll<
-prepare-predicate == dup size [>=] cons [popop] swoncat
-
-AoC2017.5.preamble == init-index-and-step-count prepare-predicate
- -
-
-
-
-
-
In [6]:
-
-
-
DefinitionWrapper.add_definitions('''
-
-init-index-and-step-count == 0 0 roll<
-        prepare-predicate == dup size [>=] cons [popop] swoncat
-
-       AoC2017.5.preamble == init-index-and-step-count prepare-predicate
-
-                AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec
-
-''', D)
-
- -
-
-
- -
-
-
-
In [7]:
-
-
-
J('[0 3 0 1 -3] AoC2017.5')
-
- -
-
-
- -
-
- - -
- -
- - -
-
5
-
-
-
- -
-
- -
-
-
-
-
- -
                AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec
-
-              AoC2017.5.0 == get_value incr_value add_value incr_step_count
-       AoC2017.5.preamble == init-index-and-step-count prepare-predicate
-
-                get_value == [roll< at] nullary
-               incr_value == [[popd incr_at] unary] dip
-                add_value == [+] cons dipd
-          incr_step_count == [++] dip
-
-init-index-and-step-count == 0 0 roll<
-        prepare-predicate == dup size [>=] cons [popop] swoncat
- -
-
-
-
-
-
-
-

This is by far the largest program I have yet written in Joy. Even with the incr_at function it is still a bear. There may be an arrangement of the parameters that would permit more elegant definitions, but it still wouldn't be as efficient as something written in assembly, C, or even Python.

- -
-
-
-
-
- - - - - - diff --git a/docs/Advent of Code 2017 December 5th.ipynb b/docs/Advent of Code 2017 December 5th.ipynb deleted file mode 100644 index 32d264e..0000000 --- a/docs/Advent of Code 2017 December 5th.ipynb +++ /dev/null @@ -1,380 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Advent of Code 2017\n", - "\n", - "## December 5th\n", - "...a list of the offsets for each jump. Jumps are relative: -1 moves to the previous instruction, and 2 skips the next one. Start at the first instruction in the list. The goal is to follow the jumps until one leads outside the list.\n", - "\n", - "In addition, these instructions are a little strange; after each jump, the offset of that instruction increases by 1. So, if you come across an offset of 3, you would move three instructions forward, but change it to a 4 for the next time it is encountered.\n", - "\n", - "For example, consider the following list of jump offsets:\n", - "\n", - " 0\n", - " 3\n", - " 0\n", - " 1\n", - " -3\n", - "\n", - "Positive jumps (\"forward\") move downward; negative jumps move upward. For legibility in this example, these offset values will be written all on one line, with the current instruction marked in parentheses. The following steps would be taken before an exit is found:\n", - "\n", - "* (0) 3 0 1 -3 - before we have taken any steps.\n", - "* (1) 3 0 1 -3 - jump with offset 0 (that is, don't jump at all). Fortunately, the instruction is then incremented to 1.\n", - "* 2 (3) 0 1 -3 - step forward because of the instruction we just modified. The first instruction is incremented again, now to 2.\n", - "* 2 4 0 1 (-3) - jump all the way to the end; leave a 4 behind.\n", - "* 2 (4) 0 1 -2 - go back to where we just were; increment -3 to -2.\n", - "* 2 5 0 1 -2 - jump 4 steps forward, escaping the maze.\n", - "\n", - "In this example, the exit is reached in 5 steps.\n", - "\n", - "How many steps does it take to reach the exit?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Breakdown\n", - "For now, I'm going to assume a starting state with the size of the sequence pre-computed. We need it to define the exit condition and it is a trivial preamble to generate it. We then need and `index` and a `step-count`, which are both initially zero. Then we have the sequence itself, and some recursive function `F` that does the work.\n", - "\n", - " size index step-count [...] F\n", - " -----------------------------------\n", - " step-count\n", - "\n", - " F == [P] [T] [R1] [R2] genrec\n", - "\n", - "Later on I was thinking about it and the Forth heuristic came to mind, to wit: four things on the stack are kind of much. Immediately I realized that the size properly belongs in the predicate of `F`! D'oh!\n", - "\n", - " index step-count [...] F\n", - " ------------------------------\n", - " step-count" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "So, let's start by nailing down the predicate:\n", - "\n", - " F == [P] [T] [R1] [R2] genrec\n", - " == [P] [T] [R1 [F] R2] ifte\n", - "\n", - " 0 0 [0 3 0 1 -3] popop 5 >=\n", - "\n", - " P == popop 5 >=" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we need the else-part:\n", - "\n", - " index step-count [0 3 0 1 -3] roll< popop\n", - "\n", - " E == roll< popop" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Last but not least, the recursive branch\n", - "\n", - " 0 0 [0 3 0 1 -3] R1 [F] R2\n", - "\n", - "The `R1` function has a big job:\n", - "\n", - " R1 == get the value at index\n", - " increment the value at the index\n", - " add the value gotten to the index\n", - " increment the step count\n", - "\n", - "The only tricky thing there is incrementing an integer in the sequence. Joy sequences are not particularly good for random access. We could encode the list of jump offsets in a big integer and use math to do the processing for a good speed-up, but it still wouldn't beat the performance of e.g. a mutable array. This is just one of those places where \"plain vanilla\" Joypy doesn't shine (in default performance. The legendary *Sufficiently-Smart Compiler* would of course rewrite this function to use an array \"under the hood\".)\n", - "\n", - "In the meantime, I'm going to write a primitive function that just does what we need." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import D, J, V, define\n", - "from joy.library import SimpleFunctionWrapper\n", - "from joy.utils.stack import list_to_stack\n", - "\n", - "\n", - "@SimpleFunctionWrapper\n", - "def incr_at(stack):\n", - " '''Given a index and a sequence of integers, increment the integer at the index.\n", - "\n", - " E.g.:\n", - "\n", - " 3 [0 1 2 3 4 5] incr_at\n", - " -----------------------------\n", - " [0 1 2 4 4 5]\n", - " \n", - " '''\n", - " sequence, (i, stack) = stack\n", - " mem = []\n", - " while i >= 0:\n", - " term, sequence = sequence\n", - " mem.append(term)\n", - " i -= 1\n", - " mem[-1] += 1\n", - " return list_to_stack(mem, sequence), stack\n", - "\n", - "\n", - "D['incr_at'] = incr_at" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 1 2 4 4 5]\n" - ] - } - ], - "source": [ - "J('3 [0 1 2 3 4 5] incr_at')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### get the value at index\n", - "\n", - " 3 0 [0 1 2 3 4] [roll< at] nullary\n", - " 3 0 [0 1 2 n 4] n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### increment the value at the index\n", - "\n", - " 3 0 [0 1 2 n 4] n [Q] dip\n", - " 3 0 [0 1 2 n 4] Q n\n", - " 3 0 [0 1 2 n 4] [popd incr_at] unary n\n", - " 3 0 [0 1 2 n+1 4] n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### add the value gotten to the index\n", - "\n", - " 3 0 [0 1 2 n+1 4] n [+] cons dipd\n", - " 3 0 [0 1 2 n+1 4] [n +] dipd\n", - " 3 n + 0 [0 1 2 n+1 4]\n", - " 3+n 0 [0 1 2 n+1 4]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### increment the step count\n", - "\n", - " 3+n 0 [0 1 2 n+1 4] [++] dip\n", - " 3+n 1 [0 1 2 n+1 4]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### All together now...\n", - "\n", - " get_value == [roll< at] nullary\n", - " incr_value == [[popd incr_at] unary] dip\n", - " add_value == [+] cons dipd\n", - " incr_step_count == [++] dip\n", - "\n", - " R1 == get_value incr_value add_value incr_step_count\n", - "\n", - " F == [P] [T] [R1] primrec\n", - " \n", - " F == [popop !size! >=] [roll< pop] [get_value incr_value add_value incr_step_count] primrec" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "from joy.library import DefinitionWrapper\n", - "\n", - "\n", - "DefinitionWrapper.add_definitions('''\n", - "\n", - " get_value == [roll< at] nullary\n", - " incr_value == [[popd incr_at] unary] dip\n", - " add_value == [+] cons dipd\n", - "incr_step_count == [++] dip\n", - "\n", - " AoC2017.5.0 == get_value incr_value add_value incr_step_count\n", - "\n", - "''', D)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "define('F == [popop 5 >=] [roll< popop] [AoC2017.5.0] primrec')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5\n" - ] - } - ], - "source": [ - "J('0 0 [0 3 0 1 -3] F')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Preamble for setting up predicate, `index`, and `step-count`\n", - "\n", - "We want to go from this to this:\n", - "\n", - " [...] AoC2017.5.preamble\n", - " ------------------------------\n", - " 0 0 [...] [popop n >=]\n", - "\n", - "Where `n` is the size of the sequence.\n", - "\n", - "The first part is obviously `0 0 roll<`, then `dup size`:\n", - "\n", - " [...] 0 0 roll< dup size\n", - " 0 0 [...] n\n", - "\n", - "Then:\n", - "\n", - " 0 0 [...] n [>=] cons [popop] swoncat\n", - "\n", - "So:\n", - "\n", - " init-index-and-step-count == 0 0 roll<\n", - " prepare-predicate == dup size [>=] cons [popop] swoncat\n", - "\n", - " AoC2017.5.preamble == init-index-and-step-count prepare-predicate" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "DefinitionWrapper.add_definitions('''\n", - "\n", - "init-index-and-step-count == 0 0 roll<\n", - " prepare-predicate == dup size [>=] cons [popop] swoncat\n", - "\n", - " AoC2017.5.preamble == init-index-and-step-count prepare-predicate\n", - "\n", - " AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec\n", - "\n", - "''', D)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5\n" - ] - } - ], - "source": [ - "J('[0 3 0 1 -3] AoC2017.5')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec\n", - "\n", - " AoC2017.5.0 == get_value incr_value add_value incr_step_count\n", - " AoC2017.5.preamble == init-index-and-step-count prepare-predicate\n", - "\n", - " get_value == [roll< at] nullary\n", - " incr_value == [[popd incr_at] unary] dip\n", - " add_value == [+] cons dipd\n", - " incr_step_count == [++] dip\n", - "\n", - " init-index-and-step-count == 0 0 roll<\n", - " prepare-predicate == dup size [>=] cons [popop] swoncat\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is by far the largest program I have yet written in Joy. Even with the `incr_at` function it is still a bear. There may be an arrangement of the parameters that would permit more elegant definitions, but it still wouldn't be as efficient as something written in assembly, C, or even Python." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Advent of Code 2017 December 5th.md b/docs/Advent of Code 2017 December 5th.md deleted file mode 100644 index 8edfe6f..0000000 --- a/docs/Advent of Code 2017 December 5th.md +++ /dev/null @@ -1,244 +0,0 @@ - -# Advent of Code 2017 - -## December 5th -...a list of the offsets for each jump. Jumps are relative: -1 moves to the previous instruction, and 2 skips the next one. Start at the first instruction in the list. The goal is to follow the jumps until one leads outside the list. - -In addition, these instructions are a little strange; after each jump, the offset of that instruction increases by 1. So, if you come across an offset of 3, you would move three instructions forward, but change it to a 4 for the next time it is encountered. - -For example, consider the following list of jump offsets: - - 0 - 3 - 0 - 1 - -3 - -Positive jumps ("forward") move downward; negative jumps move upward. For legibility in this example, these offset values will be written all on one line, with the current instruction marked in parentheses. The following steps would be taken before an exit is found: - -* (0) 3 0 1 -3 - before we have taken any steps. -* (1) 3 0 1 -3 - jump with offset 0 (that is, don't jump at all). Fortunately, the instruction is then incremented to 1. -* 2 (3) 0 1 -3 - step forward because of the instruction we just modified. The first instruction is incremented again, now to 2. -* 2 4 0 1 (-3) - jump all the way to the end; leave a 4 behind. -* 2 (4) 0 1 -2 - go back to where we just were; increment -3 to -2. -* 2 5 0 1 -2 - jump 4 steps forward, escaping the maze. - -In this example, the exit is reached in 5 steps. - -How many steps does it take to reach the exit? - -## Breakdown -For now, I'm going to assume a starting state with the size of the sequence pre-computed. We need it to define the exit condition and it is a trivial preamble to generate it. We then need and `index` and a `step-count`, which are both initially zero. Then we have the sequence itself, and some recursive function `F` that does the work. - - size index step-count [...] F - ----------------------------------- - step-count - - F == [P] [T] [R1] [R2] genrec - -Later on I was thinking about it and the Forth heuristic came to mind, to wit: four things on the stack are kind of much. Immediately I realized that the size properly belongs in the predicate of `F`! D'oh! - - index step-count [...] F - ------------------------------ - step-count - -So, let's start by nailing down the predicate: - - F == [P] [T] [R1] [R2] genrec - == [P] [T] [R1 [F] R2] ifte - - 0 0 [0 3 0 1 -3] popop 5 >= - - P == popop 5 >= - -Now we need the else-part: - - index step-count [0 3 0 1 -3] roll< popop - - E == roll< popop - -Last but not least, the recursive branch - - 0 0 [0 3 0 1 -3] R1 [F] R2 - -The `R1` function has a big job: - - R1 == get the value at index - increment the value at the index - add the value gotten to the index - increment the step count - -The only tricky thing there is incrementing an integer in the sequence. Joy sequences are not particularly good for random access. We could encode the list of jump offsets in a big integer and use math to do the processing for a good speed-up, but it still wouldn't beat the performance of e.g. a mutable array. This is just one of those places where "plain vanilla" Joypy doesn't shine (in default performance. The legendary *Sufficiently-Smart Compiler* would of course rewrite this function to use an array "under the hood".) - -In the meantime, I'm going to write a primitive function that just does what we need. - - -```python -from notebook_preamble import D, J, V, define -from joy.library import SimpleFunctionWrapper -from joy.utils.stack import list_to_stack - - -@SimpleFunctionWrapper -def incr_at(stack): - '''Given a index and a sequence of integers, increment the integer at the index. - - E.g.: - - 3 [0 1 2 3 4 5] incr_at - ----------------------------- - [0 1 2 4 4 5] - - ''' - sequence, (i, stack) = stack - mem = [] - while i >= 0: - term, sequence = sequence - mem.append(term) - i -= 1 - mem[-1] += 1 - return list_to_stack(mem, sequence), stack - - -D['incr_at'] = incr_at -``` - - -```python -J('3 [0 1 2 3 4 5] incr_at') -``` - - [0 1 2 4 4 5] - - -### get the value at index - - 3 0 [0 1 2 3 4] [roll< at] nullary - 3 0 [0 1 2 n 4] n - -### increment the value at the index - - 3 0 [0 1 2 n 4] n [Q] dip - 3 0 [0 1 2 n 4] Q n - 3 0 [0 1 2 n 4] [popd incr_at] unary n - 3 0 [0 1 2 n+1 4] n - -### add the value gotten to the index - - 3 0 [0 1 2 n+1 4] n [+] cons dipd - 3 0 [0 1 2 n+1 4] [n +] dipd - 3 n + 0 [0 1 2 n+1 4] - 3+n 0 [0 1 2 n+1 4] - -### increment the step count - - 3+n 0 [0 1 2 n+1 4] [++] dip - 3+n 1 [0 1 2 n+1 4] - -### All together now... - - get_value == [roll< at] nullary - incr_value == [[popd incr_at] unary] dip - add_value == [+] cons dipd - incr_step_count == [++] dip - - R1 == get_value incr_value add_value incr_step_count - - F == [P] [T] [R1] primrec - - F == [popop !size! >=] [roll< pop] [get_value incr_value add_value incr_step_count] primrec - - -```python -from joy.library import DefinitionWrapper - - -DefinitionWrapper.add_definitions(''' - - get_value == [roll< at] nullary - incr_value == [[popd incr_at] unary] dip - add_value == [+] cons dipd -incr_step_count == [++] dip - - AoC2017.5.0 == get_value incr_value add_value incr_step_count - -''', D) -``` - - -```python -define('F == [popop 5 >=] [roll< popop] [AoC2017.5.0] primrec') -``` - - -```python -J('0 0 [0 3 0 1 -3] F') -``` - - 5 - - -### Preamble for setting up predicate, `index`, and `step-count` - -We want to go from this to this: - - [...] AoC2017.5.preamble - ------------------------------ - 0 0 [...] [popop n >=] - -Where `n` is the size of the sequence. - -The first part is obviously `0 0 roll<`, then `dup size`: - - [...] 0 0 roll< dup size - 0 0 [...] n - -Then: - - 0 0 [...] n [>=] cons [popop] swoncat - -So: - - init-index-and-step-count == 0 0 roll< - prepare-predicate == dup size [>=] cons [popop] swoncat - - AoC2017.5.preamble == init-index-and-step-count prepare-predicate - - -```python -DefinitionWrapper.add_definitions(''' - -init-index-and-step-count == 0 0 roll< - prepare-predicate == dup size [>=] cons [popop] swoncat - - AoC2017.5.preamble == init-index-and-step-count prepare-predicate - - AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec - -''', D) -``` - - -```python -J('[0 3 0 1 -3] AoC2017.5') -``` - - 5 - - - - AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec - - AoC2017.5.0 == get_value incr_value add_value incr_step_count - AoC2017.5.preamble == init-index-and-step-count prepare-predicate - - get_value == [roll< at] nullary - incr_value == [[popd incr_at] unary] dip - add_value == [+] cons dipd - incr_step_count == [++] dip - - init-index-and-step-count == 0 0 roll< - prepare-predicate == dup size [>=] cons [popop] swoncat - - -This is by far the largest program I have yet written in Joy. Even with the `incr_at` function it is still a bear. There may be an arrangement of the parameters that would permit more elegant definitions, but it still wouldn't be as efficient as something written in assembly, C, or even Python. diff --git a/docs/Advent of Code 2017 December 5th.rst b/docs/Advent of Code 2017 December 5th.rst deleted file mode 100644 index 5040c69..0000000 --- a/docs/Advent of Code 2017 December 5th.rst +++ /dev/null @@ -1,324 +0,0 @@ - -Advent of Code 2017 -=================== - -December 5th ------------- - -...a list of the offsets for each jump. Jumps are relative: -1 moves to -the previous instruction, and 2 skips the next one. Start at the first -instruction in the list. The goal is to follow the jumps until one leads -outside the list. - -In addition, these instructions are a little strange; after each jump, -the offset of that instruction increases by 1. So, if you come across an -offset of 3, you would move three instructions forward, but change it to -a 4 for the next time it is encountered. - -For example, consider the following list of jump offsets: - -:: - - 0 - 3 - 0 - 1 - -3 - -Positive jumps ("forward") move downward; negative jumps move upward. -For legibility in this example, these offset values will be written all -on one line, with the current instruction marked in parentheses. The -following steps would be taken before an exit is found: - -- - - (0) 3 0 1 -3 - before we have taken any steps. - -- - - (1) 3 0 1 -3 - jump with offset 0 (that is, don't jump at all). - Fortunately, the instruction is then incremented to 1. - -- 2 (3) 0 1 -3 - step forward because of the instruction we just - modified. The first instruction is incremented again, now to 2. -- 2 4 0 1 (-3) - jump all the way to the end; leave a 4 behind. -- 2 (4) 0 1 -2 - go back to where we just were; increment -3 to -2. -- 2 5 0 1 -2 - jump 4 steps forward, escaping the maze. - -In this example, the exit is reached in 5 steps. - -How many steps does it take to reach the exit? - -Breakdown ---------- - -For now, I'm going to assume a starting state with the size of the -sequence pre-computed. We need it to define the exit condition and it is -a trivial preamble to generate it. We then need and ``index`` and a -``step-count``, which are both initially zero. Then we have the sequence -itself, and some recursive function ``F`` that does the work. - -:: - - size index step-count [...] F - ----------------------------------- - step-count - - F == [P] [T] [R1] [R2] genrec - -Later on I was thinking about it and the Forth heuristic came to mind, -to wit: four things on the stack are kind of much. Immediately I -realized that the size properly belongs in the predicate of ``F``! D'oh! - -:: - - index step-count [...] F - ------------------------------ - step-count - -So, let's start by nailing down the predicate: - -:: - - F == [P] [T] [R1] [R2] genrec - == [P] [T] [R1 [F] R2] ifte - - 0 0 [0 3 0 1 -3] popop 5 >= - - P == popop 5 >= - -Now we need the else-part: - -:: - - index step-count [0 3 0 1 -3] roll< popop - - E == roll< popop - -Last but not least, the recursive branch - -:: - - 0 0 [0 3 0 1 -3] R1 [F] R2 - -The ``R1`` function has a big job: - -:: - - R1 == get the value at index - increment the value at the index - add the value gotten to the index - increment the step count - -The only tricky thing there is incrementing an integer in the sequence. -Joy sequences are not particularly good for random access. We could -encode the list of jump offsets in a big integer and use math to do the -processing for a good speed-up, but it still wouldn't beat the -performance of e.g. a mutable array. This is just one of those places -where "plain vanilla" Joypy doesn't shine (in default performance. The -legendary *Sufficiently-Smart Compiler* would of course rewrite this -function to use an array "under the hood".) - -In the meantime, I'm going to write a primitive function that just does -what we need. - -.. code:: ipython2 - - from notebook_preamble import D, J, V, define - from joy.library import SimpleFunctionWrapper - from joy.utils.stack import list_to_stack - - - @SimpleFunctionWrapper - def incr_at(stack): - '''Given a index and a sequence of integers, increment the integer at the index. - - E.g.: - - 3 [0 1 2 3 4 5] incr_at - ----------------------------- - [0 1 2 4 4 5] - - ''' - sequence, (i, stack) = stack - mem = [] - while i >= 0: - term, sequence = sequence - mem.append(term) - i -= 1 - mem[-1] += 1 - return list_to_stack(mem, sequence), stack - - - D['incr_at'] = incr_at - -.. code:: ipython2 - - J('3 [0 1 2 3 4 5] incr_at') - - -.. parsed-literal:: - - [0 1 2 4 4 5] - - -get the value at index -~~~~~~~~~~~~~~~~~~~~~~ - -:: - - 3 0 [0 1 2 3 4] [roll< at] nullary - 3 0 [0 1 2 n 4] n - -increment the value at the index -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - 3 0 [0 1 2 n 4] n [Q] dip - 3 0 [0 1 2 n 4] Q n - 3 0 [0 1 2 n 4] [popd incr_at] unary n - 3 0 [0 1 2 n+1 4] n - -add the value gotten to the index -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - 3 0 [0 1 2 n+1 4] n [+] cons dipd - 3 0 [0 1 2 n+1 4] [n +] dipd - 3 n + 0 [0 1 2 n+1 4] - 3+n 0 [0 1 2 n+1 4] - -increment the step count -~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - 3+n 0 [0 1 2 n+1 4] [++] dip - 3+n 1 [0 1 2 n+1 4] - -All together now... -~~~~~~~~~~~~~~~~~~~ - -:: - - get_value == [roll< at] nullary - incr_value == [[popd incr_at] unary] dip - add_value == [+] cons dipd - incr_step_count == [++] dip - - R1 == get_value incr_value add_value incr_step_count - - F == [P] [T] [R1] primrec - - F == [popop !size! >=] [roll< pop] [get_value incr_value add_value incr_step_count] primrec - -.. code:: ipython2 - - from joy.library import DefinitionWrapper - - - DefinitionWrapper.add_definitions(''' - - get_value == [roll< at] nullary - incr_value == [[popd incr_at] unary] dip - add_value == [+] cons dipd - incr_step_count == [++] dip - - AoC2017.5.0 == get_value incr_value add_value incr_step_count - - ''', D) - -.. code:: ipython2 - - define('F == [popop 5 >=] [roll< popop] [AoC2017.5.0] primrec') - -.. code:: ipython2 - - J('0 0 [0 3 0 1 -3] F') - - -.. parsed-literal:: - - 5 - - -Preamble for setting up predicate, ``index``, and ``step-count`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -We want to go from this to this: - -:: - - [...] AoC2017.5.preamble - ------------------------------ - 0 0 [...] [popop n >=] - -Where ``n`` is the size of the sequence. - -The first part is obviously ``0 0 roll<``, then ``dup size``: - -:: - - [...] 0 0 roll< dup size - 0 0 [...] n - -Then: - -:: - - 0 0 [...] n [>=] cons [popop] swoncat - -So: - -:: - - init-index-and-step-count == 0 0 roll< - prepare-predicate == dup size [>=] cons [popop] swoncat - - AoC2017.5.preamble == init-index-and-step-count prepare-predicate - -.. code:: ipython2 - - DefinitionWrapper.add_definitions(''' - - init-index-and-step-count == 0 0 roll< - prepare-predicate == dup size [>=] cons [popop] swoncat - - AoC2017.5.preamble == init-index-and-step-count prepare-predicate - - AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec - - ''', D) - -.. code:: ipython2 - - J('[0 3 0 1 -3] AoC2017.5') - - -.. parsed-literal:: - - 5 - - -:: - - AoC2017.5 == AoC2017.5.preamble [roll< popop] [AoC2017.5.0] primrec - - AoC2017.5.0 == get_value incr_value add_value incr_step_count - AoC2017.5.preamble == init-index-and-step-count prepare-predicate - - get_value == [roll< at] nullary - incr_value == [[popd incr_at] unary] dip - add_value == [+] cons dipd - incr_step_count == [++] dip - - init-index-and-step-count == 0 0 roll< - prepare-predicate == dup size [>=] cons [popop] swoncat - -This is by far the largest program I have yet written in Joy. Even with -the ``incr_at`` function it is still a bear. There may be an arrangement -of the parameters that would permit more elegant definitions, but it -still wouldn't be as efficient as something written in assembly, C, or -even Python. diff --git a/docs/Advent of Code 2017 December 6th.html b/docs/Advent of Code 2017 December 6th.html deleted file mode 100644 index 7fcb072..0000000 --- a/docs/Advent of Code 2017 December 6th.html +++ /dev/null @@ -1,12415 +0,0 @@ - - - -Advent of Code 2017 December 6th - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Advent of Code 2017

December 6th

-
[0 2 7 0] dup max
- -
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import D, J, V, define
-
- -
-
-
- -
-
-
-
In [2]:
-
-
-
J('[0 2 7 0] dup max')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[0 2 7 0] 7
-
-
-
- -
-
- -
-
-
-
In [3]:
-
-
-
from joy.library import SimpleFunctionWrapper
-from joy.utils.stack import list_to_stack
-
-
-@SimpleFunctionWrapper
-def index_of(stack):
-    '''Given a sequence and a item, return the index of the item, or -1 if not found.
-
-    E.g.:
-
-       [a b c] a index_of
-    ------------------------
-               0
-
-       [a b c] d index_of
-    ------------------------
-            -1
-
-    '''
-    item, (sequence, stack) = stack
-    i = 0
-    while sequence:
-        term, sequence = sequence
-        if term == item:
-            break
-        i += 1
-    else:
-        i = -1
-    return i, stack
-
-
-D['index_of'] = index_of
-
- -
-
-
- -
-
-
-
In [4]:
-
-
-
J('[0 2 7 0] 7 index_of')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2
-
-
-
- -
-
- -
-
-
-
In [5]:
-
-
-
J('[0 2 7 0] 23 index_of')
-
- -
-
-
- -
-
- - -
- -
- - -
-
-1
-
-
-
- -
-
- -
-
-
-
-
-

Starting at index distribute count "blocks" to the "banks" in the sequence.

- -
[...] count index distribute
-----------------------------
-           [...]
-
-
-

This seems like it would be a PITA to implement in Joypy...

- -
-
-
-
-
-
In [6]:
-
-
-
from joy.utils.stack import iter_stack, list_to_stack
-
-
-@SimpleFunctionWrapper
-def distribute(stack):
-    '''Starting at index+1 distribute count "blocks" to the "banks" in the sequence.
-
-    [...] count index distribute
-    ----------------------------
-               [...]
-
-    '''
-    index, (count, (sequence, stack)) = stack
-    assert count >= 0
-    cheat = list(iter_stack(sequence))
-    n = len(cheat)
-    assert index < n
-    cheat[index] = 0
-    while count:
-        index += 1
-        index %= n
-        cheat[index] += 1
-        count -= 1
-    return list_to_stack(cheat), stack
-
-
-D['distribute'] = distribute
-
- -
-
-
- -
-
-
-
In [7]:
-
-
-
J('[0 2 7 0] dup max [index_of] nullary distribute')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[2 4 1 2]
-
-
-
- -
-
- -
-
-
-
In [8]:
-
-
-
J('[2 4 1 2] dup max [index_of] nullary distribute')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[3 1 2 3]
-
-
-
- -
-
- -
-
-
-
In [9]:
-
-
-
J('[3 1 2 3] dup max [index_of] nullary distribute')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[0 2 3 4]
-
-
-
- -
-
- -
-
-
-
In [10]:
-
-
-
J('[0 2 3 4] dup max [index_of] nullary distribute')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[1 3 4 1]
-
-
-
- -
-
- -
-
-
-
In [11]:
-
-
-
J('[1 3 4 1] dup max [index_of] nullary distribute')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[2 4 1 2]
-
-
-
- -
-
- -
-
-
-
-
-

Recalling "Generator Programs"

-
[a F] x
-[a F] a F 
-
-[a F] a swap [C] dip rest cons
-a   [a F]    [C] dip rest cons
-a C [a F]            rest cons
-a C   [F]                 cons
-
-w/ C == dup G
-
-a dup G [F] cons
-a a   G [F] cons
-
-w/ G == dup max [index_of] nullary distribute
- -
-
-
-
-
-
In [12]:
-
-
-
define('direco == dip rest cons')
-
- -
-
-
- -
-
-
-
In [13]:
-
-
-
define('G == [direco] cons [swap] swoncat cons')
-
- -
-
-
- -
-
-
-
In [14]:
-
-
-
define('make_distributor == [dup dup max [index_of] nullary distribute] G')
-
- -
-
-
- -
-
-
-
In [15]:
-
-
-
J('[0 2 7 0] make_distributor 6 [x] times pop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[0 2 7 0] [2 4 1 2] [3 1 2 3] [0 2 3 4] [1 3 4 1] [2 4 1 2]
-
-
-
- -
-
- -
-
-
-
-
-

A function to drive a generator and count how many states before a repeat.

First draft:

- -
[] [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec
-
-
-

(?)

- -
[]       [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec
-[] [...] [GEN]   [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec
-[] [...] [GEN]    pop index_of 0 >=
-[] [...]              index_of 0 >=
-                            -1 0 >=
-                             False
-
-
-

Base case

- -
[] [...] [GEN] [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec
-[] [...] [GEN]                      pop size --
-[] [...]                                size --
-[] [...]                                size --
-
-
-

A mistake, popop and no need for --

- -
[] [...] [GEN] popop size
-[]                   size
-n
-
-
-

Recursive case

- -
[] [...] [GEN] [pop index_of 0 >=] [popop size] [[swons] dip x] primrec
-[] [...] [GEN]                                   [swons] dip x  F
-[] [...] swons [GEN]                                         x  F
-[[...]]        [GEN]                                         x  F
-[[...]] [...]  [GEN]                                            F
-
-[[...]] [...] [GEN] F
-
-
-

What have we learned?

- -
F == [pop index_of 0 >=] [popop size] [[swons] dip x] primrec
- -
-
-
-
-
-
In [16]:
-
-
-
define('count_states == [] swap x [pop index_of 0 >=] [popop size] [[swons] dip x] primrec')
-
- -
-
-
- -
-
-
-
In [17]:
-
-
-
define('AoC2017.6 == make_distributor count_states')
-
- -
-
-
- -
-
-
-
In [18]:
-
-
-
J('[0 2 7 0] AoC2017.6')
-
- -
-
-
- -
-
- - -
- -
- - -
-
5
-
-
-
- -
-
- -
-
-
-
In [19]:
-
-
-
J('[1 1 1] AoC2017.6')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4
-
-
-
- -
-
- -
-
-
-
In [20]:
-
-
-
J('[8 0 0 0 0 0] AoC2017.6')
-
- -
-
-
- -
-
- - -
- -
- - -
-
15
-
-
-
- -
-
- -
-
-
- - - - - - diff --git a/docs/Advent of Code 2017 December 6th.ipynb b/docs/Advent of Code 2017 December 6th.ipynb deleted file mode 100644 index 6d7f188..0000000 --- a/docs/Advent of Code 2017 December 6th.ipynb +++ /dev/null @@ -1,457 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Advent of Code 2017\n", - "\n", - "## December 6th\n", - "\n", - "\n", - " [0 2 7 0] dup max\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import D, J, V, define" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 2 7 0] 7\n" - ] - } - ], - "source": [ - "J('[0 2 7 0] dup max')" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "from joy.library import SimpleFunctionWrapper\n", - "from joy.utils.stack import list_to_stack\n", - "\n", - "\n", - "@SimpleFunctionWrapper\n", - "def index_of(stack):\n", - " '''Given a sequence and a item, return the index of the item, or -1 if not found.\n", - "\n", - " E.g.:\n", - "\n", - " [a b c] a index_of\n", - " ------------------------\n", - " 0\n", - "\n", - " [a b c] d index_of\n", - " ------------------------\n", - " -1\n", - "\n", - " '''\n", - " item, (sequence, stack) = stack\n", - " i = 0\n", - " while sequence:\n", - " term, sequence = sequence\n", - " if term == item:\n", - " break\n", - " i += 1\n", - " else:\n", - " i = -1\n", - " return i, stack\n", - "\n", - "\n", - "D['index_of'] = index_of" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "J('[0 2 7 0] 7 index_of')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-1\n" - ] - } - ], - "source": [ - "J('[0 2 7 0] 23 index_of')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Starting at `index` distribute `count` \"blocks\" to the \"banks\" in the sequence.\n", - "\n", - " [...] count index distribute\n", - " ----------------------------\n", - " [...]\n", - "\n", - "This seems like it would be a PITA to implement in Joypy..." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "from joy.utils.stack import iter_stack, list_to_stack\n", - "\n", - "\n", - "@SimpleFunctionWrapper\n", - "def distribute(stack):\n", - " '''Starting at index+1 distribute count \"blocks\" to the \"banks\" in the sequence.\n", - "\n", - " [...] count index distribute\n", - " ----------------------------\n", - " [...]\n", - "\n", - " '''\n", - " index, (count, (sequence, stack)) = stack\n", - " assert count >= 0\n", - " cheat = list(iter_stack(sequence))\n", - " n = len(cheat)\n", - " assert index < n\n", - " cheat[index] = 0\n", - " while count:\n", - " index += 1\n", - " index %= n\n", - " cheat[index] += 1\n", - " count -= 1\n", - " return list_to_stack(cheat), stack\n", - "\n", - "\n", - "D['distribute'] = distribute" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 4 1 2]\n" - ] - } - ], - "source": [ - "J('[0 2 7 0] dup max [index_of] nullary distribute')" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 1 2 3]\n" - ] - } - ], - "source": [ - "J('[2 4 1 2] dup max [index_of] nullary distribute')" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 2 3 4]\n" - ] - } - ], - "source": [ - "J('[3 1 2 3] dup max [index_of] nullary distribute')" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 3 4 1]\n" - ] - } - ], - "source": [ - "J('[0 2 3 4] dup max [index_of] nullary distribute')" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 4 1 2]\n" - ] - } - ], - "source": [ - "J('[1 3 4 1] dup max [index_of] nullary distribute')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Recalling \"Generator Programs\"\n", - "\n", - " [a F] x\n", - " [a F] a F \n", - " \n", - " [a F] a swap [C] dip rest cons\n", - " a [a F] [C] dip rest cons\n", - " a C [a F] rest cons\n", - " a C [F] cons\n", - "\n", - " w/ C == dup G\n", - "\n", - " a dup G [F] cons\n", - " a a G [F] cons\n", - "\n", - " w/ G == dup max [index_of] nullary distribute" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "define('direco == dip rest cons')" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "define('G == [direco] cons [swap] swoncat cons')" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "define('make_distributor == [dup dup max [index_of] nullary distribute] G')" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 2 7 0] [2 4 1 2] [3 1 2 3] [0 2 3 4] [1 3 4 1] [2 4 1 2]\n" - ] - } - ], - "source": [ - "J('[0 2 7 0] make_distributor 6 [x] times pop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### A function to drive a generator and count how many states before a repeat.\n", - "First draft:\n", - "\n", - " [] [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec\n", - "\n", - "(?)\n", - "\n", - " [] [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec\n", - " [] [...] [GEN] [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec\n", - " [] [...] [GEN] pop index_of 0 >=\n", - " [] [...] index_of 0 >=\n", - " -1 0 >=\n", - " False\n", - "\n", - "Base case\n", - "\n", - " [] [...] [GEN] [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec\n", - " [] [...] [GEN] pop size --\n", - " [] [...] size --\n", - " [] [...] size --\n", - "\n", - "A mistake, `popop` and no need for `--`\n", - "\n", - " [] [...] [GEN] popop size\n", - " [] size\n", - " n\n", - "\n", - "Recursive case\n", - "\n", - " [] [...] [GEN] [pop index_of 0 >=] [popop size] [[swons] dip x] primrec\n", - " [] [...] [GEN] [swons] dip x F\n", - " [] [...] swons [GEN] x F\n", - " [[...]] [GEN] x F\n", - " [[...]] [...] [GEN] F\n", - "\n", - " [[...]] [...] [GEN] F\n", - "\n", - "What have we learned?\n", - "\n", - " F == [pop index_of 0 >=] [popop size] [[swons] dip x] primrec" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [], - "source": [ - "define('count_states == [] swap x [pop index_of 0 >=] [popop size] [[swons] dip x] primrec')" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "define('AoC2017.6 == make_distributor count_states')" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5\n" - ] - } - ], - "source": [ - "J('[0 2 7 0] AoC2017.6')" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n" - ] - } - ], - "source": [ - "J('[1 1 1] AoC2017.6')" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15\n" - ] - } - ], - "source": [ - "J('[8 0 0 0 0 0] AoC2017.6')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Advent of Code 2017 December 6th.md b/docs/Advent of Code 2017 December 6th.md deleted file mode 100644 index 0697b11..0000000 --- a/docs/Advent of Code 2017 December 6th.md +++ /dev/null @@ -1,267 +0,0 @@ - -# Advent of Code 2017 - -## December 6th - - - [0 2 7 0] dup max - - - -```python -from notebook_preamble import D, J, V, define -``` - - -```python -J('[0 2 7 0] dup max') -``` - - [0 2 7 0] 7 - - - -```python -from joy.library import SimpleFunctionWrapper -from joy.utils.stack import list_to_stack - - -@SimpleFunctionWrapper -def index_of(stack): - '''Given a sequence and a item, return the index of the item, or -1 if not found. - - E.g.: - - [a b c] a index_of - ------------------------ - 0 - - [a b c] d index_of - ------------------------ - -1 - - ''' - item, (sequence, stack) = stack - i = 0 - while sequence: - term, sequence = sequence - if term == item: - break - i += 1 - else: - i = -1 - return i, stack - - -D['index_of'] = index_of -``` - - -```python -J('[0 2 7 0] 7 index_of') -``` - - 2 - - - -```python -J('[0 2 7 0] 23 index_of') -``` - - -1 - - -Starting at `index` distribute `count` "blocks" to the "banks" in the sequence. - - [...] count index distribute - ---------------------------- - [...] - -This seems like it would be a PITA to implement in Joypy... - - -```python -from joy.utils.stack import iter_stack, list_to_stack - - -@SimpleFunctionWrapper -def distribute(stack): - '''Starting at index+1 distribute count "blocks" to the "banks" in the sequence. - - [...] count index distribute - ---------------------------- - [...] - - ''' - index, (count, (sequence, stack)) = stack - assert count >= 0 - cheat = list(iter_stack(sequence)) - n = len(cheat) - assert index < n - cheat[index] = 0 - while count: - index += 1 - index %= n - cheat[index] += 1 - count -= 1 - return list_to_stack(cheat), stack - - -D['distribute'] = distribute -``` - - -```python -J('[0 2 7 0] dup max [index_of] nullary distribute') -``` - - [2 4 1 2] - - - -```python -J('[2 4 1 2] dup max [index_of] nullary distribute') -``` - - [3 1 2 3] - - - -```python -J('[3 1 2 3] dup max [index_of] nullary distribute') -``` - - [0 2 3 4] - - - -```python -J('[0 2 3 4] dup max [index_of] nullary distribute') -``` - - [1 3 4 1] - - - -```python -J('[1 3 4 1] dup max [index_of] nullary distribute') -``` - - [2 4 1 2] - - -### Recalling "Generator Programs" - - [a F] x - [a F] a F - - [a F] a swap [C] dip rest cons - a [a F] [C] dip rest cons - a C [a F] rest cons - a C [F] cons - - w/ C == dup G - - a dup G [F] cons - a a G [F] cons - - w/ G == dup max [index_of] nullary distribute - - -```python -define('direco == dip rest cons') -``` - - -```python -define('G == [direco] cons [swap] swoncat cons') -``` - - -```python -define('make_distributor == [dup dup max [index_of] nullary distribute] G') -``` - - -```python -J('[0 2 7 0] make_distributor 6 [x] times pop') -``` - - [0 2 7 0] [2 4 1 2] [3 1 2 3] [0 2 3 4] [1 3 4 1] [2 4 1 2] - - -### A function to drive a generator and count how many states before a repeat. -First draft: - - [] [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - -(?) - - [] [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - [] [...] [GEN] [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - [] [...] [GEN] pop index_of 0 >= - [] [...] index_of 0 >= - -1 0 >= - False - -Base case - - [] [...] [GEN] [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - [] [...] [GEN] pop size -- - [] [...] size -- - [] [...] size -- - -A mistake, `popop` and no need for `--` - - [] [...] [GEN] popop size - [] size - n - -Recursive case - - [] [...] [GEN] [pop index_of 0 >=] [popop size] [[swons] dip x] primrec - [] [...] [GEN] [swons] dip x F - [] [...] swons [GEN] x F - [[...]] [GEN] x F - [[...]] [...] [GEN] F - - [[...]] [...] [GEN] F - -What have we learned? - - F == [pop index_of 0 >=] [popop size] [[swons] dip x] primrec - - -```python -define('count_states == [] swap x [pop index_of 0 >=] [popop size] [[swons] dip x] primrec') -``` - - -```python -define('AoC2017.6 == make_distributor count_states') -``` - - -```python -J('[0 2 7 0] AoC2017.6') -``` - - 5 - - - -```python -J('[1 1 1] AoC2017.6') -``` - - 4 - - - -```python -J('[8 0 0 0 0 0] AoC2017.6') -``` - - 15 - diff --git a/docs/Advent of Code 2017 December 6th.rst b/docs/Advent of Code 2017 December 6th.rst deleted file mode 100644 index 5da2f1b..0000000 --- a/docs/Advent of Code 2017 December 6th.rst +++ /dev/null @@ -1,305 +0,0 @@ - -Advent of Code 2017 -=================== - -December 6th ------------- - -:: - - [0 2 7 0] dup max - -.. code:: ipython2 - - from notebook_preamble import D, J, V, define - -.. code:: ipython2 - - J('[0 2 7 0] dup max') - - -.. parsed-literal:: - - [0 2 7 0] 7 - - -.. code:: ipython2 - - from joy.library import SimpleFunctionWrapper - from joy.utils.stack import list_to_stack - - - @SimpleFunctionWrapper - def index_of(stack): - '''Given a sequence and a item, return the index of the item, or -1 if not found. - - E.g.: - - [a b c] a index_of - ------------------------ - 0 - - [a b c] d index_of - ------------------------ - -1 - - ''' - item, (sequence, stack) = stack - i = 0 - while sequence: - term, sequence = sequence - if term == item: - break - i += 1 - else: - i = -1 - return i, stack - - - D['index_of'] = index_of - -.. code:: ipython2 - - J('[0 2 7 0] 7 index_of') - - -.. parsed-literal:: - - 2 - - -.. code:: ipython2 - - J('[0 2 7 0] 23 index_of') - - -.. parsed-literal:: - - -1 - - -Starting at ``index`` distribute ``count`` "blocks" to the "banks" in -the sequence. - -:: - - [...] count index distribute - ---------------------------- - [...] - -This seems like it would be a PITA to implement in Joypy... - -.. code:: ipython2 - - from joy.utils.stack import iter_stack, list_to_stack - - - @SimpleFunctionWrapper - def distribute(stack): - '''Starting at index+1 distribute count "blocks" to the "banks" in the sequence. - - [...] count index distribute - ---------------------------- - [...] - - ''' - index, (count, (sequence, stack)) = stack - assert count >= 0 - cheat = list(iter_stack(sequence)) - n = len(cheat) - assert index < n - cheat[index] = 0 - while count: - index += 1 - index %= n - cheat[index] += 1 - count -= 1 - return list_to_stack(cheat), stack - - - D['distribute'] = distribute - -.. code:: ipython2 - - J('[0 2 7 0] dup max [index_of] nullary distribute') - - -.. parsed-literal:: - - [2 4 1 2] - - -.. code:: ipython2 - - J('[2 4 1 2] dup max [index_of] nullary distribute') - - -.. parsed-literal:: - - [3 1 2 3] - - -.. code:: ipython2 - - J('[3 1 2 3] dup max [index_of] nullary distribute') - - -.. parsed-literal:: - - [0 2 3 4] - - -.. code:: ipython2 - - J('[0 2 3 4] dup max [index_of] nullary distribute') - - -.. parsed-literal:: - - [1 3 4 1] - - -.. code:: ipython2 - - J('[1 3 4 1] dup max [index_of] nullary distribute') - - -.. parsed-literal:: - - [2 4 1 2] - - -Recalling "Generator Programs" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - [a F] x - [a F] a F - - [a F] a swap [C] dip rest cons - a [a F] [C] dip rest cons - a C [a F] rest cons - a C [F] cons - - w/ C == dup G - - a dup G [F] cons - a a G [F] cons - - w/ G == dup max [index_of] nullary distribute - -.. code:: ipython2 - - define('direco == dip rest cons') - -.. code:: ipython2 - - define('G == [direco] cons [swap] swoncat cons') - -.. code:: ipython2 - - define('make_distributor == [dup dup max [index_of] nullary distribute] G') - -.. code:: ipython2 - - J('[0 2 7 0] make_distributor 6 [x] times pop') - - -.. parsed-literal:: - - [0 2 7 0] [2 4 1 2] [3 1 2 3] [0 2 3 4] [1 3 4 1] [2 4 1 2] - - -A function to drive a generator and count how many states before a repeat. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -First draft: - -:: - - [] [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - -(?) - -:: - - [] [GEN] x [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - [] [...] [GEN] [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - [] [...] [GEN] pop index_of 0 >= - [] [...] index_of 0 >= - -1 0 >= - False - -Base case - -:: - - [] [...] [GEN] [pop index_of 0 >=] [pop size --] [[swons] dip x] primrec - [] [...] [GEN] pop size -- - [] [...] size -- - [] [...] size -- - -A mistake, ``popop`` and no need for ``--`` - -:: - - [] [...] [GEN] popop size - [] size - n - -Recursive case - -:: - - [] [...] [GEN] [pop index_of 0 >=] [popop size] [[swons] dip x] primrec - [] [...] [GEN] [swons] dip x F - [] [...] swons [GEN] x F - [[...]] [GEN] x F - [[...]] [...] [GEN] F - - [[...]] [...] [GEN] F - -What have we learned? - -:: - - F == [pop index_of 0 >=] [popop size] [[swons] dip x] primrec - -.. code:: ipython2 - - define('count_states == [] swap x [pop index_of 0 >=] [popop size] [[swons] dip x] primrec') - -.. code:: ipython2 - - define('AoC2017.6 == make_distributor count_states') - -.. code:: ipython2 - - J('[0 2 7 0] AoC2017.6') - - -.. parsed-literal:: - - 5 - - -.. code:: ipython2 - - J('[1 1 1] AoC2017.6') - - -.. parsed-literal:: - - 4 - - -.. code:: ipython2 - - J('[8 0 0 0 0 0] AoC2017.6') - - -.. parsed-literal:: - - 15 - diff --git a/docs/Document.md b/docs/Document.md deleted file mode 100644 index 5c9387b..0000000 --- a/docs/Document.md +++ /dev/null @@ -1,469 +0,0 @@ - -# Joy - -This document is written to capture, at least crudely, the scope of application for Joy and the Joypy implementation. It kind of expects that you have some familiarity with Joy already. - -It is vaguely organized, in a pile. - - -## Syntax - -Very simple syntax. Could be specified as a sequence of one or more terms: - - joy ::= term term* - -Conceptually, all terms are unary functions `F :: stack -> stack` that accept a stack and return a stack. But we immediately differentiate between literals (of a few kinds), functions, and combinators (which like higher-order functions.) - - -### In Joypy there are currently four literal types. - -First we have the types borrowed from the underlying Python semantics. **Strings** (byte and Unicode with nuances depending on whether you're running under Python 2 or 3), **ints**, and **floats**. Then there is the **sequence** type, aka "quote", "list", etc... In joy it is represented by enclosing zero or more terms in square brackets: - - sequence :== '[' term* ']' - -(In Joypy it is implemented as a cons-list. All datastructures in Joypy are built out of this single sequence type, including the stack and expression. I could include Python `frozenset` but I don't.) - - literal ::= string | int | float | sequence - -Functions accept zero or more arguments from the stack and push back zero or more results. - -Combinators are functions one or more of the arguments to which are quotes containing joy expressions, and which then execute one or more of their quoted arguments to effect their function. - - term ::= literal | function | combinator - -The code for the parser is in `joy/parser.py`. - - -## Semantics - -In Joy juxtaposition of symbols is composition of functions. That means that `F G` syntactically is `G(F(...))` semantically. - -As it says in the [Wikipedia entry for Joypy](https://en.wikipedia.org/wiki/Joy_%28programming_language%29): - - "In Joy, the meaning function is a homomorphism from the syntactic monoid onto the semantic monoid. That is, the syntactic relation of concatenation of symbols maps directly onto the semantic relation of composition of functions." - -Isn't that nice? - - -## Joypy Continuation-Passing Style - -In Joypy all the combinators work by modifying the pending expression. We have enlarged the definition of function to be from a two-tuple of `(stack, expression)` to another such two-tuple: - - F :: (stack, expression) -> (stack, expression) - -Simple functions ignore the expression and pass it through unchanged, combinators do not. They can modify it and this is enough to define control-flow and other operators. - -(Actually... In Joypy the functions all also include a dictionary parameter. This allows for functions like `print_words` and `help`. It also allows for the definition of a `define` function which would let Joy code add new definitions to the dictionary during evaluation, but this is an area I am leaving unexplored at least for now. It is essentially name-binding (variables) sneaking in, breaking the purity of the system.) - - -## Evaluation - -The joy interpreter is a very simple loop. As long as the expression is non-empty the interpreter pops the next term and checks it, if it's a literal it's pushed onto the stack, if it's a function or combinator the interpreter calls it passing the current stack and expression, which are then replaced by whatever the function or combinator returns. - -There is no call stack. All state is kept either on the stack or in the pending expression. At each interpreter iteration the stack and expression are complete. (They can be pickled, saved to disc or sent over the network, and reconstituted at any time, etc...) - - -# Methods of Meta-programming - -Joy seems to lend itself to several complementary forms of meta-programming to develop more-efficient versions of functions. - - -## Compiling definitions. - -Due to the fact that "juxtaposition of symbols is composition of functions" the *simplest* way to "compile" the Joy expression `F G` would be the Python expression: - - lambda s, e, d: G(*F(s, e, d)) - -This produces a new unnamed function that delivers the output of `F` directly to `G` without passing back through the interpreter loop. - -If we wanted to do more work than that, we could inspect the bytecode of the two Python functions, figure out how they name their arguments, and attempt to produce new bytecode that corresponds to the composition of them. This is a little beyond me at the moment, but it's not unrealistic given enough time and attention. - -It will usually be easier to manually write new custom words. For example, the "plus or minus" operator `pm`, defined as: - - pm == [+] [-] cleave popdd - -Can be implemented in Python as: - - @SimpleFunctionWrapper - def pm(stack): - a, (b, stack) = stack - p = b + a - m = b - a - return m, (p, stack) - -Code that uses `pm` will will work the same but more quickly if the "compiled" version is inscribed in the dictionary. - -It would be remiss not to mention **Cython** in this connection. Many Joy functions can be transparently compiled down to machine code. - -Beyond the above, it should be possible to make use of much of the existing body of knowledge for compiling *functional programming* languages to machine code for making an actual Joy compiler. Joy omits many "features" that are common to most other languages, lambda abstraction and `let` statements for example. I have not had the time to investigate compilation of Joy in any depth so far, but I have high hopes. It should be possible (and most of the details will have been already worked out in other languages) to go from e.g. the definition form of `pm` to the Python form automatically. - - -## Partial Evaluation - -Cf. "Futamura projections" - -["partial evaluation is a technique for several different types of program optimization by specialization. The most straightforward application is to produce new programs which run faster than the originals while being guaranteed to behave in the same way."](https://en.wikipedia.org/wiki/Partial_evaluation) ~Wikipedia - -Given a function and some (but not all) of its arguments you can run the interpreter in a speculative fashion and derive new functions that are specializations of the original. - -Example from [Futamura, 1983](https://repository.kulib.kyoto-u.ac.jp/dspace/bitstream/2433/103401/1/0482-14.pdf) of converting a power function to a "to the fifth power" function: - - F(k, u) -> u^k - -I like to use a kind of crude [Gentzen notation](https://en.wikipedia.org/wiki/Natural_deduction) to describe a Joy function's semantics: - - k u F - ----------- - u^k - -Joy function implementation: - - F == 1 [popop 0 !=] [[popop 2 %] [over *] [] ifte [1 >>] dipd [sqr] dip] while [popop] dip - -This is a bit longer than a definition should be. In practice I would refactor it to be more concise and easily understood. - -In Python for comparison: - - def power(k, u): - z = 1 - while k != 0: - if k % 2: - z = z * u - k = k >> 1 - u = u * u - return z - -Using 5 for `k` and pushing evaluation forward as far as it will go with a sort of "thunk" variable for `u` we arrive at: - - u u u * dup * * - -We can replace the extra occurrences of `u` with `dup` to arrive at a definition for a Joy function that, given a number on the stack, returns that number raised to the fifth power: - - to-the-fifth == dup dup * dup * * - -Here it is in action: - - u dup dup * dup * * - u u dup * dup * * - u u u * dup * * - u u^2 dup * * - u u^2 u^2 * * - u u^4 * - u^5 - -See the appendix below for the derivation of the specialized form from the general form. - -It should be possible to write a program `FutamuraI` that works like this: - - [5] [F] FutamuraI - ------------------------- - [dup dup * dup * *] - - -That is, given the quoted program `[F]` and the argument `5`, it returns the new `to-the-fifth` function in quoted form. - - -### First Futamura Projection - -A joy interpreter written in Joy is described in the literature (available from the La Trobe archive or the mirror site) so we can apply the program `FutamuraI` to that to get a *residual* program `R` for some program `Q`: - - [Q] [joy] FutamuraI - ------------------------- - [R] - -The expected result is that, for a given input, the runtime of `R` is less than or equal to the runtime of `Q`. - -If we had a partial evaluator for Python we could create a residual program in Python for the Joy program `Q`. - - -### Second Futamura Projection - - [joy] [FutamuraI] FutamuraI - --------------------------------- - [C] - -Making a compiler by "specializing the specializer for the interpreter". - - -### Third Futamura Projection - - [FutamuraI] [FutamuraI] FutamuraI - --------------------------------------- - [K] - -"Specializing the specializer for itself yielding a tool that can convert any interpreter to an equivalent compiler" - - [joy] K - ------------- - [C] - - - - [Q] [joy] K i - ------------------- - [Q] C - ----------- - [R] - - - - - [K] K -> [K] - - - - -## Super-Compilation - -https://en.wikipedia.org/wiki/Metacompilation - -https://themonadreader.files.wordpress.com/2014/04/super-final.pdf - -This is a little hard to describe succinctly, but you are basically trying to figure out all possible paths through a program and then use that knowledge to improve the code, somehow. (I forget the details, but it's worth including and revisiting.) - - -## Gödel Machine - -http://people.idsia.ch/~juergen/goedelmachine.html - -https://en.wikipedia.org/wiki/G%C3%B6del_machine - -In Joy it often happens that a new general form is discovered that is semantically equivalent to some other form but that has greater efficiency (at least under some definite conditions.) When this happens we can perform a kind of search-and-replace operation over the whole of the current dictionary (standard library in other languages) and achieve performance gains. - -As an example, the function `[1 >>] dipd [sqr] dip` can be rewritten as `[[1 >>] dip sqr] dip` which, depending on the other optimizations some interpreter might make, could be more efficient. We can generalize this to a pattern-matching rule, something like: - - [F] dipd [G] dip == [[F] dip G] dip - -And we are justified rewriting any occurrence of the pattern on either side to the other if it improves things. - -The above also suggests a new combinator, call it `dipdip` that abstracts the pattern: - - ... a b [F] [G] dipdip - ---------------------------- - ... F a G b - -This permits the compiler to make optimizations without having to work to notice the pattern. The `dipdip` function and the interpreter can work together to do the more efficient thing. - -Joy function definitions form Directed Graphs. Not acyclical though, definition bodies do not contain references to other functions, but rather "Symbols" that name functions, so you can form e.g. two definitions that each make use of the other. Generally speaking though, you don't do this, instead you write definitions that use e.g. `genrec` general recursion combinator. - -Anyway, because Joy code is just a graph it becomes pretty easy to rewrite the graph in ways that preserve the semantics but are more efficient. Doing this in an automated fashion is essentially Schmidhuber's Gödel Machine: Finding and applying provably-correct modifications to the whole system in a self-referential way to create a self-improving general problem solver. - -Joy is intended as an effective vehicle for exploring this potential. - - -## Speculative pre-evaluation - -If you examine the traces of Joy programs it's easy to find places in the pending expression where some speculative interpreter could pre-compute results while the main interpreter was prosecuting the main "thread" of the program. For example consider (with the `.` indicating the current "location of the interpreter head" if you will, the split between the stack and the expression): - - ... a b c . F 2 3 + G H - -The `2 3 +` between `F` and `G` is not at the interpreter "head" yet it is extremely unlikely that any function `F` will prevent it (eventually) being evaluated to `5`. We can imagine an interpreter that detects this sort of thing, evaluates the sub-expression with a different CPU, and "tags" the expression at `2` with the result `5`. If evaluation reaches `2` the interpreter can just use `5` without re-evaluating the whole sub-expression `2 3 +`. - -This sort of thing happens all the time in Joy code. - -For example, if you look at the appendix for the partial evaluation example there is a stage where we have this: - - 5 u u [1 >>] dipd [sqr] dip - -Which can be written with the `dipdip` combinator: - - 5 u u [1 >>] [sqr] dipdip - -Which then becomes this: - - 5 1 >> u sqr u - -The interpreter could notice that `5 1 >>` and `u sqr` can proceed in parallel without interfering with each other. The `dipdip` combinator could be written to somehow hint to the interpreter that it should check for this posibility. - - -## JIT - -Whatever eventually winds up converting Joy code to machine code is susceptible to Just-in-Time compilation. For example, if you run Joypy on Pypy you take advantage of its JIT. - - -# Joy as UI - - -## Joy unifies CLI and GUI interfaces. - -All Joy interaction consists of two basic actions: - -1. Putting things onto the stack. -2. Executing functions. - -In a command-line setting you perform both of these actions the same way: entering Joy expressions as text. In a GUI you select items and copy or cut them to a user-visible stack (that is a first-class member of the UI, similar to the clipboard but with better visibility into contents and not restricted to one selection at a time.) You then trigger the evaluation of functions by clicking on buttons or menu items. *From the point-of-view of the underlying interpreter there is no difference between the input token streams for either UI modality.* - - -## Simple and Comprehensible Model - -In order to use their system(s) users must be able to easily and quickly develop a mental model of the system that maps to the actual system abstractions well enough to support the achievement of their goals. - -(Arguably current systems are pretty poor at this. Even an abstraction as old and ubiquitous as "filesystem" is only incompletely understood by many computer users. Many people do not understand the difference between RAM and disk storage!) - -The Joy model consists of just these main concepts: - -1. A stack of values -2. A dictionary of named commands -3. An interpreter - -Each of these is very simple and the first two even have real-world analogs (e.g. a *stack* of dishes or boxes or whatever, and, well, *dictionaries*.) It's easy to develop intuition for this system, resulting in a close match between the user's mental model and the actual system abstraction. - - -# Joy as AST for multi-language interop - -IR for Compilation - -Cf. Graal & Truffle - -"Software is eating the world"; Joy eats software. - -Universal Solvent - -Can write front-ends for translating other languages into Joy, thence to be refactored and fulminated into more efficient forms. "The Blob" of software. - - -# Minimal Basis - -Cf. SKI combinators, Peano arithmentic, Church numerals et. al., - -Folks have done work on figuring out the minimal set of combinators that are Turing-complete. Several of these sets are quite small. - -Semantics can be defined in terms of Laws of Form for down-to-the-metal modeling of programs as logic circuits. Hardware description language. - - - -# Math, Physics, Computation - - Computational algorithms are used to communicate precisely - some of the methods used in the analysis of dynamical phenomena. - Expressing the methods of variational mechanics in a computer - language forces them to be unambiguous and computationally - effective. Computation requires us to be precise about the repre- - sentation of mechanical and geometric notions as computational - objects and permits us to represent explicitly the algorithms for - manipulating these objects. Also, once formalized as a procedure, - a mathematical idea becomes a tool that can be used directly to - compute results. - - "Structure and Interpretation of Classical Mechanics", - Gerald Jay Sussman and Jack Wisdom with Meinhard E. Mayer - -. - - - -# Joy as glue language - -Basically any existing code/programs can be exposed to Joy as a function or collection of functions. - -## Shell command - -Run a shell command. - - "stdin" "cmd line" system - ----------------------------------- - "stderr" "stdout" return_code - -Then you can create e.g.: - - foo == "awk {awk program}" system - -Etc... - -## Python libraries - -## Ctypes (FFI) for loading binary libraries - - - - -# Git as File Store - -The old-fashioned File System abstraction is no longer justified. Joypy won't attempt to implement file and path operations. Instead there are a few functions that accept three args: a sha1 checksum of a blob of data, an initial index, and an offset. One function returns the string of data `blob[index:index+offset]`, while another accepts an additional quoted program and "runs it" with the data as the stack, for when you want to process a big ol' pile of data but don't want to load it into the interpreter. I imagine a use case for a third-party wrapped library that expects some sort of file or socket and streams over it somehow. Obviously, this is under-specified. - -The sha1 checksum refers to data stored in some (global, universal) git repo, which is provided to the interpreter though some as-yet unimplemented meta-interpreter action. - -**Git is a functional data type**, compatible with the semantic model of Joy. Implies shared datastore with obvious connection to git-archive & Datalad. - -Functions over static data (Wikipedia dump; MRI data &c.) can be considered timeless (however much time their first evaluation takes) and cached/archived in the global shared git repo. (Large data in e.g. cloud & bittorrent, with meta-data in git-archive/Datalad) - -Functions over streams (of possible mal-formed) data require a special stream-processing combinator and more care in their development. I haven't developed this in any detail, but it can be shown in many cases that e.g. a given function cannot grow unbounded (for all possible unbounded input streams.) - - - -# Sympy Library - -The mathematical functions in the Joypy library wrap the `math` module and other built-ins for the most part. It would be a simple matter to write wrapper functions for e.g. the Sympy packages' functions and provide symbolic math capabilities. - -It would also be possible to make a dictionary that mapped the math functions to the Sympy versions. Evaluating Joy code with this dictionary (and a special stack with Sympy variables on it) would result in symbolic execution without rewriting the Joy code. - - - -# Stack-based laguages as Dataflow - -If the "places" in a stack are considered first-class entities and tracked through "stack chatter" operations (like `swap`) we can draw flow-lines for the data and represent the functions as boxes with input and output lines. Stack chatter becomes topological rearrangements of lines. The resulting structure is conceptually identical with *Dataflow* paradigm of programming. - -(Related to this I suspect that all stack chatter disappears during compilation but I haven't nailed that down yet.) - -I'm unable to find the original webpage that describe the above. :-( - - -# Appendix Partial Evaluation Example - - k u F - ----------- - u^k - - - k u 1 [popop 0 !=] [[popop odd][over *][]ifte [1 >>] dipd [sqr] dip] while [popop] dip - - F == 1 [popop 0 !=] [[popop odd][over *][]ifte [1 >>] dipd [sqr] dip] while [popop] dip - - 5 u 1 [popop 0 !=] [[popop odd][over *][]ifte [1 >>] dipd [sqr] dip] while [popop] dip - - - 5 u 1 popop 0 != - 5 0 != - True - - - 5 u 1 [popop odd][over *][]ifte [1 >>] dipd [sqr] dip - 5 u 1 popop odd - True - - w/ sqr == dup * - - 5 u 1 over * [1 >>] dipd [sqr] dip - 5 u 1 u * [1 >>] dipd [sqr] dip - 5 u u [1 >>] dipd [sqr] dip - 5 1 >> u sqr u - 2 u_dup_* u - --or-- - 2 u_u_* u - - 2 u_u_* u popop 0 != - 2 0 != - True - - 2 u_u_* u [popop odd][over *][]ifte [1 >>] dipd [sqr] dip - ... - 2 u_u_* u [1 >>] dipd [sqr] dip - - 2 1 >> u_u_* sqr u - 1 u_u_*_dup_* u - - - 1 u_u_*_dup_* u [popop odd][over *][]ifte [1 >>] dipd [sqr] dip - 1 u_u_*_dup_* u over * [1 >>] dipd [sqr] dip - 1 u_u_*_dup_* u u_u_*_dup_* * [1 >>] dipd [sqr] dip - 1 u_u_*_dup_* u_u_u_*_dup_*_* [1 >>] dipd [sqr] dip - - 1 1 >> u_u_*_dup_* sqr u_u_u_*_dup_*_* - 0 u_u_*_dup_* dup * u_u_u_*_dup_*_* - 0 u_u_*_dup_* u_u_*_dup_* * u_u_u_*_dup_*_* - 0 u_..._* u_u_u_*_dup_*_* - - 0 u_..._* u_u_u_*_dup_*_* [popop] dip - - u_u_u_*_dup_*_* - - ^5 == dup dup * dup * * diff --git a/docs/Generator Programs.html b/docs/Generator Programs.html deleted file mode 100644 index 775f6d2..0000000 --- a/docs/Generator Programs.html +++ /dev/null @@ -1,13245 +0,0 @@ - - - -Generator Programs - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-

Using x to Generate Values

Cf. jp-reprod.html

- -
-
-
-
-
-
In [1]:
-
-
-
from notebook_preamble import J, V, define
-
- -
-
-
- -
-
-
-
-
-

Consider the x combinator:

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

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

- -
[a B] x
-[a B] a B
- -
-
-
-
-
-
-
-

Let B function swap the a with the quote and run some function C on it to generate a new value b:

- -
B == swap [C] dip
-
-[a B] a B
-[a B] a swap [C] dip
-a [a B]      [C] dip
-a C [a B]
-b [a B]
- -
-
-
-
-
-
-
-

Now discard the quoted a with rest then cons b:

- -
b [a B] rest cons
-b [B]        cons
-[b B]
- -
-
-
-
-
-
-
-

Altogether, this is the definition of B:

- -
B == swap [C] dip rest cons
- -
-
-
-
-
-
-
-

We can make a generator for the Natural numbers (0, 1, 2, ...) by using 0 for a and [dup ++] for [C]:

- -
[0 swap [dup ++] dip rest cons]
-
-
-

Let's try it:

- -
-
-
-
-
-
In [2]:
-
-
-
V('[0 swap [dup ++] dip rest cons] x')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                           . [0 swap [dup ++] dip rest cons] x
-           [0 swap [dup ++] dip rest cons] . x
-           [0 swap [dup ++] dip rest cons] . 0 swap [dup ++] dip rest cons
-         [0 swap [dup ++] dip rest cons] 0 . swap [dup ++] dip rest cons
-         0 [0 swap [dup ++] dip rest cons] . [dup ++] dip rest cons
-0 [0 swap [dup ++] dip rest cons] [dup ++] . dip rest cons
-                                         0 . dup ++ [0 swap [dup ++] dip rest cons] rest cons
-                                       0 0 . ++ [0 swap [dup ++] dip rest cons] rest cons
-                                       0 1 . [0 swap [dup ++] dip rest cons] rest cons
-       0 1 [0 swap [dup ++] dip rest cons] . rest cons
-         0 1 [swap [dup ++] dip rest cons] . cons
-         0 [1 swap [dup ++] dip rest cons] . 
-
-
-
- -
-
- -
-
-
-
-
-

After one application of x the quoted program contains 1 and 0 is below it on the stack.

- -
-
-
-
-
-
In [3]:
-
-
-
J('[0 swap [dup ++] dip rest cons] x x x x x pop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0 1 2 3 4
-
-
-
- -
-
- -
-
-
-
-
-

direco

-
-
-
-
-
-
In [4]:
-
-
-
define('direco == dip rest cons')
-
- -
-
-
- -
-
-
-
In [5]:
-
-
-
V('[0 swap [dup ++] direco] x')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                    . [0 swap [dup ++] direco] x
-           [0 swap [dup ++] direco] . x
-           [0 swap [dup ++] direco] . 0 swap [dup ++] direco
-         [0 swap [dup ++] direco] 0 . swap [dup ++] direco
-         0 [0 swap [dup ++] direco] . [dup ++] direco
-0 [0 swap [dup ++] direco] [dup ++] . direco
-0 [0 swap [dup ++] direco] [dup ++] . dip rest cons
-                                  0 . dup ++ [0 swap [dup ++] direco] rest cons
-                                0 0 . ++ [0 swap [dup ++] direco] rest cons
-                                0 1 . [0 swap [dup ++] direco] rest cons
-       0 1 [0 swap [dup ++] direco] . rest cons
-         0 1 [swap [dup ++] direco] . cons
-         0 [1 swap [dup ++] direco] . 
-
-
-
- -
-
- -
-
-
-
-
-

Making Generators

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

- -
         a [C] G
--------------------------
-   [a swap [C] direco]
- -
-
-
-
-
-
-
-

Working in reverse:

- -
[a swap   [C] direco] cons
-a [swap   [C] direco] concat
-a [swap] [[C] direco] swap
-a [[C] direco] [swap]
-a [C] [direco] cons [swap]
-
-
-

Reading from the bottom up:

- -
G == [direco] cons [swap] swap concat cons
-G == [direco] cons [swap] swoncat cons
- -
-
-
-
-
-
In [6]:
-
-
-
define('G == [direco] cons [swap] swoncat cons')
-
- -
-
-
- -
-
-
-
-
-

Let's try it out:

- -
-
-
-
-
-
In [7]:
-
-
-
J('0 [dup ++] G')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[0 swap [dup ++] direco]
-
-
-
- -
-
- -
-
-
-
In [8]:
-
-
-
J('0 [dup ++] G x x x pop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
0 1 2
-
-
-
- -
-
- -
-
-
-
-
-

Powers of 2

-
-
-
-
-
-
In [9]:
-
-
-
J('1 [dup 1 <<] G x x x x x x x x x pop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 4 8 16 32 64 128 256
-
-
-
- -
-
- -
-
-
-
-
-

[x] times

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

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

Generating Multiples of Three and Five

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

- -
3 2 1 3 1 2 3
-
-
-

To do this we want to encode the numbers as pairs of bits in a single int:

- -
    3  2  1  3  1  2  3
-0b 11 10 01 11 01 10 11 == 14811
-
-
-

And pick them off by masking with 3 (binary 11) and then shifting the int right two bits.

- -
-
-
-
-
-
In [11]:
-
-
-
define('PE1.1 == dup [3 &] dip 2 >>')
-
- -
-
-
- -
-
-
-
In [12]:
-
-
-
V('14811 PE1.1')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                  . 14811 PE1.1
-            14811 . PE1.1
-            14811 . dup [3 &] dip 2 >>
-      14811 14811 . [3 &] dip 2 >>
-14811 14811 [3 &] . dip 2 >>
-            14811 . 3 & 14811 2 >>
-          14811 3 . & 14811 2 >>
-                3 . 14811 2 >>
-          3 14811 . 2 >>
-        3 14811 2 . >>
-           3 3702 . 
-
-
-
- -
-
- -
-
-
-
-
-

If we plug 14811 and [PE1.1] into our generator form...

- -
-
-
-
-
-
In [13]:
-
-
-
J('14811 [PE1.1] G')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[14811 swap [PE1.1] direco]
-
-
-
- -
-
- -
-
-
-
-
-

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

- -
-
-
-
-
-
In [14]:
-
-
-
J('[14811 swap [PE1.1] direco] 7 [x] times')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 2 1 3 1 2 3 [0 swap [PE1.1] direco]
-
-
-
- -
-
- -
-
-
-
-
-

Reset at Zero

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

- -
-
-
-
-
-
In [15]:
-
-
-
define('PE1.1.check == dup [pop 14811] [] branch')
-
- -
-
-
- -
-
-
-
In [16]:
-
-
-
J('14811 [PE1.1.check PE1.1] G')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[14811 swap [PE1.1.check PE1.1] direco]
-
-
-
- -
-
- -
-
-
-
In [17]:
-
-
-
J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [PE1.1.check PE1.1] direco]
-
-
-
- -
-
- -
-
-
-
-
-

(It would be more efficient to reset the int every seven cycles but that's a little beyond the scope of this article. This solution does extra work, but not much, and we're not using it "in production" as they say.)

- -
-
-
-
-
-
-
-

Run 466 times

In the PE1 problem we are asked to sum all the multiples of three and five less than 1000. It's worked out that we need to use all seven numbers sixty-six times and then four more.

- -
-
-
-
-
-
In [18]:
-
-
-
J('7 66 * 4 +')
-
- -
-
-
- -
-
- - -
- -
- - -
-
466
-
-
-
- -
-
- -
-
-
-
-
-

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

- -
-
-
-
-
-
In [19]:
-
-
-
J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times')
-
- -
-
-
- -
-
- - -
- -
- - -
-
3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 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Euler Problem One

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

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

- -
-
-
-
-
-
In [22]:
-
-
-
J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
233168
-
-
-
- -
-
- -
-
-
-
-
-

A generator for the Fibonacci Sequence.

Consider:

- -
[b a F] x
-[b a F] b a F
- -
-
-
-
-
-
-
-

The obvious first thing to do is just add b and a:

- -
[b a F] b a +
-[b a F] b+a
- -
-
-
-
-
-
-
-

From here we want to arrive at:

- -
b [b+a b F]
- -
-
-
-
-
-
-
-

Let's start with swons:

- -
[b a F] b+a swons
-[b+a b a F]
- -
-
-
-
-
-
-
-

Considering this quote as a stack:

- -
F a b b+a
- -
-
-
-
-
-
-
-

We want to get it to:

- -
F b b+a b
- -
-
-
-
-
-
-
-

So:

- -
F a b b+a popdd over
-F b b+a b
- -
-
-
-
-
-
-
-

And therefore:

- -
[b+a b a F] [popdd over] infra
-[b b+a b F]
- -
-
-
-
-
-
-
-

But we can just use cons to carry b+a into the quote:

- -
[b a F] b+a [popdd over] cons infra
-[b a F] [b+a popdd over]      infra
-[b b+a b F]
- -
-
-
-
-
-
-
-

Lastly:

- -
[b b+a b F] uncons
-b [b+a b F]
- -
-
-
-
-
-
-
-

Putting it all together:

- -
F == + [popdd over] cons infra uncons
-fib_gen == [1 1 F]
- -
-
-
-
-
-
In [23]:
-
-
-
define('fib == + [popdd over] cons infra uncons')
-
- -
-
-
- -
-
-
-
In [24]:
-
-
-
define('fib_gen == [1 1 fib]')
-
- -
-
-
- -
-
-
-
In [25]:
-
-
-
J('fib_gen 10 [x] times')
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 2 3 5 8 13 21 34 55 89 [144 89 fib]
-
-
-
- -
-
- -
-
-
-
-
-

Project Euler Problem Two

-
By considering the terms in the Fibonacci sequence whose values do not exceed four million,
-find the sum of the even-valued terms.
-
-
-

Now that we have a generator for the Fibonacci sequence, we need a function that adds a term in the sequence to a sum if it is even, and pops it otherwise.

- -
-
-
-
-
-
In [26]:
-
-
-
define('PE2.1 == dup 2 % [+] [pop] branch')
-
- -
-
-
- -
-
-
-
-
-

And a predicate function that detects when the terms in the series "exceed four million".

- -
-
-
-
-
-
In [27]:
-
-
-
define('>4M == 4000000 >')
-
- -
-
-
- -
-
-
-
-
-

Now it's straightforward to define PE2 as a recursive function that generates terms in the Fibonacci sequence until they exceed four million and sums the even ones.

- -
-
-
-
-
-
In [28]:
-
-
-
define('PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec')
-
- -
-
-
- -
-
-
-
In [29]:
-
-
-
J('PE2')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4613732
-
-
-
- -
-
- -
-
-
-
-
-

Here's the collected program definitions:

- -
fib == + swons [popdd over] infra uncons
-fib_gen == [1 1 fib]
-
-even == dup 2 %
->4M == 4000000 >
-
-PE2.1 == even [+] [pop] branch
-PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec
- -
-
-
-
-
-
-
-

Even-valued Fibonacci Terms

Using o for odd and e for even:

- -
o + o = e
-e + e = e
-o + e = o
-
-
-

So the Fibonacci sequence considered in terms of just parity would be:

- -
o o e o o e o o e o o e o o e o o e
-1 1 2 3 5 8 . . .
-
-
-

Every third term is even.

- -
-
-
-
-
-
In [30]:
-
-
-
J('[1 0 fib] x x x')  # To start the sequence with 1 1 2 3 instead of 1 2 3.
-
- -
-
-
- -
-
- - -
- -
- - -
-
1 1 2 [3 2 fib]
-
-
-
- -
-
- -
-
-
-
-
-

Drive the generator three times and popop the two odd terms.

- -
-
-
-
-
-
In [31]:
-
-
-
J('[1 0 fib] x x x [popop] dipd')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2 [3 2 fib]
-
-
-
- -
-
- -
-
-
-
In [32]:
-
-
-
define('PE2.2 == x x x [popop] dipd')
-
- -
-
-
- -
-
-
-
In [33]:
-
-
-
J('[1 0 fib] 10 [PE2.2] times')
-
- -
-
-
- -
-
- - -
- -
- - -
-
2 8 34 144 610 2584 10946 46368 196418 832040 [1346269 832040 fib]
-
-
-
- -
-
- -
-
-
-
-
-

Replace x with our new driver function PE2.2 and start our fib generator at 1 0.

- -
-
-
-
-
-
In [34]:
-
-
-
J('0 [1 0 fib] PE2.2 [pop >4M] [popop] [[PE2.1] dip PE2.2] primrec')
-
- -
-
-
- -
-
- - -
- -
- - -
-
4613732
-
-
-
- -
-
- -
-
-
-
-
-

How to compile these?

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

- -
-
-
-
-
-
-
-

An Interesting Variation

-
-
-
-
-
-
In [35]:
-
-
-
define('codireco == cons dip rest cons')
-
- -
-
-
- -
-
-
-
In [36]:
-
-
-
V('[0 [dup ++] codireco] x')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                 . [0 [dup ++] codireco] x
-           [0 [dup ++] codireco] . x
-           [0 [dup ++] codireco] . 0 [dup ++] codireco
-         [0 [dup ++] codireco] 0 . [dup ++] codireco
-[0 [dup ++] codireco] 0 [dup ++] . codireco
-[0 [dup ++] codireco] 0 [dup ++] . cons dip rest cons
-[0 [dup ++] codireco] [0 dup ++] . dip rest cons
-                                 . 0 dup ++ [0 [dup ++] codireco] rest cons
-                               0 . dup ++ [0 [dup ++] codireco] rest cons
-                             0 0 . ++ [0 [dup ++] codireco] rest cons
-                             0 1 . [0 [dup ++] codireco] rest cons
-       0 1 [0 [dup ++] codireco] . rest cons
-         0 1 [[dup ++] codireco] . cons
-         0 [1 [dup ++] codireco] . 
-
-
-
- -
-
- -
-
-
-
In [37]:
-
-
-
define('G == [codireco] cons cons')
-
- -
-
-
- -
-
-
-
In [38]:
-
-
-
J('230 [dup ++] G 5 [x] times pop')
-
- -
-
-
- -
-
- - -
- -
- - -
-
230 231 232 233 234
-
-
-
- -
-
- -
-
-
- - - - - - diff --git a/docs/Generator Programs.ipynb b/docs/Generator Programs.ipynb deleted file mode 100644 index dcb3f61..0000000 --- a/docs/Generator Programs.ipynb +++ /dev/null @@ -1,1027 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Using `x` to Generate Values\n", - "\n", - "Cf. jp-reprod.html" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import J, V, define" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Consider the `x` combinator:\n", - "\n", - " x == dup i" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can apply it to a quoted program consisting of some value `a` and some function `B`:\n", - "\n", - " [a B] x\n", - " [a B] a B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let `B` function `swap` the `a` with the quote and run some function `C` on it to generate a new value `b`:\n", - "\n", - " B == swap [C] dip\n", - "\n", - " [a B] a B\n", - " [a B] a swap [C] dip\n", - " a [a B] [C] dip\n", - " a C [a B]\n", - " b [a B]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now discard the quoted `a` with `rest` then `cons` `b`:\n", - "\n", - " b [a B] rest cons\n", - " b [B] cons\n", - " [b B]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Altogether, this is the definition of `B`:\n", - "\n", - " B == swap [C] dip rest cons" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can make a generator for the Natural numbers (0, 1, 2, ...) by using `0` for `a` and `[dup ++]` for `[C]`:\n", - "\n", - " [0 swap [dup ++] dip rest cons]\n", - "\n", - "Let's try it:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [0 swap [dup ++] dip rest cons] x\n", - " [0 swap [dup ++] dip rest cons] . x\n", - " [0 swap [dup ++] dip rest cons] . 0 swap [dup ++] dip rest cons\n", - " [0 swap [dup ++] dip rest cons] 0 . swap [dup ++] dip rest cons\n", - " 0 [0 swap [dup ++] dip rest cons] . [dup ++] dip rest cons\n", - "0 [0 swap [dup ++] dip rest cons] [dup ++] . dip rest cons\n", - " 0 . dup ++ [0 swap [dup ++] dip rest cons] rest cons\n", - " 0 0 . ++ [0 swap [dup ++] dip rest cons] rest cons\n", - " 0 1 . [0 swap [dup ++] dip rest cons] rest cons\n", - " 0 1 [0 swap [dup ++] dip rest cons] . rest cons\n", - " 0 1 [swap [dup ++] dip rest cons] . cons\n", - " 0 [1 swap [dup ++] dip rest cons] . \n" - ] - } - ], - "source": [ - "V('[0 swap [dup ++] dip rest cons] x')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After one application of `x` the quoted program contains `1` and `0` is below it on the stack." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 1 2 3 4\n" - ] - } - ], - "source": [ - "J('[0 swap [dup ++] dip rest cons] x x x x x pop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## `direco`" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "define('direco == dip rest cons')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [0 swap [dup ++] direco] x\n", - " [0 swap [dup ++] direco] . x\n", - " [0 swap [dup ++] direco] . 0 swap [dup ++] direco\n", - " [0 swap [dup ++] direco] 0 . swap [dup ++] direco\n", - " 0 [0 swap [dup ++] direco] . [dup ++] direco\n", - "0 [0 swap [dup ++] direco] [dup ++] . direco\n", - "0 [0 swap [dup ++] direco] [dup ++] . dip rest cons\n", - " 0 . dup ++ [0 swap [dup ++] direco] rest cons\n", - " 0 0 . ++ [0 swap [dup ++] direco] rest cons\n", - " 0 1 . [0 swap [dup ++] direco] rest cons\n", - " 0 1 [0 swap [dup ++] direco] . rest cons\n", - " 0 1 [swap [dup ++] direco] . cons\n", - " 0 [1 swap [dup ++] direco] . \n" - ] - } - ], - "source": [ - "V('[0 swap [dup ++] direco] x')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Making Generators\n", - "We want to define a function that accepts `a` and `[C]` and builds our quoted program:\n", - "\n", - " a [C] G\n", - " -------------------------\n", - " [a swap [C] direco]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Working in reverse:\n", - "\n", - " [a swap [C] direco] cons\n", - " a [swap [C] direco] concat\n", - " a [swap] [[C] direco] swap\n", - " a [[C] direco] [swap]\n", - " a [C] [direco] cons [swap]\n", - "\n", - "Reading from the bottom up:\n", - "\n", - " G == [direco] cons [swap] swap concat cons\n", - " G == [direco] cons [swap] swoncat cons" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "define('G == [direco] cons [swap] swoncat cons')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's try it out:" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 swap [dup ++] direco]\n" - ] - } - ], - "source": [ - "J('0 [dup ++] G')" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 1 2\n" - ] - } - ], - "source": [ - "J('0 [dup ++] G x x x pop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Powers of 2" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 4 8 16 32 64 128 256\n" - ] - } - ], - "source": [ - "J('1 [dup 1 <<] G x x x x x x x x x pop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `[x] times`\n", - "If we have one of these quoted programs we can drive it using `times` with the `x` combinator." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "23 24 25 26 27 [28 swap [dup ++] direco]\n" - ] - } - ], - "source": [ - "J('23 [dup ++] G 5 [x] times')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Generating Multiples of Three and Five\n", - "Look at the treatment of the Project Euler Problem One in the \"Developing a Program\" notebook and you'll see that we might be interested in generating an endless cycle of:\n", - "\n", - " 3 2 1 3 1 2 3\n", - "\n", - "To do this we want to encode the numbers as pairs of bits in a single int:\n", - "\n", - " 3 2 1 3 1 2 3\n", - " 0b 11 10 01 11 01 10 11 == 14811\n", - "\n", - "And pick them off by masking with 3 (binary 11) and then shifting the int right two bits." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1.1 == dup [3 &] dip 2 >>')" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 14811 PE1.1\n", - " 14811 . PE1.1\n", - " 14811 . dup [3 &] dip 2 >>\n", - " 14811 14811 . [3 &] dip 2 >>\n", - "14811 14811 [3 &] . dip 2 >>\n", - " 14811 . 3 & 14811 2 >>\n", - " 14811 3 . & 14811 2 >>\n", - " 3 . 14811 2 >>\n", - " 3 14811 . 2 >>\n", - " 3 14811 2 . >>\n", - " 3 3702 . \n" - ] - } - ], - "source": [ - "V('14811 PE1.1')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If we plug `14811` and `[PE1.1]` into our generator form..." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[14811 swap [PE1.1] direco]\n" - ] - } - ], - "source": [ - "J('14811 [PE1.1] G')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "...we get a generator that works for seven cycles before it reaches zero:" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 2 1 3 1 2 3 [0 swap [PE1.1] direco]\n" - ] - } - ], - "source": [ - "J('[14811 swap [PE1.1] direco] 7 [x] times')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Reset at Zero\n", - "We need a function that checks if the int has reached zero and resets it if so." - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1.1.check == dup [pop 14811] [] branch')" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[14811 swap [PE1.1.check PE1.1] direco]\n" - ] - } - ], - "source": [ - "J('14811 [PE1.1.check PE1.1] G')" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [PE1.1.check PE1.1] direco]\n" - ] - } - ], - "source": [ - "J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "(It would be more efficient to reset the int every seven cycles but that's a little beyond the scope of this article. This solution does extra work, but not much, and we're not using it \"in production\" as they say.)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Run 466 times\n", - "In the PE1 problem we are asked to sum all the multiples of three and five less than 1000. It's worked out that we need to use all seven numbers sixty-six times and then four more." - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "466\n" - ] - } - ], - "source": [ - "J('7 66 * 4 +')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If we drive our generator 466 times and sum the stack we get 999." - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 [57 swap [PE1.1.check PE1.1] direco]\n" - ] - } - ], - "source": [ - "J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times')" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "999\n" - ] - } - ], - "source": [ - "J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Project Euler Problem One" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE1.2 == + dup [+] dip')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can add `PE1.2` to the quoted program given to `G`." - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "233168\n" - ] - } - ], - "source": [ - "J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## A generator for the Fibonacci Sequence.\n", - "Consider:\n", - "\n", - " [b a F] x\n", - " [b a F] b a F" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The obvious first thing to do is just add `b` and `a`:\n", - "\n", - " [b a F] b a +\n", - " [b a F] b+a" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "From here we want to arrive at:\n", - "\n", - " b [b+a b F]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's start with `swons`:\n", - "\n", - " [b a F] b+a swons\n", - " [b+a b a F]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Considering this quote as a stack:\n", - "\n", - " F a b b+a" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We want to get it to:\n", - "\n", - " F b b+a b" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "So:\n", - "\n", - " F a b b+a popdd over\n", - " F b b+a b" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And therefore:\n", - "\n", - " [b+a b a F] [popdd over] infra\n", - " [b b+a b F]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "But we can just use `cons` to carry `b+a` into the quote:\n", - "\n", - " [b a F] b+a [popdd over] cons infra\n", - " [b a F] [b+a popdd over] infra\n", - " [b b+a b F]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Lastly:\n", - "\n", - " [b b+a b F] uncons\n", - " b [b+a b F]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Putting it all together:\n", - "\n", - " F == + [popdd over] cons infra uncons\n", - " fib_gen == [1 1 F]" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "define('fib == + [popdd over] cons infra uncons')" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [], - "source": [ - "define('fib_gen == [1 1 fib]')" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 5 8 13 21 34 55 89 [144 89 fib]\n" - ] - } - ], - "source": [ - "J('fib_gen 10 [x] times')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Project Euler Problem Two\n", - " By considering the terms in the Fibonacci sequence whose values do not exceed four million,\n", - " find the sum of the even-valued terms.\n", - "\n", - "Now that we have a generator for the Fibonacci sequence, we need a function that adds a term in the sequence to a sum if it is even, and `pop`s it otherwise." - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE2.1 == dup 2 % [+] [pop] branch')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And a predicate function that detects when the terms in the series \"exceed four million\"." - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [], - "source": [ - "define('>4M == 4000000 >')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now it's straightforward to define `PE2` as a recursive function that generates terms in the Fibonacci sequence until they exceed four million and sums the even ones." - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec')" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4613732\n" - ] - } - ], - "source": [ - "J('PE2')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's the collected program definitions:\n", - "\n", - " fib == + swons [popdd over] infra uncons\n", - " fib_gen == [1 1 fib]\n", - "\n", - " even == dup 2 %\n", - " >4M == 4000000 >\n", - "\n", - " PE2.1 == even [+] [pop] branch\n", - " PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Even-valued Fibonacci Terms\n", - "\n", - "Using `o` for odd and `e` for even:\n", - "\n", - " o + o = e\n", - " e + e = e\n", - " o + e = o\n", - "\n", - "So the Fibonacci sequence considered in terms of just parity would be:\n", - "\n", - " o o e o o e o o e o o e o o e o o e\n", - " 1 1 2 3 5 8 . . .\n", - "\n", - "Every third term is even.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 1 2 [3 2 fib]\n" - ] - } - ], - "source": [ - "J('[1 0 fib] x x x') # To start the sequence with 1 1 2 3 instead of 1 2 3." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Drive the generator three times and `popop` the two odd terms." - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 [3 2 fib]\n" - ] - } - ], - "source": [ - "J('[1 0 fib] x x x [popop] dipd')" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [], - "source": [ - "define('PE2.2 == x x x [popop] dipd')" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 8 34 144 610 2584 10946 46368 196418 832040 [1346269 832040 fib]\n" - ] - } - ], - "source": [ - "J('[1 0 fib] 10 [PE2.2] times')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Replace `x` with our new driver function `PE2.2` and start our `fib` generator at `1 0`." - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4613732\n" - ] - } - ], - "source": [ - "J('0 [1 0 fib] PE2.2 [pop >4M] [popop] [[PE2.1] dip PE2.2] primrec')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How to compile these?\n", - "You would probably start with a special version of `G`, and perhaps modifications to the default `x`?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## An Interesting Variation" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [], - "source": [ - "define('codireco == cons dip rest cons')" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [0 [dup ++] codireco] x\n", - " [0 [dup ++] codireco] . x\n", - " [0 [dup ++] codireco] . 0 [dup ++] codireco\n", - " [0 [dup ++] codireco] 0 . [dup ++] codireco\n", - "[0 [dup ++] codireco] 0 [dup ++] . codireco\n", - "[0 [dup ++] codireco] 0 [dup ++] . cons dip rest cons\n", - "[0 [dup ++] codireco] [0 dup ++] . dip rest cons\n", - " . 0 dup ++ [0 [dup ++] codireco] rest cons\n", - " 0 . dup ++ [0 [dup ++] codireco] rest cons\n", - " 0 0 . ++ [0 [dup ++] codireco] rest cons\n", - " 0 1 . [0 [dup ++] codireco] rest cons\n", - " 0 1 [0 [dup ++] codireco] . rest cons\n", - " 0 1 [[dup ++] codireco] . cons\n", - " 0 [1 [dup ++] codireco] . \n" - ] - } - ], - "source": [ - "V('[0 [dup ++] codireco] x')" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [], - "source": [ - "define('G == [codireco] cons cons')" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "230 231 232 233 234\n" - ] - } - ], - "source": [ - "J('230 [dup ++] G 5 [x] times pop')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Generator Programs.md b/docs/Generator Programs.md deleted file mode 100644 index b10028c..0000000 --- a/docs/Generator Programs.md +++ /dev/null @@ -1,508 +0,0 @@ - -# Using `x` to Generate Values - -Cf. jp-reprod.html - - -```python -from notebook_preamble import J, V, define -``` - -Consider the `x` combinator: - - x == dup i - -We can apply it to a quoted program consisting of some value `a` and some function `B`: - - [a B] x - [a B] a B - -Let `B` function `swap` the `a` with the quote and run some function `C` on it to generate a new value `b`: - - B == swap [C] dip - - [a B] a B - [a B] a swap [C] dip - a [a B] [C] dip - a C [a B] - b [a B] - -Now discard the quoted `a` with `rest` then `cons` `b`: - - b [a B] rest cons - b [B] cons - [b B] - -Altogether, this is the definition of `B`: - - B == swap [C] dip rest cons - -We can make a generator for the Natural numbers (0, 1, 2, ...) by using `0` for `a` and `[dup ++]` for `[C]`: - - [0 swap [dup ++] dip rest cons] - -Let's try it: - - -```python -V('[0 swap [dup ++] dip rest cons] x') -``` - - . [0 swap [dup ++] dip rest cons] x - [0 swap [dup ++] dip rest cons] . x - [0 swap [dup ++] dip rest cons] . 0 swap [dup ++] dip rest cons - [0 swap [dup ++] dip rest cons] 0 . swap [dup ++] dip rest cons - 0 [0 swap [dup ++] dip rest cons] . [dup ++] dip rest cons - 0 [0 swap [dup ++] dip rest cons] [dup ++] . dip rest cons - 0 . dup ++ [0 swap [dup ++] dip rest cons] rest cons - 0 0 . ++ [0 swap [dup ++] dip rest cons] rest cons - 0 1 . [0 swap [dup ++] dip rest cons] rest cons - 0 1 [0 swap [dup ++] dip rest cons] . rest cons - 0 1 [swap [dup ++] dip rest cons] . cons - 0 [1 swap [dup ++] dip rest cons] . - - -After one application of `x` the quoted program contains `1` and `0` is below it on the stack. - - -```python -J('[0 swap [dup ++] dip rest cons] x x x x x pop') -``` - - 0 1 2 3 4 - - -## `direco` - - -```python -define('direco == dip rest cons') -``` - - -```python -V('[0 swap [dup ++] direco] x') -``` - - . [0 swap [dup ++] direco] x - [0 swap [dup ++] direco] . x - [0 swap [dup ++] direco] . 0 swap [dup ++] direco - [0 swap [dup ++] direco] 0 . swap [dup ++] direco - 0 [0 swap [dup ++] direco] . [dup ++] direco - 0 [0 swap [dup ++] direco] [dup ++] . direco - 0 [0 swap [dup ++] direco] [dup ++] . dip rest cons - 0 . dup ++ [0 swap [dup ++] direco] rest cons - 0 0 . ++ [0 swap [dup ++] direco] rest cons - 0 1 . [0 swap [dup ++] direco] rest cons - 0 1 [0 swap [dup ++] direco] . rest cons - 0 1 [swap [dup ++] direco] . cons - 0 [1 swap [dup ++] direco] . - - -## Making Generators -We want to define a function that accepts `a` and `[C]` and builds our quoted program: - - a [C] G - ------------------------- - [a swap [C] direco] - -Working in reverse: - - [a swap [C] direco] cons - a [swap [C] direco] concat - a [swap] [[C] direco] swap - a [[C] direco] [swap] - a [C] [direco] cons [swap] - -Reading from the bottom up: - - G == [direco] cons [swap] swap concat cons - G == [direco] cons [swap] swoncat cons - - -```python -define('G == [direco] cons [swap] swoncat cons') -``` - -Let's try it out: - - -```python -J('0 [dup ++] G') -``` - - [0 swap [dup ++] direco] - - - -```python -J('0 [dup ++] G x x x pop') -``` - - 0 1 2 - - -### Powers of 2 - - -```python -J('1 [dup 1 <<] G x x x x x x x x x pop') -``` - - 1 2 4 8 16 32 64 128 256 - - -### `[x] times` -If we have one of these quoted programs we can drive it using `times` with the `x` combinator. - - -```python -J('23 [dup ++] G 5 [x] times') -``` - - 23 24 25 26 27 [28 swap [dup ++] direco] - - -## Generating Multiples of Three and Five -Look at the treatment of the Project Euler Problem One in the "Developing a Program" notebook and you'll see that we might be interested in generating an endless cycle of: - - 3 2 1 3 1 2 3 - -To do this we want to encode the numbers as pairs of bits in a single int: - - 3 2 1 3 1 2 3 - 0b 11 10 01 11 01 10 11 == 14811 - -And pick them off by masking with 3 (binary 11) and then shifting the int right two bits. - - -```python -define('PE1.1 == dup [3 &] dip 2 >>') -``` - - -```python -V('14811 PE1.1') -``` - - . 14811 PE1.1 - 14811 . PE1.1 - 14811 . dup [3 &] dip 2 >> - 14811 14811 . [3 &] dip 2 >> - 14811 14811 [3 &] . dip 2 >> - 14811 . 3 & 14811 2 >> - 14811 3 . & 14811 2 >> - 3 . 14811 2 >> - 3 14811 . 2 >> - 3 14811 2 . >> - 3 3702 . - - -If we plug `14811` and `[PE1.1]` into our generator form... - - -```python -J('14811 [PE1.1] G') -``` - - [14811 swap [PE1.1] direco] - - -...we get a generator that works for seven cycles before it reaches zero: - - -```python -J('[14811 swap [PE1.1] direco] 7 [x] times') -``` - - 3 2 1 3 1 2 3 [0 swap [PE1.1] direco] - - -### Reset at Zero -We need a function that checks if the int has reached zero and resets it if so. - - -```python -define('PE1.1.check == dup [pop 14811] [] branch') -``` - - -```python -J('14811 [PE1.1.check PE1.1] G') -``` - - [14811 swap [PE1.1.check PE1.1] direco] - - - -```python -J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times') -``` - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [PE1.1.check PE1.1] direco] - - -(It would be more efficient to reset the int every seven cycles but that's a little beyond the scope of this article. This solution does extra work, but not much, and we're not using it "in production" as they say.) - -### Run 466 times -In the PE1 problem we are asked to sum all the multiples of three and five less than 1000. It's worked out that we need to use all seven numbers sixty-six times and then four more. - - -```python -J('7 66 * 4 +') -``` - - 466 - - -If we drive our generator 466 times and sum the stack we get 999. - - -```python -J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times') -``` - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 [57 swap [PE1.1.check PE1.1] direco] - - - -```python -J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum') -``` - - 999 - - -## Project Euler Problem One - - -```python -define('PE1.2 == + dup [+] dip') -``` - -Now we can add `PE1.2` to the quoted program given to `G`. - - -```python -J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop') -``` - - 233168 - - -## A generator for the Fibonacci Sequence. -Consider: - - [b a F] x - [b a F] b a F - -The obvious first thing to do is just add `b` and `a`: - - [b a F] b a + - [b a F] b+a - -From here we want to arrive at: - - b [b+a b F] - -Let's start with `swons`: - - [b a F] b+a swons - [b+a b a F] - -Considering this quote as a stack: - - F a b b+a - -We want to get it to: - - F b b+a b - -So: - - F a b b+a popdd over - F b b+a b - -And therefore: - - [b+a b a F] [popdd over] infra - [b b+a b F] - -But we can just use `cons` to carry `b+a` into the quote: - - [b a F] b+a [popdd over] cons infra - [b a F] [b+a popdd over] infra - [b b+a b F] - -Lastly: - - [b b+a b F] uncons - b [b+a b F] - -Putting it all together: - - F == + [popdd over] cons infra uncons - fib_gen == [1 1 F] - - -```python -define('fib == + [popdd over] cons infra uncons') -``` - - -```python -define('fib_gen == [1 1 fib]') -``` - - -```python -J('fib_gen 10 [x] times') -``` - - 1 2 3 5 8 13 21 34 55 89 [144 89 fib] - - -## Project Euler Problem Two - By considering the terms in the Fibonacci sequence whose values do not exceed four million, - find the sum of the even-valued terms. - -Now that we have a generator for the Fibonacci sequence, we need a function that adds a term in the sequence to a sum if it is even, and `pop`s it otherwise. - - -```python -define('PE2.1 == dup 2 % [+] [pop] branch') -``` - -And a predicate function that detects when the terms in the series "exceed four million". - - -```python -define('>4M == 4000000 >') -``` - -Now it's straightforward to define `PE2` as a recursive function that generates terms in the Fibonacci sequence until they exceed four million and sums the even ones. - - -```python -define('PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec') -``` - - -```python -J('PE2') -``` - - 4613732 - - -Here's the collected program definitions: - - fib == + swons [popdd over] infra uncons - fib_gen == [1 1 fib] - - even == dup 2 % - >4M == 4000000 > - - PE2.1 == even [+] [pop] branch - PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec - -### Even-valued Fibonacci Terms - -Using `o` for odd and `e` for even: - - o + o = e - e + e = e - o + e = o - -So the Fibonacci sequence considered in terms of just parity would be: - - o o e o o e o o e o o e o o e o o e - 1 1 2 3 5 8 . . . - -Every third term is even. - - - -```python -J('[1 0 fib] x x x') # To start the sequence with 1 1 2 3 instead of 1 2 3. -``` - - 1 1 2 [3 2 fib] - - -Drive the generator three times and `popop` the two odd terms. - - -```python -J('[1 0 fib] x x x [popop] dipd') -``` - - 2 [3 2 fib] - - - -```python -define('PE2.2 == x x x [popop] dipd') -``` - - -```python -J('[1 0 fib] 10 [PE2.2] times') -``` - - 2 8 34 144 610 2584 10946 46368 196418 832040 [1346269 832040 fib] - - -Replace `x` with our new driver function `PE2.2` and start our `fib` generator at `1 0`. - - -```python -J('0 [1 0 fib] PE2.2 [pop >4M] [popop] [[PE2.1] dip PE2.2] primrec') -``` - - 4613732 - - -## How to compile these? -You would probably start with a special version of `G`, and perhaps modifications to the default `x`? - -## An Interesting Variation - - -```python -define('codireco == cons dip rest cons') -``` - - -```python -V('[0 [dup ++] codireco] x') -``` - - . [0 [dup ++] codireco] x - [0 [dup ++] codireco] . x - [0 [dup ++] codireco] . 0 [dup ++] codireco - [0 [dup ++] codireco] 0 . [dup ++] codireco - [0 [dup ++] codireco] 0 [dup ++] . codireco - [0 [dup ++] codireco] 0 [dup ++] . cons dip rest cons - [0 [dup ++] codireco] [0 dup ++] . dip rest cons - . 0 dup ++ [0 [dup ++] codireco] rest cons - 0 . dup ++ [0 [dup ++] codireco] rest cons - 0 0 . ++ [0 [dup ++] codireco] rest cons - 0 1 . [0 [dup ++] codireco] rest cons - 0 1 [0 [dup ++] codireco] . rest cons - 0 1 [[dup ++] codireco] . cons - 0 [1 [dup ++] codireco] . - - - -```python -define('G == [codireco] cons cons') -``` - - -```python -J('230 [dup ++] G 5 [x] times pop') -``` - - 230 231 232 233 234 - diff --git a/docs/Generator Programs.rst b/docs/Generator Programs.rst deleted file mode 100644 index a201c0d..0000000 --- a/docs/Generator Programs.rst +++ /dev/null @@ -1,639 +0,0 @@ - -Using ``x`` to Generate Values -============================== - -Cf. jp-reprod.html - -.. code:: ipython2 - - from notebook_preamble import J, V, define - -Consider the ``x`` combinator: - -:: - - x == dup i - -We can apply it to a quoted program consisting of some value ``a`` and -some function ``B``: - -:: - - [a B] x - [a B] a B - -Let ``B`` function ``swap`` the ``a`` with the quote and run some -function ``C`` on it to generate a new value ``b``: - -:: - - B == swap [C] dip - - [a B] a B - [a B] a swap [C] dip - a [a B] [C] dip - a C [a B] - b [a B] - -Now discard the quoted ``a`` with ``rest`` then ``cons`` ``b``: - -:: - - b [a B] rest cons - b [B] cons - [b B] - -Altogether, this is the definition of ``B``: - -:: - - B == swap [C] dip rest cons - -We can make a generator for the Natural numbers (0, 1, 2, ...) by using -``0`` for ``a`` and ``[dup ++]`` for ``[C]``: - -:: - - [0 swap [dup ++] dip rest cons] - -Let's try it: - -.. code:: ipython2 - - V('[0 swap [dup ++] dip rest cons] x') - - -.. parsed-literal:: - - . [0 swap [dup ++] dip rest cons] x - [0 swap [dup ++] dip rest cons] . x - [0 swap [dup ++] dip rest cons] . 0 swap [dup ++] dip rest cons - [0 swap [dup ++] dip rest cons] 0 . swap [dup ++] dip rest cons - 0 [0 swap [dup ++] dip rest cons] . [dup ++] dip rest cons - 0 [0 swap [dup ++] dip rest cons] [dup ++] . dip rest cons - 0 . dup ++ [0 swap [dup ++] dip rest cons] rest cons - 0 0 . ++ [0 swap [dup ++] dip rest cons] rest cons - 0 1 . [0 swap [dup ++] dip rest cons] rest cons - 0 1 [0 swap [dup ++] dip rest cons] . rest cons - 0 1 [swap [dup ++] dip rest cons] . cons - 0 [1 swap [dup ++] dip rest cons] . - - -After one application of ``x`` the quoted program contains ``1`` and -``0`` is below it on the stack. - -.. code:: ipython2 - - J('[0 swap [dup ++] dip rest cons] x x x x x pop') - - -.. parsed-literal:: - - 0 1 2 3 4 - - -``direco`` ----------- - -.. code:: ipython2 - - define('direco == dip rest cons') - -.. code:: ipython2 - - V('[0 swap [dup ++] direco] x') - - -.. parsed-literal:: - - . [0 swap [dup ++] direco] x - [0 swap [dup ++] direco] . x - [0 swap [dup ++] direco] . 0 swap [dup ++] direco - [0 swap [dup ++] direco] 0 . swap [dup ++] direco - 0 [0 swap [dup ++] direco] . [dup ++] direco - 0 [0 swap [dup ++] direco] [dup ++] . direco - 0 [0 swap [dup ++] direco] [dup ++] . dip rest cons - 0 . dup ++ [0 swap [dup ++] direco] rest cons - 0 0 . ++ [0 swap [dup ++] direco] rest cons - 0 1 . [0 swap [dup ++] direco] rest cons - 0 1 [0 swap [dup ++] direco] . rest cons - 0 1 [swap [dup ++] direco] . cons - 0 [1 swap [dup ++] direco] . - - -Making Generators ------------------ - -We want to define a function that accepts ``a`` and ``[C]`` and builds -our quoted program: - -:: - - a [C] G - ------------------------- - [a swap [C] direco] - -Working in reverse: - -:: - - [a swap [C] direco] cons - a [swap [C] direco] concat - a [swap] [[C] direco] swap - a [[C] direco] [swap] - a [C] [direco] cons [swap] - -Reading from the bottom up: - -:: - - G == [direco] cons [swap] swap concat cons - G == [direco] cons [swap] swoncat cons - -.. code:: ipython2 - - define('G == [direco] cons [swap] swoncat cons') - -Let's try it out: - -.. code:: ipython2 - - J('0 [dup ++] G') - - -.. parsed-literal:: - - [0 swap [dup ++] direco] - - -.. code:: ipython2 - - J('0 [dup ++] G x x x pop') - - -.. parsed-literal:: - - 0 1 2 - - -Powers of 2 -~~~~~~~~~~~ - -.. code:: ipython2 - - J('1 [dup 1 <<] G x x x x x x x x x pop') - - -.. parsed-literal:: - - 1 2 4 8 16 32 64 128 256 - - -``[x] times`` -~~~~~~~~~~~~~ - -If we have one of these quoted programs we can drive it using ``times`` -with the ``x`` combinator. - -.. code:: ipython2 - - J('23 [dup ++] G 5 [x] times') - - -.. parsed-literal:: - - 23 24 25 26 27 [28 swap [dup ++] direco] - - -Generating Multiples of Three and Five --------------------------------------- - -Look at the treatment of the Project Euler Problem One in the -"Developing a Program" notebook and you'll see that we might be -interested in generating an endless cycle of: - -:: - - 3 2 1 3 1 2 3 - -To do this we want to encode the numbers as pairs of bits in a single -int: - -:: - - 3 2 1 3 1 2 3 - 0b 11 10 01 11 01 10 11 == 14811 - -And pick them off by masking with 3 (binary 11) and then shifting the -int right two bits. - -.. code:: ipython2 - - define('PE1.1 == dup [3 &] dip 2 >>') - -.. code:: ipython2 - - V('14811 PE1.1') - - -.. parsed-literal:: - - . 14811 PE1.1 - 14811 . PE1.1 - 14811 . dup [3 &] dip 2 >> - 14811 14811 . [3 &] dip 2 >> - 14811 14811 [3 &] . dip 2 >> - 14811 . 3 & 14811 2 >> - 14811 3 . & 14811 2 >> - 3 . 14811 2 >> - 3 14811 . 2 >> - 3 14811 2 . >> - 3 3702 . - - -If we plug ``14811`` and ``[PE1.1]`` into our generator form... - -.. code:: ipython2 - - J('14811 [PE1.1] G') - - -.. parsed-literal:: - - [14811 swap [PE1.1] direco] - - -...we get a generator that works for seven cycles before it reaches -zero: - -.. code:: ipython2 - - J('[14811 swap [PE1.1] direco] 7 [x] times') - - -.. parsed-literal:: - - 3 2 1 3 1 2 3 [0 swap [PE1.1] direco] - - -Reset at Zero -~~~~~~~~~~~~~ - -We need a function that checks if the int has reached zero and resets it -if so. - -.. code:: ipython2 - - define('PE1.1.check == dup [pop 14811] [] branch') - -.. code:: ipython2 - - J('14811 [PE1.1.check PE1.1] G') - - -.. parsed-literal:: - - [14811 swap [PE1.1.check PE1.1] direco] - - -.. code:: ipython2 - - J('[14811 swap [PE1.1.check PE1.1] direco] 21 [x] times') - - -.. parsed-literal:: - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 [0 swap [PE1.1.check PE1.1] direco] - - -(It would be more efficient to reset the int every seven cycles but -that's a little beyond the scope of this article. This solution does -extra work, but not much, and we're not using it "in production" as they -say.) - -Run 466 times -~~~~~~~~~~~~~ - -In the PE1 problem we are asked to sum all the multiples of three and -five less than 1000. It's worked out that we need to use all seven -numbers sixty-six times and then four more. - -.. code:: ipython2 - - J('7 66 * 4 +') - - -.. parsed-literal:: - - 466 - - -If we drive our generator 466 times and sum the stack we get 999. - -.. code:: ipython2 - - J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times') - - -.. parsed-literal:: - - 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 1 2 3 3 2 1 3 [57 swap [PE1.1.check PE1.1] direco] - - -.. code:: ipython2 - - J('[14811 swap [PE1.1.check PE1.1] direco] 466 [x] times pop enstacken sum') - - -.. parsed-literal:: - - 999 - - -Project Euler Problem One -------------------------- - -.. code:: ipython2 - - define('PE1.2 == + dup [+] dip') - -Now we can add ``PE1.2`` to the quoted program given to ``G``. - -.. code:: ipython2 - - J('0 0 0 [PE1.1.check PE1.1] G 466 [x [PE1.2] dip] times popop') - - -.. parsed-literal:: - - 233168 - - -A generator for the Fibonacci Sequence. ---------------------------------------- - -Consider: - -:: - - [b a F] x - [b a F] b a F - -The obvious first thing to do is just add ``b`` and ``a``: - -:: - - [b a F] b a + - [b a F] b+a - -From here we want to arrive at: - -:: - - b [b+a b F] - -Let's start with ``swons``: - -:: - - [b a F] b+a swons - [b+a b a F] - -Considering this quote as a stack: - -:: - - F a b b+a - -We want to get it to: - -:: - - F b b+a b - -So: - -:: - - F a b b+a popdd over - F b b+a b - -And therefore: - -:: - - [b+a b a F] [popdd over] infra - [b b+a b F] - -But we can just use ``cons`` to carry ``b+a`` into the quote: - -:: - - [b a F] b+a [popdd over] cons infra - [b a F] [b+a popdd over] infra - [b b+a b F] - -Lastly: - -:: - - [b b+a b F] uncons - b [b+a b F] - -Putting it all together: - -:: - - F == + [popdd over] cons infra uncons - fib_gen == [1 1 F] - -.. code:: ipython2 - - define('fib == + [popdd over] cons infra uncons') - -.. code:: ipython2 - - define('fib_gen == [1 1 fib]') - -.. code:: ipython2 - - J('fib_gen 10 [x] times') - - -.. parsed-literal:: - - 1 2 3 5 8 13 21 34 55 89 [144 89 fib] - - -Project Euler Problem Two -------------------------- - -:: - - By considering the terms in the Fibonacci sequence whose values do not exceed four million, - find the sum of the even-valued terms. - -Now that we have a generator for the Fibonacci sequence, we need a -function that adds a term in the sequence to a sum if it is even, and -``pop``\ s it otherwise. - -.. code:: ipython2 - - define('PE2.1 == dup 2 % [+] [pop] branch') - -And a predicate function that detects when the terms in the series -"exceed four million". - -.. code:: ipython2 - - define('>4M == 4000000 >') - -Now it's straightforward to define ``PE2`` as a recursive function that -generates terms in the Fibonacci sequence until they exceed four million -and sums the even ones. - -.. code:: ipython2 - - define('PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec') - -.. code:: ipython2 - - J('PE2') - - -.. parsed-literal:: - - 4613732 - - -Here's the collected program definitions: - -:: - - fib == + swons [popdd over] infra uncons - fib_gen == [1 1 fib] - - even == dup 2 % - >4M == 4000000 > - - PE2.1 == even [+] [pop] branch - PE2 == 0 fib_gen x [pop >4M] [popop] [[PE2.1] dip x] primrec - -Even-valued Fibonacci Terms -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Using ``o`` for odd and ``e`` for even: - -:: - - o + o = e - e + e = e - o + e = o - -So the Fibonacci sequence considered in terms of just parity would be: - -:: - - o o e o o e o o e o o e o o e o o e - 1 1 2 3 5 8 . . . - -Every third term is even. - -.. code:: ipython2 - - J('[1 0 fib] x x x') # To start the sequence with 1 1 2 3 instead of 1 2 3. - - -.. parsed-literal:: - - 1 1 2 [3 2 fib] - - -Drive the generator three times and ``popop`` the two odd terms. - -.. code:: ipython2 - - J('[1 0 fib] x x x [popop] dipd') - - -.. parsed-literal:: - - 2 [3 2 fib] - - -.. code:: ipython2 - - define('PE2.2 == x x x [popop] dipd') - -.. code:: ipython2 - - J('[1 0 fib] 10 [PE2.2] times') - - -.. parsed-literal:: - - 2 8 34 144 610 2584 10946 46368 196418 832040 [1346269 832040 fib] - - -Replace ``x`` with our new driver function ``PE2.2`` and start our -``fib`` generator at ``1 0``. - -.. code:: ipython2 - - J('0 [1 0 fib] PE2.2 [pop >4M] [popop] [[PE2.1] dip PE2.2] primrec') - - -.. parsed-literal:: - - 4613732 - - -How to compile these? ---------------------- - -You would probably start with a special version of ``G``, and perhaps -modifications to the default ``x``? - -An Interesting Variation ------------------------- - -.. code:: ipython2 - - define('codireco == cons dip rest cons') - -.. code:: ipython2 - - V('[0 [dup ++] codireco] x') - - -.. parsed-literal:: - - . [0 [dup ++] codireco] x - [0 [dup ++] codireco] . x - [0 [dup ++] codireco] . 0 [dup ++] codireco - [0 [dup ++] codireco] 0 . [dup ++] codireco - [0 [dup ++] codireco] 0 [dup ++] . codireco - [0 [dup ++] codireco] 0 [dup ++] . cons dip rest cons - [0 [dup ++] codireco] [0 dup ++] . dip rest cons - . 0 dup ++ [0 [dup ++] codireco] rest cons - 0 . dup ++ [0 [dup ++] codireco] rest cons - 0 0 . ++ [0 [dup ++] codireco] rest cons - 0 1 . [0 [dup ++] codireco] rest cons - 0 1 [0 [dup ++] codireco] . rest cons - 0 1 [[dup ++] codireco] . cons - 0 [1 [dup ++] codireco] . - - -.. code:: ipython2 - - define('G == [codireco] cons cons') - -.. code:: ipython2 - - J('230 [dup ++] G 5 [x] times pop') - - -.. parsed-literal:: - - 230 231 232 233 234 - diff --git a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.html b/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.html deleted file mode 100644 index ff494b5..0000000 --- a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.html +++ /dev/null @@ -1,15184 +0,0 @@ - - - -Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators - - - - - - - - - - - - - - - - - - - -
-
- - -
-
-
-
-

Hylomorphism

A hylomorphism H :: A -> B converts a value of type A into a value of type B by means of:

-
    -
  • A generator G :: A -> (A, B)
  • -
  • A combiner F :: (B, B) -> B
  • -
  • A predicate P :: A -> Bool to detect the base case
  • -
  • A base case value c :: B
  • -
  • Recursive calls (zero or more); it has a "call stack in the form of a cons list".
  • -
-

It may be helpful to see this function implemented in imperative Python code.

- -
-
-
-
-
-
In [1]:
-
-
-
def hylomorphism(c, F, P, G):
-    '''Return a hylomorphism function H.'''
-
-    def H(a):
-        if P(a):
-            result = c
-        else:
-            b, aa = G(a)
-            result = F(b, H(aa))
-        return result
-
-    return H
-
- -
-
-
- -
-
-
-
-
-

Finding Triangular Numbers

As a concrete example let's use a function that, given a positive integer, returns the sum of all positive integers less than that one. (In this case the types A and B are both int.)

-

With range() and sum()

-
-
-
-
-
-
In [2]:
-
-
-
r = range(10)
-r
-
- -
-
-
- -
-
- - -
- -
Out[2]:
- - - - -
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
- -
- -
-
- -
-
-
-
In [3]:
-
-
-
sum(r)
-
- -
-
-
- -
-
- - -
- -
Out[3]:
- - - - -
-
45
-
- -
- -
-
- -
-
-
-
In [4]:
-
-
-
range_sum = lambda n: sum(range(n))
-range_sum(10)
-
- -
-
-
- -
-
- - -
- -
Out[4]:
- - - - -
-
45
-
- -
- -
-
- -
-
-
-
-
-

As a hylomorphism

-
-
-
-
-
-
In [5]:
-
-
-
G = lambda n: (n - 1, n - 1)
-F = lambda a, b: a + b
-P = lambda n: n <= 1
-
-H = hylomorphism(0, F, P, G)
-
- -
-
-
- -
-
-
-
In [6]:
-
-
-
H(10)
-
- -
-
-
- -
-
- - -
- -
Out[6]:
- - - - -
-
45
-
- -
- -
-
- -
-
-
-
-
-

If you were to run the above code in a debugger and check out the call stack you would find that the variable b in each call to H() is storing the intermediate values as H() recurses. This is what was meant by "call stack in the form of a cons list".

- -
-
-
-
-
-
-
-

Joy Preamble

-
-
-
-
-
-
In [7]:
-
-
-
from notebook_preamble import D, DefinitionWrapper, J, V, define
-
- -
-
-
- -
-
-
-
-
-

Hylomorphism in Joy

We can define a combinator hylomorphism that will make a hylomorphism combinator H from constituent parts.

- -
H == c [F] [P] [G] hylomorphism
-
-
-

The function H is recursive, so we start with ifte and set the else-part to -some function J that will contain a quoted copy of H. (The then-part just -discards the leftover a and replaces it with the base case value c.)

- -
H == [P] [pop c] [J] ifte
-
-
-

The else-part J gets just the argument a on the stack.

- -
a J
-a G              The first thing to do is use the generator G
-aa b             which produces b and a new aa
-aa b [H] dip     we recur with H on the new aa
-aa H b F         and run F on the result.
-
-
-

This gives us a definition for J.

- -
J == G [H] dip F
-
-
-

Plug it in and convert to genrec.

- -
H == [P] [pop c] [G [H] dip F] ifte
-H == [P] [pop c] [G]   [dip F] genrec
-
-
-

This is the form of a hylomorphism in Joy, which nicely illustrates that -it is a simple specialization of the general recursion combinator.

- -
H == [P] [pop c] [G] [dip F] genrec
- -
-
-
-
-
-
-
-

Derivation of hylomorphism

Now we just need to derive a definition that builds the genrec arguments -out of the pieces given to the hylomorphism combinator.

- -
H == [P] [pop c]              [G]                  [dip F] genrec
-     [P] [c]    [pop] swoncat [G]        [F] [dip] swoncat genrec
-     [P] c unit [pop] swoncat [G]        [F] [dip] swoncat genrec
-     [P] c [G] [F] [unit [pop] swoncat] dipd [dip] swoncat genrec
-
-
-

Working in reverse:

-
    -
  • Use swoncat twice to decouple [c] and [F].
  • -
  • Use unit to dequote c.
  • -
  • Use dipd to untangle [unit [pop] swoncat] from the givens.
  • -
-

At this point all of the arguments (givens) to the hylomorphism are to the left so we have -a definition for hylomorphism:

- -
hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec
-
-
-

The order of parameters is different than the one we started with but -that hardly matters, you can rearrange them or just supply them in the -expected order.

- -
[P] c [G] [F] hylomorphism == H
- -
-
-
-
-
-
In [8]:
-
-
-
define('hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec')
-
- -
-
-
- -
-
-
-
-
-

Demonstrate summing a range of integers from 0 to n-1.

-
    -
  • [P] is [0 <=]
  • -
  • c is 0
  • -
  • [G] is [1 - dup]
  • -
  • [F] is [+]
  • -
-

So to sum the positive integers less than five we can do this.

- -
-
-
-
-
-
In [9]:
-
-
-
V('5 [0 <=] 0 [1 - dup] [+] hylomorphism')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                               . 5 [0 <=] 0 [1 - dup] [+] hylomorphism
-                                                                             5 . [0 <=] 0 [1 - dup] [+] hylomorphism
-                                                                      5 [0 <=] . 0 [1 - dup] [+] hylomorphism
-                                                                    5 [0 <=] 0 . [1 - dup] [+] hylomorphism
-                                                          5 [0 <=] 0 [1 - dup] . [+] hylomorphism
-                                                      5 [0 <=] 0 [1 - dup] [+] . hylomorphism
-                                                      5 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec
-                                 5 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec
-                                                                    5 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                                    5 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                                 5 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                                  5 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                            5 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                            5 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec
-                                                            5 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec
-                                                              5 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec
-                                                    5 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec
-                                                5 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec
-                                          5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec
-                                          5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec
-                                          5 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec
-                                            5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec
-    5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte
-5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i
-                                                                             5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i
-                                                                           5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i
-                                                                         False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i
-   False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i
-   5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i
-     5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i
-                   5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i
-                                                                             5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                                                           5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                                                             4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                                                           4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                 4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip +
-                                                                             4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 +
-                                                                      4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 +
-                                                              4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 +
-                                                    4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 +
-                                            4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 +
-    4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 +
-4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 +
-                                                                             4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 +
-                                                                           4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 +
-                                                                         False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 +
-   False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 +
-   4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 +
-     4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 +
-                   4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 +
-                                                                             4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +
-                                                                           4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +
-                                                                             3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +
-                                                                           3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +
-                                 3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 +
-                                                                             3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 +
-                                                                      3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 +
-                                                              3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 +
-                                                    3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 +
-                                            3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 +
-    3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 +
-3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 +
-                                                                             3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 +
-                                                                           3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 +
-                                                                         False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 +
-   False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 +
-   3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 +
-     3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 +
-                   3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 +
-                                                                             3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +
-                                                                           3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +
-                                                                             2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +
-                                                                           2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +
-                                 2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 +
-                                                                             2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 +
-                                                                      2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 +
-                                                              2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 +
-                                                    2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 +
-                                            2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 +
-    2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 +
-2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 +
-                                                                             2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 +
-                                                                           2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 +
-                                                                         False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 +
-   False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 +
-   2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 +
-     2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 +
-                   2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 +
-                                                                             2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +
-                                                                           2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +
-                                                                             1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +
-                                                                           1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +
-                                 1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 +
-                                                                             1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 +
-                                                                      1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 +
-                                                              1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 +
-                                                    1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 +
-                                            1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 +
-    1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 +
-1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 +
-                                                                             1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 +
-                                                                           1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 +
-                                                                         False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 +
-   False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 +
-   1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 +
-     1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 +
-                   1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 +
-                                                                             1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +
-                                                                           1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +
-                                                                             0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +
-                                                                           0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +
-                                 0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 +
-                                                                             0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 +
-                                                                      0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 +
-                                                              0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 +
-                                                    0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 +
-                                            0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 +
-    0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 +
-0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 +
-                                                                             0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 +
-                                                                           0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 +
-                                                                          True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 +
-    True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 +
-    0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 +
-      0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 +
-                                                                     0 [pop 0] . i 0 + 1 + 2 + 3 + 4 +
-                                                                             0 . pop 0 0 + 1 + 2 + 3 + 4 +
-                                                                               . 0 0 + 1 + 2 + 3 + 4 +
-                                                                             0 . 0 + 1 + 2 + 3 + 4 +
-                                                                           0 0 . + 1 + 2 + 3 + 4 +
-                                                                             0 . 1 + 2 + 3 + 4 +
-                                                                           0 1 . + 2 + 3 + 4 +
-                                                                             1 . 2 + 3 + 4 +
-                                                                           1 2 . + 3 + 4 +
-                                                                             3 . 3 + 4 +
-                                                                           3 3 . + 4 +
-                                                                             6 . 4 +
-                                                                           6 4 . +
-                                                                            10 . 
-
-
-
- -
-
- -
-
-
-
-
-

Anamorphism

An anamorphism can be defined as a hylomorphism that uses [] for c and -swons for F.

- -
[P] [G] anamorphism == [P] [] [G] [swons] hylomorphism == A
-
-
-

This allows us to define an anamorphism combinator in terms of -the hylomorphism combinator.

- -
[] swap [swons] hylomorphism == anamorphism
-
-
-

Partial evaluation gives us a "pre-cooked" form.

- -
[P] [G] . anamorphism
-[P] [G] . [] swap [swons] hylomorphism
-[P] [G] [] . swap [swons] hylomorphism
-[P] [] [G] . [swons] hylomorphism
-[P] [] [G] [swons] . hylomorphism
-[P] [] [G] [swons] . [unit [pop] swoncat] dipd [dip] swoncat genrec
-[P] [] [G] [swons] [unit [pop] swoncat] . dipd [dip] swoncat genrec
-[P] [] . unit [pop] swoncat [G] [swons] [dip] swoncat genrec
-[P] [[]] [pop] . swoncat [G] [swons] [dip] swoncat genrec
-[P] [pop []] [G] [swons] [dip] . swoncat genrec
-
-[P] [pop []] [G] [dip swons] genrec
-
-
-

(We could also have just substituted for c and F in the definition of H.)

- -
H == [P] [pop c ] [G] [dip F    ] genrec
-A == [P] [pop []] [G] [dip swons] genrec
-
-
-

The partial evaluation is overkill in this case but it serves as a -reminder that this sort of program specialization can, in many cases, be -carried out automatically.)

-

Untangle [G] from [pop []] using swap.

- -
[P] [G] [pop []] swap [dip swons] genrec
-
-
-

All of the arguments to anamorphism are to the left, so we have a definition for it.

- -
anamorphism == [pop []] swap [dip swons] genrec
-
-
-

An example of an anamorphism is the range function.

- -
range == [0 <=] [1 - dup] anamorphism
- -
-
-
-
-
-
-
-

Catamorphism

A catamorphism can be defined as a hylomorphism that uses [uncons swap] for [G] -and [[] =] for the predicate [P].

- -
c [F] catamorphism == [[] =] c [uncons swap] [F] hylomorphism == C
-
-
-

This allows us to define a catamorphism combinator in terms of -the hylomorphism combinator.

- -
[[] =] roll> [uncons swap] swap hylomorphism == catamorphism
-
-
-

Partial evaluation doesn't help much.

- -
c [F] . catamorphism
-c [F] . [[] =] roll> [uncons swap] swap hylomorphism
-c [F] [[] =] . roll> [uncons swap] swap hylomorphism
-[[] =] c [F] [uncons swap] . swap hylomorphism
-[[] =] c [uncons swap] [F] . hylomorphism
-[[] =] c [uncons swap] [F] [unit [pop] swoncat] . dipd [dip] swoncat genrec
-[[] =] c . unit [pop] swoncat [uncons swap] [F] [dip] swoncat genrec
-[[] =] [c] [pop] . swoncat [uncons swap] [F] [dip] swoncat genrec
-[[] =] [pop c] [uncons swap] [F] [dip] . swoncat genrec
-[[] =] [pop c] [uncons swap] [dip F] genrec
-
-
-

Because the arguments to catamorphism have to be prepared (unlike the arguments -to anamorphism, which only need to be rearranged slightly) there isn't much point -to "pre-cooking" the definition.

- -
catamorphism == [[] =] roll> [uncons swap] swap hylomorphism
-
-
-

An example of a catamorphism is the sum function.

- -
sum == 0 [+] catamorphism
- -
-
-
-
-
-
-
-

"Fusion Law" for catas (UNFINISHED!!!)

I'm not sure exactly how to translate the "Fusion Law" for catamorphisms into Joy.

-

I know that a map composed with a cata can be expressed as a new cata:

- -
[F] map b [B] cata == b [F B] cata
-
-
-

But this isn't the one described in "Bananas...". That's more like:

-

A cata composed with some function can be expressed as some other cata:

- -
b [B] catamorphism F == c [C] catamorphism
-
-
-

Given:

- -
b F == c
-
-...
-
-B F == [F] dip C
-
-...
-
-b[B]cata F == c[C]cata
-
-F(B(head, tail)) == C(head, F(tail))
-
-1 [2 3] B F         1 [2 3] F C
-
-
-b F == c
-B F == F C
-
-b [B] catamorphism F == c [C] catamorphism
-b [B] catamorphism F == b F [C] catamorphism
-
-...
-
-
-

Or maybe,

- -
[F] map b [B] cata == c [C] cata     ???
-
-[F] map b [B] cata == b [F B] cata    I think this is generally true, unless F consumes stack items
-                                        instead of just transforming TOS.  Of course, there's always [F] unary.
-b [F] unary [[F] unary B] cata
-
-[10 *] map 0 swap [+] step == 0 swap [10 * +] step
-
-
-
-

For example:

- -
F == 10 *
-b == 0
-B == +
-c == 0
-C == F +
-
-b F    == c
-0 10 * == 0
-
-B F    == [F]    dip C
-+ 10 * == [10 *] dip F +
-+ 10 * == [10 *] dip 10 * +
-
-n m + 10 * == 10(n+m)
-
-n m [10 *] dip 10 * +
-n 10 * m 10 * +
-10n m 10 * +
-10n 10m +
-10n+10m
-
-10n+10m = 10(n+m)
-
-
-

Ergo:

- -
0 [+] catamorphism 10 * == 0 [10 * +] catamorphism
- -
-
-
-
-
-
-
-

The step combinator will usually be better to use than catamorphism.

-
sum == 0 swap [+] step
-sum == 0 [+] catamorphism
- -
-
-
-
-
-
-
-

anamorphism catamorphism == hylomorphism

Here is (part of) the payoff.

-

An anamorphism followed by (composed with) a -catamorphism is a hylomorphism, with the advantage that the hylomorphism -does not create the intermediate list structure. The values are stored in -either the call stack, for those implementations that use one, or in the pending -expression ("continuation") for the Joypy interpreter. They still have to -be somewhere, converting from an anamorphism and catamorphism to a hylomorphism -just prevents using additional storage and doing additional processing.

- -
    range == [0 <=] [1 - dup] anamorphism
-      sum == 0 [+] catamorphism
-
-range sum == [0 <=] [1 - dup] anamorphism 0 [+] catamorphism
-          == [0 <=] 0 [1 - dup] [+] hylomorphism
-
-
-

We can let the hylomorphism combinator build range_sum for us or just -substitute ourselves.

- -
        H == [P]    [pop c] [G]       [dip F] genrec
-range_sum == [0 <=] [pop 0] [1 - dup] [dip +] genrec
- -
-
-
-
-
-
In [8]:
-
-
-
defs = '''
-anamorphism == [pop []] swap [dip swons] genrec
-hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec
-catamorphism == [[] =] roll> [uncons swap] swap hylomorphism
-range == [0 <=] [1 - dup] anamorphism
-sum == 0 [+] catamorphism
-range_sum == [0 <=] 0 [1 - dup] [+] hylomorphism
-'''
-
-DefinitionWrapper.add_definitions(defs, D)
-
- -
-
-
- -
-
-
-
In [9]:
-
-
-
J('10 range')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[9 8 7 6 5 4 3 2 1 0]
-
-
-
- -
-
- -
-
-
-
In [10]:
-
-
-
J('[9 8 7 6 5 4 3 2 1 0] sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
45
-
-
-
- -
-
- -
-
-
-
In [11]:
-
-
-
V('10 range sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                                                                               . 10 range sum
-                                                                                                                            10 . range sum
-                                                                                                                            10 . [0 <=] [1 - dup] anamorphism sum
-                                                                                                                     10 [0 <=] . [1 - dup] anamorphism sum
-                                                                                                           10 [0 <=] [1 - dup] . anamorphism sum
-                                                                                                           10 [0 <=] [1 - dup] . [pop []] swap [dip swons] genrec sum
-                                                                                                  10 [0 <=] [1 - dup] [pop []] . swap [dip swons] genrec sum
-                                                                                                  10 [0 <=] [pop []] [1 - dup] . [dip swons] genrec sum
-                                                                                      10 [0 <=] [pop []] [1 - dup] [dip swons] . genrec sum
-                                         10 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte sum
-                                    10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [10] [0 <=] . infra first choice i sum
-                                                                                                                            10 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum
-                                                                                                                          10 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum
-                                        False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] . swaack first choice i sum
-                                        10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i sum
-                                          10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i sum
-                                                         10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i sum
-                                                                                                                            10 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum
-                                                                                                                          10 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum
-                                                                                                                             9 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum
-                                                                                                                           9 9 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum
-                                                                            9 9 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons sum
-                                                                                                                             9 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 9 swons sum
-                                                                                                                      9 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 9 swons sum
-                                                                                                             9 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 9 swons sum
-                                                                                                   9 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 9 swons sum
-                                                                                       9 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 9 swons sum
-                                          9 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 9 swons sum
-                                      9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [9] [0 <=] . infra first choice i 9 swons sum
-                                                                                                                             9 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum
-                                                                                                                           9 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] . swaack first choice i 9 swons sum
-                                         9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 9 swons sum
-                                           9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 9 swons sum
-                                                          9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 9 swons sum
-                                                                                                                             9 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum
-                                                                                                                           9 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum
-                                                                                                                             8 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum
-                                                                                                                           8 8 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum
-                                                                            8 8 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 9 swons sum
-                                                                                                                             8 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum
-                                                                                                                      8 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum
-                                                                                                             8 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 8 swons 9 swons sum
-                                                                                                   8 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 8 swons 9 swons sum
-                                                                                       8 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 8 swons 9 swons sum
-                                          8 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 8 swons 9 swons sum
-                                      8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [8] [0 <=] . infra first choice i 8 swons 9 swons sum
-                                                                                                                             8 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum
-                                                                                                                           8 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] . swaack first choice i 8 swons 9 swons sum
-                                         8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 8 swons 9 swons sum
-                                           8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 8 swons 9 swons sum
-                                                          8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 8 swons 9 swons sum
-                                                                                                                             8 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum
-                                                                                                                           8 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum
-                                                                                                                             7 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum
-                                                                                                                           7 7 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum
-                                                                            7 7 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 8 swons 9 swons sum
-                                                                                                                             7 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum
-                                                                                                                      7 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum
-                                                                                                             7 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum
-                                                                                                   7 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 7 swons 8 swons 9 swons sum
-                                                                                       7 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 7 swons 8 swons 9 swons sum
-                                          7 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 7 swons 8 swons 9 swons sum
-                                      7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [7] [0 <=] . infra first choice i 7 swons 8 swons 9 swons sum
-                                                                                                                             7 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum
-                                                                                                                           7 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] . swaack first choice i 7 swons 8 swons 9 swons sum
-                                         7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 7 swons 8 swons 9 swons sum
-                                           7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 7 swons 8 swons 9 swons sum
-                                                          7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 7 swons 8 swons 9 swons sum
-                                                                                                                             7 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum
-                                                                                                                           7 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum
-                                                                                                                             6 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum
-                                                                                                                           6 6 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum
-                                                                            6 6 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 7 swons 8 swons 9 swons sum
-                                                                                                                             6 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                      6 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                             6 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                   6 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum
-                                                                                       6 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 6 swons 7 swons 8 swons 9 swons sum
-                                          6 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 6 swons 7 swons 8 swons 9 swons sum
-                                      6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [6] [0 <=] . infra first choice i 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             6 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           6 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] . swaack first choice i 6 swons 7 swons 8 swons 9 swons sum
-                                         6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 6 swons 7 swons 8 swons 9 swons sum
-                                           6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 6 swons 7 swons 8 swons 9 swons sum
-                                                          6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             6 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           6 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             5 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           5 5 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                            5 5 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             5 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                      5 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                             5 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                   5 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                       5 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          5 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                      5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [5] [0 <=] . infra first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             5 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           5 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] . swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                           5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                          5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             5 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           5 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             4 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           4 4 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                            4 4 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             4 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                      4 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                             4 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                   4 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                       4 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          4 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                      4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [4] [0 <=] . infra first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             4 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           4 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] . swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                           4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                          4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             4 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           4 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             3 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           3 3 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                            3 3 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             3 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                      3 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                             3 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                   3 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                       3 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          3 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                      3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [3] [0 <=] . infra first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             3 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           3 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] . swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                           3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                          3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             3 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           3 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             2 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           2 2 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                            2 2 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             2 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                      2 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                             2 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                   2 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                       2 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          2 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                      2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [2] [0 <=] . infra first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             2 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           2 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                           2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                          2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             2 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           2 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             1 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           1 1 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                            1 1 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             1 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                      1 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                             1 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                   1 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                       1 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          1 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                      1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [1] [0 <=] . infra first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             1 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           1 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                         1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                           1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                          1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             1 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           1 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             0 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           0 0 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                            0 0 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             0 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                      0 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                             0 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                   0 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                       0 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          0 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                      0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [0] [0 <=] . infra first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             0 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           0 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                          True . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          True [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] . swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                          0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                            0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] True . choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                    0 [pop []] . i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                             0 . pop [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                               . [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                            [] . 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                          [] 0 . swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                          [] 0 . swap cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                          0 [] . cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                           [0] . 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         [0] 1 . swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         [0] 1 . swap cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         1 [0] . cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                         [1 0] . 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                       [1 0] 2 . swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                       [1 0] 2 . swap cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                       2 [1 0] . cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                       [2 1 0] . 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                     [2 1 0] 3 . swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                     [2 1 0] 3 . swap cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                     3 [2 1 0] . cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                     [3 2 1 0] . 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                   [3 2 1 0] 4 . swons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                   [3 2 1 0] 4 . swap cons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                   4 [3 2 1 0] . cons 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                   [4 3 2 1 0] . 5 swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                 [4 3 2 1 0] 5 . swons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                 [4 3 2 1 0] 5 . swap cons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                 5 [4 3 2 1 0] . cons 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                                 [5 4 3 2 1 0] . 6 swons 7 swons 8 swons 9 swons sum
-                                                                                                               [5 4 3 2 1 0] 6 . swons 7 swons 8 swons 9 swons sum
-                                                                                                               [5 4 3 2 1 0] 6 . swap cons 7 swons 8 swons 9 swons sum
-                                                                                                               6 [5 4 3 2 1 0] . cons 7 swons 8 swons 9 swons sum
-                                                                                                               [6 5 4 3 2 1 0] . 7 swons 8 swons 9 swons sum
-                                                                                                             [6 5 4 3 2 1 0] 7 . swons 8 swons 9 swons sum
-                                                                                                             [6 5 4 3 2 1 0] 7 . swap cons 8 swons 9 swons sum
-                                                                                                             7 [6 5 4 3 2 1 0] . cons 8 swons 9 swons sum
-                                                                                                             [7 6 5 4 3 2 1 0] . 8 swons 9 swons sum
-                                                                                                           [7 6 5 4 3 2 1 0] 8 . swons 9 swons sum
-                                                                                                           [7 6 5 4 3 2 1 0] 8 . swap cons 9 swons sum
-                                                                                                           8 [7 6 5 4 3 2 1 0] . cons 9 swons sum
-                                                                                                           [8 7 6 5 4 3 2 1 0] . 9 swons sum
-                                                                                                         [8 7 6 5 4 3 2 1 0] 9 . swons sum
-                                                                                                         [8 7 6 5 4 3 2 1 0] 9 . swap cons sum
-                                                                                                         9 [8 7 6 5 4 3 2 1 0] . cons sum
-                                                                                                         [9 8 7 6 5 4 3 2 1 0] . sum
-                                                                                                         [9 8 7 6 5 4 3 2 1 0] . 0 [+] catamorphism
-                                                                                                       [9 8 7 6 5 4 3 2 1 0] 0 . [+] catamorphism
-                                                                                                   [9 8 7 6 5 4 3 2 1 0] 0 [+] . catamorphism
-                                                                                                   [9 8 7 6 5 4 3 2 1 0] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism
-                                                                                            [9 8 7 6 5 4 3 2 1 0] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism
-                                                                                            [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] . [uncons swap] swap hylomorphism
-                                                                              [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] [uncons swap] . swap hylomorphism
-                                                                              [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . hylomorphism
-                                                                              [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec
-                                                         [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec
-                                                                                                [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec
-                                                                                                [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec
-                                                                                             [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec
-                                                                                              [9 8 7 6 5 4 3 2 1 0] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec
-                                                                                        [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec
-                                                                                        [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec
-                                                                                        [9 8 7 6 5 4 3 2 1 0] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec
-                                                                                          [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec
-                                                                            [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec
-                                                                        [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec
-                                                                  [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec
-                                                                  [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec
-                                                                  [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec
-                                                                    [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec
-                        [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte
-[9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[9 8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i
-                                                                                                         [9 8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i
-                                                                                                      [9 8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i
-                       False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] . swaack first choice i
-                       [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i
-                         [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i
-                                       [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i
-                                                                                                         [9 8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +
-                                                                                                         9 [8 7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +
-                                                                                                         [8 7 6 5 4 3 2 1 0] 9 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +
-                                                           [8 7 6 5 4 3 2 1 0] 9 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip +
-                                                                                                           [8 7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 9 +
-                                                                                                    [8 7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 9 +
-                                                                                            [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 9 +
-                                                                              [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 9 +
-                                                                      [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 9 +
-                          [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 9 +
-    [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 9 +
-                                                                                                           [8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 +
-                                                                                                        [8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 +
-                         False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] . swaack first choice i 9 +
-                         [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 +
-                           [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 9 +
-                                         [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 9 +
-                                                                                                           [8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 +
-                                                                                                           8 [7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 +
-                                                                                                           [7 6 5 4 3 2 1 0] 8 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 +
-                                                             [7 6 5 4 3 2 1 0] 8 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 9 +
-                                                                                                             [7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 8 + 9 +
-                                                                                                      [7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 8 + 9 +
-                                                                                              [7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 8 + 9 +
-                                                                                [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 8 + 9 +
-                                                                        [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 8 + 9 +
-                            [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 8 + 9 +
-        [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 8 + 9 +
-                                                                                                             [7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 +
-                                                                                                          [7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 +
-                           False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] . swaack first choice i 8 + 9 +
-                           [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 +
-                             [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 +
-                                           [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 8 + 9 +
-                                                                                                             [7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 +
-                                                                                                             7 [6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 +
-                                                                                                             [6 5 4 3 2 1 0] 7 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 +
-                                                               [6 5 4 3 2 1 0] 7 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 8 + 9 +
-                                                                                                               [6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 +
-                                                                                                        [6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 +
-                                                                                                [6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 7 + 8 + 9 +
-                                                                                  [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 7 + 8 + 9 +
-                                                                          [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 7 + 8 + 9 +
-                              [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 7 + 8 + 9 +
-            [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[6 5 4 3 2 1 0]] [[] =] . infra first choice i 7 + 8 + 9 +
-                                                                                                               [6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 +
-                                                                                                            [6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 +
-                             False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] . swaack first choice i 7 + 8 + 9 +
-                             [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 +
-                               [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 +
-                                             [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 7 + 8 + 9 +
-                                                                                                               [6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 +
-                                                                                                               6 [5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 +
-                                                                                                               [5 4 3 2 1 0] 6 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 +
-                                                                 [5 4 3 2 1 0] 6 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 7 + 8 + 9 +
-                                                                                                                 [5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 +
-                                                                                                          [5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 +
-                                                                                                  [5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 +
-                                                                                    [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 6 + 7 + 8 + 9 +
-                                                                            [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 6 + 7 + 8 + 9 +
-                                [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 +
-                [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[5 4 3 2 1 0]] [[] =] . infra first choice i 6 + 7 + 8 + 9 +
-                                                                                                                 [5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 +
-                                                                                                              [5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 +
-                               False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] . swaack first choice i 6 + 7 + 8 + 9 +
-                               [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 +
-                                 [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 +
-                                               [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 +
-                                                                                                                 [5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 +
-                                                                                                                 5 [4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 +
-                                                                                                                 [4 3 2 1 0] 5 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 +
-                                                                   [4 3 2 1 0] 5 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 6 + 7 + 8 + 9 +
-                                                                                                                   [4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                                                                                            [4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                                                                                    [4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                                                                      [4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                                                              [4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 5 + 6 + 7 + 8 + 9 +
-                                  [4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 +
-                    [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[4 3 2 1 0]] [[] =] . infra first choice i 5 + 6 + 7 + 8 + 9 +
-                                                                                                                   [4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 +
-                                                                                                                [4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 +
-                                 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] . swaack first choice i 5 + 6 + 7 + 8 + 9 +
-                                 [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 +
-                                   [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 +
-                                                 [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 +
-                                                                                                                   [4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                   4 [3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                   [3 2 1 0] 4 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +
-                                                                     [3 2 1 0] 4 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                     [3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                              [3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                      [3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                        [3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                [3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                    [3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 +
-                        [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3 2 1 0]] [[] =] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                     [3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                  [3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                   False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                   [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                     [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                   [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                     [3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                     3 [2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                     [2 1 0] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                       [2 1 0] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                       [2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                [2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                        [2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                          [2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                  [2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                      [2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                            [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 1 0]] [[] =] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                       [2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                    [2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                     False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                     [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                       [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                     [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                       [2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                       2 [1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                       [1 0] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                         [1 0] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         [1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                  [1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                          [1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                            [1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                    [1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                        [1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[1 0]] [[] =] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         [1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                      [1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                       False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                       [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                         [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                       [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         [1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         1 [0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         [0] 1 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                           [0] 1 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           [0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                    [0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                            [0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                              [0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                      [0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                          [0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                    [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[0]] [[] =] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           [0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                        [0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                         False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                         [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                           [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                         [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           [0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                          0 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                          [] 0 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                            [] 0 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                            [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                     [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                             [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                               [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                       [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                           [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                      [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[]] [[] =] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                            [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                         [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                          True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                           True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                           [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                             [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                    [] [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                            [] . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                               . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                             0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                             0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                             1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                             3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           3 3 . + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                             6 . 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                           6 4 . + 5 + 6 + 7 + 8 + 9 +
-                                                                                                                            10 . 5 + 6 + 7 + 8 + 9 +
-                                                                                                                          10 5 . + 6 + 7 + 8 + 9 +
-                                                                                                                            15 . 6 + 7 + 8 + 9 +
-                                                                                                                          15 6 . + 7 + 8 + 9 +
-                                                                                                                            21 . 7 + 8 + 9 +
-                                                                                                                          21 7 . + 8 + 9 +
-                                                                                                                            28 . 8 + 9 +
-                                                                                                                          28 8 . + 9 +
-                                                                                                                            36 . 9 +
-                                                                                                                          36 9 . +
-                                                                                                                            45 . 
-
-
-
- -
-
- -
-
-
-
In [12]:
-
-
-
V('10 range_sum')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                                 . 10 range_sum
-                                                                              10 . range_sum
-                                                                              10 . [0 <=] 0 [1 - dup] [+] hylomorphism
-                                                                       10 [0 <=] . 0 [1 - dup] [+] hylomorphism
-                                                                     10 [0 <=] 0 . [1 - dup] [+] hylomorphism
-                                                           10 [0 <=] 0 [1 - dup] . [+] hylomorphism
-                                                       10 [0 <=] 0 [1 - dup] [+] . hylomorphism
-                                                       10 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec
-                                  10 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec
-                                                                     10 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                                     10 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                                  10 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                                   10 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                             10 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec
-                                                             10 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec
-                                                             10 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec
-                                                               10 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec
-                                                     10 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec
-                                                 10 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec
-                                           10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec
-                                           10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec
-                                           10 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec
-                                             10 [0 <=] [pop 0] [1 - dup] [dip +] . genrec
-     10 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte
-10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [10] [0 <=] . infra first choice i
-                                                                              10 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i
-                                                                            10 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i
-    False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] . swaack first choice i
-    10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i
-      10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i
-                    10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i
-                                                                              10 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                                                            10 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                                                               9 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                                                             9 9 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +
-                                   9 9 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip +
-                                                                               9 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 9 +
-                                                                        9 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 9 +
-                                                                9 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 9 +
-                                                      9 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 9 +
-                                              9 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 9 +
-      9 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 9 +
-  9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [9] [0 <=] . infra first choice i 9 +
-                                                                               9 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 +
-                                                                             9 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] . swaack first choice i 9 +
-     9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 +
-       9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 9 +
-                     9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 9 +
-                                                                               9 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +
-                                                                             9 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +
-                                                                               8 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +
-                                                                             8 8 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +
-                                   8 8 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 9 +
-                                                                               8 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 8 + 9 +
-                                                                        8 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 8 + 9 +
-                                                                8 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 8 + 9 +
-                                                      8 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 8 + 9 +
-                                              8 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 8 + 9 +
-      8 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 8 + 9 +
-  8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [8] [0 <=] . infra first choice i 8 + 9 +
-                                                                               8 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 +
-                                                                             8 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] . swaack first choice i 8 + 9 +
-     8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 +
-       8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 +
-                     8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 8 + 9 +
-                                                                               8 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +
-                                                                             8 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +
-                                                                               7 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +
-                                                                             7 7 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +
-                                   7 7 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 8 + 9 +
-                                                                               7 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 +
-                                                                        7 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 +
-                                                                7 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 7 + 8 + 9 +
-                                                      7 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 7 + 8 + 9 +
-                                              7 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 7 + 8 + 9 +
-      7 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 7 + 8 + 9 +
-  7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [7] [0 <=] . infra first choice i 7 + 8 + 9 +
-                                                                               7 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 +
-                                                                             7 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] . swaack first choice i 7 + 8 + 9 +
-     7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 +
-       7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 +
-                     7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 7 + 8 + 9 +
-                                                                               7 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +
-                                                                             7 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +
-                                                                               6 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +
-                                                                             6 6 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +
-                                   6 6 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 7 + 8 + 9 +
-                                                                               6 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 +
-                                                                        6 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 +
-                                                                6 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 +
-                                                      6 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 6 + 7 + 8 + 9 +
-                                              6 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 6 + 7 + 8 + 9 +
-      6 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 +
-  6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [6] [0 <=] . infra first choice i 6 + 7 + 8 + 9 +
-                                                                               6 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 +
-                                                                             6 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] . swaack first choice i 6 + 7 + 8 + 9 +
-     6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 +
-       6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 +
-                     6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 +
-                                                                               6 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +
-                                                                             6 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +
-                                                                               5 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +
-                                                                             5 5 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +
-                                   5 5 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 6 + 7 + 8 + 9 +
-                                                                               5 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                                                        5 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                                                5 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                                      5 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 5 + 6 + 7 + 8 + 9 +
-                                              5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 5 + 6 + 7 + 8 + 9 +
-      5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 +
-  5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i 5 + 6 + 7 + 8 + 9 +
-                                                                               5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 +
-                                                                             5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i 5 + 6 + 7 + 8 + 9 +
-     5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 +
-       5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 +
-                     5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 +
-                                                                               5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +
-                                                                             5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +
-                                                                               4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +
-                                                                             4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +
-                                   4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 +
-                                                                               4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                        4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                                      4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +
-                                              4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 +
-      4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 +
-  4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-     4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 +
-       4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 +
-                     4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                   3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                        3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                      3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                              3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-      3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-  3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-     3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-       3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                     3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                   2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                        2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                      2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                              2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-      2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-  2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-     2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-       2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                     2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                   1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                        1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                      1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                              1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-      1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-  1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                           False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-     False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-     1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-       1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                     1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                   0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                        0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                      0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                              0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-      0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-  0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                            True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-      True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-      0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-        0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                       0 [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               0 . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                                 . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             3 3 . + 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                               6 . 4 + 5 + 6 + 7 + 8 + 9 +
-                                                                             6 4 . + 5 + 6 + 7 + 8 + 9 +
-                                                                              10 . 5 + 6 + 7 + 8 + 9 +
-                                                                            10 5 . + 6 + 7 + 8 + 9 +
-                                                                              15 . 6 + 7 + 8 + 9 +
-                                                                            15 6 . + 7 + 8 + 9 +
-                                                                              21 . 7 + 8 + 9 +
-                                                                            21 7 . + 8 + 9 +
-                                                                              28 . 8 + 9 +
-                                                                            28 8 . + 9 +
-                                                                              36 . 9 +
-                                                                            36 9 . +
-                                                                              45 . 
-
-
-
- -
-
- -
-
-
-
-
-

Factorial Function and Paramorphisms

A paramorphism P :: B -> A is a recursion combinator that uses dup on intermediate values.

- -
n swap [P] [pop] [[F] dupdip G] primrec
-
-
-

With

-
    -
  • n :: A is the "identity" for F (like 1 for multiplication, 0 for addition)
  • -
  • F :: (A, B) -> A
  • -
  • G :: B -> B generates the next B value.
  • -
  • and lastly P :: B -> Bool detects the end of the series.
  • -
- -
-
-
-
-
-
-
-

For Factorial function (types A and B are both integer):

- -
n == 1
-F == *
-G == --
-P == 1 <=
- -
-
-
-
-
-
In [15]:
-
-
-
define('factorial == 1 swap [1 <=] [pop] [[*] dupdip --] primrec')
-
- -
-
-
- -
-
-
-
-
-

Try it with input 3 (omitting evaluation of predicate):

- -
3 1 swap [1 <=] [pop] [[*] dupdip --] primrec
-1 3      [1 <=] [pop] [[*] dupdip --] primrec
-
-1 3 [*] dupdip --
-1 3  * 3      --
-3      3      --
-3      2
-
-3 2 [*] dupdip --
-3 2  *  2      --
-6       2      --
-6       1
-
-6 1 [1 <=] [pop] [[*] dupdip --] primrec
-
-6 1 pop
-6
- -
-
-
-
-
-
In [16]:
-
-
-
J('3 factorial')
-
- -
-
-
- -
-
- - -
- -
- - -
-
6
-
-
-
- -
-
- -
-
-
-
-
-

Derive paramorphism from the form above.

-
n swap [P] [pop] [[F] dupdip G] primrec
-
-n swap [P]       [pop]     [[F] dupdip G]                  primrec
-n [P] [swap] dip [pop]     [[F] dupdip G]                  primrec
-n [P] [[F] dupdip G]                [[swap] dip [pop]] dip primrec
-n [P] [F] [dupdip G]           cons [[swap] dip [pop]] dip primrec
-n [P] [F] [G] [dupdip] swoncat cons [[swap] dip [pop]] dip primrec
-
-paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec
- -
-
-
-
-
-
In [17]:
-
-
-
define('paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec')
-define('factorial == 1 [1 <=] [*] [--] paramorphism')
-
- -
-
-
- -
-
-
-
In [18]:
-
-
-
J('3 factorial')
-
- -
-
-
- -
-
- - -
- -
- - -
-
6
-
-
-
- -
-
- -
-
-
-
-
-

tails

An example of a paramorphism for lists given in the "Bananas..." paper is tails which returns the list of "tails" of a list.

- -
[1 2 3] tails == [[] [3] [2 3]]
-
-
-

Using paramorphism we would write:

- -
n == []
-F == rest swons
-G == rest
-P == not
-
-tails == [] [not] [rest swons] [rest] paramorphism
- -
-
-
-
-
-
In [19]:
-
-
-
define('tails == [] [not] [rest swons] [rest] paramorphism')
-
- -
-
-
- -
-
-
-
In [20]:
-
-
-
J('[1 2 3] tails')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[[] [3] [2 3]]
-
-
-
- -
-
- -
-
-
-
In [21]:
-
-
-
J('25 range tails [popop] infra [sum] map')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276]
-
-
-
- -
-
- -
-
-
-
In [22]:
-
-
-
J('25 range [range_sum] map')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[276 253 231 210 190 171 153 136 120 105 91 78 66 55 45 36 28 21 15 10 6 3 1 0 0]
-
-
-
- -
-
- -
-
-
-
-
-

Factoring rest

Right before the recursion begins we have:

- -
[] [1 2 3] [not] [pop] [[rest swons] dupdip rest] primrec
-
-
-

But we might prefer to factor rest in the quote:

- -
[] [1 2 3] [not] [pop] [rest [swons] dupdip] primrec
-
-
-

There's no way to do that with the paramorphism combinator as defined. We would have to write and use a slightly different recursion combinator that accepted an additional "preprocessor" function [H] and built:

- -
n swap [P] [pop] [H [F] dupdip G] primrec
-
-
-

Or just write it out manually. This is yet another place where the sufficiently smart compiler will one day automatically refactor the code. We could write a paramorphism combinator that checked [F] and [G] for common prefix and extracted it.

- -
-
-
-
-
-
-
-

Patterns of Recursion

Our story so far...

-
    -
  • A combiner F :: (B, B) -> B
  • -
  • A predicate P :: A -> Bool to detect the base case
  • -
  • A base case value c :: B
  • -
-

Hylo-, Ana-, Cata-

-
w/ G :: A -> (A, B)
-
-H == [P   ] [pop c ] [G          ] [dip F    ] genrec
-A == [P   ] [pop []] [G          ] [dip swons] genrec
-C == [[] =] [pop c ] [uncons swap] [dip F    ] genrec
-
-
-

Para-, ?-, ?-

-
w/ G :: B -> B
-
-P == c  swap [P   ] [pop] [[F    ] dupdip G          ] primrec
-? == [] swap [P   ] [pop] [[swons] dupdip G          ] primrec
-? == c  swap [[] =] [pop] [[F    ] dupdip uncons swap] primrec
- -
-
-
-
-
-
-
-

Four Generalizations

There are at least four kinds of recursive combinator, depending on two choices. The first choice is whether the combiner function should be evaluated during the recursion or pushed into the pending expression to be "collapsed" at the end. The second choice is whether the combiner needs to operate on the current value of the datastructure or the generator's output.

- -
H ==        [P] [pop c] [G             ] [dip F] genrec
-H == c swap [P] [pop]   [G [F]    dip  ] [i]     genrec
-H ==        [P] [pop c] [  [G] dupdip  ] [dip F] genrec
-H == c swap [P] [pop]   [  [F] dupdip G] [i]     genrec
-
-
-

Consider:

- -
... a G [H] dip F                w/ a G == a' b
-... c a G [F] dip H                 a G == b  a'
-... a [G] dupdip [H] dip F          a G == a'
-... c a [F] dupdip G H              a G == a'
- -
-
-
-
-
-
-
-

1

-
H == [P] [pop c] [G] [dip F] genrec
-
-
-

Iterate n times.

- -
... a [P] [pop c] [G] [dip F] genrec
-... a  G [H] dip F
-... a' b [H] dip F
-... a' H b F
-... a'  G [H] dip F b F
-... a'' b [H] dip F b F
-... a'' H b F b F
-... a''  G [H] dip F b F b F
-... a''' b [H] dip F b F b F
-... a''' H b F b F b F
-... a''' pop c b F b F b F
-... c b F b F b F
-
-
-

This form builds up a continuation that contains the intermediate results along with the pending combiner functions. When the base case is reached the last term is replaced by the identity value c and the continuation "collapses" into the final result.

- -
-
-
-
-
-
-
-

2

When you can start with the identity value c on the stack and the combiner can operate as you go, using the intermediate results immediately rather than queuing them up, use this form. An important difference is that the generator function must return its results in the reverse order.

- -
H == c swap [P] [pop] [G [F] dip] primrec
-
-... c a G [F] dip H
-... c b a' [F] dip H
-... c b F a' H
-... c b F a' G [F] dip H
-... c b F b a'' [F] dip H
-... c b F b F a'' H
-... c b F b F a'' G [F] dip H
-... c b F b F b a''' [F] dip H
-... c b F b F b F a''' H
-... c b F b F b F a''' pop
-... c b F b F b F
-
-
-

The end line here is the same as for above, but only because we didn't evaluate F when it normally would have been.

- -
-
-
-
-
-
-
-

3

If the combiner and the generator both need to work on the current value then dup must be used at some point, and the generator must produce one item instead of two (the b is instead the duplicate of a.)

- -
H == [P] [pop c] [[G] dupdip] [dip F] genrec
-
-... a [G] dupdip [H] dip F
-... a  G a       [H] dip F
-... a'   a       [H] dip F
-... a' H a F
-... a' [G] dupdip [H] dip F a F
-... a'  G  a'     [H] dip F a F
-... a''    a'     [H] dip F a F
-... a'' H  a' F a F
-... a'' [G] dupdip [H] dip F a' F a F
-... a''  G  a''    [H] dip F a' F a F
-... a'''    a''    [H] dip F a' F a F
-... a''' H  a'' F a' F a F
-... a''' pop c  a'' F a' F a F
-...          c  a'' F a' F a F
- -
-
-
-
-
-
-
-

4

And, last but not least, if you can combine as you go, starting with c, and the combiner needs to work on the current item, this is the form:

- -
W == c swap [P] [pop] [[F] dupdip G] primrec
-
-... a c swap [P] [pop] [[F] dupdip G] primrec
-... c a [P] [pop] [[F] dupdip G] primrec
-... c a [F] dupdip G W
-... c a  F a G W
-... c a  F a'  W
-... c a  F a'  [F] dupdip G W
-... c a  F a'   F  a'     G W
-... c a  F a'   F  a''      W
-... c a  F a'   F  a''      [F] dupdip G W
-... c a  F a'   F  a''       F  a''    G W
-... c a  F a'   F  a''       F  a'''     W
-... c a  F a'   F  a''       F  a'''     pop
-... c a  F a'   F  a''       F
- -
-
-
-
-
-
-
-

Each of the four variations above can be specialized to ana- and catamorphic forms.

- -
-
-
-
-
-
In [23]:
-
-
-
def WTFmorphism(c, F, P, G):
-    '''Return a hylomorphism function H.'''
-
-    def H(a, d=c):
-        if P(a):
-            result = d
-        else:
-            a, b = G(a)
-            result = H(a, F(d, b))
-        return result
-
-    return H
-
- -
-
-
- -
-
-
-
In [24]:
-
-
-
F = lambda a, b: a + b
-P = lambda n: n <= 1
-G = lambda n: (n - 1, n - 1)
-
-wtf = WTFmorphism(0, F, P, G)
-
-print wtf(5)
-
- -
-
-
- -
-
- - -
- -
- - -
-
10
-
-
-
- -
-
- -
-
-
-
-
- -
H == [P   ] [pop c ] [G          ] [dip F    ] genrec
- -
-
-
-
-
-
In [25]:
-
-
-
DefinitionWrapper.add_definitions('''
-P == 1 <=
-Ga == -- dup
-Gb == --
-c == 0
-F == +
-''', D)
-
- -
-
-
- -
-
-
-
In [26]:
-
-
-
V('[1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                                                             . [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec
-                                                                                                     [1 2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec
-                                                                                              [1 2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec
-                                                                                     [1 2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec
-                                                                       [1 2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec
-                                                           [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec
-          [1 2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte
-[1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[1 2 3]] [[] =] . infra first choice i
-                                                                                                     [1 2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i
-                                                                                                  [1 2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i
-                                                                                                       False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i
-         False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] . swaack first choice i
-         [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i
-           [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i
-                          [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i
-                                                                                                     [1 2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons
-                                                                                                     1 [2 3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons
-                                                                                                     [2 3] 1 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons
-                                                  [2 3] 1 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons
-                                                                                                       [2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 1 swons
-                                                                                                [2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 1 swons
-                                                                                       [2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 1 swons
-                                                                         [2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 1 swons
-                                                             [2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 1 swons
-            [2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 1 swons
-    [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[2 3]] [[] =] . infra first choice i 1 swons
-                                                                                                       [2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons
-                                                                                                    [2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons
-                                                                                                       False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons
-           False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] . swaack first choice i 1 swons
-           [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons
-             [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons
-                            [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 1 swons
-                                                                                                       [2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons
-                                                                                                       2 [3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons
-                                                                                                       [3] 2 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons
-                                                    [3] 2 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 1 swons
-                                                                                                         [3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons
-                                                                                                  [3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons
-                                                                                         [3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 2 swons 1 swons
-                                                                           [3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 2 swons 1 swons
-                                                               [3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 2 swons 1 swons
-              [3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 2 swons 1 swons
-        [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[3]] [[] =] . infra first choice i 2 swons 1 swons
-                                                                                                         [3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons
-                                                                                                      [3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons
-                                                                                                       False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons
-             False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] . swaack first choice i 2 swons 1 swons
-             [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 1 swons
-               [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 1 swons
-                              [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 2 swons 1 swons
-                                                                                                         [3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons
-                                                                                                        3 [] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons
-                                                                                                        [] 3 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons
-                                                     [] 3 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 2 swons 1 swons
-                                                                                                          [] . [[] =] [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons
-                                                                                                   [] [[] =] . [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons
-                                                                                          [] [[] =] [pop []] . [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons
-                                                                            [] [[] =] [pop []] [uncons swap] . [dip swons] genrec 3 swons 2 swons 1 swons
-                                                                [] [[] =] [pop []] [uncons swap] [dip swons] . genrec 3 swons 2 swons 1 swons
-               [] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 3 swons 2 swons 1 swons
-          [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[]] [[] =] . infra first choice i 3 swons 2 swons 1 swons
-                                                                                                          [] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons
-                                                                                                       [] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons
-                                                                                                        True . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons
-               True [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] . swaack first choice i 3 swons 2 swons 1 swons
-               [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 3 swons 2 swons 1 swons
-                 [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] True . choice i 3 swons 2 swons 1 swons
-                                                                                                 [] [pop []] . i 3 swons 2 swons 1 swons
-                                                                                                          [] . pop [] 3 swons 2 swons 1 swons
-                                                                                                             . [] 3 swons 2 swons 1 swons
-                                                                                                          [] . 3 swons 2 swons 1 swons
-                                                                                                        [] 3 . swons 2 swons 1 swons
-                                                                                                        [] 3 . swap cons 2 swons 1 swons
-                                                                                                        3 [] . cons 2 swons 1 swons
-                                                                                                         [3] . 2 swons 1 swons
-                                                                                                       [3] 2 . swons 1 swons
-                                                                                                       [3] 2 . swap cons 1 swons
-                                                                                                       2 [3] . cons 1 swons
-                                                                                                       [2 3] . 1 swons
-                                                                                                     [2 3] 1 . swons
-                                                                                                     [2 3] 1 . swap cons
-                                                                                                     1 [2 3] . cons
-                                                                                                     [1 2 3] . 
-
-
-
- -
-
- -
-
-
-
In [27]:
-
-
-
V('3 [P] [pop c] [Ga] [dip F] genrec')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                               . 3 [P] [pop c] [Ga] [dip F] genrec
-                                                             3 . [P] [pop c] [Ga] [dip F] genrec
-                                                         3 [P] . [pop c] [Ga] [dip F] genrec
-                                                 3 [P] [pop c] . [Ga] [dip F] genrec
-                                            3 [P] [pop c] [Ga] . [dip F] genrec
-                                    3 [P] [pop c] [Ga] [dip F] . genrec
-    3 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte
-3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [3] [P] . infra first choice i
-                                                             3 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i
-                                                             3 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i
-                                                           3 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i
-                                                         False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i
-False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] . swaack first choice i
-3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i
-  3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i
-                3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i
-                                                             3 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F
-                                                             3 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F
-                                                             2 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F
-                                                           2 2 . [[P] [pop c] [Ga] [dip F] genrec] dip F
-                         2 2 [[P] [pop c] [Ga] [dip F] genrec] . dip F
-                                                             2 . [P] [pop c] [Ga] [dip F] genrec 2 F
-                                                         2 [P] . [pop c] [Ga] [dip F] genrec 2 F
-                                                 2 [P] [pop c] . [Ga] [dip F] genrec 2 F
-                                            2 [P] [pop c] [Ga] . [dip F] genrec 2 F
-                                    2 [P] [pop c] [Ga] [dip F] . genrec 2 F
-    2 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 2 F
-2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [2] [P] . infra first choice i 2 F
-                                                             2 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F
-                                                             2 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F
-                                                           2 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F
-                                                         False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F
-False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] . swaack first choice i 2 F
-2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F
-  2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i 2 F
-                2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i 2 F
-                                                             2 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F
-                                                             2 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F
-                                                             1 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F
-                                                           1 1 . [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F
-                         1 1 [[P] [pop c] [Ga] [dip F] genrec] . dip F 2 F
-                                                             1 . [P] [pop c] [Ga] [dip F] genrec 1 F 2 F
-                                                         1 [P] . [pop c] [Ga] [dip F] genrec 1 F 2 F
-                                                 1 [P] [pop c] . [Ga] [dip F] genrec 1 F 2 F
-                                            1 [P] [pop c] [Ga] . [dip F] genrec 1 F 2 F
-                                    1 [P] [pop c] [Ga] [dip F] . genrec 1 F 2 F
-    1 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 1 F 2 F
-1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [1] [P] . infra first choice i 1 F 2 F
-                                                             1 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F
-                                                             1 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F
-                                                           1 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F
-                                                          True . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F
- True [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] . swaack first choice i 1 F 2 F
- 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F
-   1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F
-                                                     1 [pop c] . i 1 F 2 F
-                                                             1 . pop c 1 F 2 F
-                                                               . c 1 F 2 F
-                                                               . 0 1 F 2 F
-                                                             0 . 1 F 2 F
-                                                           0 1 . F 2 F
-                                                           0 1 . + 2 F
-                                                             1 . 2 F
-                                                           1 2 . F
-                                                           1 2 . +
-                                                             3 . 
-
-
-
- -
-
- -
-
-
-
In [28]:
-
-
-
V('3 [P] [pop []] [Ga] [dip swons] genrec')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                         . 3 [P] [pop []] [Ga] [dip swons] genrec
-                                                                       3 . [P] [pop []] [Ga] [dip swons] genrec
-                                                                   3 [P] . [pop []] [Ga] [dip swons] genrec
-                                                          3 [P] [pop []] . [Ga] [dip swons] genrec
-                                                     3 [P] [pop []] [Ga] . [dip swons] genrec
-                                         3 [P] [pop []] [Ga] [dip swons] . genrec
-    3 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte
-3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [3] [P] . infra first choice i
-                                                                       3 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i
-                                                                       3 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i
-                                                                     3 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i
-                                                                   False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i
-False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] . swaack first choice i
-3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i
-  3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i
-                 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i
-                                                                       3 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons
-                                                                       3 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons
-                                                                       2 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons
-                                                                     2 2 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons
-                              2 2 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons
-                                                                       2 . [P] [pop []] [Ga] [dip swons] genrec 2 swons
-                                                                   2 [P] . [pop []] [Ga] [dip swons] genrec 2 swons
-                                                          2 [P] [pop []] . [Ga] [dip swons] genrec 2 swons
-                                                     2 [P] [pop []] [Ga] . [dip swons] genrec 2 swons
-                                         2 [P] [pop []] [Ga] [dip swons] . genrec 2 swons
-    2 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 2 swons
-2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [2] [P] . infra first choice i 2 swons
-                                                                       2 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons
-                                                                       2 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons
-                                                                     2 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons
-                                                                   False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons
-False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons
-2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons
-  2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons
-                 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i 2 swons
-                                                                       2 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons
-                                                                       2 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons
-                                                                       1 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons
-                                                                     1 1 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons
-                              1 1 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons 2 swons
-                                                                       1 . [P] [pop []] [Ga] [dip swons] genrec 1 swons 2 swons
-                                                                   1 [P] . [pop []] [Ga] [dip swons] genrec 1 swons 2 swons
-                                                          1 [P] [pop []] . [Ga] [dip swons] genrec 1 swons 2 swons
-                                                     1 [P] [pop []] [Ga] . [dip swons] genrec 1 swons 2 swons
-                                         1 [P] [pop []] [Ga] [dip swons] . genrec 1 swons 2 swons
-    1 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons
-1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [1] [P] . infra first choice i 1 swons 2 swons
-                                                                       1 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons
-                                                                       1 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons
-                                                                     1 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons
-                                                                    True . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons
- True [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons
- 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 1 swons 2 swons
-   1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] True . choice i 1 swons 2 swons
-                                                              1 [pop []] . i 1 swons 2 swons
-                                                                       1 . pop [] 1 swons 2 swons
-                                                                         . [] 1 swons 2 swons
-                                                                      [] . 1 swons 2 swons
-                                                                    [] 1 . swons 2 swons
-                                                                    [] 1 . swap cons 2 swons
-                                                                    1 [] . cons 2 swons
-                                                                     [1] . 2 swons
-                                                                   [1] 2 . swons
-                                                                   [1] 2 . swap cons
-                                                                   2 [1] . cons
-                                                                   [2 1] . 
-
-
-
- -
-
- -
-
-
-
In [29]:
-
-
-
V('[2 1] [[] =] [pop c ] [uncons swap] [dip F] genrec')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                                               . [2 1] [[] =] [pop c] [uncons swap] [dip F] genrec
-                                                                                         [2 1] . [[] =] [pop c] [uncons swap] [dip F] genrec
-                                                                                  [2 1] [[] =] . [pop c] [uncons swap] [dip F] genrec
-                                                                          [2 1] [[] =] [pop c] . [uncons swap] [dip F] genrec
-                                                            [2 1] [[] =] [pop c] [uncons swap] . [dip F] genrec
-                                                    [2 1] [[] =] [pop c] [uncons swap] [dip F] . genrec
-        [2 1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte
-[2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[2 1]] [[] =] . infra first choice i
-                                                                                         [2 1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i
-                                                                                      [2 1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i
-                                                                                         False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i
-       False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] . swaack first choice i
-       [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i
-         [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i
-                       [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i
-                                                                                         [2 1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F
-                                                                                         2 [1] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F
-                                                                                         [1] 2 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F
-                                           [1] 2 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F
-                                                                                           [1] . [[] =] [pop c] [uncons swap] [dip F] genrec 2 F
-                                                                                    [1] [[] =] . [pop c] [uncons swap] [dip F] genrec 2 F
-                                                                            [1] [[] =] [pop c] . [uncons swap] [dip F] genrec 2 F
-                                                              [1] [[] =] [pop c] [uncons swap] . [dip F] genrec 2 F
-                                                      [1] [[] =] [pop c] [uncons swap] [dip F] . genrec 2 F
-          [1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 2 F
-    [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[1]] [[] =] . infra first choice i 2 F
-                                                                                           [1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F
-                                                                                        [1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F
-                                                                                         False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F
-         False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] . swaack first choice i 2 F
-         [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F
-           [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i 2 F
-                         [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i 2 F
-                                                                                           [1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F
-                                                                                          1 [] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F
-                                                                                          [] 1 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F
-                                            [] 1 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F 2 F
-                                                                                            [] . [[] =] [pop c] [uncons swap] [dip F] genrec 1 F 2 F
-                                                                                     [] [[] =] . [pop c] [uncons swap] [dip F] genrec 1 F 2 F
-                                                                             [] [[] =] [pop c] . [uncons swap] [dip F] genrec 1 F 2 F
-                                                               [] [[] =] [pop c] [uncons swap] . [dip F] genrec 1 F 2 F
-                                                       [] [[] =] [pop c] [uncons swap] [dip F] . genrec 1 F 2 F
-           [] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 1 F 2 F
-      [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[]] [[] =] . infra first choice i 1 F 2 F
-                                                                                            [] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F
-                                                                                         [] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F
-                                                                                          True . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F
-           True [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] . swaack first choice i 1 F 2 F
-           [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F
-             [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F
-                                                                                    [] [pop c] . i 1 F 2 F
-                                                                                            [] . pop c 1 F 2 F
-                                                                                               . c 1 F 2 F
-                                                                                               . 0 1 F 2 F
-                                                                                             0 . 1 F 2 F
-                                                                                           0 1 . F 2 F
-                                                                                           0 1 . + 2 F
-                                                                                             1 . 2 F
-                                                                                           1 2 . F
-                                                                                           1 2 . +
-                                                                                             3 . 
-
-
-
- -
-
- -
-
-
-
-
-

Appendix - Fun with Symbols

-
|[ (c, F), (G, P) ]| == (|c, F|) • [(G, P)]
-
-
-

"Bananas, Lenses, & Barbed Wire"

- -
(|...|)  [(...)]  [<...>]
-
-
-

I think they are having slightly too much fun with the symbols.

-

"Too much is always better than not enough."

- -
-
-
-
-
-
-
-

Tree with node and list of trees.

-
tree = [] | [node [tree*]]
- -
-
-
-
-
-
-
-

treestep

-
tree z [C] [N] treestep
-
-
-   [] z [C] [N] treestep
----------------------------
-      z
-
-
-   [node [tree*]] z [C] [N] treestep
---------------------------------------- w/ K == z [C] [N] treestep
-       node N [tree*] [K] map C
- -
-
-
-
-
-
-
-

Derive the recursive form.

-
K == [not] [pop z] [J] ifte
-
-
-       [node [tree*]] J
-------------------------------
-   node N [tree*] [K] map C
-
-
-J == .. [N] .. [K] .. [C] ..
-
-[node [tree*]] uncons [N] dip
-node [[tree*]]        [N] dip
-node N [[tree*]]
-
-node N [[tree*]] i [K] map
-node N  [tree*]    [K] map
-node N  [K.tree*]
-
-J == uncons [N] dip i [K] map [C] i
-
-K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte
-K == [not] [pop z] [uncons [N] dip i]   [map [C] i] genrec
- -
-
-
-
-
-
-
-

Extract the givens to parameterize the program.

-
[not] [pop z]                   [uncons [N] dip unquote] [map [C] i] genrec
-[not] [z]         [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
-[not]  z     unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
-z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec
-  \............TS0............/
-z TS0 [uncons [N] dip unquote]                      [map [C] i] genrec
-z [uncons [N] dip unquote]                [TS0] dip [map [C] i] genrec
-z [[N] dip unquote]      [uncons] swoncat [TS0] dip [map [C] i] genrec
-z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec
-      \...........TS1.................../
-z [N] TS1 [TS0] dip [map [C] i]                       genrec
-z [N]               [map [C] i]            [TS1 [TS0] dip] dip      genrec
-z [N]               [map  C   ]            [TS1 [TS0] dip] dip      genrec
-z [N]                    [C] [map] swoncat [TS1 [TS0] dip] dip genrec
-z [C] [N] swap               [map] swoncat [TS1 [TS0] dip] dip genrec
- -
-
-
-
-
-
-
- -
     TS0 == [not] swap unit [pop] swoncat
-     TS1 == [dip i] cons [uncons] swoncat
-treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
- -
-
-
-
-
-
-
- -
   [] 0 [C] [N] treestep
----------------------------
-      0
-
-
-      [n [tree*]] 0 [sum +] [] treestep
-   --------------------------------------------------
-       n [tree*] [0 [sum +] [] treestep] map sum +
- -
-
-
-
-
-
In [40]:
-
-
-
DefinitionWrapper.add_definitions('''
-
-     TS0 == [not] swap unit [pop] swoncat
-     TS1 == [dip i] cons [uncons] swoncat
-treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec
-
-''', D)
-
- -
-
-
- -
-
-
-
In [31]:
-
-
-
V('[] 0 [sum +] [] treestep')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                                                       . [] 0 [sum +] [] treestep
-                                                                                                    [] . 0 [sum +] [] treestep
-                                                                                                  [] 0 . [sum +] [] treestep
-                                                                                          [] 0 [sum +] . [] treestep
-                                                                                       [] 0 [sum +] [] . treestep
-                                                                                       [] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
-                                                                                       [] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
-                                                                                 [] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
-                                                                                 [] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
-                                                                                 [] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
-                                                                                   [] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
-                                                                   [] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
-                                                                                               [] 0 [] . TS1 [TS0] dip [map sum +] genrec
-                                                                                               [] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                       [] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                       [] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                              [] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
-                                                                              [] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
-                                                                              [] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
-                                                                                [] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
-                                                                          [] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
-                                                                                                  [] 0 . TS0 [uncons [] dip i] [map sum +] genrec
-                                                                                                  [] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                            [] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                            [] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                            [] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                         [] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                          [] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                    [] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                    [] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
-                                                                                    [] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
-                                                                                      [] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
-                                                                    [] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
-                                                        [] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
-     [] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
-[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i
-                                                                                                    [] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
-                                                                                                  True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i
-    True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i
-    [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i
-      [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i
-                                                                                            [] [pop 0] . i
-                                                                                                    [] . pop 0
-                                                                                                       . 0
-                                                                                                     0 . 
-
-
-
- -
-
- -
-
-
-
In [32]:
-
-
-
V('[23 []] 0 [sum +] [] treestep')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                                                                 . [23 []] 0 [sum +] [] treestep
-                                                                                                         [23 []] . 0 [sum +] [] treestep
-                                                                                                       [23 []] 0 . [sum +] [] treestep
-                                                                                               [23 []] 0 [sum +] . [] treestep
-                                                                                            [23 []] 0 [sum +] [] . treestep
-                                                                                            [23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
-                                                                                            [23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
-                                                                                      [23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
-                                                                                      [23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
-                                                                                      [23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
-                                                                                        [23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
-                                                                        [23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
-                                                                                                    [23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec
-                                                                                                    [23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                            [23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                            [23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                   [23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
-                                                                                   [23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
-                                                                                   [23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
-                                                                                     [23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
-                                                                               [23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
-                                                                                                       [23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec
-                                                                                                       [23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                 [23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                 [23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                 [23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                              [23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                               [23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                         [23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                         [23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
-                                                                                         [23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
-                                                                                           [23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
-                                                                         [23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
-                                                             [23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
-          [23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
-[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i
-                                                                                                         [23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
-                                                                                                           False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i
-        False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i
-        [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
-          [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
-                        [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
-                                                                                                         [23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                         23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                      23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                              23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                         23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                              23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                           23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                      23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
-                                                                                                           23 [] . sum +
-                                                                                                           23 [] . 0 [+] catamorphism +
-                                                                                                         23 [] 0 . [+] catamorphism +
-                                                                                                     23 [] 0 [+] . catamorphism +
-                                                                                                     23 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +
-                                                                                              23 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +
-                                                                                              23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
-                                                                                23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
-                                                                                23 [] [[] =] 0 [uncons swap] [+] . hylomorphism +
-                                                                                23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
-                                                           23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
-                                                                                                  23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                  23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                               23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                          23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                          23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                          23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                            23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
-                                                                              23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
-                                                                          23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
-                                                                    23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
-                                                                    23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
-                                                                    23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
-                                                                      23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
-                          23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
-                  23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i +
-                                                                                                           23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
-                                                                                                        23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
-                                                                                                         23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +
-                       23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i +
-                       23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i +
-                            23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i +
-                                                                                                   23 [] [pop 0] . i +
-                                                                                                           23 [] . pop 0 +
-                                                                                                              23 . 0 +
-                                                                                                            23 0 . +
-                                                                                                              23 . 
-
-
-
- -
-
- -
-
-
-
In [33]:
-
-
-
V('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep')
-
- -
-
-
- -
-
- - -
- -
- - -
-
                                                                                                                                                                  . [23 [[2 []] [3 []]]] 0 [sum +] [] treestep
-                                                                                                                                             [23 [[2 []] [3 []]]] . 0 [sum +] [] treestep
-                                                                                                                                           [23 [[2 []] [3 []]]] 0 . [sum +] [] treestep
-                                                                                                                                   [23 [[2 []] [3 []]]] 0 [sum +] . [] treestep
-                                                                                                                                [23 [[2 []] [3 []]]] 0 [sum +] [] . treestep
-                                                                                                                                [23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec
-                                                                                                                                [23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec
-                                                                                                                          [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec
-                                                                                                                          [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec
-                                                                                                                          [23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec
-                                                                                                                            [23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec
-                                                                                                            [23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec
-                                                                                                                                        [23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec
-                                                                                                                                        [23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                                                                [23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                                                                [23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec
-                                                                                                                       [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec
-                                                                                                                       [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec
-                                                                                                                       [23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec
-                                                                                                                         [23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec
-                                                                                                                   [23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec
-                                                                                                                                           [23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec
-                                                                                                                                           [23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                                                     [23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                                                     [23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                                                     [23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                                                  [23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                                                   [23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                                             [23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec
-                                                                                                                             [23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec
-                                                                                                                             [23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec
-                                                                                                                               [23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec
-                                                                                                             [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec
-                                                                                                 [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec
-                                              [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte
-                       [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i
-                                                                                                                                             [23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
-                                                                                                                                                            False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i
-                                            False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i
-                                            [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i
-                                              [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i
-                                                            [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i
-                                                                                                                                             [23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                                                             23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                                                          23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                                                                               23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                                                             23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                                                                               23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                                                                               23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +
-                                                                                          23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +
-23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum +
-                                                                                                                                                                  . [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                      [[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                 [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                        23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                  23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                          23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                        23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                            23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                         23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                             23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                        23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                         23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                    23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                    23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                         23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                       23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                        23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                        23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                     23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                             23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                        23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                             23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                          23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                     23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                          23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                          23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                        23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                    23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                    23 3 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                             23 3 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                             23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                               23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                               23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                               23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                          23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                 23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                 23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                              23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                               23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                         23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                         23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                         23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                           23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                             23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                         23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                   23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                   23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                   23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                     23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                         23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                               23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                          23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                       23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                        23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                    23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                    23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                           23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                  23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                          23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                             23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                           23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                             23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                          23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                           [3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                                3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                                                                                    3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +
-                                                                                               3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum +
-                                                                                                                                                        23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
-                                                                                                                                                  23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
-                                                                                                                                          23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +
-                                                                                                                        23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum +
-                                                                                                            23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum +
-                                                         23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum +
-                                             23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum +
-                                                                                                                                                        23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
-                                                                                                                                                         23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +
-                                                    23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum +
-                                                    23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum +
-                                                         23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum +
-                                                                       23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum +
-                                                                                                                                                        23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                        23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                     23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                             23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                        23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                             23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                          23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +
-                                                                                                     23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                          23 2 [] . sum + [3] swaack first [23] swaack sum +
-                                                                                                                                                          23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum +
-                                                                                                                                                        23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum +
-                                                                                                                                                    23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum +
-                                                                                                                                                    23 2 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
-                                                                                                                                             23 2 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
-                                                                                                                                             23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +
-                                                                                                                               23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum +
-                                                                                                                               23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum +
-                                                                                                                               23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                          23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                                 23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                                 23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                              23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                               23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                         23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                         23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                         23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                                           23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                             23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                         23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                   23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                   23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                   23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum +
-                                                                                                                     23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum +
-                                                                         23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum +
-                                                               23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum +
-                                                                                                                                                          23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
-                                                                                                                                                       23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
-                                                                                                                                                        23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +
-                                                                    23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum +
-                                                                    23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum +
-                                                                           23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum +
-                                                                                                                                                  23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum +
-                                                                                                                                                          23 2 [] . pop 0 + [3] swaack first [23] swaack sum +
-                                                                                                                                                             23 2 . 0 + [3] swaack first [23] swaack sum +
-                                                                                                                                                           23 2 0 . + [3] swaack first [23] swaack sum +
-                                                                                                                                                             23 2 . [3] swaack first [23] swaack sum +
-                                                                                                                                                         23 2 [3] . swaack first [23] swaack sum +
-                                                                                                                                                         3 [2 23] . first [23] swaack sum +
-                                                                                                                                                              3 2 . [23] swaack sum +
-                                                                                                                                                         3 2 [23] . swaack sum +
-                                                                                                                                                         23 [2 3] . sum +
-                                                                                                                                                         23 [2 3] . 0 [+] catamorphism +
-                                                                                                                                                       23 [2 3] 0 . [+] catamorphism +
-                                                                                                                                                   23 [2 3] 0 [+] . catamorphism +
-                                                                                                                                                   23 [2 3] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +
-                                                                                                                                            23 [2 3] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +
-                                                                                                                                            23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism +
-                                                                                                                              23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism +
-                                                                                                                              23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism +
-                                                                                                                              23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +
-                                                                                                         23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +
-                                                                                                                                                23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                                                23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                                             23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                                              23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                                        23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                                        23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                                        23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                                          23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +
-                                                                                                                            23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +
-                                                                                                                        23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +
-                                                                                                                  23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +
-                                                                                                                  23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +
-                                                                                                                  23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +
-                                                                                                                    23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec +
-                                                                        23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +
-                                                             23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i +
-                                                                                                                                                         23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
-                                                                                                                                                      23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
-                                                                                                                                                         23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +
-                                                                    23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i +
-                                                                    23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i +
-                                                                         23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i +
-                                                                                       23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i +
-                                                                                                                                                         23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
-                                                                                                                                                         23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
-                                                                                                                                                         23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +
-                                                                                                           23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + +
-                                                                                                                                                           23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + +
-                                                                                                                                                    23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + +
-                                                                                                                                            23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + +
-                                                                                                                              23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + +
-                                                                                                                      23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + +
-                                                                          23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + +
-                                                                 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + +
-                                                                                                                                                           23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
-                                                                                                                                                        23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
-                                                                                                                                                         23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +
-                                                                      23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + +
-                                                                      23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + +
-                                                                           23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + +
-                                                                                         23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + +
-                                                                                                                                                           23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
-                                                                                                                                                          23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
-                                                                                                                                                          23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +
-                                                                                                            23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + +
-                                                                                                                                                            23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
-                                                                                                                                                     23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +
-                                                                                                                                             23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + +
-                                                                                                                               23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + +
-                                                                                                                       23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + +
-                                                                           23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + +
-                                                                   23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + +
-                                                                                                                                                            23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
-                                                                                                                                                         23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
-                                                                                                                                                          23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +
-                                                                        23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + +
-                                                                        23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + +
-                                                                             23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + +
-                                                                                                                                                    23 [] [pop 0] . i 3 + 2 + +
-                                                                                                                                                            23 [] . pop 0 3 + 2 + +
-                                                                                                                                                               23 . 0 3 + 2 + +
-                                                                                                                                                             23 0 . 3 + 2 + +
-                                                                                                                                                           23 0 3 . + 2 + +
-                                                                                                                                                             23 3 . 2 + +
-                                                                                                                                                           23 3 2 . + +
-                                                                                                                                                             23 5 . +
-                                                                                                                                                               28 . 
-
-
-
- -
-
- -
-
-
-
In [34]:
-
-
-
J('[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep')
-
- -
-
-
- -
-
- - -
- -
- - -
-
140
-
-
-
- -
-
- -
-
-
-
In [35]:
-
-
-
J('[] [] [unit cons] [23 +] treestep')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[]
-
-
-
- -
-
- -
-
-
-
In [36]:
-
-
-
J('[23 []] [] [unit cons] [23 +] treestep')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[46 []]
-
-
-
- -
-
- -
-
-
-
In [37]:
-
-
-
J('[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[46 [[25 []] [26 []]]]
-
-
-
- -
-
- -
-
-
-
In [38]:
-
-
-
define('treemap == [] [unit cons] roll< treestep')
-
- -
-
-
- -
-
-
-
In [39]:
-
-
-
J('[23 [[2 []] [3 []]]] [23 +] treemap')
-
- -
-
-
- -
-
- - -
- -
- - -
-
[46 [[25 []] [26 []]]]
-
-
-
- -
-
- -
-
-
- - - - - - diff --git a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.ipynb b/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.ipynb deleted file mode 100644 index fde17ad..0000000 --- a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.ipynb +++ /dev/null @@ -1,2987 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Cf. [\"Bananas, Lenses, & Barbed Wire\"](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# [Hylomorphism](https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29)\n", - "A [hylomorphism](https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29) `H :: A -> B` converts a value of type A into a value of type B by means of:\n", - "\n", - "- A generator `G :: A -> (A, B)`\n", - "- A combiner `F :: (B, B) -> B`\n", - "- A predicate `P :: A -> Bool` to detect the base case\n", - "- A base case value `c :: B`\n", - "- Recursive calls (zero or more); it has a \"call stack in the form of a cons list\".\n", - "\n", - "It may be helpful to see this function implemented in imperative Python code." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "def hylomorphism(c, F, P, G):\n", - " '''Return a hylomorphism function H.'''\n", - "\n", - " def H(a):\n", - " if P(a):\n", - " result = c\n", - " else:\n", - " b, aa = G(a)\n", - " result = F(b, H(aa))\n", - " return result\n", - "\n", - " return H" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Finding [Triangular Numbers](https://en.wikipedia.org/wiki/Triangular_number)\n", - "As a concrete example let's use a function that, given a positive integer, returns the sum of all positive integers less than that one. (In this case the types A and B are both `int`.)\n", - "### With `range()` and `sum()`" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "r = range(10)\n", - "r" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "45" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sum(r)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "45" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "range_sum = lambda n: sum(range(n))\n", - "range_sum(10)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### As a hylomorphism" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "G = lambda n: (n - 1, n - 1)\n", - "F = lambda a, b: a + b\n", - "P = lambda n: n <= 1\n", - "\n", - "H = hylomorphism(0, F, P, G)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "45" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "H(10)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you were to run the above code in a debugger and check out the call stack you would find that the variable `b` in each call to `H()` is storing the intermediate values as `H()` recurses. This is what was meant by \"call stack in the form of a cons list\"." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Joy Preamble" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "from notebook_preamble import D, DefinitionWrapper, J, V, define" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hylomorphism in Joy\n", - "We can define a combinator `hylomorphism` that will make a hylomorphism combinator `H` from constituent parts.\n", - "\n", - " H == c [F] [P] [G] hylomorphism\n", - "\n", - "The function `H` is recursive, so we start with `ifte` and set the else-part to\n", - "some function `J` that will contain a quoted copy of `H`. (The then-part just\n", - "discards the leftover `a` and replaces it with the base case value `c`.)\n", - "\n", - " H == [P] [pop c] [J] ifte\n", - "\n", - "The else-part `J` gets just the argument `a` on the stack.\n", - "\n", - " a J\n", - " a G The first thing to do is use the generator G\n", - " aa b which produces b and a new aa\n", - " aa b [H] dip we recur with H on the new aa\n", - " aa H b F and run F on the result.\n", - "\n", - "This gives us a definition for `J`.\n", - "\n", - " J == G [H] dip F\n", - "\n", - "Plug it in and convert to genrec.\n", - "\n", - " H == [P] [pop c] [G [H] dip F] ifte\n", - " H == [P] [pop c] [G] [dip F] genrec\n", - "\n", - "This is the form of a hylomorphism in Joy, which nicely illustrates that\n", - "it is a simple specialization of the general recursion combinator.\n", - "\n", - " H == [P] [pop c] [G] [dip F] genrec" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Derivation of `hylomorphism`\n", - "\n", - "Now we just need to derive a definition that builds the `genrec` arguments\n", - "out of the pieces given to the `hylomorphism` combinator.\n", - "\n", - " H == [P] [pop c] [G] [dip F] genrec\n", - " [P] [c] [pop] swoncat [G] [F] [dip] swoncat genrec\n", - " [P] c unit [pop] swoncat [G] [F] [dip] swoncat genrec\n", - " [P] c [G] [F] [unit [pop] swoncat] dipd [dip] swoncat genrec\n", - "\n", - "Working in reverse:\n", - "- Use `swoncat` twice to decouple `[c]` and `[F]`.\n", - "- Use `unit` to dequote `c`.\n", - "- Use `dipd` to untangle `[unit [pop] swoncat]` from the givens.\n", - "\n", - "At this point all of the arguments (givens) to the hylomorphism are to the left so we have\n", - "a definition for `hylomorphism`:\n", - "\n", - " hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec\n", - "\n", - "The order of parameters is different than the one we started with but\n", - "that hardly matters, you can rearrange them or just supply them in the\n", - "expected order.\n", - "\n", - " [P] c [G] [F] hylomorphism == H\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "define('hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Demonstrate summing a range of integers from 0 to n-1.\n", - "\n", - "- `[P]` is `[0 <=]`\n", - "- `c` is `0`\n", - "- `[G]` is `[1 - dup]`\n", - "- `[F]` is `[+]`\n", - "\n", - "So to sum the positive integers less than five we can do this." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 5 [0 <=] 0 [1 - dup] [+] hylomorphism\n", - " 5 . [0 <=] 0 [1 - dup] [+] hylomorphism\n", - " 5 [0 <=] . 0 [1 - dup] [+] hylomorphism\n", - " 5 [0 <=] 0 . [1 - dup] [+] hylomorphism\n", - " 5 [0 <=] 0 [1 - dup] . [+] hylomorphism\n", - " 5 [0 <=] 0 [1 - dup] [+] . hylomorphism\n", - " 5 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec\n", - " 5 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec\n", - " 5 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec\n", - " 5 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec\n", - " 5 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec\n", - " 5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec\n", - " 5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec\n", - " 5 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec\n", - " 5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec\n", - " 5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte\n", - "5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i\n", - " 5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i\n", - " 5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i\n", - " 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i\n", - " 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i\n", - " 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i\n", - " 5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip +\n", - " 4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 +\n", - " 4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 +\n", - " 4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 +\n", - " 4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 +\n", - " 4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 +\n", - " 4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 +\n", - "4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 +\n", - " 4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 +\n", - " 4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 +\n", - " 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 +\n", - " 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 +\n", - " 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 +\n", - " 4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +\n", - " 4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +\n", - " 3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +\n", - " 3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 +\n", - " 3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 +\n", - " 3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 +\n", - " 3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 +\n", - " 3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 +\n", - " 3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 +\n", - " 3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 +\n", - " 3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 +\n", - "3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 +\n", - " 3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 +\n", - " 3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 +\n", - " 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 +\n", - " 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 +\n", - " 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 +\n", - " 3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +\n", - " 3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +\n", - " 2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +\n", - " 2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 +\n", - " 2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 +\n", - " 2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 +\n", - " 2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 +\n", - " 2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 +\n", - " 2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 +\n", - " 2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 +\n", - " 2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 +\n", - "2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 +\n", - " 2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 +\n", - " 2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 +\n", - " 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 +\n", - " 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 +\n", - " 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 +\n", - " 2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +\n", - " 2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +\n", - " 1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +\n", - " 1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 +\n", - " 1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 +\n", - " 1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 +\n", - " 1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 +\n", - " 1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 +\n", - " 1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 +\n", - " 1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 +\n", - " 1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 +\n", - "1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 +\n", - " 1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 +\n", - " 1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 +\n", - " 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 +\n", - " 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 +\n", - " 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 +\n", - " 1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +\n", - " 1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +\n", - " 0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +\n", - " 0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 +\n", - " 0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 +\n", - " 0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 +\n", - " 0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 +\n", - " 0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 +\n", - " 0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 +\n", - " 0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 +\n", - " 0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 +\n", - "0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 +\n", - " 0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 +\n", - " 0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 +\n", - " True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 +\n", - " True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 +\n", - " 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 +\n", - " 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 +\n", - " 0 [pop 0] . i 0 + 1 + 2 + 3 + 4 +\n", - " 0 . pop 0 0 + 1 + 2 + 3 + 4 +\n", - " . 0 0 + 1 + 2 + 3 + 4 +\n", - " 0 . 0 + 1 + 2 + 3 + 4 +\n", - " 0 0 . + 1 + 2 + 3 + 4 +\n", - " 0 . 1 + 2 + 3 + 4 +\n", - " 0 1 . + 2 + 3 + 4 +\n", - " 1 . 2 + 3 + 4 +\n", - " 1 2 . + 3 + 4 +\n", - " 3 . 3 + 4 +\n", - " 3 3 . + 4 +\n", - " 6 . 4 +\n", - " 6 4 . +\n", - " 10 . \n" - ] - } - ], - "source": [ - "V('5 [0 <=] 0 [1 - dup] [+] hylomorphism')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Anamorphism\n", - "An anamorphism can be defined as a hylomorphism that uses `[]` for `c` and\n", - "`swons` for `F`.\n", - "\n", - " [P] [G] anamorphism == [P] [] [G] [swons] hylomorphism == A\n", - "\n", - "This allows us to define an anamorphism combinator in terms of\n", - "the hylomorphism combinator.\n", - "\n", - " [] swap [swons] hylomorphism == anamorphism\n", - "\n", - "Partial evaluation gives us a \"pre-cooked\" form.\n", - "\n", - " [P] [G] . anamorphism\n", - " [P] [G] . [] swap [swons] hylomorphism\n", - " [P] [G] [] . swap [swons] hylomorphism\n", - " [P] [] [G] . [swons] hylomorphism\n", - " [P] [] [G] [swons] . hylomorphism\n", - " [P] [] [G] [swons] . [unit [pop] swoncat] dipd [dip] swoncat genrec\n", - " [P] [] [G] [swons] [unit [pop] swoncat] . dipd [dip] swoncat genrec\n", - " [P] [] . unit [pop] swoncat [G] [swons] [dip] swoncat genrec\n", - " [P] [[]] [pop] . swoncat [G] [swons] [dip] swoncat genrec\n", - " [P] [pop []] [G] [swons] [dip] . swoncat genrec\n", - "\n", - " [P] [pop []] [G] [dip swons] genrec\n", - "\n", - "(We could also have just substituted for `c` and `F` in the definition of `H`.)\n", - "\n", - " H == [P] [pop c ] [G] [dip F ] genrec\n", - " A == [P] [pop []] [G] [dip swons] genrec\n", - "\n", - "The partial evaluation is overkill in this case but it serves as a\n", - "reminder that this sort of program specialization can, in many cases, be\n", - "carried out automatically.)\n", - "\n", - "Untangle `[G]` from `[pop []]` using `swap`.\n", - "\n", - " [P] [G] [pop []] swap [dip swons] genrec\n", - "\n", - "All of the arguments to `anamorphism` are to the left, so we have a definition for it.\n", - "\n", - " anamorphism == [pop []] swap [dip swons] genrec\n", - "\n", - "An example of an anamorphism is the range function.\n", - "\n", - " range == [0 <=] [1 - dup] anamorphism\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Catamorphism\n", - "A catamorphism can be defined as a hylomorphism that uses `[uncons swap]` for `[G]`\n", - "and `[[] =]` for the predicate `[P]`.\n", - "\n", - " c [F] catamorphism == [[] =] c [uncons swap] [F] hylomorphism == C\n", - "\n", - "This allows us to define a `catamorphism` combinator in terms of\n", - "the `hylomorphism` combinator.\n", - "\n", - " [[] =] roll> [uncons swap] swap hylomorphism == catamorphism\n", - " \n", - "Partial evaluation doesn't help much.\n", - "\n", - " c [F] . catamorphism\n", - " c [F] . [[] =] roll> [uncons swap] swap hylomorphism\n", - " c [F] [[] =] . roll> [uncons swap] swap hylomorphism\n", - " [[] =] c [F] [uncons swap] . swap hylomorphism\n", - " [[] =] c [uncons swap] [F] . hylomorphism\n", - " [[] =] c [uncons swap] [F] [unit [pop] swoncat] . dipd [dip] swoncat genrec\n", - " [[] =] c . unit [pop] swoncat [uncons swap] [F] [dip] swoncat genrec\n", - " [[] =] [c] [pop] . swoncat [uncons swap] [F] [dip] swoncat genrec\n", - " [[] =] [pop c] [uncons swap] [F] [dip] . swoncat genrec\n", - " [[] =] [pop c] [uncons swap] [dip F] genrec\n", - "\n", - "Because the arguments to catamorphism have to be prepared (unlike the arguments\n", - "to anamorphism, which only need to be rearranged slightly) there isn't much point\n", - "to \"pre-cooking\" the definition.\n", - "\n", - " catamorphism == [[] =] roll> [uncons swap] swap hylomorphism\n", - "\n", - "An example of a catamorphism is the sum function.\n", - "\n", - " sum == 0 [+] catamorphism" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### \"Fusion Law\" for catas (UNFINISHED!!!)\n", - "\n", - "I'm not sure exactly how to translate the \"Fusion Law\" for catamorphisms into Joy.\n", - "\n", - "I know that a `map` composed with a cata can be expressed as a new cata:\n", - "\n", - " [F] map b [B] cata == b [F B] cata\n", - "\n", - "But this isn't the one described in \"Bananas...\". That's more like:\n", - "\n", - "A cata composed with some function can be expressed as some other cata:\n", - "\n", - " b [B] catamorphism F == c [C] catamorphism\n", - "\n", - "Given:\n", - "\n", - " b F == c\n", - "\n", - " ...\n", - "\n", - " B F == [F] dip C\n", - "\n", - " ...\n", - "\n", - " b[B]cata F == c[C]cata\n", - "\n", - " F(B(head, tail)) == C(head, F(tail))\n", - "\n", - " 1 [2 3] B F 1 [2 3] F C\n", - "\n", - "\n", - " b F == c\n", - " B F == F C\n", - "\n", - " b [B] catamorphism F == c [C] catamorphism\n", - " b [B] catamorphism F == b F [C] catamorphism\n", - "\n", - " ...\n", - "\n", - "Or maybe,\n", - "\n", - " [F] map b [B] cata == c [C] cata ???\n", - "\n", - " [F] map b [B] cata == b [F B] cata I think this is generally true, unless F consumes stack items\n", - " instead of just transforming TOS. Of course, there's always [F] unary.\n", - " b [F] unary [[F] unary B] cata\n", - "\n", - " [10 *] map 0 swap [+] step == 0 swap [10 * +] step\n", - "\n", - "\n", - "For example:\n", - "\n", - " F == 10 *\n", - " b == 0\n", - " B == +\n", - " c == 0\n", - " C == F +\n", - " \n", - " b F == c\n", - " 0 10 * == 0\n", - "\n", - " B F == [F] dip C\n", - " + 10 * == [10 *] dip F +\n", - " + 10 * == [10 *] dip 10 * +\n", - "\n", - " n m + 10 * == 10(n+m)\n", - "\n", - " n m [10 *] dip 10 * +\n", - " n 10 * m 10 * +\n", - " 10n m 10 * +\n", - " 10n 10m +\n", - " 10n+10m\n", - "\n", - " 10n+10m = 10(n+m)\n", - "\n", - "Ergo:\n", - "\n", - " 0 [+] catamorphism 10 * == 0 [10 * +] catamorphism" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## The `step` combinator will usually be better to use than `catamorphism`.\n", - "\n", - " sum == 0 swap [+] step\n", - " sum == 0 [+] catamorphism" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# anamorphism catamorphism == hylomorphism\n", - "Here is (part of) the payoff.\n", - "\n", - "An anamorphism followed by (composed with) a\n", - "catamorphism is a hylomorphism, with the advantage that the hylomorphism \n", - "does not create the intermediate list structure. The values are stored in\n", - "either the call stack, for those implementations that use one, or in the pending\n", - "expression (\"continuation\") for the Joypy interpreter. They still have to \n", - "be somewhere, converting from an anamorphism and catamorphism to a hylomorphism\n", - "just prevents using additional storage and doing additional processing.\n", - "\n", - " range == [0 <=] [1 - dup] anamorphism\n", - " sum == 0 [+] catamorphism\n", - "\n", - " range sum == [0 <=] [1 - dup] anamorphism 0 [+] catamorphism\n", - " == [0 <=] 0 [1 - dup] [+] hylomorphism\n", - "\n", - "We can let the `hylomorphism` combinator build `range_sum` for us or just\n", - "substitute ourselves.\n", - "\n", - " H == [P] [pop c] [G] [dip F] genrec\n", - " range_sum == [0 <=] [pop 0] [1 - dup] [dip +] genrec\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "defs = '''\n", - "anamorphism == [pop []] swap [dip swons] genrec\n", - "hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec\n", - "catamorphism == [[] =] roll> [uncons swap] swap hylomorphism\n", - "range == [0 <=] [1 - dup] anamorphism\n", - "sum == 0 [+] catamorphism\n", - "range_sum == [0 <=] 0 [1 - dup] [+] hylomorphism\n", - "'''\n", - "\n", - "DefinitionWrapper.add_definitions(defs, D)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 8 7 6 5 4 3 2 1 0]\n" - ] - } - ], - "source": [ - "J('10 range')" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "45\n" - ] - } - ], - "source": [ - "J('[9 8 7 6 5 4 3 2 1 0] sum')" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 10 range sum\n", - " 10 . range sum\n", - " 10 . [0 <=] [1 - dup] anamorphism sum\n", - " 10 [0 <=] . [1 - dup] anamorphism sum\n", - " 10 [0 <=] [1 - dup] . anamorphism sum\n", - " 10 [0 <=] [1 - dup] . [pop []] swap [dip swons] genrec sum\n", - " 10 [0 <=] [1 - dup] [pop []] . swap [dip swons] genrec sum\n", - " 10 [0 <=] [pop []] [1 - dup] . [dip swons] genrec sum\n", - " 10 [0 <=] [pop []] [1 - dup] [dip swons] . genrec sum\n", - " 10 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte sum\n", - " 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [10] [0 <=] . infra first choice i sum\n", - " 10 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum\n", - " 10 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] . swaack first choice i sum\n", - " 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i sum\n", - " 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i sum\n", - " 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i sum\n", - " 10 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum\n", - " 10 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum\n", - " 9 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum\n", - " 9 9 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum\n", - " 9 9 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons sum\n", - " 9 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 9 swons sum\n", - " 9 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 9 swons sum\n", - " 9 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 9 swons sum\n", - " 9 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 9 swons sum\n", - " 9 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 9 swons sum\n", - " 9 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 9 swons sum\n", - " 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [9] [0 <=] . infra first choice i 9 swons sum\n", - " 9 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum\n", - " 9 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] . swaack first choice i 9 swons sum\n", - " 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 9 swons sum\n", - " 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 9 swons sum\n", - " 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 9 swons sum\n", - " 9 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum\n", - " 9 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum\n", - " 8 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum\n", - " 8 8 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum\n", - " 8 8 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 9 swons sum\n", - " 8 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum\n", - " 8 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum\n", - " 8 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 8 swons 9 swons sum\n", - " 8 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 8 swons 9 swons sum\n", - " 8 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 8 swons 9 swons sum\n", - " 8 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 8 swons 9 swons sum\n", - " 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [8] [0 <=] . infra first choice i 8 swons 9 swons sum\n", - " 8 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum\n", - " 8 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] . swaack first choice i 8 swons 9 swons sum\n", - " 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 8 swons 9 swons sum\n", - " 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 8 swons 9 swons sum\n", - " 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 8 swons 9 swons sum\n", - " 8 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum\n", - " 8 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum\n", - " 7 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum\n", - " 7 7 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum\n", - " 7 7 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 8 swons 9 swons sum\n", - " 7 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum\n", - " 7 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum\n", - " 7 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum\n", - " 7 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 7 swons 8 swons 9 swons sum\n", - " 7 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 7 swons 8 swons 9 swons sum\n", - " 7 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 7 swons 8 swons 9 swons sum\n", - " 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [7] [0 <=] . infra first choice i 7 swons 8 swons 9 swons sum\n", - " 7 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum\n", - " 7 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] . swaack first choice i 7 swons 8 swons 9 swons sum\n", - " 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 7 swons 8 swons 9 swons sum\n", - " 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 7 swons 8 swons 9 swons sum\n", - " 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 7 swons 8 swons 9 swons sum\n", - " 7 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum\n", - " 7 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum\n", - " 6 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum\n", - " 6 6 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum\n", - " 6 6 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 7 swons 8 swons 9 swons sum\n", - " 6 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [6] [0 <=] . infra first choice i 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] . swaack first choice i 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 6 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 5 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 5 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [5] [0 <=] . infra first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] . swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 4 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 4 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [4] [0 <=] . infra first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] . swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 3 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 3 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [3] [0 <=] . infra first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] . swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 2 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 2 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [2] [0 <=] . infra first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 1 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 1 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [1] [0 <=] . infra first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 0 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 0 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [0] [0 <=] . infra first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " True . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " True [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] . swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] True . choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [pop []] . i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 . pop [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " . [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [] . 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [] 0 . swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [] 0 . swap cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 0 [] . cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [0] . 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [0] 1 . swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [0] 1 . swap cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 1 [0] . cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [1 0] . 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [1 0] 2 . swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [1 0] 2 . swap cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 2 [1 0] . cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [2 1 0] . 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [2 1 0] 3 . swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [2 1 0] 3 . swap cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 3 [2 1 0] . cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [3 2 1 0] . 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [3 2 1 0] 4 . swons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [3 2 1 0] 4 . swap cons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " 4 [3 2 1 0] . cons 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [4 3 2 1 0] . 5 swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [4 3 2 1 0] 5 . swons 6 swons 7 swons 8 swons 9 swons sum\n", - " [4 3 2 1 0] 5 . swap cons 6 swons 7 swons 8 swons 9 swons sum\n", - " 5 [4 3 2 1 0] . cons 6 swons 7 swons 8 swons 9 swons sum\n", - " [5 4 3 2 1 0] . 6 swons 7 swons 8 swons 9 swons sum\n", - " [5 4 3 2 1 0] 6 . swons 7 swons 8 swons 9 swons sum\n", - " [5 4 3 2 1 0] 6 . swap cons 7 swons 8 swons 9 swons sum\n", - " 6 [5 4 3 2 1 0] . cons 7 swons 8 swons 9 swons sum\n", - " [6 5 4 3 2 1 0] . 7 swons 8 swons 9 swons sum\n", - " [6 5 4 3 2 1 0] 7 . swons 8 swons 9 swons sum\n", - " [6 5 4 3 2 1 0] 7 . swap cons 8 swons 9 swons sum\n", - " 7 [6 5 4 3 2 1 0] . cons 8 swons 9 swons sum\n", - " [7 6 5 4 3 2 1 0] . 8 swons 9 swons sum\n", - " [7 6 5 4 3 2 1 0] 8 . swons 9 swons sum\n", - " [7 6 5 4 3 2 1 0] 8 . swap cons 9 swons sum\n", - " 8 [7 6 5 4 3 2 1 0] . cons 9 swons sum\n", - " [8 7 6 5 4 3 2 1 0] . 9 swons sum\n", - " [8 7 6 5 4 3 2 1 0] 9 . swons sum\n", - " [8 7 6 5 4 3 2 1 0] 9 . swap cons sum\n", - " 9 [8 7 6 5 4 3 2 1 0] . cons sum\n", - " [9 8 7 6 5 4 3 2 1 0] . sum\n", - " [9 8 7 6 5 4 3 2 1 0] . 0 [+] catamorphism\n", - " [9 8 7 6 5 4 3 2 1 0] 0 . [+] catamorphism\n", - " [9 8 7 6 5 4 3 2 1 0] 0 [+] . catamorphism\n", - " [9 8 7 6 5 4 3 2 1 0] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism\n", - " [9 8 7 6 5 4 3 2 1 0] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] . [uncons swap] swap hylomorphism\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] [uncons swap] . swap hylomorphism\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . hylomorphism\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec\n", - " [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte\n", - "[9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[9 8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i\n", - " [9 8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i\n", - " [9 8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] . swaack first choice i\n", - " [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i\n", - " [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i\n", - " [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i\n", - " [9 8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +\n", - " 9 [8 7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +\n", - " [8 7 6 5 4 3 2 1 0] 9 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +\n", - " [8 7 6 5 4 3 2 1 0] 9 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip +\n", - " [8 7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 9 +\n", - " [8 7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 9 +\n", - " [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 9 +\n", - " [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 9 +\n", - " [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 9 +\n", - " [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 9 +\n", - " [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 9 +\n", - " [8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 +\n", - " [8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] . swaack first choice i 9 +\n", - " [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 +\n", - " [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 9 +\n", - " [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 9 +\n", - " [8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 +\n", - " 8 [7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 +\n", - " [7 6 5 4 3 2 1 0] 8 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 +\n", - " [7 6 5 4 3 2 1 0] 8 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 9 +\n", - " [7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] . swaack first choice i 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 8 + 9 +\n", - " [7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 +\n", - " 7 [6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 +\n", - " [6 5 4 3 2 1 0] 7 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 +\n", - " [6 5 4 3 2 1 0] 7 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 8 + 9 +\n", - " [6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[6 5 4 3 2 1 0]] [[] =] . infra first choice i 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] . swaack first choice i 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 7 + 8 + 9 +\n", - " [6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 +\n", - " 6 [5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] 6 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] 6 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[5 4 3 2 1 0]] [[] =] . infra first choice i 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] . swaack first choice i 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 +\n", - " [5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 +\n", - " 5 [4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] 5 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] 5 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[4 3 2 1 0]] [[] =] . infra first choice i 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] . swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 +\n", - " [4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] 4 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] 4 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3 2 1 0]] [[] =] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 1 0]] [[] =] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[1 0]] [[] =] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] 1 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] 1 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[0]] [[] =] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] 0 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] 0 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[]] [[] =] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " [] . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 3 . + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 6 . 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 6 4 . + 5 + 6 + 7 + 8 + 9 +\n", - " 10 . 5 + 6 + 7 + 8 + 9 +\n", - " 10 5 . + 6 + 7 + 8 + 9 +\n", - " 15 . 6 + 7 + 8 + 9 +\n", - " 15 6 . + 7 + 8 + 9 +\n", - " 21 . 7 + 8 + 9 +\n", - " 21 7 . + 8 + 9 +\n", - " 28 . 8 + 9 +\n", - " 28 8 . + 9 +\n", - " 36 . 9 +\n", - " 36 9 . +\n", - " 45 . \n" - ] - } - ], - "source": [ - "V('10 range sum')" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 10 range_sum\n", - " 10 . range_sum\n", - " 10 . [0 <=] 0 [1 - dup] [+] hylomorphism\n", - " 10 [0 <=] . 0 [1 - dup] [+] hylomorphism\n", - " 10 [0 <=] 0 . [1 - dup] [+] hylomorphism\n", - " 10 [0 <=] 0 [1 - dup] . [+] hylomorphism\n", - " 10 [0 <=] 0 [1 - dup] [+] . hylomorphism\n", - " 10 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec\n", - " 10 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec\n", - " 10 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec\n", - " 10 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec\n", - " 10 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec\n", - " 10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec\n", - " 10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec\n", - " 10 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec\n", - " 10 [0 <=] [pop 0] [1 - dup] [dip +] . genrec\n", - " 10 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte\n", - "10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [10] [0 <=] . infra first choice i\n", - " 10 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i\n", - " 10 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] . swaack first choice i\n", - " 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i\n", - " 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i\n", - " 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i\n", - " 10 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 10 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 9 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 9 9 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +\n", - " 9 9 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip +\n", - " 9 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 9 +\n", - " 9 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 9 +\n", - " 9 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 9 +\n", - " 9 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 9 +\n", - " 9 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 9 +\n", - " 9 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 9 +\n", - " 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [9] [0 <=] . infra first choice i 9 +\n", - " 9 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 +\n", - " 9 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] . swaack first choice i 9 +\n", - " 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 +\n", - " 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 9 +\n", - " 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 9 +\n", - " 9 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +\n", - " 9 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +\n", - " 8 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +\n", - " 8 8 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 +\n", - " 8 8 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 9 +\n", - " 8 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 8 + 9 +\n", - " 8 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 8 + 9 +\n", - " 8 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 8 + 9 +\n", - " 8 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 8 + 9 +\n", - " 8 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 8 + 9 +\n", - " 8 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 8 + 9 +\n", - " 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [8] [0 <=] . infra first choice i 8 + 9 +\n", - " 8 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 +\n", - " 8 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] . swaack first choice i 8 + 9 +\n", - " 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 +\n", - " 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 +\n", - " 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 8 + 9 +\n", - " 8 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +\n", - " 8 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +\n", - " 7 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +\n", - " 7 7 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 +\n", - " 7 7 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 8 + 9 +\n", - " 7 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 +\n", - " 7 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 +\n", - " 7 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 7 + 8 + 9 +\n", - " 7 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 7 + 8 + 9 +\n", - " 7 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 7 + 8 + 9 +\n", - " 7 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 7 + 8 + 9 +\n", - " 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [7] [0 <=] . infra first choice i 7 + 8 + 9 +\n", - " 7 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 +\n", - " 7 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] . swaack first choice i 7 + 8 + 9 +\n", - " 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 +\n", - " 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 +\n", - " 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 7 + 8 + 9 +\n", - " 7 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +\n", - " 7 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +\n", - " 6 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +\n", - " 6 6 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 +\n", - " 6 6 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 7 + 8 + 9 +\n", - " 6 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 +\n", - " 6 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 +\n", - " 6 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 +\n", - " 6 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 6 + 7 + 8 + 9 +\n", - " 6 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 6 + 7 + 8 + 9 +\n", - " 6 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 +\n", - " 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [6] [0 <=] . infra first choice i 6 + 7 + 8 + 9 +\n", - " 6 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 +\n", - " 6 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] . swaack first choice i 6 + 7 + 8 + 9 +\n", - " 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 +\n", - " 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 +\n", - " 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 +\n", - " 6 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +\n", - " 6 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +\n", - " 5 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +\n", - " 5 5 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 +\n", - " 5 5 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 6 + 7 + 8 + 9 +\n", - " 5 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " 5 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " 5 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " 5 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 5 + 6 + 7 + 8 + 9 +\n", - " 5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 5 + 6 + 7 + 8 + 9 +\n", - " 5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 +\n", - " 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i 5 + 6 + 7 + 8 + 9 +\n", - " 5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " 5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i 5 + 6 + 7 + 8 + 9 +\n", - " 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 +\n", - " 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 +\n", - " 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 +\n", - " 5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +\n", - " 5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +\n", - " 4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +\n", - " 4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 +\n", - " 4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 +\n", - " 4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 3 3 . + 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 6 . 4 + 5 + 6 + 7 + 8 + 9 +\n", - " 6 4 . + 5 + 6 + 7 + 8 + 9 +\n", - " 10 . 5 + 6 + 7 + 8 + 9 +\n", - " 10 5 . + 6 + 7 + 8 + 9 +\n", - " 15 . 6 + 7 + 8 + 9 +\n", - " 15 6 . + 7 + 8 + 9 +\n", - " 21 . 7 + 8 + 9 +\n", - " 21 7 . + 8 + 9 +\n", - " 28 . 8 + 9 +\n", - " 28 8 . + 9 +\n", - " 36 . 9 +\n", - " 36 9 . +\n", - " 45 . \n" - ] - } - ], - "source": [ - "V('10 range_sum')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Factorial Function and Paramorphisms\n", - "A paramorphism `P :: B -> A` is a recursion combinator that uses `dup` on intermediate values.\n", - "\n", - " n swap [P] [pop] [[F] dupdip G] primrec\n", - "\n", - "With\n", - "- `n :: A` is the \"identity\" for `F` (like 1 for multiplication, 0 for addition)\n", - "- `F :: (A, B) -> A`\n", - "- `G :: B -> B` generates the next `B` value.\n", - "- and lastly `P :: B -> Bool` detects the end of the series." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For Factorial function (types `A` and `B` are both integer):\n", - "\n", - " n == 1\n", - " F == *\n", - " G == --\n", - " P == 1 <=" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "define('factorial == 1 swap [1 <=] [pop] [[*] dupdip --] primrec')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Try it with input 3 (omitting evaluation of predicate):\n", - "\n", - " 3 1 swap [1 <=] [pop] [[*] dupdip --] primrec\n", - " 1 3 [1 <=] [pop] [[*] dupdip --] primrec\n", - "\n", - " 1 3 [*] dupdip --\n", - " 1 3 * 3 --\n", - " 3 3 --\n", - " 3 2\n", - "\n", - " 3 2 [*] dupdip --\n", - " 3 2 * 2 --\n", - " 6 2 --\n", - " 6 1\n", - "\n", - " 6 1 [1 <=] [pop] [[*] dupdip --] primrec\n", - "\n", - " 6 1 pop\n", - " 6" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6\n" - ] - } - ], - "source": [ - "J('3 factorial')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Derive `paramorphism` from the form above.\n", - "\n", - " n swap [P] [pop] [[F] dupdip G] primrec\n", - "\n", - " n swap [P] [pop] [[F] dupdip G] primrec\n", - " n [P] [swap] dip [pop] [[F] dupdip G] primrec\n", - " n [P] [[F] dupdip G] [[swap] dip [pop]] dip primrec\n", - " n [P] [F] [dupdip G] cons [[swap] dip [pop]] dip primrec\n", - " n [P] [F] [G] [dupdip] swoncat cons [[swap] dip [pop]] dip primrec\n", - "\n", - " paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "define('paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec')\n", - "define('factorial == 1 [1 <=] [*] [--] paramorphism')" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6\n" - ] - } - ], - "source": [ - "J('3 factorial')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# `tails`\n", - "An example of a paramorphism for lists given in the [\"Bananas...\" paper](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125) is `tails` which returns the list of \"tails\" of a list.\n", - "\n", - " [1 2 3] tails == [[] [3] [2 3]]\n", - " \n", - "Using `paramorphism` we would write:\n", - "\n", - " n == []\n", - " F == rest swons\n", - " G == rest\n", - " P == not\n", - "\n", - " tails == [] [not] [rest swons] [rest] paramorphism" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "define('tails == [] [not] [rest swons] [rest] paramorphism')" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[] [3] [2 3]]\n" - ] - } - ], - "source": [ - "J('[1 2 3] tails')" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276]\n" - ] - } - ], - "source": [ - "J('25 range tails [popop] infra [sum] map')" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[276 253 231 210 190 171 153 136 120 105 91 78 66 55 45 36 28 21 15 10 6 3 1 0 0]\n" - ] - } - ], - "source": [ - "J('25 range [range_sum] map')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Factoring `rest`\n", - "Right before the recursion begins we have:\n", - " \n", - " [] [1 2 3] [not] [pop] [[rest swons] dupdip rest] primrec\n", - " \n", - "But we might prefer to factor `rest` in the quote:\n", - "\n", - " [] [1 2 3] [not] [pop] [rest [swons] dupdip] primrec\n", - "\n", - "There's no way to do that with the `paramorphism` combinator as defined. We would have to write and use a slightly different recursion combinator that accepted an additional \"preprocessor\" function `[H]` and built:\n", - "\n", - " n swap [P] [pop] [H [F] dupdip G] primrec\n", - "\n", - "Or just write it out manually. This is yet another place where the *sufficiently smart compiler* will one day automatically refactor the code. We could write a `paramorphism` combinator that checked `[F]` and `[G]` for common prefix and extracted it." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Patterns of Recursion\n", - "Our story so far...\n", - "\n", - "- A combiner `F :: (B, B) -> B`\n", - "- A predicate `P :: A -> Bool` to detect the base case\n", - "- A base case value `c :: B`\n", - "\n", - "\n", - "### Hylo-, Ana-, Cata-\n", - "\n", - " w/ G :: A -> (A, B)\n", - "\n", - " H == [P ] [pop c ] [G ] [dip F ] genrec\n", - " A == [P ] [pop []] [G ] [dip swons] genrec\n", - " C == [[] =] [pop c ] [uncons swap] [dip F ] genrec\n", - "\n", - "### Para-, ?-, ?-\n", - "\n", - " w/ G :: B -> B\n", - "\n", - " P == c swap [P ] [pop] [[F ] dupdip G ] primrec\n", - " ? == [] swap [P ] [pop] [[swons] dupdip G ] primrec\n", - " ? == c swap [[] =] [pop] [[F ] dupdip uncons swap] primrec\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Four Generalizations\n", - "There are at least four kinds of recursive combinator, depending on two choices. The first choice is whether the combiner function should be evaluated during the recursion or pushed into the pending expression to be \"collapsed\" at the end. The second choice is whether the combiner needs to operate on the current value of the datastructure or the generator's output.\n", - "\n", - " H == [P] [pop c] [G ] [dip F] genrec\n", - " H == c swap [P] [pop] [G [F] dip ] [i] genrec\n", - " H == [P] [pop c] [ [G] dupdip ] [dip F] genrec\n", - " H == c swap [P] [pop] [ [F] dupdip G] [i] genrec\n", - "\n", - "Consider:\n", - "\n", - " ... a G [H] dip F w/ a G == a' b\n", - " ... c a G [F] dip H a G == b a'\n", - " ... a [G] dupdip [H] dip F a G == a'\n", - " ... c a [F] dupdip G H a G == a'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 1\n", - "\n", - " H == [P] [pop c] [G] [dip F] genrec\n", - "\n", - "Iterate n times.\n", - "\n", - " ... a [P] [pop c] [G] [dip F] genrec\n", - " ... a G [H] dip F\n", - " ... a' b [H] dip F\n", - " ... a' H b F\n", - " ... a' G [H] dip F b F\n", - " ... a'' b [H] dip F b F\n", - " ... a'' H b F b F\n", - " ... a'' G [H] dip F b F b F\n", - " ... a''' b [H] dip F b F b F\n", - " ... a''' H b F b F b F\n", - " ... a''' pop c b F b F b F\n", - " ... c b F b F b F\n", - "\n", - "This form builds up a continuation that contains the intermediate results along with the pending combiner functions. When the base case is reached the last term is replaced by the identity value c and the continuation \"collapses\" into the final result." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 2\n", - "When you can start with the identity value c on the stack and the combiner can operate as you go, using the intermediate results immediately rather than queuing them up, use this form. An important difference is that the generator function must return its results in the reverse order.\n", - "\n", - " H == c swap [P] [pop] [G [F] dip] primrec\n", - "\n", - " ... c a G [F] dip H\n", - " ... c b a' [F] dip H\n", - " ... c b F a' H\n", - " ... c b F a' G [F] dip H\n", - " ... c b F b a'' [F] dip H\n", - " ... c b F b F a'' H\n", - " ... c b F b F a'' G [F] dip H\n", - " ... c b F b F b a''' [F] dip H\n", - " ... c b F b F b F a''' H\n", - " ... c b F b F b F a''' pop\n", - " ... c b F b F b F\n", - "\n", - "The end line here is the same as for above, but only because we didn't evaluate `F` when it normally would have been." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 3\n", - "If the combiner and the generator both need to work on the current value then `dup` must be used at some point, and the generator must produce one item instead of two (the b is instead the duplicate of a.)\n", - "\n", - "\n", - " H == [P] [pop c] [[G] dupdip] [dip F] genrec\n", - "\n", - " ... a [G] dupdip [H] dip F\n", - " ... a G a [H] dip F\n", - " ... a' a [H] dip F\n", - " ... a' H a F\n", - " ... a' [G] dupdip [H] dip F a F\n", - " ... a' G a' [H] dip F a F\n", - " ... a'' a' [H] dip F a F\n", - " ... a'' H a' F a F\n", - " ... a'' [G] dupdip [H] dip F a' F a F\n", - " ... a'' G a'' [H] dip F a' F a F\n", - " ... a''' a'' [H] dip F a' F a F\n", - " ... a''' H a'' F a' F a F\n", - " ... a''' pop c a'' F a' F a F\n", - " ... c a'' F a' F a F" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 4\n", - "And, last but not least, if you can combine as you go, starting with c, and the combiner needs to work on the current item, this is the form:\n", - "\n", - " W == c swap [P] [pop] [[F] dupdip G] primrec\n", - "\n", - " ... a c swap [P] [pop] [[F] dupdip G] primrec\n", - " ... c a [P] [pop] [[F] dupdip G] primrec\n", - " ... c a [F] dupdip G W\n", - " ... c a F a G W\n", - " ... c a F a' W\n", - " ... c a F a' [F] dupdip G W\n", - " ... c a F a' F a' G W\n", - " ... c a F a' F a'' W\n", - " ... c a F a' F a'' [F] dupdip G W\n", - " ... c a F a' F a'' F a'' G W\n", - " ... c a F a' F a'' F a''' W\n", - " ... c a F a' F a'' F a''' pop\n", - " ... c a F a' F a'' F" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Each of the four variations above can be specialized to ana- and catamorphic forms." - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "def WTFmorphism(c, F, P, G):\n", - " '''Return a hylomorphism function H.'''\n", - "\n", - " def H(a, d=c):\n", - " if P(a):\n", - " result = d\n", - " else:\n", - " a, b = G(a)\n", - " result = H(a, F(d, b))\n", - " return result\n", - "\n", - " return H" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10\n" - ] - } - ], - "source": [ - "F = lambda a, b: a + b\n", - "P = lambda n: n <= 1\n", - "G = lambda n: (n - 1, n - 1)\n", - "\n", - "wtf = WTFmorphism(0, F, P, G)\n", - "\n", - "print wtf(5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " H == [P ] [pop c ] [G ] [dip F ] genrec" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [], - "source": [ - "DefinitionWrapper.add_definitions('''\n", - "P == 1 <=\n", - "Ga == -- dup\n", - "Gb == --\n", - "c == 0\n", - "F == +\n", - "''', D)" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec\n", - " [1 2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec\n", - " [1 2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec\n", - " [1 2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec\n", - " [1 2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec\n", - " [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec\n", - " [1 2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte\n", - "[1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[1 2 3]] [[] =] . infra first choice i\n", - " [1 2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i\n", - " [1 2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i\n", - " False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i\n", - " False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] . swaack first choice i\n", - " [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i\n", - " [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i\n", - " [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i\n", - " [1 2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons\n", - " 1 [2 3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons\n", - " [2 3] 1 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons\n", - " [2 3] 1 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons\n", - " [2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 1 swons\n", - " [2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 1 swons\n", - " [2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 1 swons\n", - " [2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 1 swons\n", - " [2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 1 swons\n", - " [2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 1 swons\n", - " [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[2 3]] [[] =] . infra first choice i 1 swons\n", - " [2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons\n", - " [2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons\n", - " False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons\n", - " False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] . swaack first choice i 1 swons\n", - " [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons\n", - " [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons\n", - " [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 1 swons\n", - " [2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons\n", - " 2 [3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons\n", - " [3] 2 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons\n", - " [3] 2 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 1 swons\n", - " [3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons\n", - " [3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons\n", - " [3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 2 swons 1 swons\n", - " [3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 2 swons 1 swons\n", - " [3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 2 swons 1 swons\n", - " [3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 2 swons 1 swons\n", - " [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[3]] [[] =] . infra first choice i 2 swons 1 swons\n", - " [3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons\n", - " [3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons\n", - " False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons\n", - " False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] . swaack first choice i 2 swons 1 swons\n", - " [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 1 swons\n", - " [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 1 swons\n", - " [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 2 swons 1 swons\n", - " [3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons\n", - " 3 [] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons\n", - " [] 3 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons\n", - " [] 3 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 2 swons 1 swons\n", - " [] . [[] =] [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons\n", - " [] [[] =] . [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons\n", - " [] [[] =] [pop []] . [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons\n", - " [] [[] =] [pop []] [uncons swap] . [dip swons] genrec 3 swons 2 swons 1 swons\n", - " [] [[] =] [pop []] [uncons swap] [dip swons] . genrec 3 swons 2 swons 1 swons\n", - " [] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 3 swons 2 swons 1 swons\n", - " [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[]] [[] =] . infra first choice i 3 swons 2 swons 1 swons\n", - " [] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons\n", - " [] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons\n", - " True . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons\n", - " True [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] . swaack first choice i 3 swons 2 swons 1 swons\n", - " [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 3 swons 2 swons 1 swons\n", - " [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] True . choice i 3 swons 2 swons 1 swons\n", - " [] [pop []] . i 3 swons 2 swons 1 swons\n", - " [] . pop [] 3 swons 2 swons 1 swons\n", - " . [] 3 swons 2 swons 1 swons\n", - " [] . 3 swons 2 swons 1 swons\n", - " [] 3 . swons 2 swons 1 swons\n", - " [] 3 . swap cons 2 swons 1 swons\n", - " 3 [] . cons 2 swons 1 swons\n", - " [3] . 2 swons 1 swons\n", - " [3] 2 . swons 1 swons\n", - " [3] 2 . swap cons 1 swons\n", - " 2 [3] . cons 1 swons\n", - " [2 3] . 1 swons\n", - " [2 3] 1 . swons\n", - " [2 3] 1 . swap cons\n", - " 1 [2 3] . cons\n", - " [1 2 3] . \n" - ] - } - ], - "source": [ - "V('[1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec')" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 3 [P] [pop c] [Ga] [dip F] genrec\n", - " 3 . [P] [pop c] [Ga] [dip F] genrec\n", - " 3 [P] . [pop c] [Ga] [dip F] genrec\n", - " 3 [P] [pop c] . [Ga] [dip F] genrec\n", - " 3 [P] [pop c] [Ga] . [dip F] genrec\n", - " 3 [P] [pop c] [Ga] [dip F] . genrec\n", - " 3 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte\n", - "3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [3] [P] . infra first choice i\n", - " 3 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i\n", - " 3 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i\n", - " 3 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i\n", - " False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i\n", - "False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] . swaack first choice i\n", - "3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i\n", - " 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i\n", - " 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i\n", - " 3 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F\n", - " 3 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F\n", - " 2 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F\n", - " 2 2 . [[P] [pop c] [Ga] [dip F] genrec] dip F\n", - " 2 2 [[P] [pop c] [Ga] [dip F] genrec] . dip F\n", - " 2 . [P] [pop c] [Ga] [dip F] genrec 2 F\n", - " 2 [P] . [pop c] [Ga] [dip F] genrec 2 F\n", - " 2 [P] [pop c] . [Ga] [dip F] genrec 2 F\n", - " 2 [P] [pop c] [Ga] . [dip F] genrec 2 F\n", - " 2 [P] [pop c] [Ga] [dip F] . genrec 2 F\n", - " 2 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 2 F\n", - "2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [2] [P] . infra first choice i 2 F\n", - " 2 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F\n", - " 2 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F\n", - " 2 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F\n", - " False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F\n", - "False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] . swaack first choice i 2 F\n", - "2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F\n", - " 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i 2 F\n", - " 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i 2 F\n", - " 2 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F\n", - " 2 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F\n", - " 1 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F\n", - " 1 1 . [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F\n", - " 1 1 [[P] [pop c] [Ga] [dip F] genrec] . dip F 2 F\n", - " 1 . [P] [pop c] [Ga] [dip F] genrec 1 F 2 F\n", - " 1 [P] . [pop c] [Ga] [dip F] genrec 1 F 2 F\n", - " 1 [P] [pop c] . [Ga] [dip F] genrec 1 F 2 F\n", - " 1 [P] [pop c] [Ga] . [dip F] genrec 1 F 2 F\n", - " 1 [P] [pop c] [Ga] [dip F] . genrec 1 F 2 F\n", - " 1 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 1 F 2 F\n", - "1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [1] [P] . infra first choice i 1 F 2 F\n", - " 1 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F\n", - " 1 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F\n", - " 1 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F\n", - " True . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F\n", - " True [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] . swaack first choice i 1 F 2 F\n", - " 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F\n", - " 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F\n", - " 1 [pop c] . i 1 F 2 F\n", - " 1 . pop c 1 F 2 F\n", - " . c 1 F 2 F\n", - " . 0 1 F 2 F\n", - " 0 . 1 F 2 F\n", - " 0 1 . F 2 F\n", - " 0 1 . + 2 F\n", - " 1 . 2 F\n", - " 1 2 . F\n", - " 1 2 . +\n", - " 3 . \n" - ] - } - ], - "source": [ - "V('3 [P] [pop c] [Ga] [dip F] genrec')" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . 3 [P] [pop []] [Ga] [dip swons] genrec\n", - " 3 . [P] [pop []] [Ga] [dip swons] genrec\n", - " 3 [P] . [pop []] [Ga] [dip swons] genrec\n", - " 3 [P] [pop []] . [Ga] [dip swons] genrec\n", - " 3 [P] [pop []] [Ga] . [dip swons] genrec\n", - " 3 [P] [pop []] [Ga] [dip swons] . genrec\n", - " 3 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte\n", - "3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [3] [P] . infra first choice i\n", - " 3 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i\n", - " 3 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i\n", - " 3 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i\n", - " False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i\n", - "False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] . swaack first choice i\n", - "3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i\n", - " 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i\n", - " 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i\n", - " 3 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons\n", - " 3 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons\n", - " 2 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons\n", - " 2 2 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons\n", - " 2 2 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons\n", - " 2 . [P] [pop []] [Ga] [dip swons] genrec 2 swons\n", - " 2 [P] . [pop []] [Ga] [dip swons] genrec 2 swons\n", - " 2 [P] [pop []] . [Ga] [dip swons] genrec 2 swons\n", - " 2 [P] [pop []] [Ga] . [dip swons] genrec 2 swons\n", - " 2 [P] [pop []] [Ga] [dip swons] . genrec 2 swons\n", - " 2 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 2 swons\n", - "2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [2] [P] . infra first choice i 2 swons\n", - " 2 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons\n", - " 2 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons\n", - " 2 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons\n", - " False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons\n", - "False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons\n", - "2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons\n", - " 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons\n", - " 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i 2 swons\n", - " 2 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons\n", - " 2 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons\n", - " 1 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons\n", - " 1 1 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons\n", - " 1 1 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons 2 swons\n", - " 1 . [P] [pop []] [Ga] [dip swons] genrec 1 swons 2 swons\n", - " 1 [P] . [pop []] [Ga] [dip swons] genrec 1 swons 2 swons\n", - " 1 [P] [pop []] . [Ga] [dip swons] genrec 1 swons 2 swons\n", - " 1 [P] [pop []] [Ga] . [dip swons] genrec 1 swons 2 swons\n", - " 1 [P] [pop []] [Ga] [dip swons] . genrec 1 swons 2 swons\n", - " 1 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons\n", - "1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [1] [P] . infra first choice i 1 swons 2 swons\n", - " 1 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons\n", - " 1 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons\n", - " 1 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons\n", - " True . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons\n", - " True [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons\n", - " 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 1 swons 2 swons\n", - " 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] True . choice i 1 swons 2 swons\n", - " 1 [pop []] . i 1 swons 2 swons\n", - " 1 . pop [] 1 swons 2 swons\n", - " . [] 1 swons 2 swons\n", - " [] . 1 swons 2 swons\n", - " [] 1 . swons 2 swons\n", - " [] 1 . swap cons 2 swons\n", - " 1 [] . cons 2 swons\n", - " [1] . 2 swons\n", - " [1] 2 . swons\n", - " [1] 2 . swap cons\n", - " 2 [1] . cons\n", - " [2 1] . \n" - ] - } - ], - "source": [ - "V('3 [P] [pop []] [Ga] [dip swons] genrec')" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [2 1] [[] =] [pop c] [uncons swap] [dip F] genrec\n", - " [2 1] . [[] =] [pop c] [uncons swap] [dip F] genrec\n", - " [2 1] [[] =] . [pop c] [uncons swap] [dip F] genrec\n", - " [2 1] [[] =] [pop c] . [uncons swap] [dip F] genrec\n", - " [2 1] [[] =] [pop c] [uncons swap] . [dip F] genrec\n", - " [2 1] [[] =] [pop c] [uncons swap] [dip F] . genrec\n", - " [2 1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte\n", - "[2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[2 1]] [[] =] . infra first choice i\n", - " [2 1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i\n", - " [2 1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i\n", - " False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i\n", - " False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] . swaack first choice i\n", - " [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i\n", - " [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i\n", - " [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i\n", - " [2 1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F\n", - " 2 [1] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F\n", - " [1] 2 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F\n", - " [1] 2 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F\n", - " [1] . [[] =] [pop c] [uncons swap] [dip F] genrec 2 F\n", - " [1] [[] =] . [pop c] [uncons swap] [dip F] genrec 2 F\n", - " [1] [[] =] [pop c] . [uncons swap] [dip F] genrec 2 F\n", - " [1] [[] =] [pop c] [uncons swap] . [dip F] genrec 2 F\n", - " [1] [[] =] [pop c] [uncons swap] [dip F] . genrec 2 F\n", - " [1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 2 F\n", - " [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[1]] [[] =] . infra first choice i 2 F\n", - " [1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F\n", - " [1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F\n", - " False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F\n", - " False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] . swaack first choice i 2 F\n", - " [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F\n", - " [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i 2 F\n", - " [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i 2 F\n", - " [1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F\n", - " 1 [] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F\n", - " [] 1 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F\n", - " [] 1 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F 2 F\n", - " [] . [[] =] [pop c] [uncons swap] [dip F] genrec 1 F 2 F\n", - " [] [[] =] . [pop c] [uncons swap] [dip F] genrec 1 F 2 F\n", - " [] [[] =] [pop c] . [uncons swap] [dip F] genrec 1 F 2 F\n", - " [] [[] =] [pop c] [uncons swap] . [dip F] genrec 1 F 2 F\n", - " [] [[] =] [pop c] [uncons swap] [dip F] . genrec 1 F 2 F\n", - " [] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 1 F 2 F\n", - " [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[]] [[] =] . infra first choice i 1 F 2 F\n", - " [] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F\n", - " [] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F\n", - " True . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F\n", - " True [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] . swaack first choice i 1 F 2 F\n", - " [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F\n", - " [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F\n", - " [] [pop c] . i 1 F 2 F\n", - " [] . pop c 1 F 2 F\n", - " . c 1 F 2 F\n", - " . 0 1 F 2 F\n", - " 0 . 1 F 2 F\n", - " 0 1 . F 2 F\n", - " 0 1 . + 2 F\n", - " 1 . 2 F\n", - " 1 2 . F\n", - " 1 2 . +\n", - " 3 . \n" - ] - } - ], - "source": [ - "V('[2 1] [[] =] [pop c ] [uncons swap] [dip F] genrec')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Appendix - Fun with Symbols\n", - "\n", - " |[ (c, F), (G, P) ]| == (|c, F|) • [(G, P)]\n", - "\n", - "[\"Bananas, Lenses, & Barbed Wire\"](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125)\n", - "\n", - " (|...|) [(...)] [<...>]\n", - "\n", - "I think they are having slightly too much fun with the symbols.\n", - "\n", - "\"Too much is always better than not enough.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Tree with node and list of trees.\n", - "\n", - " tree = [] | [node [tree*]]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### `treestep`\n", - "\n", - " tree z [C] [N] treestep\n", - "\n", - "\n", - " [] z [C] [N] treestep\n", - " ---------------------------\n", - " z\n", - "\n", - "\n", - " [node [tree*]] z [C] [N] treestep\n", - " --------------------------------------- w/ K == z [C] [N] treestep\n", - " node N [tree*] [K] map C" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Derive the recursive form.\n", - " K == [not] [pop z] [J] ifte\n", - "\n", - "\n", - " [node [tree*]] J\n", - " ------------------------------\n", - " node N [tree*] [K] map C\n", - "\n", - "\n", - " J == .. [N] .. [K] .. [C] ..\n", - "\n", - " [node [tree*]] uncons [N] dip\n", - " node [[tree*]] [N] dip\n", - " node N [[tree*]]\n", - "\n", - " node N [[tree*]] i [K] map\n", - " node N [tree*] [K] map\n", - " node N [K.tree*]\n", - "\n", - " J == uncons [N] dip i [K] map [C] i\n", - "\n", - " K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte\n", - " K == [not] [pop z] [uncons [N] dip i] [map [C] i] genrec" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Extract the givens to parameterize the program.\n", - " [not] [pop z] [uncons [N] dip unquote] [map [C] i] genrec\n", - " [not] [z] [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec\n", - " [not] z unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec\n", - " z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec\n", - " \\............TS0............/\n", - " z TS0 [uncons [N] dip unquote] [map [C] i] genrec\n", - " z [uncons [N] dip unquote] [TS0] dip [map [C] i] genrec\n", - " z [[N] dip unquote] [uncons] swoncat [TS0] dip [map [C] i] genrec\n", - " z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec\n", - " \\...........TS1.................../\n", - " z [N] TS1 [TS0] dip [map [C] i] genrec\n", - " z [N] [map [C] i] [TS1 [TS0] dip] dip genrec\n", - " z [N] [map C ] [TS1 [TS0] dip] dip genrec\n", - " z [N] [C] [map] swoncat [TS1 [TS0] dip] dip genrec\n", - " z [C] [N] swap [map] swoncat [TS1 [TS0] dip] dip genrec" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " TS0 == [not] swap unit [pop] swoncat\n", - " TS1 == [dip i] cons [uncons] swoncat\n", - " treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " [] 0 [C] [N] treestep\n", - " ---------------------------\n", - " 0\n", - "\n", - "\n", - " [n [tree*]] 0 [sum +] [] treestep\n", - " --------------------------------------------------\n", - " n [tree*] [0 [sum +] [] treestep] map sum +" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [], - "source": [ - "DefinitionWrapper.add_definitions('''\n", - "\n", - " TS0 == [not] swap unit [pop] swoncat\n", - " TS1 == [dip i] cons [uncons] swoncat\n", - "treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec\n", - "\n", - "''', D)" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [] 0 [sum +] [] treestep\n", - " [] . 0 [sum +] [] treestep\n", - " [] 0 . [sum +] [] treestep\n", - " [] 0 [sum +] . [] treestep\n", - " [] 0 [sum +] [] . treestep\n", - " [] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec\n", - " [] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec\n", - " [] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec\n", - " [] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec\n", - " [] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec\n", - " [] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec\n", - " [] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec\n", - " [] 0 [] . TS1 [TS0] dip [map sum +] genrec\n", - " [] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec\n", - " [] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec\n", - " [] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec\n", - " [] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec\n", - " [] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec\n", - " [] 0 . TS0 [uncons [] dip i] [map sum +] genrec\n", - " [] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec\n", - " [] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec\n", - " [] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec\n", - " [] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec\n", - " [] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte\n", - "[] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i\n", - " [] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i\n", - " True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i\n", - " True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i\n", - " [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i\n", - " [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i\n", - " [] [pop 0] . i\n", - " [] . pop 0\n", - " . 0\n", - " 0 . \n" - ] - } - ], - "source": [ - "V('[] 0 [sum +] [] treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [23 []] 0 [sum +] [] treestep\n", - " [23 []] . 0 [sum +] [] treestep\n", - " [23 []] 0 . [sum +] [] treestep\n", - " [23 []] 0 [sum +] . [] treestep\n", - " [23 []] 0 [sum +] [] . treestep\n", - " [23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec\n", - " [23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec\n", - " [23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec\n", - " [23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec\n", - " [23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec\n", - " [23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec\n", - " [23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec\n", - " [23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec\n", - " [23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec\n", - " [23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec\n", - " [23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec\n", - " [23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec\n", - " [23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec\n", - " [23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte\n", - "[23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i\n", - " [23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i\n", - " False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i\n", - " False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i\n", - " [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i\n", - " [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i\n", - " [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i\n", - " [23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +\n", - " 23 [] . sum +\n", - " 23 [] . 0 [+] catamorphism +\n", - " 23 [] 0 . [+] catamorphism +\n", - " 23 [] 0 [+] . catamorphism +\n", - " 23 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +\n", - " 23 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +\n", - " 23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism +\n", - " 23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism +\n", - " 23 [] [[] =] 0 [uncons swap] [+] . hylomorphism +\n", - " 23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +\n", - " 23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +\n", - " 23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +\n", - " 23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +\n", - " 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +\n", - " 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +\n", - " 23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +\n", - " 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec +\n", - " 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +\n", - " 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i +\n", - " 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +\n", - " 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +\n", - " 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i +\n", - " 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i +\n", - " 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i +\n", - " 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i +\n", - " 23 [] [pop 0] . i +\n", - " 23 [] . pop 0 +\n", - " 23 . 0 +\n", - " 23 0 . +\n", - " 23 . \n" - ] - } - ], - "source": [ - "V('[23 []] 0 [sum +] [] treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " . [23 [[2 []] [3 []]]] 0 [sum +] [] treestep\n", - " [23 [[2 []] [3 []]]] . 0 [sum +] [] treestep\n", - " [23 [[2 []] [3 []]]] 0 . [sum +] [] treestep\n", - " [23 [[2 []] [3 []]]] 0 [sum +] . [] treestep\n", - " [23 [[2 []] [3 []]]] 0 [sum +] [] . treestep\n", - " [23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec\n", - " [23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec\n", - " [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec\n", - " [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec\n", - " [23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec\n", - " [23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec\n", - " [23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec\n", - " [23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec\n", - " [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec\n", - " [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte\n", - " [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i\n", - " [23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i\n", - " False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i\n", - " False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i\n", - " [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i\n", - " [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i\n", - " [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i\n", - " [23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +\n", - " 23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum +\n", - "23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum +\n", - " . [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " [[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " [3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum +\n", - " 3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum +\n", - " 23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum +\n", - " 23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +\n", - " 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum +\n", - " 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum +\n", - " 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum +\n", - " 23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum +\n", - " 23 2 [] . sum + [3] swaack first [23] swaack sum +\n", - " 23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum +\n", - " 23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +\n", - " 23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum +\n", - " 23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum +\n", - " 23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum +\n", - " 23 2 [] . pop 0 + [3] swaack first [23] swaack sum +\n", - " 23 2 . 0 + [3] swaack first [23] swaack sum +\n", - " 23 2 0 . + [3] swaack first [23] swaack sum +\n", - " 23 2 . [3] swaack first [23] swaack sum +\n", - " 23 2 [3] . swaack first [23] swaack sum +\n", - " 3 [2 23] . first [23] swaack sum +\n", - " 3 2 . [23] swaack sum +\n", - " 3 2 [23] . swaack sum +\n", - " 23 [2 3] . sum +\n", - " 23 [2 3] . 0 [+] catamorphism +\n", - " 23 [2 3] 0 . [+] catamorphism +\n", - " 23 [2 3] 0 [+] . catamorphism +\n", - " 23 [2 3] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism +\n", - " 23 [2 3] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism +\n", - " 23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism +\n", - " 23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism +\n", - " 23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism +\n", - " 23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec +\n", - " 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec +\n", - " 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec +\n", - " 23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec +\n", - " 23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec +\n", - " 23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte +\n", - " 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i +\n", - " 23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +\n", - " 23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +\n", - " 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i +\n", - " 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i +\n", - " 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i +\n", - " 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i +\n", - " 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i +\n", - " 23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +\n", - " 23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +\n", - " 23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + +\n", - " 23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + +\n", - " 23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + +\n", - " 23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + +\n", - " 23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + +\n", - " 23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + +\n", - " 23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + +\n", - " 23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + +\n", - " 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + +\n", - " 23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +\n", - " 23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +\n", - " 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + +\n", - " 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + +\n", - " 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + +\n", - " 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + +\n", - " 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + +\n", - " 23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +\n", - " 23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +\n", - " 23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + +\n", - " 23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + +\n", - " 23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +\n", - " 23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + +\n", - " 23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + +\n", - " 23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + +\n", - " 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + +\n", - " 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + +\n", - " 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + +\n", - " 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +\n", - " 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +\n", - " 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + +\n", - " 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + +\n", - " 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + +\n", - " 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + +\n", - " 23 [] [pop 0] . i 3 + 2 + +\n", - " 23 [] . pop 0 3 + 2 + +\n", - " 23 . 0 3 + 2 + +\n", - " 23 0 . 3 + 2 + +\n", - " 23 0 3 . + 2 + +\n", - " 23 3 . 2 + +\n", - " 23 3 2 . + +\n", - " 23 5 . +\n", - " 28 . \n" - ] - } - ], - "source": [ - "V('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "140\n" - ] - } - ], - "source": [ - "J('[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[]\n" - ] - } - ], - "source": [ - "J('[] [] [unit cons] [23 +] treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[46 []]\n" - ] - } - ], - "source": [ - "J('[23 []] [] [unit cons] [23 +] treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[46 [[25 []] [26 []]]]\n" - ] - } - ], - "source": [ - "J('[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [], - "source": [ - "define('treemap == [] [unit cons] roll< treestep')" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[46 [[25 []] [26 []]]]\n" - ] - } - ], - "source": [ - "J('[23 [[2 []] [3 []]]] [23 +] treemap')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.md b/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.md deleted file mode 100644 index dfb43dc..0000000 --- a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.md +++ /dev/null @@ -1,2449 +0,0 @@ - -Cf. ["Bananas, Lenses, & Barbed Wire"](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125) - -# [Hylomorphism](https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29) -A [hylomorphism](https://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29) `H :: A -> B` converts a value of type A into a value of type B by means of: - -- A generator `G :: A -> (A, B)` -- A combiner `F :: (B, B) -> B` -- A predicate `P :: A -> Bool` to detect the base case -- A base case value `c :: B` -- Recursive calls (zero or more); it has a "call stack in the form of a cons list". - -It may be helpful to see this function implemented in imperative Python code. - - -```python -def hylomorphism(c, F, P, G): - '''Return a hylomorphism function H.''' - - def H(a): - if P(a): - result = c - else: - b, aa = G(a) - result = F(b, H(aa)) - return result - - return H -``` - -### Finding [Triangular Numbers](https://en.wikipedia.org/wiki/Triangular_number) -As a concrete example let's use a function that, given a positive integer, returns the sum of all positive integers less than that one. (In this case the types A and B are both `int`.) -### With `range()` and `sum()` - - -```python -r = range(10) -r -``` - - - - - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - - - - -```python -sum(r) -``` - - - - - 45 - - - - -```python -range_sum = lambda n: sum(range(n)) -range_sum(10) -``` - - - - - 45 - - - -### As a hylomorphism - - -```python -G = lambda n: (n - 1, n - 1) -F = lambda a, b: a + b -P = lambda n: n <= 1 - -H = hylomorphism(0, F, P, G) -``` - - -```python -H(10) -``` - - - - - 45 - - - -If you were to run the above code in a debugger and check out the call stack you would find that the variable `b` in each call to `H()` is storing the intermediate values as `H()` recurses. This is what was meant by "call stack in the form of a cons list". - -### Joy Preamble - - -```python -from notebook_preamble import D, DefinitionWrapper, J, V, define -``` - -## Hylomorphism in Joy -We can define a combinator `hylomorphism` that will make a hylomorphism combinator `H` from constituent parts. - - H == c [F] [P] [G] hylomorphism - -The function `H` is recursive, so we start with `ifte` and set the else-part to -some function `J` that will contain a quoted copy of `H`. (The then-part just -discards the leftover `a` and replaces it with the base case value `c`.) - - H == [P] [pop c] [J] ifte - -The else-part `J` gets just the argument `a` on the stack. - - a J - a G The first thing to do is use the generator G - aa b which produces b and a new aa - aa b [H] dip we recur with H on the new aa - aa H b F and run F on the result. - -This gives us a definition for `J`. - - J == G [H] dip F - -Plug it in and convert to genrec. - - H == [P] [pop c] [G [H] dip F] ifte - H == [P] [pop c] [G] [dip F] genrec - -This is the form of a hylomorphism in Joy, which nicely illustrates that -it is a simple specialization of the general recursion combinator. - - H == [P] [pop c] [G] [dip F] genrec - -## Derivation of `hylomorphism` - -Now we just need to derive a definition that builds the `genrec` arguments -out of the pieces given to the `hylomorphism` combinator. - - H == [P] [pop c] [G] [dip F] genrec - [P] [c] [pop] swoncat [G] [F] [dip] swoncat genrec - [P] c unit [pop] swoncat [G] [F] [dip] swoncat genrec - [P] c [G] [F] [unit [pop] swoncat] dipd [dip] swoncat genrec - -Working in reverse: -- Use `swoncat` twice to decouple `[c]` and `[F]`. -- Use `unit` to dequote `c`. -- Use `dipd` to untangle `[unit [pop] swoncat]` from the givens. - -At this point all of the arguments (givens) to the hylomorphism are to the left so we have -a definition for `hylomorphism`: - - hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec - -The order of parameters is different than the one we started with but -that hardly matters, you can rearrange them or just supply them in the -expected order. - - [P] c [G] [F] hylomorphism == H - - - - -```python -define('hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec') -``` - -Demonstrate summing a range of integers from 0 to n-1. - -- `[P]` is `[0 <=]` -- `c` is `0` -- `[G]` is `[1 - dup]` -- `[F]` is `[+]` - -So to sum the positive integers less than five we can do this. - - -```python -V('5 [0 <=] 0 [1 - dup] [+] hylomorphism') -``` - - . 5 [0 <=] 0 [1 - dup] [+] hylomorphism - 5 . [0 <=] 0 [1 - dup] [+] hylomorphism - 5 [0 <=] . 0 [1 - dup] [+] hylomorphism - 5 [0 <=] 0 . [1 - dup] [+] hylomorphism - 5 [0 <=] 0 [1 - dup] . [+] hylomorphism - 5 [0 <=] 0 [1 - dup] [+] . hylomorphism - 5 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec - 5 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec - 5 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec - 5 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec - 5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec - 5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i - 5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i - 5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i - 5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + - 4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 + - 4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 + - 4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 + - 4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 + - 4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 + - 4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 + - 4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + - 4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 + - 4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 + - 3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 + - 3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 + - 3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 + - 3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 + - 3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 + - 3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 + - 3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + - 3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 + - 3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 + - 2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 + - 2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + - 2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 + - 2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 + - 1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 + - 1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + - 1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + - 1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + - 0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 + - 0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + - 0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + - True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + - True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + - 0 [pop 0] . i 0 + 1 + 2 + 3 + 4 + - 0 . pop 0 0 + 1 + 2 + 3 + 4 + - . 0 0 + 1 + 2 + 3 + 4 + - 0 . 0 + 1 + 2 + 3 + 4 + - 0 0 . + 1 + 2 + 3 + 4 + - 0 . 1 + 2 + 3 + 4 + - 0 1 . + 2 + 3 + 4 + - 1 . 2 + 3 + 4 + - 1 2 . + 3 + 4 + - 3 . 3 + 4 + - 3 3 . + 4 + - 6 . 4 + - 6 4 . + - 10 . - - -# Anamorphism -An anamorphism can be defined as a hylomorphism that uses `[]` for `c` and -`swons` for `F`. - - [P] [G] anamorphism == [P] [] [G] [swons] hylomorphism == A - -This allows us to define an anamorphism combinator in terms of -the hylomorphism combinator. - - [] swap [swons] hylomorphism == anamorphism - -Partial evaluation gives us a "pre-cooked" form. - - [P] [G] . anamorphism - [P] [G] . [] swap [swons] hylomorphism - [P] [G] [] . swap [swons] hylomorphism - [P] [] [G] . [swons] hylomorphism - [P] [] [G] [swons] . hylomorphism - [P] [] [G] [swons] . [unit [pop] swoncat] dipd [dip] swoncat genrec - [P] [] [G] [swons] [unit [pop] swoncat] . dipd [dip] swoncat genrec - [P] [] . unit [pop] swoncat [G] [swons] [dip] swoncat genrec - [P] [[]] [pop] . swoncat [G] [swons] [dip] swoncat genrec - [P] [pop []] [G] [swons] [dip] . swoncat genrec - - [P] [pop []] [G] [dip swons] genrec - -(We could also have just substituted for `c` and `F` in the definition of `H`.) - - H == [P] [pop c ] [G] [dip F ] genrec - A == [P] [pop []] [G] [dip swons] genrec - -The partial evaluation is overkill in this case but it serves as a -reminder that this sort of program specialization can, in many cases, be -carried out automatically.) - -Untangle `[G]` from `[pop []]` using `swap`. - - [P] [G] [pop []] swap [dip swons] genrec - -All of the arguments to `anamorphism` are to the left, so we have a definition for it. - - anamorphism == [pop []] swap [dip swons] genrec - -An example of an anamorphism is the range function. - - range == [0 <=] [1 - dup] anamorphism - - -# Catamorphism -A catamorphism can be defined as a hylomorphism that uses `[uncons swap]` for `[G]` -and `[[] =]` for the predicate `[P]`. - - c [F] catamorphism == [[] =] c [uncons swap] [F] hylomorphism == C - -This allows us to define a `catamorphism` combinator in terms of -the `hylomorphism` combinator. - - [[] =] roll> [uncons swap] swap hylomorphism == catamorphism - -Partial evaluation doesn't help much. - - c [F] . catamorphism - c [F] . [[] =] roll> [uncons swap] swap hylomorphism - c [F] [[] =] . roll> [uncons swap] swap hylomorphism - [[] =] c [F] [uncons swap] . swap hylomorphism - [[] =] c [uncons swap] [F] . hylomorphism - [[] =] c [uncons swap] [F] [unit [pop] swoncat] . dipd [dip] swoncat genrec - [[] =] c . unit [pop] swoncat [uncons swap] [F] [dip] swoncat genrec - [[] =] [c] [pop] . swoncat [uncons swap] [F] [dip] swoncat genrec - [[] =] [pop c] [uncons swap] [F] [dip] . swoncat genrec - [[] =] [pop c] [uncons swap] [dip F] genrec - -Because the arguments to catamorphism have to be prepared (unlike the arguments -to anamorphism, which only need to be rearranged slightly) there isn't much point -to "pre-cooking" the definition. - - catamorphism == [[] =] roll> [uncons swap] swap hylomorphism - -An example of a catamorphism is the sum function. - - sum == 0 [+] catamorphism - -### "Fusion Law" for catas (UNFINISHED!!!) - -I'm not sure exactly how to translate the "Fusion Law" for catamorphisms into Joy. - -I know that a `map` composed with a cata can be expressed as a new cata: - - [F] map b [B] cata == b [F B] cata - -But this isn't the one described in "Bananas...". That's more like: - -A cata composed with some function can be expressed as some other cata: - - b [B] catamorphism F == c [C] catamorphism - -Given: - - b F == c - - ... - - B F == [F] dip C - - ... - - b[B]cata F == c[C]cata - - F(B(head, tail)) == C(head, F(tail)) - - 1 [2 3] B F 1 [2 3] F C - - - b F == c - B F == F C - - b [B] catamorphism F == c [C] catamorphism - b [B] catamorphism F == b F [C] catamorphism - - ... - -Or maybe, - - [F] map b [B] cata == c [C] cata ??? - - [F] map b [B] cata == b [F B] cata I think this is generally true, unless F consumes stack items - instead of just transforming TOS. Of course, there's always [F] unary. - b [F] unary [[F] unary B] cata - - [10 *] map 0 swap [+] step == 0 swap [10 * +] step - - -For example: - - F == 10 * - b == 0 - B == + - c == 0 - C == F + - - b F == c - 0 10 * == 0 - - B F == [F] dip C - + 10 * == [10 *] dip F + - + 10 * == [10 *] dip 10 * + - - n m + 10 * == 10(n+m) - - n m [10 *] dip 10 * + - n 10 * m 10 * + - 10n m 10 * + - 10n 10m + - 10n+10m - - 10n+10m = 10(n+m) - -Ergo: - - 0 [+] catamorphism 10 * == 0 [10 * +] catamorphism - -## The `step` combinator will usually be better to use than `catamorphism`. - - sum == 0 swap [+] step - sum == 0 [+] catamorphism - -# anamorphism catamorphism == hylomorphism -Here is (part of) the payoff. - -An anamorphism followed by (composed with) a -catamorphism is a hylomorphism, with the advantage that the hylomorphism -does not create the intermediate list structure. The values are stored in -either the call stack, for those implementations that use one, or in the pending -expression ("continuation") for the Joypy interpreter. They still have to -be somewhere, converting from an anamorphism and catamorphism to a hylomorphism -just prevents using additional storage and doing additional processing. - - range == [0 <=] [1 - dup] anamorphism - sum == 0 [+] catamorphism - - range sum == [0 <=] [1 - dup] anamorphism 0 [+] catamorphism - == [0 <=] 0 [1 - dup] [+] hylomorphism - -We can let the `hylomorphism` combinator build `range_sum` for us or just -substitute ourselves. - - H == [P] [pop c] [G] [dip F] genrec - range_sum == [0 <=] [pop 0] [1 - dup] [dip +] genrec - - - -```python -defs = ''' -anamorphism == [pop []] swap [dip swons] genrec -hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec -catamorphism == [[] =] roll> [uncons swap] swap hylomorphism -range == [0 <=] [1 - dup] anamorphism -sum == 0 [+] catamorphism -range_sum == [0 <=] 0 [1 - dup] [+] hylomorphism -''' - -DefinitionWrapper.add_definitions(defs, D) -``` - - -```python -J('10 range') -``` - - [9 8 7 6 5 4 3 2 1 0] - - - -```python -J('[9 8 7 6 5 4 3 2 1 0] sum') -``` - - 45 - - - -```python -V('10 range sum') -``` - - . 10 range sum - 10 . range sum - 10 . [0 <=] [1 - dup] anamorphism sum - 10 [0 <=] . [1 - dup] anamorphism sum - 10 [0 <=] [1 - dup] . anamorphism sum - 10 [0 <=] [1 - dup] . [pop []] swap [dip swons] genrec sum - 10 [0 <=] [1 - dup] [pop []] . swap [dip swons] genrec sum - 10 [0 <=] [pop []] [1 - dup] . [dip swons] genrec sum - 10 [0 <=] [pop []] [1 - dup] [dip swons] . genrec sum - 10 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [10] [0 <=] . infra first choice i sum - 10 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum - 10 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] . swaack first choice i sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i sum - 10 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 10 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 9 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 9 9 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 9 9 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons sum - 9 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 9 swons sum - 9 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 9 swons sum - 9 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 9 swons sum - 9 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 9 swons sum - 9 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 9 swons sum - 9 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [9] [0 <=] . infra first choice i 9 swons sum - 9 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum - 9 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] . swaack first choice i 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 9 swons sum - 9 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 9 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 8 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 8 8 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 8 8 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 9 swons sum - 8 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [8] [0 <=] . infra first choice i 8 swons 9 swons sum - 8 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum - 8 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] . swaack first choice i 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 8 swons 9 swons sum - 8 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 8 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 7 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 7 7 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 7 7 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 8 swons 9 swons sum - 7 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [7] [0 <=] . infra first choice i 7 swons 8 swons 9 swons sum - 7 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum - 7 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] . swaack first choice i 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 7 swons 8 swons 9 swons sum - 7 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 7 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 6 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 6 6 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 6 6 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 7 swons 8 swons 9 swons sum - 6 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [6] [0 <=] . infra first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] . swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 6 swons 7 swons 8 swons 9 swons sum - 6 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 6 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 5 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 5 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [5] [0 <=] . infra first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] . swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 4 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 4 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [4] [0 <=] . infra first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] . swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 3 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 3 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [3] [0 <=] . infra first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] . swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 2 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 2 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [2] [0 <=] . infra first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 1 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 1 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [1] [0 <=] . infra first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 0 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 0 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [0] [0 <=] . infra first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - True . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - True [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] . swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] True . choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [pop []] . i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . pop [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - . [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [] . 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [] 0 . swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [] 0 . swap cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [] . cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [0] . 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [0] 1 . swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [0] 1 . swap cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0] . cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [1 0] . 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [1 0] 2 . swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [1 0] 2 . swap cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 0] . cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [2 1 0] . 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [2 1 0] 3 . swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [2 1 0] 3 . swap cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [2 1 0] . cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [3 2 1 0] . 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [3 2 1 0] 4 . swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [3 2 1 0] 4 . swap cons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [3 2 1 0] . cons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [4 3 2 1 0] . 5 swons 6 swons 7 swons 8 swons 9 swons sum - [4 3 2 1 0] 5 . swons 6 swons 7 swons 8 swons 9 swons sum - [4 3 2 1 0] 5 . swap cons 6 swons 7 swons 8 swons 9 swons sum - 5 [4 3 2 1 0] . cons 6 swons 7 swons 8 swons 9 swons sum - [5 4 3 2 1 0] . 6 swons 7 swons 8 swons 9 swons sum - [5 4 3 2 1 0] 6 . swons 7 swons 8 swons 9 swons sum - [5 4 3 2 1 0] 6 . swap cons 7 swons 8 swons 9 swons sum - 6 [5 4 3 2 1 0] . cons 7 swons 8 swons 9 swons sum - [6 5 4 3 2 1 0] . 7 swons 8 swons 9 swons sum - [6 5 4 3 2 1 0] 7 . swons 8 swons 9 swons sum - [6 5 4 3 2 1 0] 7 . swap cons 8 swons 9 swons sum - 7 [6 5 4 3 2 1 0] . cons 8 swons 9 swons sum - [7 6 5 4 3 2 1 0] . 8 swons 9 swons sum - [7 6 5 4 3 2 1 0] 8 . swons 9 swons sum - [7 6 5 4 3 2 1 0] 8 . swap cons 9 swons sum - 8 [7 6 5 4 3 2 1 0] . cons 9 swons sum - [8 7 6 5 4 3 2 1 0] . 9 swons sum - [8 7 6 5 4 3 2 1 0] 9 . swons sum - [8 7 6 5 4 3 2 1 0] 9 . swap cons sum - 9 [8 7 6 5 4 3 2 1 0] . cons sum - [9 8 7 6 5 4 3 2 1 0] . sum - [9 8 7 6 5 4 3 2 1 0] . 0 [+] catamorphism - [9 8 7 6 5 4 3 2 1 0] 0 . [+] catamorphism - [9 8 7 6 5 4 3 2 1 0] 0 [+] . catamorphism - [9 8 7 6 5 4 3 2 1 0] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] . [uncons swap] swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] [uncons swap] . swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[9 8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i - [9 8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i - [9 8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] . swaack first choice i - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i - [9 8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + - 9 [8 7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + - [8 7 6 5 4 3 2 1 0] 9 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + - [8 7 6 5 4 3 2 1 0] 9 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + - [8 7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 9 + - [8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 + - [8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] . swaack first choice i 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 9 + - [8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 + - 8 [7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 + - [7 6 5 4 3 2 1 0] 8 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 + - [7 6 5 4 3 2 1 0] 8 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 9 + - [7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] . swaack first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 8 + 9 + - [7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 + - 7 [6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 + - [6 5 4 3 2 1 0] 7 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 + - [6 5 4 3 2 1 0] 7 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 8 + 9 + - [6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[6 5 4 3 2 1 0]] [[] =] . infra first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] . swaack first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 7 + 8 + 9 + - [6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 + - 6 [5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 + - [5 4 3 2 1 0] 6 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 + - [5 4 3 2 1 0] 6 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 7 + 8 + 9 + - [5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[5 4 3 2 1 0]] [[] =] . infra first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] . swaack first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 [4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - [4 3 2 1 0] 5 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - [4 3 2 1 0] 5 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 6 + 7 + 8 + 9 + - [4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[4 3 2 1 0]] [[] =] . infra first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] . swaack first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 [3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] 4 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] 4 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3 2 1 0]] [[] =] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 1 0]] [[] =] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[1 0]] [[] =] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] 1 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] 1 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[0]] [[] =] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] 0 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] 0 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[]] [[] =] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 . + 4 + 5 + 6 + 7 + 8 + 9 + - 6 . 4 + 5 + 6 + 7 + 8 + 9 + - 6 4 . + 5 + 6 + 7 + 8 + 9 + - 10 . 5 + 6 + 7 + 8 + 9 + - 10 5 . + 6 + 7 + 8 + 9 + - 15 . 6 + 7 + 8 + 9 + - 15 6 . + 7 + 8 + 9 + - 21 . 7 + 8 + 9 + - 21 7 . + 8 + 9 + - 28 . 8 + 9 + - 28 8 . + 9 + - 36 . 9 + - 36 9 . + - 45 . - - - -```python -V('10 range_sum') -``` - - . 10 range_sum - 10 . range_sum - 10 . [0 <=] 0 [1 - dup] [+] hylomorphism - 10 [0 <=] . 0 [1 - dup] [+] hylomorphism - 10 [0 <=] 0 . [1 - dup] [+] hylomorphism - 10 [0 <=] 0 [1 - dup] . [+] hylomorphism - 10 [0 <=] 0 [1 - dup] [+] . hylomorphism - 10 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec - 10 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec - 10 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec - 10 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec - 10 [0 <=] [pop 0] [1 - dup] [dip +] . genrec - 10 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [10] [0 <=] . infra first choice i - 10 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i - 10 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] . swaack first choice i - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i - 10 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 10 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 9 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 9 9 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 9 9 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + - 9 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 9 + - 9 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 9 + - 9 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 9 + - 9 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 9 + - 9 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 9 + - 9 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [9] [0 <=] . infra first choice i 9 + - 9 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 + - 9 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] . swaack first choice i 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 9 + - 9 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 9 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 8 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 8 8 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 8 8 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 9 + - 8 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 8 + 9 + - 8 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 8 + 9 + - 8 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 8 + 9 + - 8 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 8 + 9 + - 8 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 8 + 9 + - 8 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [8] [0 <=] . infra first choice i 8 + 9 + - 8 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 + - 8 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] . swaack first choice i 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 8 + 9 + - 8 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 8 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 7 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 7 7 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 7 7 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 8 + 9 + - 7 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [7] [0 <=] . infra first choice i 7 + 8 + 9 + - 7 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 + - 7 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] . swaack first choice i 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 7 + 8 + 9 + - 7 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 7 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 6 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 6 6 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 6 6 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 7 + 8 + 9 + - 6 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [6] [0 <=] . infra first choice i 6 + 7 + 8 + 9 + - 6 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 + - 6 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] . swaack first choice i 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 + - 6 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 6 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 5 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 5 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 6 + 7 + 8 + 9 + - 5 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i 5 + 6 + 7 + 8 + 9 + - 5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 + - 5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 + - 5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 + - 4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 + - 4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 . + 4 + 5 + 6 + 7 + 8 + 9 + - 6 . 4 + 5 + 6 + 7 + 8 + 9 + - 6 4 . + 5 + 6 + 7 + 8 + 9 + - 10 . 5 + 6 + 7 + 8 + 9 + - 10 5 . + 6 + 7 + 8 + 9 + - 15 . 6 + 7 + 8 + 9 + - 15 6 . + 7 + 8 + 9 + - 21 . 7 + 8 + 9 + - 21 7 . + 8 + 9 + - 28 . 8 + 9 + - 28 8 . + 9 + - 36 . 9 + - 36 9 . + - 45 . - - -# Factorial Function and Paramorphisms -A paramorphism `P :: B -> A` is a recursion combinator that uses `dup` on intermediate values. - - n swap [P] [pop] [[F] dupdip G] primrec - -With -- `n :: A` is the "identity" for `F` (like 1 for multiplication, 0 for addition) -- `F :: (A, B) -> A` -- `G :: B -> B` generates the next `B` value. -- and lastly `P :: B -> Bool` detects the end of the series. - -For Factorial function (types `A` and `B` are both integer): - - n == 1 - F == * - G == -- - P == 1 <= - - -```python -define('factorial == 1 swap [1 <=] [pop] [[*] dupdip --] primrec') -``` - -Try it with input 3 (omitting evaluation of predicate): - - 3 1 swap [1 <=] [pop] [[*] dupdip --] primrec - 1 3 [1 <=] [pop] [[*] dupdip --] primrec - - 1 3 [*] dupdip -- - 1 3 * 3 -- - 3 3 -- - 3 2 - - 3 2 [*] dupdip -- - 3 2 * 2 -- - 6 2 -- - 6 1 - - 6 1 [1 <=] [pop] [[*] dupdip --] primrec - - 6 1 pop - 6 - - -```python -J('3 factorial') -``` - - 6 - - -### Derive `paramorphism` from the form above. - - n swap [P] [pop] [[F] dupdip G] primrec - - n swap [P] [pop] [[F] dupdip G] primrec - n [P] [swap] dip [pop] [[F] dupdip G] primrec - n [P] [[F] dupdip G] [[swap] dip [pop]] dip primrec - n [P] [F] [dupdip G] cons [[swap] dip [pop]] dip primrec - n [P] [F] [G] [dupdip] swoncat cons [[swap] dip [pop]] dip primrec - - paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec - - -```python -define('paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec') -define('factorial == 1 [1 <=] [*] [--] paramorphism') -``` - - -```python -J('3 factorial') -``` - - 6 - - -# `tails` -An example of a paramorphism for lists given in the ["Bananas..." paper](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125) is `tails` which returns the list of "tails" of a list. - - [1 2 3] tails == [[] [3] [2 3]] - -Using `paramorphism` we would write: - - n == [] - F == rest swons - G == rest - P == not - - tails == [] [not] [rest swons] [rest] paramorphism - - -```python -define('tails == [] [not] [rest swons] [rest] paramorphism') -``` - - -```python -J('[1 2 3] tails') -``` - - [[] [3] [2 3]] - - - -```python -J('25 range tails [popop] infra [sum] map') -``` - - [1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276] - - - -```python -J('25 range [range_sum] map') -``` - - [276 253 231 210 190 171 153 136 120 105 91 78 66 55 45 36 28 21 15 10 6 3 1 0 0] - - -### Factoring `rest` -Right before the recursion begins we have: - - [] [1 2 3] [not] [pop] [[rest swons] dupdip rest] primrec - -But we might prefer to factor `rest` in the quote: - - [] [1 2 3] [not] [pop] [rest [swons] dupdip] primrec - -There's no way to do that with the `paramorphism` combinator as defined. We would have to write and use a slightly different recursion combinator that accepted an additional "preprocessor" function `[H]` and built: - - n swap [P] [pop] [H [F] dupdip G] primrec - -Or just write it out manually. This is yet another place where the *sufficiently smart compiler* will one day automatically refactor the code. We could write a `paramorphism` combinator that checked `[F]` and `[G]` for common prefix and extracted it. - -# Patterns of Recursion -Our story so far... - -- A combiner `F :: (B, B) -> B` -- A predicate `P :: A -> Bool` to detect the base case -- A base case value `c :: B` - - -### Hylo-, Ana-, Cata- - - w/ G :: A -> (A, B) - - H == [P ] [pop c ] [G ] [dip F ] genrec - A == [P ] [pop []] [G ] [dip swons] genrec - C == [[] =] [pop c ] [uncons swap] [dip F ] genrec - -### Para-, ?-, ?- - - w/ G :: B -> B - - P == c swap [P ] [pop] [[F ] dupdip G ] primrec - ? == [] swap [P ] [pop] [[swons] dupdip G ] primrec - ? == c swap [[] =] [pop] [[F ] dupdip uncons swap] primrec - - -# Four Generalizations -There are at least four kinds of recursive combinator, depending on two choices. The first choice is whether the combiner function should be evaluated during the recursion or pushed into the pending expression to be "collapsed" at the end. The second choice is whether the combiner needs to operate on the current value of the datastructure or the generator's output. - - H == [P] [pop c] [G ] [dip F] genrec - H == c swap [P] [pop] [G [F] dip ] [i] genrec - H == [P] [pop c] [ [G] dupdip ] [dip F] genrec - H == c swap [P] [pop] [ [F] dupdip G] [i] genrec - -Consider: - - ... a G [H] dip F w/ a G == a' b - ... c a G [F] dip H a G == b a' - ... a [G] dupdip [H] dip F a G == a' - ... c a [F] dupdip G H a G == a' - -### 1 - - H == [P] [pop c] [G] [dip F] genrec - -Iterate n times. - - ... a [P] [pop c] [G] [dip F] genrec - ... a G [H] dip F - ... a' b [H] dip F - ... a' H b F - ... a' G [H] dip F b F - ... a'' b [H] dip F b F - ... a'' H b F b F - ... a'' G [H] dip F b F b F - ... a''' b [H] dip F b F b F - ... a''' H b F b F b F - ... a''' pop c b F b F b F - ... c b F b F b F - -This form builds up a continuation that contains the intermediate results along with the pending combiner functions. When the base case is reached the last term is replaced by the identity value c and the continuation "collapses" into the final result. - -### 2 -When you can start with the identity value c on the stack and the combiner can operate as you go, using the intermediate results immediately rather than queuing them up, use this form. An important difference is that the generator function must return its results in the reverse order. - - H == c swap [P] [pop] [G [F] dip] primrec - - ... c a G [F] dip H - ... c b a' [F] dip H - ... c b F a' H - ... c b F a' G [F] dip H - ... c b F b a'' [F] dip H - ... c b F b F a'' H - ... c b F b F a'' G [F] dip H - ... c b F b F b a''' [F] dip H - ... c b F b F b F a''' H - ... c b F b F b F a''' pop - ... c b F b F b F - -The end line here is the same as for above, but only because we didn't evaluate `F` when it normally would have been. - -### 3 -If the combiner and the generator both need to work on the current value then `dup` must be used at some point, and the generator must produce one item instead of two (the b is instead the duplicate of a.) - - - H == [P] [pop c] [[G] dupdip] [dip F] genrec - - ... a [G] dupdip [H] dip F - ... a G a [H] dip F - ... a' a [H] dip F - ... a' H a F - ... a' [G] dupdip [H] dip F a F - ... a' G a' [H] dip F a F - ... a'' a' [H] dip F a F - ... a'' H a' F a F - ... a'' [G] dupdip [H] dip F a' F a F - ... a'' G a'' [H] dip F a' F a F - ... a''' a'' [H] dip F a' F a F - ... a''' H a'' F a' F a F - ... a''' pop c a'' F a' F a F - ... c a'' F a' F a F - -### 4 -And, last but not least, if you can combine as you go, starting with c, and the combiner needs to work on the current item, this is the form: - - W == c swap [P] [pop] [[F] dupdip G] primrec - - ... a c swap [P] [pop] [[F] dupdip G] primrec - ... c a [P] [pop] [[F] dupdip G] primrec - ... c a [F] dupdip G W - ... c a F a G W - ... c a F a' W - ... c a F a' [F] dupdip G W - ... c a F a' F a' G W - ... c a F a' F a'' W - ... c a F a' F a'' [F] dupdip G W - ... c a F a' F a'' F a'' G W - ... c a F a' F a'' F a''' W - ... c a F a' F a'' F a''' pop - ... c a F a' F a'' F - -Each of the four variations above can be specialized to ana- and catamorphic forms. - - -```python -def WTFmorphism(c, F, P, G): - '''Return a hylomorphism function H.''' - - def H(a, d=c): - if P(a): - result = d - else: - a, b = G(a) - result = H(a, F(d, b)) - return result - - return H -``` - - -```python -F = lambda a, b: a + b -P = lambda n: n <= 1 -G = lambda n: (n - 1, n - 1) - -wtf = WTFmorphism(0, F, P, G) - -print wtf(5) -``` - - 10 - - - H == [P ] [pop c ] [G ] [dip F ] genrec - - -```python -DefinitionWrapper.add_definitions(''' -P == 1 <= -Ga == -- dup -Gb == -- -c == 0 -F == + -''', D) -``` - - -```python -V('[1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec') -``` - - . [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec - [1 2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec - [1 2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec - [1 2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec - [1 2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec - [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec - [1 2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[1 2 3]] [[] =] . infra first choice i - [1 2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i - [1 2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i - False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i - False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] . swaack first choice i - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i - [1 2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons - 1 [2 3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons - [2 3] 1 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons - [2 3] 1 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons - [2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 1 swons - [2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 1 swons - [2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 1 swons - [2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 1 swons - [2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 1 swons - [2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[2 3]] [[] =] . infra first choice i 1 swons - [2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons - [2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons - False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons - False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] . swaack first choice i 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 1 swons - [2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons - 2 [3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons - [3] 2 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons - [3] 2 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 1 swons - [3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons - [3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons - [3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 2 swons 1 swons - [3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 2 swons 1 swons - [3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 2 swons 1 swons - [3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[3]] [[] =] . infra first choice i 2 swons 1 swons - [3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons - [3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons - False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons - False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] . swaack first choice i 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 2 swons 1 swons - [3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons - 3 [] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons - [] 3 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons - [] 3 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 2 swons 1 swons - [] . [[] =] [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] . [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] . [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] [uncons swap] . [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] [uncons swap] [dip swons] . genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 3 swons 2 swons 1 swons - [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[]] [[] =] . infra first choice i 3 swons 2 swons 1 swons - [] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons - [] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons - True . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons - True [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] . swaack first choice i 3 swons 2 swons 1 swons - [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 3 swons 2 swons 1 swons - [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] True . choice i 3 swons 2 swons 1 swons - [] [pop []] . i 3 swons 2 swons 1 swons - [] . pop [] 3 swons 2 swons 1 swons - . [] 3 swons 2 swons 1 swons - [] . 3 swons 2 swons 1 swons - [] 3 . swons 2 swons 1 swons - [] 3 . swap cons 2 swons 1 swons - 3 [] . cons 2 swons 1 swons - [3] . 2 swons 1 swons - [3] 2 . swons 1 swons - [3] 2 . swap cons 1 swons - 2 [3] . cons 1 swons - [2 3] . 1 swons - [2 3] 1 . swons - [2 3] 1 . swap cons - 1 [2 3] . cons - [1 2 3] . - - - -```python -V('3 [P] [pop c] [Ga] [dip F] genrec') -``` - - . 3 [P] [pop c] [Ga] [dip F] genrec - 3 . [P] [pop c] [Ga] [dip F] genrec - 3 [P] . [pop c] [Ga] [dip F] genrec - 3 [P] [pop c] . [Ga] [dip F] genrec - 3 [P] [pop c] [Ga] . [dip F] genrec - 3 [P] [pop c] [Ga] [dip F] . genrec - 3 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [3] [P] . infra first choice i - 3 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - 3 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - 3 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] . swaack first choice i - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i - 3 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F - 3 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F - 2 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F - 2 2 . [[P] [pop c] [Ga] [dip F] genrec] dip F - 2 2 [[P] [pop c] [Ga] [dip F] genrec] . dip F - 2 . [P] [pop c] [Ga] [dip F] genrec 2 F - 2 [P] . [pop c] [Ga] [dip F] genrec 2 F - 2 [P] [pop c] . [Ga] [dip F] genrec 2 F - 2 [P] [pop c] [Ga] . [dip F] genrec 2 F - 2 [P] [pop c] [Ga] [dip F] . genrec 2 F - 2 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [2] [P] . infra first choice i 2 F - 2 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - 2 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - 2 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] . swaack first choice i 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i 2 F - 2 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 2 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 1 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 1 1 . [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 1 1 [[P] [pop c] [Ga] [dip F] genrec] . dip F 2 F - 1 . [P] [pop c] [Ga] [dip F] genrec 1 F 2 F - 1 [P] . [pop c] [Ga] [dip F] genrec 1 F 2 F - 1 [P] [pop c] . [Ga] [dip F] genrec 1 F 2 F - 1 [P] [pop c] [Ga] . [dip F] genrec 1 F 2 F - 1 [P] [pop c] [Ga] [dip F] . genrec 1 F 2 F - 1 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 1 F 2 F - 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [1] [P] . infra first choice i 1 F 2 F - 1 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - 1 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - 1 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - True . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - True [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] . swaack first choice i 1 F 2 F - 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F - 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F - 1 [pop c] . i 1 F 2 F - 1 . pop c 1 F 2 F - . c 1 F 2 F - . 0 1 F 2 F - 0 . 1 F 2 F - 0 1 . F 2 F - 0 1 . + 2 F - 1 . 2 F - 1 2 . F - 1 2 . + - 3 . - - - -```python -V('3 [P] [pop []] [Ga] [dip swons] genrec') -``` - - . 3 [P] [pop []] [Ga] [dip swons] genrec - 3 . [P] [pop []] [Ga] [dip swons] genrec - 3 [P] . [pop []] [Ga] [dip swons] genrec - 3 [P] [pop []] . [Ga] [dip swons] genrec - 3 [P] [pop []] [Ga] . [dip swons] genrec - 3 [P] [pop []] [Ga] [dip swons] . genrec - 3 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [3] [P] . infra first choice i - 3 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - 3 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - 3 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] . swaack first choice i - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i - 3 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 3 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 2 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 2 2 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 2 2 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons - 2 . [P] [pop []] [Ga] [dip swons] genrec 2 swons - 2 [P] . [pop []] [Ga] [dip swons] genrec 2 swons - 2 [P] [pop []] . [Ga] [dip swons] genrec 2 swons - 2 [P] [pop []] [Ga] . [dip swons] genrec 2 swons - 2 [P] [pop []] [Ga] [dip swons] . genrec 2 swons - 2 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [2] [P] . infra first choice i 2 swons - 2 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - 2 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - 2 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i 2 swons - 2 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 2 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 1 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 1 1 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 1 1 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons 2 swons - 1 . [P] [pop []] [Ga] [dip swons] genrec 1 swons 2 swons - 1 [P] . [pop []] [Ga] [dip swons] genrec 1 swons 2 swons - 1 [P] [pop []] . [Ga] [dip swons] genrec 1 swons 2 swons - 1 [P] [pop []] [Ga] . [dip swons] genrec 1 swons 2 swons - 1 [P] [pop []] [Ga] [dip swons] . genrec 1 swons 2 swons - 1 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons - 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [1] [P] . infra first choice i 1 swons 2 swons - 1 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - 1 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - 1 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - True . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - True [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons - 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 1 swons 2 swons - 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] True . choice i 1 swons 2 swons - 1 [pop []] . i 1 swons 2 swons - 1 . pop [] 1 swons 2 swons - . [] 1 swons 2 swons - [] . 1 swons 2 swons - [] 1 . swons 2 swons - [] 1 . swap cons 2 swons - 1 [] . cons 2 swons - [1] . 2 swons - [1] 2 . swons - [1] 2 . swap cons - 2 [1] . cons - [2 1] . - - - -```python -V('[2 1] [[] =] [pop c ] [uncons swap] [dip F] genrec') -``` - - . [2 1] [[] =] [pop c] [uncons swap] [dip F] genrec - [2 1] . [[] =] [pop c] [uncons swap] [dip F] genrec - [2 1] [[] =] . [pop c] [uncons swap] [dip F] genrec - [2 1] [[] =] [pop c] . [uncons swap] [dip F] genrec - [2 1] [[] =] [pop c] [uncons swap] . [dip F] genrec - [2 1] [[] =] [pop c] [uncons swap] [dip F] . genrec - [2 1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[2 1]] [[] =] . infra first choice i - [2 1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i - [2 1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i - False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i - False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] . swaack first choice i - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i - [2 1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F - 2 [1] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F - [1] 2 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F - [1] 2 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F - [1] . [[] =] [pop c] [uncons swap] [dip F] genrec 2 F - [1] [[] =] . [pop c] [uncons swap] [dip F] genrec 2 F - [1] [[] =] [pop c] . [uncons swap] [dip F] genrec 2 F - [1] [[] =] [pop c] [uncons swap] . [dip F] genrec 2 F - [1] [[] =] [pop c] [uncons swap] [dip F] . genrec 2 F - [1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[1]] [[] =] . infra first choice i 2 F - [1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F - [1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F - False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F - False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] . swaack first choice i 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i 2 F - [1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F - 1 [] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F - [] 1 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F - [] 1 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F 2 F - [] . [[] =] [pop c] [uncons swap] [dip F] genrec 1 F 2 F - [] [[] =] . [pop c] [uncons swap] [dip F] genrec 1 F 2 F - [] [[] =] [pop c] . [uncons swap] [dip F] genrec 1 F 2 F - [] [[] =] [pop c] [uncons swap] . [dip F] genrec 1 F 2 F - [] [[] =] [pop c] [uncons swap] [dip F] . genrec 1 F 2 F - [] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 1 F 2 F - [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[]] [[] =] . infra first choice i 1 F 2 F - [] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F - [] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F - True . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F - True [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] . swaack first choice i 1 F 2 F - [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F - [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F - [] [pop c] . i 1 F 2 F - [] . pop c 1 F 2 F - . c 1 F 2 F - . 0 1 F 2 F - 0 . 1 F 2 F - 0 1 . F 2 F - 0 1 . + 2 F - 1 . 2 F - 1 2 . F - 1 2 . + - 3 . - - -## Appendix - Fun with Symbols - - |[ (c, F), (G, P) ]| == (|c, F|) • [(G, P)] - -["Bananas, Lenses, & Barbed Wire"](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.125) - - (|...|) [(...)] [<...>] - -I think they are having slightly too much fun with the symbols. - -"Too much is always better than not enough." - -# Tree with node and list of trees. - - tree = [] | [node [tree*]] - -### `treestep` - - tree z [C] [N] treestep - - - [] z [C] [N] treestep - --------------------------- - z - - - [node [tree*]] z [C] [N] treestep - --------------------------------------- w/ K == z [C] [N] treestep - node N [tree*] [K] map C - -### Derive the recursive form. - K == [not] [pop z] [J] ifte - - - [node [tree*]] J - ------------------------------ - node N [tree*] [K] map C - - - J == .. [N] .. [K] .. [C] .. - - [node [tree*]] uncons [N] dip - node [[tree*]] [N] dip - node N [[tree*]] - - node N [[tree*]] i [K] map - node N [tree*] [K] map - node N [K.tree*] - - J == uncons [N] dip i [K] map [C] i - - K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte - K == [not] [pop z] [uncons [N] dip i] [map [C] i] genrec - -### Extract the givens to parameterize the program. - [not] [pop z] [uncons [N] dip unquote] [map [C] i] genrec - [not] [z] [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec - [not] z unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec - z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec - \............TS0............/ - z TS0 [uncons [N] dip unquote] [map [C] i] genrec - z [uncons [N] dip unquote] [TS0] dip [map [C] i] genrec - z [[N] dip unquote] [uncons] swoncat [TS0] dip [map [C] i] genrec - z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec - \...........TS1.................../ - z [N] TS1 [TS0] dip [map [C] i] genrec - z [N] [map [C] i] [TS1 [TS0] dip] dip genrec - z [N] [map C ] [TS1 [TS0] dip] dip genrec - z [N] [C] [map] swoncat [TS1 [TS0] dip] dip genrec - z [C] [N] swap [map] swoncat [TS1 [TS0] dip] dip genrec - - TS0 == [not] swap unit [pop] swoncat - TS1 == [dip i] cons [uncons] swoncat - treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec - - [] 0 [C] [N] treestep - --------------------------- - 0 - - - [n [tree*]] 0 [sum +] [] treestep - -------------------------------------------------- - n [tree*] [0 [sum +] [] treestep] map sum + - - -```python -DefinitionWrapper.add_definitions(''' - - TS0 == [not] swap unit [pop] swoncat - TS1 == [dip i] cons [uncons] swoncat -treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec - -''', D) -``` - - -```python -V('[] 0 [sum +] [] treestep') -``` - - . [] 0 [sum +] [] treestep - [] . 0 [sum +] [] treestep - [] 0 . [sum +] [] treestep - [] 0 [sum +] . [] treestep - [] 0 [sum +] [] . treestep - [] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec - [] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec - [] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec - [] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec - [] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec - [] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec - [] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec - [] 0 [] . TS1 [TS0] dip [map sum +] genrec - [] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec - [] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec - [] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec - [] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec - [] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec - [] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec - [] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec - [] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec - [] 0 . TS0 [uncons [] dip i] [map sum +] genrec - [] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec - [] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec - [] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec - [] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec - [] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec - [] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec - [] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte - [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i - [] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i - True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i - True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i - [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i - [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i - [] [pop 0] . i - [] . pop 0 - . 0 - 0 . - - - -```python -V('[23 []] 0 [sum +] [] treestep') -``` - - . [23 []] 0 [sum +] [] treestep - [23 []] . 0 [sum +] [] treestep - [23 []] 0 . [sum +] [] treestep - [23 []] 0 [sum +] . [] treestep - [23 []] 0 [sum +] [] . treestep - [23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec - [23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec - [23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec - [23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec - [23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec - [23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec - [23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec - [23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec - [23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec - [23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec - [23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i - [23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i - False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i - False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i - [23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + - 23 [] . sum + - 23 [] . 0 [+] catamorphism + - 23 [] 0 . [+] catamorphism + - 23 [] 0 [+] . catamorphism + - 23 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + - 23 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + - 23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + - 23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + - 23 [] [[] =] 0 [uncons swap] [+] . hylomorphism + - 23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + - 23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + - 23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + - 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i + - 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i + - 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i + - 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i + - 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + - 23 [] [pop 0] . i + - 23 [] . pop 0 + - 23 . 0 + - 23 0 . + - 23 . - - - -```python -V('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep') -``` - - . [23 [[2 []] [3 []]]] 0 [sum +] [] treestep - [23 [[2 []] [3 []]]] . 0 [sum +] [] treestep - [23 [[2 []] [3 []]]] 0 . [sum +] [] treestep - [23 [[2 []] [3 []]]] 0 [sum +] . [] treestep - [23 [[2 []] [3 []]]] 0 [sum +] [] . treestep - [23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec - [23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec - [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i - [23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i - False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i - False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i - [23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + - 23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum + - . [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - [[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - [3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum + - 23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum + - 23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum + - 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum + - 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum + - 23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum + - 23 2 [] . sum + [3] swaack first [23] swaack sum + - 23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum + - 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum + - 23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum + - 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum + - 23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum + - 23 2 [] . pop 0 + [3] swaack first [23] swaack sum + - 23 2 . 0 + [3] swaack first [23] swaack sum + - 23 2 0 . + [3] swaack first [23] swaack sum + - 23 2 . [3] swaack first [23] swaack sum + - 23 2 [3] . swaack first [23] swaack sum + - 3 [2 23] . first [23] swaack sum + - 3 2 . [23] swaack sum + - 3 2 [23] . swaack sum + - 23 [2 3] . sum + - 23 [2 3] . 0 [+] catamorphism + - 23 [2 3] 0 . [+] catamorphism + - 23 [2 3] 0 [+] . catamorphism + - 23 [2 3] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + - 23 [2 3] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + - 23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism + - 23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism + - 23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism + - 23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + - 23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + - 23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i + - 23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i + - 23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i + - 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i + - 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i + - 23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + + - 23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + + - 23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + + - 23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + + - 23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + + - 23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + + - 23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + + - 23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + + - 23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + + - 23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + + - 23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + + - 23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + + - 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + + - 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + + - 23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + + - 23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + + - 23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + + - 23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + + - 23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + + - 23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + + - 23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + + - 23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + + - 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + + - 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + + - 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + + - 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + + - 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + + - 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + + - 23 [] [pop 0] . i 3 + 2 + + - 23 [] . pop 0 3 + 2 + + - 23 . 0 3 + 2 + + - 23 0 . 3 + 2 + + - 23 0 3 . + 2 + + - 23 3 . 2 + + - 23 3 2 . + + - 23 5 . + - 28 . - - - -```python -J('[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep') -``` - - 140 - - - -```python -J('[] [] [unit cons] [23 +] treestep') -``` - - [] - - - -```python -J('[23 []] [] [unit cons] [23 +] treestep') -``` - - [46 []] - - - -```python -J('[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep') -``` - - [46 [[25 []] [26 []]]] - - - -```python -define('treemap == [] [unit cons] roll< treestep') -``` - - -```python -J('[23 [[2 []] [3 []]]] [23 +] treemap') -``` - - [46 [[25 []] [26 []]]] - diff --git a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst b/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst deleted file mode 100644 index 14cbbb7..0000000 --- a/docs/Hylo-, Ana-, Cata-, and Para-morphisms - Recursion Combinators.rst +++ /dev/null @@ -1,2680 +0,0 @@ - -Cf. `"Bananas, Lenses, & Barbed -Wire" `__ - -`Hylomorphism `__ -==================================================================================== - -A -`hylomorphism `__ -``H :: A -> B`` converts a value of type A into a value of type B by -means of: - -- A generator ``G :: A -> (A, B)`` -- A combiner ``F :: (B, B) -> B`` -- A predicate ``P :: A -> Bool`` to detect the base case -- A base case value ``c :: B`` -- Recursive calls (zero or more); it has a "call stack in the form of a - cons list". - -It may be helpful to see this function implemented in imperative Python -code. - -.. code:: ipython2 - - def hylomorphism(c, F, P, G): - '''Return a hylomorphism function H.''' - - def H(a): - if P(a): - result = c - else: - b, aa = G(a) - result = F(b, H(aa)) - return result - - return H - -Finding `Triangular Numbers `__ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -As a concrete example let's use a function that, given a positive -integer, returns the sum of all positive integers less than that one. -(In this case the types A and B are both ``int``.) ### With ``range()`` -and ``sum()`` - -.. code:: ipython2 - - r = range(10) - r - - - - -.. parsed-literal:: - - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - - - -.. code:: ipython2 - - sum(r) - - - - -.. parsed-literal:: - - 45 - - - -.. code:: ipython2 - - range_sum = lambda n: sum(range(n)) - range_sum(10) - - - - -.. parsed-literal:: - - 45 - - - -As a hylomorphism -~~~~~~~~~~~~~~~~~ - -.. code:: ipython2 - - G = lambda n: (n - 1, n - 1) - F = lambda a, b: a + b - P = lambda n: n <= 1 - - H = hylomorphism(0, F, P, G) - -.. code:: ipython2 - - H(10) - - - - -.. parsed-literal:: - - 45 - - - -If you were to run the above code in a debugger and check out the call -stack you would find that the variable ``b`` in each call to ``H()`` is -storing the intermediate values as ``H()`` recurses. This is what was -meant by "call stack in the form of a cons list". - -Joy Preamble -~~~~~~~~~~~~ - -.. code:: ipython2 - - from notebook_preamble import D, DefinitionWrapper, J, V, define - -Hylomorphism in Joy -------------------- - -We can define a combinator ``hylomorphism`` that will make a -hylomorphism combinator ``H`` from constituent parts. - -:: - - H == c [F] [P] [G] hylomorphism - -The function ``H`` is recursive, so we start with ``ifte`` and set the -else-part to some function ``J`` that will contain a quoted copy of -``H``. (The then-part just discards the leftover ``a`` and replaces it -with the base case value ``c``.) - -:: - - H == [P] [pop c] [J] ifte - -The else-part ``J`` gets just the argument ``a`` on the stack. - -:: - - a J - a G The first thing to do is use the generator G - aa b which produces b and a new aa - aa b [H] dip we recur with H on the new aa - aa H b F and run F on the result. - -This gives us a definition for ``J``. - -:: - - J == G [H] dip F - -Plug it in and convert to genrec. - -:: - - H == [P] [pop c] [G [H] dip F] ifte - H == [P] [pop c] [G] [dip F] genrec - -This is the form of a hylomorphism in Joy, which nicely illustrates that -it is a simple specialization of the general recursion combinator. - -:: - - H == [P] [pop c] [G] [dip F] genrec - -Derivation of ``hylomorphism`` ------------------------------- - -Now we just need to derive a definition that builds the ``genrec`` -arguments out of the pieces given to the ``hylomorphism`` combinator. - -:: - - H == [P] [pop c] [G] [dip F] genrec - [P] [c] [pop] swoncat [G] [F] [dip] swoncat genrec - [P] c unit [pop] swoncat [G] [F] [dip] swoncat genrec - [P] c [G] [F] [unit [pop] swoncat] dipd [dip] swoncat genrec - -Working in reverse: - Use ``swoncat`` twice to decouple ``[c]`` and -``[F]``. - Use ``unit`` to dequote ``c``. - Use ``dipd`` to untangle -``[unit [pop] swoncat]`` from the givens. - -At this point all of the arguments (givens) to the hylomorphism are to -the left so we have a definition for ``hylomorphism``: - -:: - - hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec - -The order of parameters is different than the one we started with but -that hardly matters, you can rearrange them or just supply them in the -expected order. - -:: - - [P] c [G] [F] hylomorphism == H - -.. code:: ipython2 - - define('hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec') - -Demonstrate summing a range of integers from 0 to n-1. - -- ``[P]`` is ``[0 <=]`` -- ``c`` is ``0`` -- ``[G]`` is ``[1 - dup]`` -- ``[F]`` is ``[+]`` - -So to sum the positive integers less than five we can do this. - -.. code:: ipython2 - - V('5 [0 <=] 0 [1 - dup] [+] hylomorphism') - - -.. parsed-literal:: - - . 5 [0 <=] 0 [1 - dup] [+] hylomorphism - 5 . [0 <=] 0 [1 - dup] [+] hylomorphism - 5 [0 <=] . 0 [1 - dup] [+] hylomorphism - 5 [0 <=] 0 . [1 - dup] [+] hylomorphism - 5 [0 <=] 0 [1 - dup] . [+] hylomorphism - 5 [0 <=] 0 [1 - dup] [+] . hylomorphism - 5 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec - 5 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec - 5 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec - 5 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec - 5 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec - 5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec - 5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i - 5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i - 5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i - 5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + - 4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 + - 4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 + - 4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 + - 4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 + - 4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 + - 4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 + - 4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + - 4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 + - 4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + - 3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 + - 3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 + - 3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 + - 3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 + - 3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 + - 3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 + - 3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 + - 3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + - 3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 + - 3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + - 2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 + - 2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 + - 2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 + - 2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + - 2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 + - 2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + - 1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 + - 1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 + - 1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 + - 1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + - 1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + - 1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + - 0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + - 0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + - 0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 + - 0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + - 0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + - True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + - True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + - 0 [pop 0] . i 0 + 1 + 2 + 3 + 4 + - 0 . pop 0 0 + 1 + 2 + 3 + 4 + - . 0 0 + 1 + 2 + 3 + 4 + - 0 . 0 + 1 + 2 + 3 + 4 + - 0 0 . + 1 + 2 + 3 + 4 + - 0 . 1 + 2 + 3 + 4 + - 0 1 . + 2 + 3 + 4 + - 1 . 2 + 3 + 4 + - 1 2 . + 3 + 4 + - 3 . 3 + 4 + - 3 3 . + 4 + - 6 . 4 + - 6 4 . + - 10 . - - -Anamorphism -=========== - -An anamorphism can be defined as a hylomorphism that uses ``[]`` for -``c`` and ``swons`` for ``F``. - -:: - - [P] [G] anamorphism == [P] [] [G] [swons] hylomorphism == A - -This allows us to define an anamorphism combinator in terms of the -hylomorphism combinator. - -:: - - [] swap [swons] hylomorphism == anamorphism - -Partial evaluation gives us a "pre-cooked" form. - -:: - - [P] [G] . anamorphism - [P] [G] . [] swap [swons] hylomorphism - [P] [G] [] . swap [swons] hylomorphism - [P] [] [G] . [swons] hylomorphism - [P] [] [G] [swons] . hylomorphism - [P] [] [G] [swons] . [unit [pop] swoncat] dipd [dip] swoncat genrec - [P] [] [G] [swons] [unit [pop] swoncat] . dipd [dip] swoncat genrec - [P] [] . unit [pop] swoncat [G] [swons] [dip] swoncat genrec - [P] [[]] [pop] . swoncat [G] [swons] [dip] swoncat genrec - [P] [pop []] [G] [swons] [dip] . swoncat genrec - - [P] [pop []] [G] [dip swons] genrec - -(We could also have just substituted for ``c`` and ``F`` in the -definition of ``H``.) - -:: - - H == [P] [pop c ] [G] [dip F ] genrec - A == [P] [pop []] [G] [dip swons] genrec - -The partial evaluation is overkill in this case but it serves as a -reminder that this sort of program specialization can, in many cases, be -carried out automatically.) - -Untangle ``[G]`` from ``[pop []]`` using ``swap``. - -:: - - [P] [G] [pop []] swap [dip swons] genrec - -All of the arguments to ``anamorphism`` are to the left, so we have a -definition for it. - -:: - - anamorphism == [pop []] swap [dip swons] genrec - -An example of an anamorphism is the range function. - -:: - - range == [0 <=] [1 - dup] anamorphism - -Catamorphism -============ - -A catamorphism can be defined as a hylomorphism that uses -``[uncons swap]`` for ``[G]`` and ``[[] =]`` for the predicate ``[P]``. - -:: - - c [F] catamorphism == [[] =] c [uncons swap] [F] hylomorphism == C - -This allows us to define a ``catamorphism`` combinator in terms of the -``hylomorphism`` combinator. - -:: - - [[] =] roll> [uncons swap] swap hylomorphism == catamorphism - -Partial evaluation doesn't help much. - -:: - - c [F] . catamorphism - c [F] . [[] =] roll> [uncons swap] swap hylomorphism - c [F] [[] =] . roll> [uncons swap] swap hylomorphism - [[] =] c [F] [uncons swap] . swap hylomorphism - [[] =] c [uncons swap] [F] . hylomorphism - [[] =] c [uncons swap] [F] [unit [pop] swoncat] . dipd [dip] swoncat genrec - [[] =] c . unit [pop] swoncat [uncons swap] [F] [dip] swoncat genrec - [[] =] [c] [pop] . swoncat [uncons swap] [F] [dip] swoncat genrec - [[] =] [pop c] [uncons swap] [F] [dip] . swoncat genrec - [[] =] [pop c] [uncons swap] [dip F] genrec - -Because the arguments to catamorphism have to be prepared (unlike the -arguments to anamorphism, which only need to be rearranged slightly) -there isn't much point to "pre-cooking" the definition. - -:: - - catamorphism == [[] =] roll> [uncons swap] swap hylomorphism - -An example of a catamorphism is the sum function. - -:: - - sum == 0 [+] catamorphism - -"Fusion Law" for catas (UNFINISHED!!!) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -I'm not sure exactly how to translate the "Fusion Law" for catamorphisms -into Joy. - -I know that a ``map`` composed with a cata can be expressed as a new -cata: - -:: - - [F] map b [B] cata == b [F B] cata - -But this isn't the one described in "Bananas...". That's more like: - -A cata composed with some function can be expressed as some other cata: - -:: - - b [B] catamorphism F == c [C] catamorphism - -Given: - -:: - - b F == c - - ... - - B F == [F] dip C - - ... - - b[B]cata F == c[C]cata - - F(B(head, tail)) == C(head, F(tail)) - - 1 [2 3] B F 1 [2 3] F C - - - b F == c - B F == F C - - b [B] catamorphism F == c [C] catamorphism - b [B] catamorphism F == b F [C] catamorphism - - ... - -Or maybe, - -:: - - [F] map b [B] cata == c [C] cata ??? - - [F] map b [B] cata == b [F B] cata I think this is generally true, unless F consumes stack items - instead of just transforming TOS. Of course, there's always [F] unary. - b [F] unary [[F] unary B] cata - - [10 *] map 0 swap [+] step == 0 swap [10 * +] step - -For example: - -:: - - F == 10 * - b == 0 - B == + - c == 0 - C == F + - - b F == c - 0 10 * == 0 - - B F == [F] dip C - + 10 * == [10 *] dip F + - + 10 * == [10 *] dip 10 * + - - n m + 10 * == 10(n+m) - - n m [10 *] dip 10 * + - n 10 * m 10 * + - 10n m 10 * + - 10n 10m + - 10n+10m - - 10n+10m = 10(n+m) - -Ergo: - -:: - - 0 [+] catamorphism 10 * == 0 [10 * +] catamorphism - -The ``step`` combinator will usually be better to use than ``catamorphism``. ----------------------------------------------------------------------------- - -:: - - sum == 0 swap [+] step - sum == 0 [+] catamorphism - -anamorphism catamorphism == hylomorphism -======================================== - -Here is (part of) the payoff. - -An anamorphism followed by (composed with) a catamorphism is a -hylomorphism, with the advantage that the hylomorphism does not create -the intermediate list structure. The values are stored in either the -call stack, for those implementations that use one, or in the pending -expression ("continuation") for the Joypy interpreter. They still have -to be somewhere, converting from an anamorphism and catamorphism to a -hylomorphism just prevents using additional storage and doing additional -processing. - -:: - - range == [0 <=] [1 - dup] anamorphism - sum == 0 [+] catamorphism - - range sum == [0 <=] [1 - dup] anamorphism 0 [+] catamorphism - == [0 <=] 0 [1 - dup] [+] hylomorphism - -We can let the ``hylomorphism`` combinator build ``range_sum`` for us or -just substitute ourselves. - -:: - - H == [P] [pop c] [G] [dip F] genrec - range_sum == [0 <=] [pop 0] [1 - dup] [dip +] genrec - -.. code:: ipython2 - - defs = ''' - anamorphism == [pop []] swap [dip swons] genrec - hylomorphism == [unit [pop] swoncat] dipd [dip] swoncat genrec - catamorphism == [[] =] roll> [uncons swap] swap hylomorphism - range == [0 <=] [1 - dup] anamorphism - sum == 0 [+] catamorphism - range_sum == [0 <=] 0 [1 - dup] [+] hylomorphism - ''' - - DefinitionWrapper.add_definitions(defs, D) - -.. code:: ipython2 - - J('10 range') - - -.. parsed-literal:: - - [9 8 7 6 5 4 3 2 1 0] - - -.. code:: ipython2 - - J('[9 8 7 6 5 4 3 2 1 0] sum') - - -.. parsed-literal:: - - 45 - - -.. code:: ipython2 - - V('10 range sum') - - -.. parsed-literal:: - - . 10 range sum - 10 . range sum - 10 . [0 <=] [1 - dup] anamorphism sum - 10 [0 <=] . [1 - dup] anamorphism sum - 10 [0 <=] [1 - dup] . anamorphism sum - 10 [0 <=] [1 - dup] . [pop []] swap [dip swons] genrec sum - 10 [0 <=] [1 - dup] [pop []] . swap [dip swons] genrec sum - 10 [0 <=] [pop []] [1 - dup] . [dip swons] genrec sum - 10 [0 <=] [pop []] [1 - dup] [dip swons] . genrec sum - 10 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [10] [0 <=] . infra first choice i sum - 10 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum - 10 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] swaack first choice i sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 10] . swaack first choice i sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i sum - 10 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i sum - 10 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 10 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 9 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 9 9 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons sum - 9 9 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons sum - 9 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 9 swons sum - 9 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 9 swons sum - 9 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 9 swons sum - 9 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 9 swons sum - 9 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 9 swons sum - 9 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [9] [0 <=] . infra first choice i 9 swons sum - 9 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum - 9 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] swaack first choice i 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 9] . swaack first choice i 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 9 swons sum - 9 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 9 swons sum - 9 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 9 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 8 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 8 8 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 9 swons sum - 8 8 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 9 swons sum - 8 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 8 swons 9 swons sum - 8 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [8] [0 <=] . infra first choice i 8 swons 9 swons sum - 8 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum - 8 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] swaack first choice i 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 8] . swaack first choice i 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 8 swons 9 swons sum - 8 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 8 swons 9 swons sum - 8 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 8 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 7 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 7 7 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 8 swons 9 swons sum - 7 7 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 8 swons 9 swons sum - 7 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 7 swons 8 swons 9 swons sum - 7 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [7] [0 <=] . infra first choice i 7 swons 8 swons 9 swons sum - 7 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum - 7 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] swaack first choice i 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 7] . swaack first choice i 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 7 swons 8 swons 9 swons sum - 7 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 7 swons 8 swons 9 swons sum - 7 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 7 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 6 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 6 6 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 7 swons 8 swons 9 swons sum - 6 6 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 7 swons 8 swons 9 swons sum - 6 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 6 swons 7 swons 8 swons 9 swons sum - 6 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [6] [0 <=] . infra first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 6] . swaack first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 6 swons 7 swons 8 swons 9 swons sum - 6 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 6 swons 7 swons 8 swons 9 swons sum - 6 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 6 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 5 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 5 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 6 swons 7 swons 8 swons 9 swons sum - 5 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [5] [0 <=] . infra first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 5] . swaack first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 5 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 4 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 4 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [4] [0 <=] . infra first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 4] . swaack first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 3 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 3 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [3] [0 <=] . infra first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 3] . swaack first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 2 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 2 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [2] [0 <=] . infra first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 1 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 1 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [1] [0 <=] . infra first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - False [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . i 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 . 1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 1 . - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 0 . [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 0 [[0 <=] [pop []] [1 - dup] [dip swons] genrec] . dip swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . [0 <=] [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] . [pop []] [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] . [1 - dup] [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] [1 - dup] . [dip swons] genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] [1 - dup] [dip swons] . genrec 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [0 <=] [pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] . ifte 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [0] [0 <=] . infra first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . 0 <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 0 . <= [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - True . [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - True [[pop []] [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] 0] . swaack first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [1 - dup [[0 <=] [pop []] [1 - dup] [dip swons] genrec] dip swons] [pop []] True . choice i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [pop []] . i 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 . pop [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - . [] 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [] . 0 swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [] 0 . swons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [] 0 . swap cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 0 [] . cons 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [0] . 1 swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [0] 1 . swons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [0] 1 . swap cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 1 [0] . cons 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [1 0] . 2 swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [1 0] 2 . swons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [1 0] 2 . swap cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 2 [1 0] . cons 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [2 1 0] . 3 swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [2 1 0] 3 . swons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [2 1 0] 3 . swap cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 3 [2 1 0] . cons 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [3 2 1 0] . 4 swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [3 2 1 0] 4 . swons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [3 2 1 0] 4 . swap cons 5 swons 6 swons 7 swons 8 swons 9 swons sum - 4 [3 2 1 0] . cons 5 swons 6 swons 7 swons 8 swons 9 swons sum - [4 3 2 1 0] . 5 swons 6 swons 7 swons 8 swons 9 swons sum - [4 3 2 1 0] 5 . swons 6 swons 7 swons 8 swons 9 swons sum - [4 3 2 1 0] 5 . swap cons 6 swons 7 swons 8 swons 9 swons sum - 5 [4 3 2 1 0] . cons 6 swons 7 swons 8 swons 9 swons sum - [5 4 3 2 1 0] . 6 swons 7 swons 8 swons 9 swons sum - [5 4 3 2 1 0] 6 . swons 7 swons 8 swons 9 swons sum - [5 4 3 2 1 0] 6 . swap cons 7 swons 8 swons 9 swons sum - 6 [5 4 3 2 1 0] . cons 7 swons 8 swons 9 swons sum - [6 5 4 3 2 1 0] . 7 swons 8 swons 9 swons sum - [6 5 4 3 2 1 0] 7 . swons 8 swons 9 swons sum - [6 5 4 3 2 1 0] 7 . swap cons 8 swons 9 swons sum - 7 [6 5 4 3 2 1 0] . cons 8 swons 9 swons sum - [7 6 5 4 3 2 1 0] . 8 swons 9 swons sum - [7 6 5 4 3 2 1 0] 8 . swons 9 swons sum - [7 6 5 4 3 2 1 0] 8 . swap cons 9 swons sum - 8 [7 6 5 4 3 2 1 0] . cons 9 swons sum - [8 7 6 5 4 3 2 1 0] . 9 swons sum - [8 7 6 5 4 3 2 1 0] 9 . swons sum - [8 7 6 5 4 3 2 1 0] 9 . swap cons sum - 9 [8 7 6 5 4 3 2 1 0] . cons sum - [9 8 7 6 5 4 3 2 1 0] . sum - [9 8 7 6 5 4 3 2 1 0] . 0 [+] catamorphism - [9 8 7 6 5 4 3 2 1 0] 0 . [+] catamorphism - [9 8 7 6 5 4 3 2 1 0] 0 [+] . catamorphism - [9 8 7 6 5 4 3 2 1 0] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] . [uncons swap] swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [+] [uncons swap] . swap hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . hylomorphism - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec - [9 8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[9 8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i - [9 8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i - [9 8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] swaack first choice i - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [9 8 7 6 5 4 3 2 1 0]] . swaack first choice i - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i - [9 8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i - [9 8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + - 9 [8 7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + - [8 7 6 5 4 3 2 1 0] 9 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + - [8 7 6 5 4 3 2 1 0] 9 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + - [8 7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 9 + - [8 7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[8 7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 9 + - [8 7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 + - [8 7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] swaack first choice i 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [8 7 6 5 4 3 2 1 0]] . swaack first choice i 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 9 + - [8 7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 9 + - [8 7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 + - 8 [7 6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 + - [7 6 5 4 3 2 1 0] 8 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 9 + - [7 6 5 4 3 2 1 0] 8 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 9 + - [7 6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 8 + 9 + - [7 6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[7 6 5 4 3 2 1 0]] [[] =] . infra first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] swaack first choice i 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [7 6 5 4 3 2 1 0]] . swaack first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 + - [7 6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 8 + 9 + - [7 6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 + - 7 [6 5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 + - [6 5 4 3 2 1 0] 7 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 8 + 9 + - [6 5 4 3 2 1 0] 7 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 8 + 9 + - [6 5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 7 + 8 + 9 + - [6 5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[6 5 4 3 2 1 0]] [[] =] . infra first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] swaack first choice i 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [6 5 4 3 2 1 0]] . swaack first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 + - [6 5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 7 + 8 + 9 + - [6 5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 + - 6 [5 4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 + - [5 4 3 2 1 0] 6 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 7 + 8 + 9 + - [5 4 3 2 1 0] 6 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 7 + 8 + 9 + - [5 4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[5 4 3 2 1 0]] [[] =] . infra first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] swaack first choice i 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [5 4 3 2 1 0]] . swaack first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 + - [5 4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 [4 3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - [4 3 2 1 0] 5 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - [4 3 2 1 0] 5 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 6 + 7 + 8 + 9 + - [4 3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[4 3 2 1 0]] [[] =] . infra first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [4 3 2 1 0]] . swaack first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 + - [4 3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 [3 2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] 4 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] 4 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3 2 1 0]] [[] =] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3 2 1 0]] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 + - [3 2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [2 1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 1 0]] [[] =] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 1 0]] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [2 1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[1 0]] [[] =] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [1 0]] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [1 0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] 1 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] 1 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] . [[] =] [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] . [pop 0] [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] . [uncons swap] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] [uncons swap] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] [uncons swap] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[0]] [[] =] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [0]] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [0] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] 0 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] 0 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[]] [[] =] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] []] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - [] . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 . + 4 + 5 + 6 + 7 + 8 + 9 + - 6 . 4 + 5 + 6 + 7 + 8 + 9 + - 6 4 . + 5 + 6 + 7 + 8 + 9 + - 10 . 5 + 6 + 7 + 8 + 9 + - 10 5 . + 6 + 7 + 8 + 9 + - 15 . 6 + 7 + 8 + 9 + - 15 6 . + 7 + 8 + 9 + - 21 . 7 + 8 + 9 + - 21 7 . + 8 + 9 + - 28 . 8 + 9 + - 28 8 . + 9 + - 36 . 9 + - 36 9 . + - 45 . - - -.. code:: ipython2 - - V('10 range_sum') - - -.. parsed-literal:: - - . 10 range_sum - 10 . range_sum - 10 . [0 <=] 0 [1 - dup] [+] hylomorphism - 10 [0 <=] . 0 [1 - dup] [+] hylomorphism - 10 [0 <=] 0 . [1 - dup] [+] hylomorphism - 10 [0 <=] 0 [1 - dup] . [+] hylomorphism - 10 [0 <=] 0 [1 - dup] [+] . hylomorphism - 10 [0 <=] 0 [1 - dup] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec - 10 [0 <=] 0 [1 - dup] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec - 10 [0 <=] 0 . unit [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] 0 . [] cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] 0 [] . cons [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [0] . [pop] swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [0] [pop] . swoncat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [0] [pop] . swap concat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [pop] [0] . concat [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [pop 0] . [1 - dup] [+] [dip] swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] . [+] [dip] swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] [+] . [dip] swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swoncat genrec - 10 [0 <=] [pop 0] [1 - dup] [+] [dip] . swap concat genrec - 10 [0 <=] [pop 0] [1 - dup] [dip] [+] . concat genrec - 10 [0 <=] [pop 0] [1 - dup] [dip +] . genrec - 10 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [10] [0 <=] . infra first choice i - 10 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i - 10 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] swaack first choice i - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 10] . swaack first choice i - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i - 10 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i - 10 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 10 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 9 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 9 9 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + - 9 9 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + - 9 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 9 + - 9 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 9 + - 9 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 9 + - 9 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 9 + - 9 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 9 + - 9 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [9] [0 <=] . infra first choice i 9 + - 9 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 + - 9 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] swaack first choice i 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 9] . swaack first choice i 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 9 + - 9 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 9 + - 9 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 9 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 8 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 8 8 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 9 + - 8 8 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 9 + - 8 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 8 + 9 + - 8 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 8 + 9 + - 8 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 8 + 9 + - 8 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 8 + 9 + - 8 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 8 + 9 + - 8 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [8] [0 <=] . infra first choice i 8 + 9 + - 8 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 + - 8 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] swaack first choice i 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 8] . swaack first choice i 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 8 + 9 + - 8 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 8 + 9 + - 8 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 8 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 7 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 7 7 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 8 + 9 + - 7 7 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 8 + 9 + - 7 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 7 + 8 + 9 + - 7 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [7] [0 <=] . infra first choice i 7 + 8 + 9 + - 7 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 + - 7 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] swaack first choice i 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 7] . swaack first choice i 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 7 + 8 + 9 + - 7 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 7 + 8 + 9 + - 7 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 7 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 6 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 6 6 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 7 + 8 + 9 + - 6 6 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 7 + 8 + 9 + - 6 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 6 + 7 + 8 + 9 + - 6 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [6] [0 <=] . infra first choice i 6 + 7 + 8 + 9 + - 6 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 + - 6 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] swaack first choice i 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 6] . swaack first choice i 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 6 + 7 + 8 + 9 + - 6 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 6 + 7 + 8 + 9 + - 6 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 6 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 5 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 6 + 7 + 8 + 9 + - 5 5 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 6 + 7 + 8 + 9 + - 5 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 5 + 6 + 7 + 8 + 9 + - 5 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [5] [0 <=] . infra first choice i 5 + 6 + 7 + 8 + 9 + - 5 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 + - 5 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] swaack first choice i 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 5] . swaack first choice i 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 5 + 6 + 7 + 8 + 9 + - 5 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 5 + 6 + 7 + 8 + 9 + - 5 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 5 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 4 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 5 + 6 + 7 + 8 + 9 + - 4 4 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 5 + 6 + 7 + 8 + 9 + - 4 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 4 + 5 + 6 + 7 + 8 + 9 + - 4 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [4] [0 <=] . infra first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 4] . swaack first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 4 + 5 + 6 + 7 + 8 + 9 + - 4 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 4 + 5 + 6 + 7 + 8 + 9 + - 4 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 4 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [3] [0 <=] . infra first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 3] . swaack first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 2 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 2 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [2] [0 <=] . infra first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 2] . swaack first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 2 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 1 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 1 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [1] [0 <=] . infra first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - False [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 1] . swaack first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [False] . first choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] False . choice i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . i 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 1 . - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 [[0 <=] [pop 0] [1 - dup] [dip +] genrec] . dip + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . [0 <=] [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] . [pop 0] [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] . [1 - dup] [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] [1 - dup] . [dip +] genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] [1 - dup] [dip +] . genrec 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [0 <=] [pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] . ifte 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [0] [0 <=] . infra first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 0 <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . <= [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True . [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - True [[pop 0] [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] 0] . swaack first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] [True] . first choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [1 - dup [[0 <=] [pop 0] [1 - dup] [dip +] genrec] dip +] [pop 0] True . choice i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 [pop 0] . i 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . pop 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - . 0 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 0 . + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 . 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 0 1 . + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 . 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 1 2 . + 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 . 3 + 4 + 5 + 6 + 7 + 8 + 9 + - 3 3 . + 4 + 5 + 6 + 7 + 8 + 9 + - 6 . 4 + 5 + 6 + 7 + 8 + 9 + - 6 4 . + 5 + 6 + 7 + 8 + 9 + - 10 . 5 + 6 + 7 + 8 + 9 + - 10 5 . + 6 + 7 + 8 + 9 + - 15 . 6 + 7 + 8 + 9 + - 15 6 . + 7 + 8 + 9 + - 21 . 7 + 8 + 9 + - 21 7 . + 8 + 9 + - 28 . 8 + 9 + - 28 8 . + 9 + - 36 . 9 + - 36 9 . + - 45 . - - -Factorial Function and Paramorphisms -==================================== - -A paramorphism ``P :: B -> A`` is a recursion combinator that uses -``dup`` on intermediate values. - -:: - - n swap [P] [pop] [[F] dupdip G] primrec - -With - ``n :: A`` is the "identity" for ``F`` (like 1 for -multiplication, 0 for addition) - ``F :: (A, B) -> A`` - ``G :: B -> B`` -generates the next ``B`` value. - and lastly ``P :: B -> Bool`` detects -the end of the series. - -For Factorial function (types ``A`` and ``B`` are both integer): - -:: - - n == 1 - F == * - G == -- - P == 1 <= - -.. code:: ipython2 - - define('factorial == 1 swap [1 <=] [pop] [[*] dupdip --] primrec') - -Try it with input 3 (omitting evaluation of predicate): - -:: - - 3 1 swap [1 <=] [pop] [[*] dupdip --] primrec - 1 3 [1 <=] [pop] [[*] dupdip --] primrec - - 1 3 [*] dupdip -- - 1 3 * 3 -- - 3 3 -- - 3 2 - - 3 2 [*] dupdip -- - 3 2 * 2 -- - 6 2 -- - 6 1 - - 6 1 [1 <=] [pop] [[*] dupdip --] primrec - - 6 1 pop - 6 - -.. code:: ipython2 - - J('3 factorial') - - -.. parsed-literal:: - - 6 - - -Derive ``paramorphism`` from the form above. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - n swap [P] [pop] [[F] dupdip G] primrec - - n swap [P] [pop] [[F] dupdip G] primrec - n [P] [swap] dip [pop] [[F] dupdip G] primrec - n [P] [[F] dupdip G] [[swap] dip [pop]] dip primrec - n [P] [F] [dupdip G] cons [[swap] dip [pop]] dip primrec - n [P] [F] [G] [dupdip] swoncat cons [[swap] dip [pop]] dip primrec - - paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec - -.. code:: ipython2 - - define('paramorphism == [dupdip] swoncat cons [[swap] dip [pop]] dip primrec') - define('factorial == 1 [1 <=] [*] [--] paramorphism') - -.. code:: ipython2 - - J('3 factorial') - - -.. parsed-literal:: - - 6 - - -``tails`` -========= - -An example of a paramorphism for lists given in the `"Bananas..." -paper `__ -is ``tails`` which returns the list of "tails" of a list. - -:: - - [1 2 3] tails == [[] [3] [2 3]] - -Using ``paramorphism`` we would write: - -:: - - n == [] - F == rest swons - G == rest - P == not - - tails == [] [not] [rest swons] [rest] paramorphism - -.. code:: ipython2 - - define('tails == [] [not] [rest swons] [rest] paramorphism') - -.. code:: ipython2 - - J('[1 2 3] tails') - - -.. parsed-literal:: - - [[] [3] [2 3]] - - -.. code:: ipython2 - - J('25 range tails [popop] infra [sum] map') - - -.. parsed-literal:: - - [1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276] - - -.. code:: ipython2 - - J('25 range [range_sum] map') - - -.. parsed-literal:: - - [276 253 231 210 190 171 153 136 120 105 91 78 66 55 45 36 28 21 15 10 6 3 1 0 0] - - -Factoring ``rest`` -~~~~~~~~~~~~~~~~~~ - -Right before the recursion begins we have: - -:: - - [] [1 2 3] [not] [pop] [[rest swons] dupdip rest] primrec - -But we might prefer to factor ``rest`` in the quote: - -:: - - [] [1 2 3] [not] [pop] [rest [swons] dupdip] primrec - -There's no way to do that with the ``paramorphism`` combinator as -defined. We would have to write and use a slightly different recursion -combinator that accepted an additional "preprocessor" function ``[H]`` -and built: - -:: - - n swap [P] [pop] [H [F] dupdip G] primrec - -Or just write it out manually. This is yet another place where the -*sufficiently smart compiler* will one day automatically refactor the -code. We could write a ``paramorphism`` combinator that checked ``[F]`` -and ``[G]`` for common prefix and extracted it. - -Patterns of Recursion -===================== - -Our story so far... - -- A combiner ``F :: (B, B) -> B`` -- A predicate ``P :: A -> Bool`` to detect the base case -- A base case value ``c :: B`` - -Hylo-, Ana-, Cata- -~~~~~~~~~~~~~~~~~~ - -:: - - w/ G :: A -> (A, B) - - H == [P ] [pop c ] [G ] [dip F ] genrec - A == [P ] [pop []] [G ] [dip swons] genrec - C == [[] =] [pop c ] [uncons swap] [dip F ] genrec - -Para-, ?-, ?- -~~~~~~~~~~~~~ - -:: - - w/ G :: B -> B - - P == c swap [P ] [pop] [[F ] dupdip G ] primrec - ? == [] swap [P ] [pop] [[swons] dupdip G ] primrec - ? == c swap [[] =] [pop] [[F ] dupdip uncons swap] primrec - -Four Generalizations -==================== - -There are at least four kinds of recursive combinator, depending on two -choices. The first choice is whether the combiner function should be -evaluated during the recursion or pushed into the pending expression to -be "collapsed" at the end. The second choice is whether the combiner -needs to operate on the current value of the datastructure or the -generator's output. - -:: - - H == [P] [pop c] [G ] [dip F] genrec - H == c swap [P] [pop] [G [F] dip ] [i] genrec - H == [P] [pop c] [ [G] dupdip ] [dip F] genrec - H == c swap [P] [pop] [ [F] dupdip G] [i] genrec - -Consider: - -:: - - ... a G [H] dip F w/ a G == a' b - ... c a G [F] dip H a G == b a' - ... a [G] dupdip [H] dip F a G == a' - ... c a [F] dupdip G H a G == a' - -1 -~ - -:: - - H == [P] [pop c] [G] [dip F] genrec - -Iterate n times. - -:: - - ... a [P] [pop c] [G] [dip F] genrec - ... a G [H] dip F - ... a' b [H] dip F - ... a' H b F - ... a' G [H] dip F b F - ... a'' b [H] dip F b F - ... a'' H b F b F - ... a'' G [H] dip F b F b F - ... a''' b [H] dip F b F b F - ... a''' H b F b F b F - ... a''' pop c b F b F b F - ... c b F b F b F - -This form builds up a continuation that contains the intermediate -results along with the pending combiner functions. When the base case is -reached the last term is replaced by the identity value c and the -continuation "collapses" into the final result. - -2 -~ - -When you can start with the identity value c on the stack and the -combiner can operate as you go, using the intermediate results -immediately rather than queuing them up, use this form. An important -difference is that the generator function must return its results in the -reverse order. - -:: - - H == c swap [P] [pop] [G [F] dip] primrec - - ... c a G [F] dip H - ... c b a' [F] dip H - ... c b F a' H - ... c b F a' G [F] dip H - ... c b F b a'' [F] dip H - ... c b F b F a'' H - ... c b F b F a'' G [F] dip H - ... c b F b F b a''' [F] dip H - ... c b F b F b F a''' H - ... c b F b F b F a''' pop - ... c b F b F b F - -The end line here is the same as for above, but only because we didn't -evaluate ``F`` when it normally would have been. - -3 -~ - -If the combiner and the generator both need to work on the current value -then ``dup`` must be used at some point, and the generator must produce -one item instead of two (the b is instead the duplicate of a.) - -:: - - H == [P] [pop c] [[G] dupdip] [dip F] genrec - - ... a [G] dupdip [H] dip F - ... a G a [H] dip F - ... a' a [H] dip F - ... a' H a F - ... a' [G] dupdip [H] dip F a F - ... a' G a' [H] dip F a F - ... a'' a' [H] dip F a F - ... a'' H a' F a F - ... a'' [G] dupdip [H] dip F a' F a F - ... a'' G a'' [H] dip F a' F a F - ... a''' a'' [H] dip F a' F a F - ... a''' H a'' F a' F a F - ... a''' pop c a'' F a' F a F - ... c a'' F a' F a F - -4 -~ - -And, last but not least, if you can combine as you go, starting with c, -and the combiner needs to work on the current item, this is the form: - -:: - - W == c swap [P] [pop] [[F] dupdip G] primrec - - ... a c swap [P] [pop] [[F] dupdip G] primrec - ... c a [P] [pop] [[F] dupdip G] primrec - ... c a [F] dupdip G W - ... c a F a G W - ... c a F a' W - ... c a F a' [F] dupdip G W - ... c a F a' F a' G W - ... c a F a' F a'' W - ... c a F a' F a'' [F] dupdip G W - ... c a F a' F a'' F a'' G W - ... c a F a' F a'' F a''' W - ... c a F a' F a'' F a''' pop - ... c a F a' F a'' F - -Each of the four variations above can be specialized to ana- and -catamorphic forms. - -.. code:: ipython2 - - def WTFmorphism(c, F, P, G): - '''Return a hylomorphism function H.''' - - def H(a, d=c): - if P(a): - result = d - else: - a, b = G(a) - result = H(a, F(d, b)) - return result - - return H - -.. code:: ipython2 - - F = lambda a, b: a + b - P = lambda n: n <= 1 - G = lambda n: (n - 1, n - 1) - - wtf = WTFmorphism(0, F, P, G) - - print wtf(5) - - -.. parsed-literal:: - - 10 - - -:: - - H == [P ] [pop c ] [G ] [dip F ] genrec - -.. code:: ipython2 - - DefinitionWrapper.add_definitions(''' - P == 1 <= - Ga == -- dup - Gb == -- - c == 0 - F == + - ''', D) - -.. code:: ipython2 - - V('[1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec') - - -.. parsed-literal:: - - . [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] genrec - [1 2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec - [1 2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec - [1 2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec - [1 2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec - [1 2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec - [1 2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[1 2 3]] [[] =] . infra first choice i - [1 2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i - [1 2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i - False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] swaack first choice i - False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [1 2 3]] . swaack first choice i - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i - [1 2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i - [1 2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons - 1 [2 3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons - [2 3] 1 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons - [2 3] 1 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons - [2 3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 1 swons - [2 3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 1 swons - [2 3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 1 swons - [2 3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 1 swons - [2 3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 1 swons - [2 3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[2 3]] [[] =] . infra first choice i 1 swons - [2 3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons - [2 3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons - False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] swaack first choice i 1 swons - False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [2 3]] . swaack first choice i 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 1 swons - [2 3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 1 swons - [2 3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons - 2 [3] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons - [3] 2 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 1 swons - [3] 2 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 1 swons - [3] . [[] =] [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons - [3] [[] =] . [pop []] [uncons swap] [dip swons] genrec 2 swons 1 swons - [3] [[] =] [pop []] . [uncons swap] [dip swons] genrec 2 swons 1 swons - [3] [[] =] [pop []] [uncons swap] . [dip swons] genrec 2 swons 1 swons - [3] [[] =] [pop []] [uncons swap] [dip swons] . genrec 2 swons 1 swons - [3] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[3]] [[] =] . infra first choice i 2 swons 1 swons - [3] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons - [3] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons - False . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] swaack first choice i 2 swons 1 swons - False [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [3]] . swaack first choice i 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons 1 swons - [3] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . i 2 swons 1 swons - [3] . uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons - 3 [] . swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons - [] 3 . [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons 2 swons 1 swons - [] 3 [[[] =] [pop []] [uncons swap] [dip swons] genrec] . dip swons 2 swons 1 swons - [] . [[] =] [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] . [pop []] [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] . [uncons swap] [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] [uncons swap] . [dip swons] genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] [uncons swap] [dip swons] . genrec 3 swons 2 swons 1 swons - [] [[] =] [pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] . ifte 3 swons 2 swons 1 swons - [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [[]] [[] =] . infra first choice i 3 swons 2 swons 1 swons - [] . [] = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons - [] [] . = [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons - True . [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] swaack first choice i 3 swons 2 swons 1 swons - True [[pop []] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] []] . swaack first choice i 3 swons 2 swons 1 swons - [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 3 swons 2 swons 1 swons - [] [uncons swap [[[] =] [pop []] [uncons swap] [dip swons] genrec] dip swons] [pop []] True . choice i 3 swons 2 swons 1 swons - [] [pop []] . i 3 swons 2 swons 1 swons - [] . pop [] 3 swons 2 swons 1 swons - . [] 3 swons 2 swons 1 swons - [] . 3 swons 2 swons 1 swons - [] 3 . swons 2 swons 1 swons - [] 3 . swap cons 2 swons 1 swons - 3 [] . cons 2 swons 1 swons - [3] . 2 swons 1 swons - [3] 2 . swons 1 swons - [3] 2 . swap cons 1 swons - 2 [3] . cons 1 swons - [2 3] . 1 swons - [2 3] 1 . swons - [2 3] 1 . swap cons - 1 [2 3] . cons - [1 2 3] . - - -.. code:: ipython2 - - V('3 [P] [pop c] [Ga] [dip F] genrec') - - -.. parsed-literal:: - - . 3 [P] [pop c] [Ga] [dip F] genrec - 3 . [P] [pop c] [Ga] [dip F] genrec - 3 [P] . [pop c] [Ga] [dip F] genrec - 3 [P] [pop c] . [Ga] [dip F] genrec - 3 [P] [pop c] [Ga] . [dip F] genrec - 3 [P] [pop c] [Ga] [dip F] . genrec - 3 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [3] [P] . infra first choice i - 3 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - 3 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - 3 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] swaack first choice i - False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 3] . swaack first choice i - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i - 3 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i - 3 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F - 3 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F - 2 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F - 2 2 . [[P] [pop c] [Ga] [dip F] genrec] dip F - 2 2 [[P] [pop c] [Ga] [dip F] genrec] . dip F - 2 . [P] [pop c] [Ga] [dip F] genrec 2 F - 2 [P] . [pop c] [Ga] [dip F] genrec 2 F - 2 [P] [pop c] . [Ga] [dip F] genrec 2 F - 2 [P] [pop c] [Ga] . [dip F] genrec 2 F - 2 [P] [pop c] [Ga] [dip F] . genrec 2 F - 2 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [2] [P] . infra first choice i 2 F - 2 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - 2 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - 2 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - False . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] swaack first choice i 2 F - False [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 2] . swaack first choice i 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] False . choice i 2 F - 2 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . i 2 F - 2 . Ga [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 2 . -- dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 1 . dup [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 1 1 . [[P] [pop c] [Ga] [dip F] genrec] dip F 2 F - 1 1 [[P] [pop c] [Ga] [dip F] genrec] . dip F 2 F - 1 . [P] [pop c] [Ga] [dip F] genrec 1 F 2 F - 1 [P] . [pop c] [Ga] [dip F] genrec 1 F 2 F - 1 [P] [pop c] . [Ga] [dip F] genrec 1 F 2 F - 1 [P] [pop c] [Ga] . [dip F] genrec 1 F 2 F - 1 [P] [pop c] [Ga] [dip F] . genrec 1 F 2 F - 1 [P] [pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] . ifte 1 F 2 F - 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [1] [P] . infra first choice i 1 F 2 F - 1 . P [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - 1 . 1 <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - 1 1 . <= [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - True . [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] swaack first choice i 1 F 2 F - True [[pop c] [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] 1] . swaack first choice i 1 F 2 F - 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F - 1 [Ga [[P] [pop c] [Ga] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F - 1 [pop c] . i 1 F 2 F - 1 . pop c 1 F 2 F - . c 1 F 2 F - . 0 1 F 2 F - 0 . 1 F 2 F - 0 1 . F 2 F - 0 1 . + 2 F - 1 . 2 F - 1 2 . F - 1 2 . + - 3 . - - -.. code:: ipython2 - - V('3 [P] [pop []] [Ga] [dip swons] genrec') - - -.. parsed-literal:: - - . 3 [P] [pop []] [Ga] [dip swons] genrec - 3 . [P] [pop []] [Ga] [dip swons] genrec - 3 [P] . [pop []] [Ga] [dip swons] genrec - 3 [P] [pop []] . [Ga] [dip swons] genrec - 3 [P] [pop []] [Ga] . [dip swons] genrec - 3 [P] [pop []] [Ga] [dip swons] . genrec - 3 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [3] [P] . infra first choice i - 3 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - 3 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - 3 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] swaack first choice i - False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 3] . swaack first choice i - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i - 3 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i - 3 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 3 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 2 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 2 2 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons - 2 2 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons - 2 . [P] [pop []] [Ga] [dip swons] genrec 2 swons - 2 [P] . [pop []] [Ga] [dip swons] genrec 2 swons - 2 [P] [pop []] . [Ga] [dip swons] genrec 2 swons - 2 [P] [pop []] [Ga] . [dip swons] genrec 2 swons - 2 [P] [pop []] [Ga] [dip swons] . genrec 2 swons - 2 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [2] [P] . infra first choice i 2 swons - 2 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - 2 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - 2 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - False . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] swaack first choice i 2 swons - False [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 2] . swaack first choice i 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [False] . first choice i 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] False . choice i 2 swons - 2 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . i 2 swons - 2 . Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 2 . -- dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 1 . dup [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 1 1 . [[P] [pop []] [Ga] [dip swons] genrec] dip swons 2 swons - 1 1 [[P] [pop []] [Ga] [dip swons] genrec] . dip swons 2 swons - 1 . [P] [pop []] [Ga] [dip swons] genrec 1 swons 2 swons - 1 [P] . [pop []] [Ga] [dip swons] genrec 1 swons 2 swons - 1 [P] [pop []] . [Ga] [dip swons] genrec 1 swons 2 swons - 1 [P] [pop []] [Ga] . [dip swons] genrec 1 swons 2 swons - 1 [P] [pop []] [Ga] [dip swons] . genrec 1 swons 2 swons - 1 [P] [pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] . ifte 1 swons 2 swons - 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [1] [P] . infra first choice i 1 swons 2 swons - 1 . P [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - 1 . 1 <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - 1 1 . <= [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - True . [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] swaack first choice i 1 swons 2 swons - True [[pop []] [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] 1] . swaack first choice i 1 swons 2 swons - 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] [True] . first choice i 1 swons 2 swons - 1 [Ga [[P] [pop []] [Ga] [dip swons] genrec] dip swons] [pop []] True . choice i 1 swons 2 swons - 1 [pop []] . i 1 swons 2 swons - 1 . pop [] 1 swons 2 swons - . [] 1 swons 2 swons - [] . 1 swons 2 swons - [] 1 . swons 2 swons - [] 1 . swap cons 2 swons - 1 [] . cons 2 swons - [1] . 2 swons - [1] 2 . swons - [1] 2 . swap cons - 2 [1] . cons - [2 1] . - - -.. code:: ipython2 - - V('[2 1] [[] =] [pop c ] [uncons swap] [dip F] genrec') - - -.. parsed-literal:: - - . [2 1] [[] =] [pop c] [uncons swap] [dip F] genrec - [2 1] . [[] =] [pop c] [uncons swap] [dip F] genrec - [2 1] [[] =] . [pop c] [uncons swap] [dip F] genrec - [2 1] [[] =] [pop c] . [uncons swap] [dip F] genrec - [2 1] [[] =] [pop c] [uncons swap] . [dip F] genrec - [2 1] [[] =] [pop c] [uncons swap] [dip F] . genrec - [2 1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[2 1]] [[] =] . infra first choice i - [2 1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i - [2 1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i - False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] swaack first choice i - False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [2 1]] . swaack first choice i - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i - [2 1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i - [2 1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F - 2 [1] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F - [1] 2 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F - [1] 2 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F - [1] . [[] =] [pop c] [uncons swap] [dip F] genrec 2 F - [1] [[] =] . [pop c] [uncons swap] [dip F] genrec 2 F - [1] [[] =] [pop c] . [uncons swap] [dip F] genrec 2 F - [1] [[] =] [pop c] [uncons swap] . [dip F] genrec 2 F - [1] [[] =] [pop c] [uncons swap] [dip F] . genrec 2 F - [1] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[1]] [[] =] . infra first choice i 2 F - [1] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F - [1] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F - False . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] swaack first choice i 2 F - False [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [1]] . swaack first choice i 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [False] . first choice i 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] False . choice i 2 F - [1] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . i 2 F - [1] . uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F - 1 [] . swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F - [] 1 . [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F 2 F - [] 1 [[[] =] [pop c] [uncons swap] [dip F] genrec] . dip F 2 F - [] . [[] =] [pop c] [uncons swap] [dip F] genrec 1 F 2 F - [] [[] =] . [pop c] [uncons swap] [dip F] genrec 1 F 2 F - [] [[] =] [pop c] . [uncons swap] [dip F] genrec 1 F 2 F - [] [[] =] [pop c] [uncons swap] . [dip F] genrec 1 F 2 F - [] [[] =] [pop c] [uncons swap] [dip F] . genrec 1 F 2 F - [] [[] =] [pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] . ifte 1 F 2 F - [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [[]] [[] =] . infra first choice i 1 F 2 F - [] . [] = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F - [] [] . = [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F - True . [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] swaack first choice i 1 F 2 F - True [[pop c] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] []] . swaack first choice i 1 F 2 F - [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] [True] . first choice i 1 F 2 F - [] [uncons swap [[[] =] [pop c] [uncons swap] [dip F] genrec] dip F] [pop c] True . choice i 1 F 2 F - [] [pop c] . i 1 F 2 F - [] . pop c 1 F 2 F - . c 1 F 2 F - . 0 1 F 2 F - 0 . 1 F 2 F - 0 1 . F 2 F - 0 1 . + 2 F - 1 . 2 F - 1 2 . F - 1 2 . + - 3 . - - -Appendix - Fun with Symbols ---------------------------- - -:: - - |[ (c, F), (G, P) ]| == (|c, F|) • [(G, P)] - -`"Bananas, Lenses, & Barbed -Wire" `__ - -:: - - (|...|) [(...)] [<...>] - -I think they are having slightly too much fun with the symbols. - -"Too much is always better than not enough." - -Tree with node and list of trees. -================================= - -:: - - tree = [] | [node [tree*]] - -``treestep`` -~~~~~~~~~~~~ - -:: - - tree z [C] [N] treestep - - - [] z [C] [N] treestep - --------------------------- - z - - - [node [tree*]] z [C] [N] treestep - --------------------------------------- w/ K == z [C] [N] treestep - node N [tree*] [K] map C - -Derive the recursive form. -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - K == [not] [pop z] [J] ifte - - - [node [tree*]] J - ------------------------------ - node N [tree*] [K] map C - - - J == .. [N] .. [K] .. [C] .. - - [node [tree*]] uncons [N] dip - node [[tree*]] [N] dip - node N [[tree*]] - - node N [[tree*]] i [K] map - node N [tree*] [K] map - node N [K.tree*] - - J == uncons [N] dip i [K] map [C] i - - K == [not] [pop z] [uncons [N] dip i [K] map [C] i] ifte - K == [not] [pop z] [uncons [N] dip i] [map [C] i] genrec - -Extract the givens to parameterize the program. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - [not] [pop z] [uncons [N] dip unquote] [map [C] i] genrec - [not] [z] [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec - [not] z unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec - z [not] swap unit [pop] swoncat [uncons [N] dip unquote] [map [C] i] genrec - \............TS0............/ - z TS0 [uncons [N] dip unquote] [map [C] i] genrec - z [uncons [N] dip unquote] [TS0] dip [map [C] i] genrec - z [[N] dip unquote] [uncons] swoncat [TS0] dip [map [C] i] genrec - z [N] [dip unquote] cons [uncons] swoncat [TS0] dip [map [C] i] genrec - \...........TS1.................../ - z [N] TS1 [TS0] dip [map [C] i] genrec - z [N] [map [C] i] [TS1 [TS0] dip] dip genrec - z [N] [map C ] [TS1 [TS0] dip] dip genrec - z [N] [C] [map] swoncat [TS1 [TS0] dip] dip genrec - z [C] [N] swap [map] swoncat [TS1 [TS0] dip] dip genrec - -:: - - TS0 == [not] swap unit [pop] swoncat - TS1 == [dip i] cons [uncons] swoncat - treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec - -:: - - [] 0 [C] [N] treestep - --------------------------- - 0 - - - [n [tree*]] 0 [sum +] [] treestep - -------------------------------------------------- - n [tree*] [0 [sum +] [] treestep] map sum + - -.. code:: ipython2 - - DefinitionWrapper.add_definitions(''' - - TS0 == [not] swap unit [pop] swoncat - TS1 == [dip i] cons [uncons] swoncat - treestep == swap [map] swoncat [TS1 [TS0] dip] dip genrec - - ''', D) - -.. code:: ipython2 - - V('[] 0 [sum +] [] treestep') - - -.. parsed-literal:: - - . [] 0 [sum +] [] treestep - [] . 0 [sum +] [] treestep - [] 0 . [sum +] [] treestep - [] 0 [sum +] . [] treestep - [] 0 [sum +] [] . treestep - [] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec - [] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec - [] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec - [] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec - [] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec - [] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec - [] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec - [] 0 [] . TS1 [TS0] dip [map sum +] genrec - [] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec - [] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec - [] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec - [] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec - [] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec - [] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec - [] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec - [] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec - [] 0 . TS0 [uncons [] dip i] [map sum +] genrec - [] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec - [] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec - [] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec - [] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec - [] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec - [] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec - [] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec - [] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte - [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[]] [not] . infra first choice i - [] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i - True . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] swaack first choice i - True [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] []] . swaack first choice i - [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [True] . first choice i - [] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] True . choice i - [] [pop 0] . i - [] . pop 0 - . 0 - 0 . - - -.. code:: ipython2 - - V('[23 []] 0 [sum +] [] treestep') - - -.. parsed-literal:: - - . [23 []] 0 [sum +] [] treestep - [23 []] . 0 [sum +] [] treestep - [23 []] 0 . [sum +] [] treestep - [23 []] 0 [sum +] . [] treestep - [23 []] 0 [sum +] [] . treestep - [23 []] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec - [23 []] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec - [23 []] 0 [] . TS1 [TS0] dip [map sum +] genrec - [23 []] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec - [23 []] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec - [23 []] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec - [23 []] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec - [23 []] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec - [23 []] 0 . TS0 [uncons [] dip i] [map sum +] genrec - [23 []] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec - [23 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec - [23 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec - [23 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec - [23 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 []]] [not] . infra first choice i - [23 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i - False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] swaack first choice i - False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 []]] . swaack first choice i - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i - [23 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i - [23 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + - 23 [] . sum + - 23 [] . 0 [+] catamorphism + - 23 [] 0 . [+] catamorphism + - 23 [] 0 [+] . catamorphism + - 23 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + - 23 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + - 23 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + - 23 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + - 23 [] [[] =] 0 [uncons swap] [+] . hylomorphism + - 23 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + - 23 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + - 23 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + - 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + - 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i + - 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i + - 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i + - 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i + - 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + - 23 [] [pop 0] . i + - 23 [] . pop 0 + - 23 . 0 + - 23 0 . + - 23 . - - -.. code:: ipython2 - - V('[23 [[2 []] [3 []]]] 0 [sum +] [] treestep') - - -.. parsed-literal:: - - . [23 [[2 []] [3 []]]] 0 [sum +] [] treestep - [23 [[2 []] [3 []]]] . 0 [sum +] [] treestep - [23 [[2 []] [3 []]]] 0 . [sum +] [] treestep - [23 [[2 []] [3 []]]] 0 [sum +] . [] treestep - [23 [[2 []] [3 []]]] 0 [sum +] [] . treestep - [23 [[2 []] [3 []]]] 0 [sum +] [] . swap [map] swoncat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [sum +] . [map] swoncat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swoncat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [sum +] [map] . swap concat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [map] [sum +] . concat [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [map sum +] . [TS1 [TS0] dip] dip genrec - [23 [[2 []] [3 []]]] 0 [] [map sum +] [TS1 [TS0] dip] . dip genrec - [23 [[2 []] [3 []]]] 0 [] . TS1 [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [] . [dip i] cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [] [dip i] . cons [uncons] swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [[] dip i] . [uncons] swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swoncat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [[] dip i] [uncons] . swap concat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [uncons] [[] dip i] . concat [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [uncons [] dip i] . [TS0] dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [uncons [] dip i] [TS0] . dip [map sum +] genrec - [23 [[2 []] [3 []]]] 0 . TS0 [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] 0 . [not] swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] 0 [not] . swap unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] 0 . unit [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] 0 . [] cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] 0 [] . cons [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [0] . [pop] swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [0] [pop] . swoncat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [0] [pop] . swap concat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop] [0] . concat [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec - [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec - [23 [[2 []] [3 []]]] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[23 [[2 []] [3 []]]]] [not] . infra first choice i - [23 [[2 []] [3 []]]] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i - False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] swaack first choice i - False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [23 [[2 []] [3 []]]]] . swaack first choice i - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False] . first choice i - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i - [23 [[2 []] [3 []]]] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i - [23 [[2 []] [3 []]]] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[[2 []] [3 []]]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[[2 []] [3 []]]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [[[2 []] [3 []]]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[[2 []] [3 []]]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 . [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[2 []] [3 []]] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + - 23 [[2 []] [3 []]] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + - 23 [] [[[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first] . infra sum + - . [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - [[3 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - [[3 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[3 []] 23] [not] . infra first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [3 []] 23] . swaack first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 [3 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . sum + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . 0 [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 . [+] catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 [+] . catamorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 3 23] [[] =] . infra first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 3 23] . swaack first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 3 23] . first choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] [pop 0] . i + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . pop 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . 0 + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 0 . + [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 . [] swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 23 3 [] . swaack first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - [3 23] . first [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 3 . [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 3 [[2 []] 23] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] infra first [23] swaack sum + - 3 [[2 []] 23] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . infra first [23] swaack sum + - 23 [2 []] . [not] [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] . [pop 0] [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] . [uncons [] dip i] [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] [uncons [] dip i] . [map sum +] genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] [uncons [] dip i] [map sum +] . genrec [3] swaack first [23] swaack sum + - 23 [2 []] [not] [pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . ifte [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [[2 []] 23] [not] . infra first choice i [3] swaack first [23] swaack sum + - 23 [2 []] . not [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum + - 23 False . [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] swaack first choice i [3] swaack first [23] swaack sum + - 23 False [[pop 0] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [2 []] 23] . swaack first choice i [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] [False 23] . first choice i [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] [pop 0] False . choice i [3] swaack first [23] swaack sum + - 23 [2 []] [uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum +] . i [3] swaack first [23] swaack sum + - 23 [2 []] . uncons [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [[]] . [] dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [[]] [] . dip i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 . [[]] i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [[]] . i [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 . [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [] . [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] map sum + [3] swaack first [23] swaack sum + - 23 2 [] [[not] [pop 0] [uncons [] dip i] [map sum +] genrec] . map sum + [3] swaack first [23] swaack sum + - 23 2 [] . sum + [3] swaack first [23] swaack sum + - 23 2 [] . 0 [+] catamorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 . [+] catamorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 [+] . catamorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [+] . [uncons swap] swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [+] [uncons swap] . swap hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [uncons swap] [+] . hylomorphism + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec + [3] swaack first [23] swaack sum + - 23 2 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + [3] swaack first [23] swaack sum + - 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 2 23] [[] =] . infra first choice i + [3] swaack first [23] swaack sum + - 23 2 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 2 23] . swaack first choice i + [3] swaack first [23] swaack sum + - 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 2 23] . first choice i + [3] swaack first [23] swaack sum + - 23 2 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i + [3] swaack first [23] swaack sum + - 23 2 [] [pop 0] . i + [3] swaack first [23] swaack sum + - 23 2 [] . pop 0 + [3] swaack first [23] swaack sum + - 23 2 . 0 + [3] swaack first [23] swaack sum + - 23 2 0 . + [3] swaack first [23] swaack sum + - 23 2 . [3] swaack first [23] swaack sum + - 23 2 [3] . swaack first [23] swaack sum + - 3 [2 23] . first [23] swaack sum + - 3 2 . [23] swaack sum + - 3 2 [23] . swaack sum + - 23 [2 3] . sum + - 23 [2 3] . 0 [+] catamorphism + - 23 [2 3] 0 . [+] catamorphism + - 23 [2 3] 0 [+] . catamorphism + - 23 [2 3] 0 [+] . [[] =] roll> [uncons swap] swap hylomorphism + - 23 [2 3] 0 [+] [[] =] . roll> [uncons swap] swap hylomorphism + - 23 [2 3] [[] =] 0 [+] . [uncons swap] swap hylomorphism + - 23 [2 3] [[] =] 0 [+] [uncons swap] . swap hylomorphism + - 23 [2 3] [[] =] 0 [uncons swap] [+] . hylomorphism + - 23 [2 3] [[] =] 0 [uncons swap] [+] . [unit [pop] swoncat] dipd [dip] swoncat genrec + - 23 [2 3] [[] =] 0 [uncons swap] [+] [unit [pop] swoncat] . dipd [dip] swoncat genrec + - 23 [2 3] [[] =] 0 . unit [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] 0 . [] cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] 0 [] . cons [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [0] . [pop] swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [0] [pop] . swoncat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [0] [pop] . swap concat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop] [0] . concat [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] . [uncons swap] [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] . [+] [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [+] . [dip] swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swoncat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [+] [dip] . swap concat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [dip] [+] . concat genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap] [dip +] . genrec + - 23 [2 3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[2 3] 23] [[] =] . infra first choice i + - 23 [2 3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i + - 23 [2 3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i + - 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] swaack first choice i + - 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [2 3] 23] . swaack first choice i + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i + - 23 [2 3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i + - 23 [2 3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + + - 23 2 [3] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + + - 23 [3] 2 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + + - 23 [3] 2 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + + - 23 [3] . [[] =] [pop 0] [uncons swap] [dip +] genrec 2 + + - 23 [3] [[] =] . [pop 0] [uncons swap] [dip +] genrec 2 + + - 23 [3] [[] =] [pop 0] . [uncons swap] [dip +] genrec 2 + + - 23 [3] [[] =] [pop 0] [uncons swap] . [dip +] genrec 2 + + - 23 [3] [[] =] [pop 0] [uncons swap] [dip +] . genrec 2 + + - 23 [3] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[3] 23] [[] =] . infra first choice i 2 + + - 23 [3] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + + - 23 [3] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + + - 23 False . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] swaack first choice i 2 + + - 23 False [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [3] 23] . swaack first choice i 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [False 23] . first choice i 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] False . choice i 2 + + - 23 [3] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . i 2 + + - 23 [3] . uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + + - 23 3 [] . swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + + - 23 [] 3 . [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip + 2 + + - 23 [] 3 [[[] =] [pop 0] [uncons swap] [dip +] genrec] . dip + 2 + + - 23 [] . [[] =] [pop 0] [uncons swap] [dip +] genrec 3 + 2 + + - 23 [] [[] =] . [pop 0] [uncons swap] [dip +] genrec 3 + 2 + + - 23 [] [[] =] [pop 0] . [uncons swap] [dip +] genrec 3 + 2 + + - 23 [] [[] =] [pop 0] [uncons swap] . [dip +] genrec 3 + 2 + + - 23 [] [[] =] [pop 0] [uncons swap] [dip +] . genrec 3 + 2 + + - 23 [] [[] =] [pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] . ifte 3 + 2 + + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [[] 23] [[] =] . infra first choice i 3 + 2 + + - 23 [] . [] = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + + - 23 [] [] . = [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + + - 23 True . [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] swaack first choice i 3 + 2 + + - 23 True [[pop 0] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [] 23] . swaack first choice i 3 + 2 + + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] [True 23] . first choice i 3 + 2 + + - 23 [] [uncons swap [[[] =] [pop 0] [uncons swap] [dip +] genrec] dip +] [pop 0] True . choice i 3 + 2 + + - 23 [] [pop 0] . i 3 + 2 + + - 23 [] . pop 0 3 + 2 + + - 23 . 0 3 + 2 + + - 23 0 . 3 + 2 + + - 23 0 3 . + 2 + + - 23 3 . 2 + + - 23 3 2 . + + - 23 5 . + - 28 . - - -.. code:: ipython2 - - J('[23 [[2 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]] [3 [[23 [[2 []] [3 []]]][23 [[2 []] [3 []]]]]]]] 0 [sum +] [] treestep') - - -.. parsed-literal:: - - 140 - - -.. code:: ipython2 - - J('[] [] [unit cons] [23 +] treestep') - - -.. parsed-literal:: - - [] - - -.. code:: ipython2 - - J('[23 []] [] [unit cons] [23 +] treestep') - - -.. parsed-literal:: - - [46 []] - - -.. code:: ipython2 - - J('[23 [[2 []] [3 []]]] [] [unit cons] [23 +] treestep') - - -.. parsed-literal:: - - [46 [[25 []] [26 []]]] - - -.. code:: ipython2 - - define('treemap == [] [unit cons] roll< treestep') - -.. code:: ipython2 - - J('[23 [[2 []] [3 []]]] [23 +] treemap') - - -.. parsed-literal:: - - [46 [[25 []] [26 []]]] - diff --git a/docs/Library Examples.pdf b/docs/Library Examples.pdf deleted file mode 100644 index c534cacbc306d00ce08cde278bf40a42847bcb21..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 198245 zcmb5WW0d6IvMpM+U0t^AF5B#~ZJS-TZQHhO+qUhh+xy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. - -All of the notebooks are also available as HTML and Markdown files (generated using nbconvert) so you can view them without running Jupyter. - -In order to run the [Jupyter Notebooks](https://jupyter.org/index.html) you need Jupyter (obviously) and you should install `Joypy`. Here's an example using `virtualenv` from the `joypy/` directory: - - virtualenv --system-site-packages - . .//bin/activate - python ./setup.py install - -Once that's done you should be able to start Jupyter Notebook server with, e.g.: - - python -n notebook - -This starts it using the `virtualenv` version of Python so `joy` will be available. Navigate to the `joypy/docs` directory and the notebooks should be able to import the `notebook_preamble.py` file. - -## Table of Contents - -- 1. Basic Use of Joy in a Notebook -- 2. Library Examples - Short examples of each word in the dictionary. Various formats. -- 3. Developing a Program - Working with the first problem from Project Euler, "Find the sum of all the multiples of 3 or 5 below 1000", several forms of the program are derived. -- 4. Replacing Functions in the Dictionary - Shows the basics of defining new "primitive" functions in Python or as definitions and adding them to the dictionary. -- Factorial Function and Paramorphisms - A basic pattern of recursive control-flow. -- Generator Programs - Using the x combinator to make generator programs which can be used to create unbounded streams of values. -- Hylo-, Ana-, Cata-morphisms - Some basic patterns of recursive control-flow structures. -- Quadratic - Not-so-annoying Quadratic Formula. -- Trees - Ordered Binary Trees in Joy and more recursion. -- Zipper - A preliminary examination of the idea of data-structure "zippers" for traversing datastructures. -- notebook_preamble.py - Imported into notebooks to simplify the preamble code. -- pe1.py pe1.txt - Set up and execute a Joy program for the first problem from Project Euler. The pe1.txt file is the trace. It's 2.8M uncompressed. Compressed with gzip it becomes just 0.12M. -- repl.py - Run this script to start a REPL. Useful for e.g. running Joy code in a debugger. - -## Notes - -One of the things that interests me about Joy is how programming becomes -less about writing code and more about sound reasoning about simple -(almost geometric) programs. Many of the notebooks in this collection -consist of several pages of discussion to arrive at a few lines of Joy -definitions. I think this is a good thing. This is "literate -programming". The "programs" resemble mathematical proofs. You aren't -implementing so much as deriving. The structure of Joy seems to force -you to think clearly about the task in a way that is reliable but -extremely flexible. It feels like a puzzle game, and the puzzles are -often simple, and the solutions build on each other.