TreeRules

TreeRules[tree]

returns the rules associated with the Tree object tree.

Details

  • TreeRules returns the rules associated with a tree expression.
  • The inverse operation of TreeRules is performed by RulesTree.
  • If tree has children, then TreeRules[tree] gives data{rule1,rule2,}, where data is the data in tree and rulei are the rules associated with its children.

Examples

open allclose all

Basic Examples  (1)

Get the rules associated with a tree:

Scope  (2)

Use TreeRules on a leaf:

Use TreeRules on any tree:

Properties & Relations  (2)

RulesTree constructs a tree associated with the given rules:

Use TreeRules on the result to recover the original rules:

TreeRules[tree] is generally equivalent to TreeFold[{Rule,Identity},tree]:

Possible Issues  (1)

TreeRules[Tree[data,None]] generally gives data:

However, TreeRules[Tree[expr{},None]] gives (expr{}){} instead:

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

Text

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

BibTeX

@misc{reference.wolfram_2021_treerules, author="Wolfram Research", title="{TreeRules}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/TreeRules.html}", note=[Accessed: 22-June-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_treerules, organization={Wolfram Research}, title={TreeRules}, year={2021}, url={https://reference.wolfram.com/language/ref/TreeRules.html}, note=[Accessed: 22-June-2021 ]}

CMS

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

APA

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