// ┬1 A tree of depth=4 // └┬2 with 3 branches and // └┬3 a single leaf. // └─4 // constdepth4: Tree<string> = branch(1, [branch(2, [branch(3, [leaf(4)])])]])
constdepth2: Tree<string> = pipe(depth4, cropDepth(2)) // // ┬1 Has been cropped to a tree of depth=2 // └─2 depth2 = branch(1, [leaf(2)])
Crop all nodes from a tree that are deeper than the given depth. For example: