Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data BinTree a = Leaf | Node a (BinTree a) (BinTree a)
- collapse :: BinTree a -> (a -> b -> b -> b) -> b -> b
- collapse (Leaf) _ x = x
- collapse (Node a left right) f x = f a (collapse left f x) (collapse right f x)
- treeToList :: BinTree a -> [a]
- treeToList t = collapse t helper []
- where
- helper x y z = [x] ++ y ++ z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement