Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create a tree of the counts of the distinct data of each subtree
ResourceFunction["TreeCounts"][tree] replaces the data of each subtree of tree with an association whose keys are the distinct data of that subtree and whose values give the number of times those data appear in that subtree. |
Give a tree of the counts of the distinct data of each subtree:
In[1]:= |
Out[1]= |
Counts gives an Association of the counts of the distinct elements of a list:
In[2]:= |
Out[2]= |
TreeCounts gives an Association of the counts of the distinct data of each subtree at each node of a tree:
In[3]:= |
Out[3]= |
Use Merge to merge two associations, using Total to combine elements with the same key:
In[4]:= |
Out[4]= |
TreeCounts automatically merges the counts from sibling branches:
In[5]:= |
Out[5]= |
TreeCount gives the total number of times a pattern matches the data in a tree:
In[6]:= |
Out[6]= |
TreeCounts gives the counts of the distinct data for each branch of a tree:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License