Defines general interfaces for tree-like data structures and standard function operations on these interfaces.
Binary |
interface Binary<out This : Tree, Tree : TreeNode<Tree>> : TreeNode<Tree>
Common interface for binary operators. |
TreeNode |
interface TreeNode<out Tree>
Interface implemented by elements of a tree. |
Unary |
interface Unary<out This : Tree, Tree : TreeNode<Tree>> : TreeNode<Tree>
Common interface for unary operators. |
fold |
fun <Tree : TreeNode<Tree>, R> TreeNode<Tree>.fold(atom: Tree.() -> R, unary: Unary<*, Tree>.(R) -> R, binary: Binary<*, Tree>.(R, R) -> R): R
Standard tree fold. You can provide transformation operations for atoms, unary and binary nodes. |
map |
fun <Tree : TreeNode<Tree>> TreeNode<Tree>.map(atom: Tree.() -> Tree = { this }, unary: Unary<Tree, Tree>.(Tree) -> Tree = { this.copy(inner = it) }, binary: Binary<Tree, Tree>.(Tree, Tree) -> Tree = { left, right -> this.copy(left, right)}): Tree
Change tree structure while preserving tree type. You can provide transformation operations for atoms, unary and binary nodes. The only requirement is that operations don't change the type of the tree. |