- ExpressionTree gives a Tree object.
- Possible forms for struct include:
"HeadTrees" trees corresponding to heads of subexpressions of the expression "Heads" heads of subexpressions of the expression "Arguments" arguments of subexpressions of the expression by level "Subexpressions" subexpressions of the expression by level "Atoms" atomic subexpressions of the expression at level -1
- Possible structures for the expression f[a,b][g[1,2],x,y] include:
- Held versions of these structures for struct include:
"HeldHeadTrees" trees corresponding to held heads of subexpressions of the expression "HeldHeads" held heads of subexpressions of the expression "HeldArguments" held arguments of subexpressions of the expression by level "HeldSubexpressions" held subexpressions of the expression by level "HeldAtoms" held atomic subexpressions of the expression at level -1
- TreeExpression[ExpressionTree[expr,struct],struct] gives expr.
- ExpressionTree takes the same options as Tree.
Examplesopen allclose all
Basic Examples (3)
ExpressionTree[atom,"HeadTrees"] gives a leaf containing the atomic expression atom:
Styling Individual Tree Elements (2)
Styling Entire Tree (4)
Tree Layout and Graphics Options (3)
Specify Graphics options:
Properties & Relations (16)
With the default structure "HeadTrees", ExpressionTree constructs a tree with subtrees containing data giving the tree structure of the heads of subexpressions:
Use TreeFold to insert a parent node above each subtree:
Map maps on the arguments in an expression by default:
Use TreeFold to insert a sibling node before each subtree:
TreeMap maps on the data of subtrees in a tree:
Map can map on the heads and leaves directly:
TreeMap can map on the data of just the leaves in a tree:
Map can map on the atoms in an expression directly:
ExpressionTree evaluates subexpressions before constructing the tree:
Use Unevaluated to defer evaluation of subexpressions until after the tree is constructed:
Held structures ensure that subexpressions are wrapped in HoldForm to prevent all evaluation:
Show the HoldForm wrappers:
Possible Issues (2)
ExpressionTree[expr,"Heads"] gives a leaf containing expr, not expr:
Wolfram Research (2021), ExpressionTree, Wolfram Language function, https://reference.wolfram.com/language/ref/ExpressionTree.html.
Wolfram Language. 2021. "ExpressionTree." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ExpressionTree.html.
Wolfram Language. (2021). ExpressionTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ExpressionTree.html