summaryrefslogblamecommitdiff
path: root/61-69/62a.hs
blob: a3a068b52371e4764727798ee5f34c0cb1e66433 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                    
data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq)

atLevel :: Tree a -> Int -> [a]

atLevel Empty _ = []
atLevel (Branch x l r) n
  | n == 1 = [x]
  | n > 1 = atLevel l (n - 1) ++ atLevel r (n - 1)
  | otherwise = []