source: project/wiki/eggref/5/tree @ 40161

Last change on this file since 40161 was 40161, checked in by Idiomdrottning, 8 weeks ago

A new tree is born

File size: 1.1 KB
Line 
1
2== tree
3[[toc:]]
4This is an implementation
5of
6[[https://github.com/pre-srfi/trees/blob/master/spec.md|John Cowan's tree library]] with
7the following additional procedures added.
8
9
10=== tree-find
11 (tree-find pred tree default)
12
13Walks the tree in preorder and exits out early when a node (a subtree
14or atom) matches {{pred}}. Returns the first matching node, not a copy
15but the real one. If there is on match, return default, which is a
16mandatory argument.
17
18
19=== tree-find-equal?
20 (tree-find-equal? tree needle)
21
22Like {{tree-find}}, but finds the first node that's {{equal?}} to the
23{{needle}} or returns {{#f}} as a default.
24
25The reason you might need that is because many of the other operations
26in the library act on subtrees, not copies of subtrees. So this is a
27way for you to turn a copy into a reference to the original subtree.
28
29
30=== tree-atoms-any?
31 (tree-atoms-any? pred tree)
32
33Like {{tree-any?}}, but only consider atoms.
34
35
36=== tree-atoms-every?
37 (tree-atoms-every? pred tree)
38
39Like {{tree-every?}}, but only consider atoms.
40
41
42=== tree-remove
43 (tree-remove pred tree)
44
45Remove every node (whether subtrees or atoms) that matches {{pred}}.
46
Note: See TracBrowser for help on using the repository browser.