Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Grow Tree objects by iteratively adding children to leaves using information from their ancestors
ResourceFunction["AncestralNestTree"][f,tree] adds children to each leaf of tree, with f[{expr1,expr2,…}] giving the list of data for the new children of a leaf whose path from the root of tree goes through vertices having data expr1,expr2,… in order. | |
ResourceFunction["AncestralNestTree"][f,tree,n] successively applies f to the data of each leaf up to level n, adding at most n levels to each leaf. | |
ResourceFunction["AncestralNestTree"][f,tree,n,h] additionally applies h to the data of the new subtrees. | |
ResourceFunction["AncestralNestTree"][f,expr,…] constructs a tree by nesting f on the tree leaf with data expr. |
Extend the leaves of a tree:
In[1]:= | ![]() |
Out[1]= | ![]() |
Build a tree from an expression:
In[2]:= | ![]() |
Out[2]= | ![]() |
Style the tree:
In[3]:= | ![]() |
Out[3]= | ![]() |
Store all permutations of {a,b,c,d} as paths from root to leaf:
In[4]:= | ![]() |
Out[4]= | ![]() |
Letting a,b,c,d be square matrices, find all matrix products involving each matrix at most once without having to repeat subcomputations or store more than 4 matrix products at a time:
In[5]:= | ![]() |
AncestralNestTree[f@*Last,args] is equivalent to NestTree[f,args] in most cases:
In[6]:= | ![]() |
Out[6]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License