Computation on Trees

The Wolfram Language enables high-level functional programming using symbolic trees. Trees can be converted between different representations, and trees can be recursively constructed and traversed.

NestTree recursively build up a tree by applying a function to the leaves

TreeFold recursively reduce a tree to a single value

TreeMap traverse a tree, applying a function to each subtree

Operations on Subtrees

TreeInsert insert subtrees at the specified positions

TreeDelete delete subtrees at the specified positions

TreeReplacePart replace subtrees at the specified positions

Pattern Matching on Trees

TreeCases list of subtrees matching a pattern

TreePosition positions of subtrees matching a pattern

TreeCount number of subtrees matching a pattern

Conversion Functions

TreeRules convert a tree to nested rules

TreeExpression convert a tree to an expression

TreeGraph convert a tree to a graph

RulesTree  ▪  ExpressionTree  ▪  GraphTree  ▪  ...

Properties and Measurements »

TreeExtract extract subtrees at the specified positions

TreeCases  ▪  TreePosition  ▪  TreeSize  ▪  TreeDepth  ▪  TreeLeaves  ▪  ...