Bumped version to 0.2.0; docs edits.
I've added cond and cmp to the library so that should bump the minor version no. I think.
This commit is contained in:
@@ -336,7 +336,7 @@ Example:
|
||||
|
||||
|
||||
Now we can define ``Tree-add``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
@@ -361,7 +361,7 @@ Putting it all together:
|
||||
define('Tree-add == [popop not] [[pop] dipd Tree-new] [] [[P >] [T] [E] ifte] genrec')
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
~~~~~~~~
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
@@ -594,7 +594,7 @@ Let's look at it *in situ*:
|
||||
[key value left right] R0 [Tree-iter] R1
|
||||
|
||||
Processing the current node.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
``R0`` is almost certainly going to use ``dup`` to make a copy of the
|
||||
node and then ``dip`` on some function to process the copy with it:
|
||||
@@ -615,7 +615,7 @@ For example, if we're getting all the keys ``F`` would be ``first``:
|
||||
key [key value left right] [Tree-iter] R1
|
||||
|
||||
Recur
|
||||
~~~~~
|
||||
^^^^^
|
||||
|
||||
Now ``R1`` needs to apply ``[Tree-iter]`` to ``left`` and ``right``. If
|
||||
we drop the key and value from the node using ``rest`` twice we are left
|
||||
@@ -680,7 +680,7 @@ Working backward:
|
||||
[F] [not] [pop] roll< [dupdip rest rest] cons [step] genrec
|
||||
|
||||
``Tree-iter``
|
||||
-------------
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
@@ -691,7 +691,7 @@ Working backward:
|
||||
define('Tree-iter == [not] [pop] roll< [dupdip rest rest] cons [step] genrec')
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
~~~~~~~~
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
@@ -793,7 +793,7 @@ when they run:
|
||||
[key value left right] R0 [BTree-iter-order] R1
|
||||
|
||||
Process the left child.
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Staring at this for a bit suggests ``dup third`` to start:
|
||||
|
||||
@@ -813,7 +813,7 @@ Now maybe:
|
||||
left Tree-iter-order [key value left right] [Tree-iter-order]
|
||||
|
||||
Process the current node.
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
So far, so good. Now we need to process the current node's values:
|
||||
|
||||
@@ -833,7 +833,7 @@ works fine as-is.
|
||||
left Tree-iter-order key [key value left right] [Tree-iter-order]
|
||||
|
||||
Process the right child.
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
First ditch the rest of the node and get the right child:
|
||||
|
||||
@@ -851,7 +851,7 @@ right side:
|
||||
left Tree-iter-order key right Tree-iter-order
|
||||
|
||||
Defining ``Tree-iter-order``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The result is a little awkward:
|
||||
|
||||
@@ -938,7 +938,7 @@ have to decide for yourself what ``[E]`` should be.
|
||||
[] key E
|
||||
|
||||
The base case ``[]``
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
As before, the stopping predicate just has to detect the empty list:
|
||||
|
||||
@@ -969,7 +969,7 @@ The anonymous specialized recursive function that will do the real work.
|
||||
[pop not] [E] [R0] [R1] genrec
|
||||
|
||||
Node case ``[key value left right]``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Now we need to figure out ``R0`` and ``R1``:
|
||||
|
||||
@@ -986,8 +986,8 @@ and ``R1 == P [T>] [E] [T<] cmp``:
|
||||
|
||||
[key value left right] key [BTree-get] P [T>] [E] [T<] cmp
|
||||
|
||||
Predicate:
|
||||
^^^^^^^^^^
|
||||
Predicate
|
||||
^^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
@@ -1142,7 +1142,7 @@ So:
|
||||
|
||||
|
||||
Tree-delete
|
||||
===========
|
||||
-----------
|
||||
|
||||
Now let's write a function that can return a tree datastructure with a
|
||||
key, value pair deleted:
|
||||
|
||||
Reference in New Issue
Block a user