codist.tree

Tree utilities and type definitions.

Module Attributes

Lambda

A singleton used in change operations

Tree

A tree type.

Functions

keyroots(tree)

Postorder traversal of keyroot indices for keyroots in \(T\)

leftmosts(tree)

The postorder traversal of \(l(i)\) for each index \(i\) in \(T\)

parents(tree)

The postorder enumeration of the indices of the parent of each node, The root of the tree has the parent Lambda (i.e. indicating no parent).

postorder(tree)

A postorder traversal of the node data in tree

t(root, *children)

Small convenience function to help construct trees

Lambda: Final[str] = 'Λ'

A singleton used in change operations

Tree: type[tuple[T, tuple[Tree[T], ...]]] = Tree

A tree type. A tree is any tuple of the form: Tree[T] = tuple[T, tuple[Tree[T], ...]]

keyroots(tree: Tree) tuple[int, ...]

Postorder traversal of keyroot indices for keyroots in \(T\)

leftmosts(tree: Tree) tuple[int, ...]

The postorder traversal of \(l(i)\) for each index \(i\) in \(T\)

parents(tree: Tree) tuple[int | Lambda, ...]

The postorder enumeration of the indices of the parent of each node, The root of the tree has the parent Lambda (i.e. indicating no parent)

postorder(tree: Tree) tuple[T, ...]

A postorder traversal of the node data in tree

t(root: T, *children: Tree) Tree

Small convenience function to help construct trees