Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Interactively fold a tree
ResourceFunction["TreeFoldInteractive"][f,tree] successively folds the subtrees of tree, applying f to both the data of a subtree and the list of results for its children whenever it is clicked.  | |
ResourceFunction["TreeFoldInteractive"][f,tree,h] applies f to h[tree] instead of the data of tree.  | |
ResourceFunction["TreeFoldInteractive"][{f,f-1},tree,h] applies f-1 at the last level and f at each inner level.  | 
Interactively fold a tree with a binary function f:
| In[1]:= | ![]()  | 
| Out[1]= | 
Interactively fold a tree with a binary function f after applying a function g to the data in the leaves:
| In[2]:= | ![]()  | 
| Out[2]= | ![]()  | 
Clicking a leaf applies g:
| In[3]:= | ![]()  | 
| Out[3]= | ![]()  | 
Clicking an inner node folds its corresponding subtree:
| In[4]:= | ![]()  | 
| Out[4]= | ![]()  | 
Clicking the root node folds the whole tree:
| In[5]:= | ![]()  | 
| Out[5]= | 
Interactively fold a property of subtrees:
| 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