summaryrefslogtreecommitdiff
path: root/61-69/61a.hs
blob: c7c3662930b1e15e4f1fe16bebf43d5d55790fec (plain) (blame)
1
2
3
4
5
6
7
data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq)

leaves :: Tree a -> [a]

leaves Empty = []
leaves (Branch x Empty Empty) = [x]
leaves (Branch _ l r) = leaves l ++ leaves r