diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-05-11 06:51:16 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-05-11 06:51:16 -0700 |
commit | 00e87d26df9f2cd0580b48f92db8ea93a845fbf7 (patch) | |
tree | 71552622c8baddcc82c3b7f4ba53f9884e66a952 /tests | |
parent | 25b5bdc5dfe62037faef8f19c070de434b660aa6 (diff) | |
download | txr-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 'tests')
-rw-r--r-- | tests/010/tree.tl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/010/tree.tl b/tests/010/tree.tl index ed86c076..38144476 100644 --- a/tests/010/tree.tl +++ b/tests/010/tree.tl @@ -33,6 +33,24 @@ (tree-lookup tr 18) 18 (tree-lookup tr 19) 19) +(mtest + [tr 0] 0 + [tr 5] 5 + [tr 19] 19) + +(mtest + [tr 0..3] (0 1 2) + [tr 3..5] (3 4) + [tr -2..0] () + [tr -2..4] (0 1 2 3) + [tr :..4] (0 1 2 3) + [tr 18..100] (18 19) + [tr 18..:] (18 19) + [tr 100..200] ()) + +(vtest + [tr :..:] (range 0 19)) + (vtest (build (for* ((i (tree-begin tr)) (n (tree-next i))) (n) |