diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-10-03 17:38:31 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-10-03 17:38:31 -0700 |
commit | ea991039e9f7e9254a283e4eca92b6f8a9090425 (patch) | |
tree | c7dc34c289b353a137862066506afee09148581a | |
parent | 53b4090be0ed161aadf9a7c36ebc896f3e131a1f (diff) | |
download | txr-ea991039e9f7e9254a283e4eca92b6f8a9090425.tar.gz txr-ea991039e9f7e9254a283e4eca92b6f8a9090425.tar.bz2 txr-ea991039e9f7e9254a283e4eca92b6f8a9090425.zip |
* txr.1: Starte dodcumenting the forgotten merge directive.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | txr.1 | 24 |
2 files changed, 28 insertions, 0 deletions
@@ -1,5 +1,9 @@ 2011-10-03 Kaz Kylheku <kaz@kylheku.com> + * txr.1: Starte dodcumenting the forgotten merge directive. + +2011-10-03 Kaz Kylheku <kaz@kylheku.com> + Implemented new last clause for collect and coll. Bugfix in cases inside coll: was not collecting bindings. Bugfix for until inside coll: was not seeing bindings @@ -1832,6 +1832,30 @@ Example (with flatten): a[3]="4" a[4]="5" +.SS The Merge Directive + +The merge directive provides a way of combining two or more variables +in a somewhat complicated but very useful way. + +To understand what merge does we first have to define a property called depth. +The depth of an atom such as a string is defined as 1. The depth of an empty +list is 0. The depth of a nonempty list is one plus the depth of its deepest +element. So for instance "foo" has depth 1, ("foo") has depth 2, and ("foo" +("bar")) has depth three. + +We can now define the binary (two argument) merge operation as follows. (merge +A B) first normalizes the values A and B such that they have normal depth. +1. A value which has depth zero is put into a one element list. +2. If either value has a smaller depth than the other, it is wrapped +in a list as many times as needed to give it equal depth. +Finally, the values are appended together. + +Merge takes more than two arguments. These are merged by a left reduction. The +leftmost two values are merged, and then this result is merged with the third +value, and so on. + +Merge is useful for combining the results from collects at different +levels of nesting such that elements are at the appropriate depth. .SS The Cat Directive |