Trees, flatten tree, and prune tree

Can someone please detail some how to use trees and flatten and purning trees? I’ve worked with it without any successful attempts. I don’t know the logic so I don’t really know how its used. Just looking at expanding my vocabulary

Flatten is easy, you take all the items in the entire tree (in whatever order they come in by default) and place them all in a single list. The default path for this list is {0}, but using the Flatten component you can pick any path you like.

Pruning will remove all the branches from a tree that have fewer or more than some custom number of items. This is useful when you have an algorithm which is only meaningful if you have a minimum number of values per list. For example imagine shooting a bunch of rays into a shape and getting all the intersections. Some rays miss the shape entirely (resulting in empty lists), some rays only intersect the shape once and some rays intersect it twice. You only care about those cases where it intersects twice, so you prune the tree to get rid of all the single hits.


1 Like