TreeLeafQ
Examples
open allclose allScope (1)
TreeLeafQ works for any expression:
Properties & Relations (8)
In TreeLeafQ[tree], the tree must be a valid Tree object:
TreeLeafQ[Tree[data,None]] gives True:
TreeLeafQ[Tree[data,{subtree1,subtree2,…}]] gives False:
TreeLeafQ[Tree[data,{}]] even gives False:
TreeLeafQ[tree] gives True when TreeChildren[tree] gives None:
TreeLeafQ[tree] gives False when TreeChildren[tree] gives a list:
TreeLeafQ[tree] gives False even when TreeChildren[tree] gives {}:
TreeLeafQ[tree] gives True when TreeDepth[tree] gives 0:
A root with an empty list of children has depth 1:
TreeSize[tree] gives 1 when TreeLeafQ[tree] gives True:
A root with an empty list of children also has size 1:
TreeLeaves[tree] returns the list of subtrees for which TreeLeafQ gives True:
TreeLeafCount[tree] is equivalent to Length[TreeSelect[tree,TreeLeafQ]]:
Text
Wolfram Research (2021), TreeLeafQ, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeLeafQ.html (updated 2022).
CMS
Wolfram Language. 2021. "TreeLeafQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/TreeLeafQ.html.
APA
Wolfram Language. (2021). TreeLeafQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeLeafQ.html