TreeExtract

TreeExtract[tree,pos]

extracts the subtree of tree at the position specified by pos.

TreeExtract[tree,{pos1,pos2,}]

extracts a list of subtrees of tree.

TreeExtract[tree,pos,h]

extracts subtrees of tree, applying h to each subtree.

TreeExtract[pos]

represents an operator form of TreeExtract that can be applied to a tree.

Details

Examples

open allclose all

Basic Examples  (3)

Extract the second child of a tree:

Extract a subtree:

Extract multiple subtrees:

Scope  (9)

Extract the first child:

Extract the second to last child:

Extract a span of children:

Extract using different specifications:

Use the operator form of TreeExtract:

Extract subtrees by level:

Extract subtrees matching a data pattern:

Extract subtrees with exactly two children:

Take a tree containing another tree as data:

Extract a subtree from that data tree:

Alternatively, use 0 to refer to the tree data:

Properties & Relations  (1)

Extract the subtrees given by TreePosition:

Possible Issues  (1)

TreeExtract[tree,{}] returns an empty list of subtrees because the list of positions is empty:

TreeExtract[tree,{{}}] extracts the subtree at position {}, which is the whole tree:

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

Text

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

BibTeX

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

BibLaTeX

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

CMS

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

APA

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