nustack
ReferenceNutree

query

Tree queries -- read-only inspection of Term structures.

Module nu.tree.query.

Tree queries -- read-only inspection of Term structures.

Domain-free: predicates and counts over any Term tree.

NameCallMeaning
counttree.count(root, pred=None)Count nodes matching predicate. None counts all.
depthtree.depth(root)Maximum depth. A leaf has depth 0.
findtree.find(root, pred)Find all nodes matching predicate (pre-order).
find_firsttree.find_first(root, pred)Find first matching node (pre-order), or None.
sizetree.size(root)Total number of nodes.

count

Count nodes matching predicate. None counts all.

tree.count(root, pred=None)

Path nu.tree.count. Defined on nu.tree.query, bound as a function. Builds int.

Arguments

NameTypeDefaultMeaning
rootNu
predCallable[[Nu], bool] | NoneNone

Undocumented: example.

depth

Maximum depth. A leaf has depth 0.

tree.depth(root)

Path nu.tree.depth. Defined on nu.tree.query, bound as a function. Builds int.

Arguments

NameTypeDefaultMeaning
rootNu

Undocumented: example.

find

Find all nodes matching predicate (pre-order).

tree.find(root, pred)

Path nu.tree.find. Defined on nu.tree.query, bound as a function. Builds list[Nu].

Arguments

NameTypeDefaultMeaning
rootNu
predCallable[[Nu], bool]

Undocumented: example.

find_first

Find first matching node (pre-order), or None.

tree.find_first(root, pred)

Path nu.tree.find_first. Defined on nu.tree.query, bound as a function. Builds Nu | None.

Arguments

NameTypeDefaultMeaning
rootNu
predCallable[[Nu], bool]

Undocumented: example.

size

Total number of nodes.

tree.size(root)

Path nu.tree.size. Defined on nu.tree.query, bound as a function. Builds int.

Arguments

NameTypeDefaultMeaning
rootNu

Undocumented: example.

On this page