TreeLeafCount
TreeLeafCount[tree]
gives the number of leaves of tree.
Details
- TreeLeafCount counts the number of leaves of a Tree object.
- TreeLeafCount[tree] is equivalent to TreeCount[tree,_,{-1}].
Examples
open allclose allProperties & Relations (8)
TreeLeafCount[tree] is equivalent to Length[TreeSelect[tree,TreeLeafQ]]:
TreeLeafCount[tree] is equivalent to Length[TreeLeaves[tree]]:
TreeLeafCount[tree] is equivalent to TreeCount[tree,_,{-1}]:
TreeLeafCount[Tree[{tree1,tree2,…}]] gives TreeLeafCount[tree1]+TreeLeafCount[tree2]+…:
TreeLeafCount[Tree[data,None]] gives 1:
TreeLeafCount[Tree[data,{}]] gives 0:
TreeSize[Tree[data,{}]] gives 1:
TreeLeafCount can be computed using TreeFold:
LeafCount[expr] is generally equivalent to TreeLeafCount[ExpressionTree[expr,"Subexpressions",HeadsTrue]]:
LeafCount[expr,HeadsFalse] is generally equivalent to TreeLeafCount[ExpressionTree[expr,"Subexpressions"]]:
Text
Wolfram Research (2022), TreeLeafCount, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeLeafCount.html.
CMS
Wolfram Language. 2022. "TreeLeafCount." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TreeLeafCount.html.
APA
Wolfram Language. (2022). TreeLeafCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeLeafCount.html