Leaf Branch Tree Forest

From XPUB & Lens-Based wiki

Trees are often used in computer science as examples -- "tree" in fact can refer to a specific kind of data structure. One interesting approach to trees from a computer science perspective, is as a hierarchy of structures. The tree itself is made of branches, and each branch eventually contains leaves. At a larger scale still, a forest could be said to be "made of trees".

In a pair, create first a set of primitives, starting with leaf, then branch, then tree, then forest. In each case, write each function to use the preceding one you defined (so branch uses leaf, tree uses branch, forest uses tree). Try to write the functions in as simple and straightforward a way as possible as your first priority is to complete each step of the hierarchy. Once this is done, focus on refining a specific element (say the leaves or then branch). If you like you can now work independently on different parts.