TreeExpression

TreeExpression[tree]

gives the expression corresponding to the tree tree.

TreeExpression[tree,struct]

interprets the data of the descendants according to struct.

Details

  • In TreeExpression[tree], tree must be 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
  • TreeExpression[ExpressionTree[expr,struct],struct] gives expr.

Examples

open allclose all

Basic Examples  (1)

Transform a tree with two leaves into an expression:

Specify the structure to use:

Scope  (2)

Transform a leaf into an expression:

Transform a tree with multiple levels:

Properties & Relations  (2)

The expression constructed by TreeExpression is evaluated before being returned:

Transform a tree into an expression:

Transform the resulting expression back into a tree:

Wolfram Research (2021), TreeExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeExpression.html.

Text

Wolfram Research (2021), TreeExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeExpression.html.

BibTeX

@misc{reference.wolfram_2021_treeexpression, author="Wolfram Research", title="{TreeExpression}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/TreeExpression.html}", note=[Accessed: 27-September-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_treeexpression, organization={Wolfram Research}, title={TreeExpression}, year={2021}, url={https://reference.wolfram.com/language/ref/TreeExpression.html}, note=[Accessed: 27-September-2021 ]}

CMS

Wolfram Language. 2021. "TreeExpression." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TreeExpression.html.

APA

Wolfram Language. (2021). TreeExpression. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeExpression.html