subs :: Tree a -> [Tree a]
subs t@(One _) = [t]
subs t@(Two l r) = t : (subs l ++ subs r)This is a preorder traversal of subtree occurrences. Equal-valued occurrences are retained: the answer is a list, not a deduplicated set. Every occurrence is either the root or lies in exactly one child, which proves completeness by structural induction.
Articles by others on the same topic
There are currently no matching articles.