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

countLeaves :: Tree a -> Int

countLeaves Empty = 0
countLeaves (Branch _ Empty Empty) = 1
countLeaves (Branch _ l r) = countLeaves l + countLeaves r