summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-11 06:51:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-11 06:51:16 -0700
commit00e87d26df9f2cd0580b48f92db8ea93a845fbf7 (patch)
tree71552622c8baddcc82c3b7f4ba53f9884e66a952 /txr.1
parent25b5bdc5dfe62037faef8f19c070de434b660aa6 (diff)
downloadtxr-00e87d26df9f2cd0580b48f92db8ea93a845fbf7.tar.gz
txr-00e87d26df9f2cd0580b48f92db8ea93a845fbf7.tar.bz2
txr-00e87d26df9f2cd0580b48f92db8ea93a845fbf7.zip
tree: support indexing and range extraction.
* lib.c (do_generic_funcall): Support tree object invocation with one or two arguments via sub and ref. (sub): Implement for trees via sub_tree. (ref): Implement for trees via tree_lookup. * tree.c (sub_tree): New function. (tree_init): Register sub-tree intrinsic. * tree.h (sub_tree): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented: DWIM bracket syntax on trees, sub and ref support for trees, sub-tree function, * share/txr/stdlib/doc-syms.tl: Regenerated.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.175
1 files changed, 75 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 814147e2..9f19355d 100644
--- a/txr.1
+++ b/txr.1
@@ -15145,6 +15145,19 @@ if there is no such entry. The expression
.meta alt
is always evaluated, whether or not its value is used.
+.meIP >> [ search-tree << key ]
+Retrieves an element from the search tree as if by applying the
+.code tree-lookup
+function to
+.metn key .
+
+.meIP >> [ search-tree << from-key .. to-below-key ]
+Retrieves a list of elements from the search tree as if by evaluating the
+.mono
+.meti (sub-tree < search-tree < from-key << to-below-key )
+.onom
+expression.
+
.meIP >> [ regex >> [ start <> [ from-end ]] < string ]
Determine whether regular expression
.meta regex
@@ -30605,6 +30618,18 @@ object, then the function behaves like
If
.meta sequence
+is a
+.code tree
+object, then the function behaves like
+.codn sub-tree .
+Note: because
+.code sub-tree
+is not an accessor, assigning to the
+.code sub
+syntax in this case will produce an error.
+
+If
+.meta sequence
is a structure, it must support the
.code lambda
method. The
@@ -31592,6 +31617,16 @@ are erroneous. For hashes, accesses to nonexistent elements
are treated leniently, and produce
.codn nil .
+If
+.meta sequence
+is a search tree, then
+.code ref
+behaves like
+.codn tree-lookup .
+The
+.code refset
+function is not supported by search trees.
+
The
.code refset
function is strict for out-of-range indices over all sequences,
@@ -51925,6 +51960,46 @@ is invoked more than once on the same iterator without any intervening calls to
it returns the same node; it does not appear to change the state of
the iterator and therefore does not advance through successive nodes.
+.coNP Function @ sub-tree
+.synb
+.mets (sub-tree < tree >> [ from-key <> [ to-key ]])
+.syne
+.desc
+The
+.code sub-tree
+function selects those elements elements in
+.meta tree
+which are not less than
+.meta from-key
+but less than
+.metn to-key .
+
+If only the
+.meta from-key
+argument is specified, then
+.code sub-tree
+selects those elements which are not less than
+.metn from-key .
+
+Similarly, if only the
+.meta to-key
+argument is specified, then
+.code sub-tree
+selects those elements which are less than
+.metn to-key .
+
+If neither
+.meta from-key
+nor
+.meta to-key
+are specified, then
+.code sub-tree
+selects all elements from the tree.
+
+A list of the selected elements is returned, in which the elements appear in
+the same order as they do in
+.metn tree .
+
.coNP Function @ copy-tree-iter
.synb
.mets (copy-tree-iter < iter )