Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Count the terminal nodes of an expression tree
ResourceFunction["ProperLeafCount"][expr] counts terminal nodes of the tree graph associated with atomistic tree expression expr. |
Count leaves of binary trees:
In[1]:= |
Out[1]= |
ProperLeafCount is usually less than LeafCount:
In[2]:= |
Out[2]= |
In at least one trivial case, ProperLeafCount can equal LeafCount:
In[3]:= |
Out[3]= |
For nonatomistic inputs, a similar atomistic form is assumed:
In[4]:= |
Out[4]= |
This work is licensed under a Creative Commons Attribution 4.0 International License