summaryrefslogtreecommitdiffstats
path: root/tests/perm.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-04-29 19:20:15 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-04-29 19:20:15 -0700
commit853e299c38e5514810574b1094136d64ed375831 (patch)
treed90a1490ab52a43bdc08f6d9a87c23c51a82f532 /tests/perm.tl
parent3c6a8eb20849ee1028b225883beb3f0363ef255b (diff)
downloadtxr-853e299c38e5514810574b1094136d64ed375831.tar.gz
txr-853e299c38e5514810574b1094136d64ed375831.tar.bz2
txr-853e299c38e5514810574b1094136d64ed375831.zip
tree: new tree-begin-at function.
* tree.c (enum tree_iter_state): New iterator state tr_find_low_prepared dedicated to the tree-begin-at traversal. This state indicates that tree-next should visit the starting node that it is given, and then after that, treat anything to the left of it as having been visited. In the other states, tree-next does not visit the node it is given but uses it as the starting point to find the next node. (tn_find_next): Bugfix here: when navigating the right link, the function neglected to add the node to the path. But the logic for backtracking up the path expects this: it checks whether the node from the path is the parent of a right child. Somehow this didn't cause a problem for full traversals with tree-begin; at least the existing test cases don't expose an issue. It caused a problem for tree-begin-at, though. (tn_find_low): New static function. This finds the low-key node in the tree, priming the iterator object with the correct state and path content to continue the traversal from that node on . We need the tr_find_low_prepared state in the iterator in order to visit the low node itself that was found. (tree_begin_at): New function. (tree_init): Register tree-begin-at intrinsic. * tree.h (tree_begin_at): Declared. * tests/010/tree.tl: New test cases for tree-begin-at. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests/perm.tl')
0 files changed, 0 insertions, 0 deletions