leaves utility
This commit is contained in:
parent
eacea41dac
commit
e333c76d6f
@ -157,6 +157,11 @@ root = rootLabel
|
|||||||
subs = subForest
|
subs = subForest
|
||||||
branches = subForest
|
branches = subForest
|
||||||
|
|
||||||
|
-- | List just the leaf nodes of a tree
|
||||||
|
leaves :: Tree a -> [a]
|
||||||
|
leaves (Node v []) = [v]
|
||||||
|
leaves (Node _ branches) = concatMap leaves branches
|
||||||
|
|
||||||
-- | get the sub-tree rooted at the first (left-most, depth-first) occurrence
|
-- | get the sub-tree rooted at the first (left-most, depth-first) occurrence
|
||||||
-- of the specified node value
|
-- of the specified node value
|
||||||
subtreeat :: Eq a => a -> Tree a -> Maybe (Tree a)
|
subtreeat :: Eq a => a -> Tree a -> Maybe (Tree a)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user