summaryrefslogtreecommitdiff
path: root/H62.hs
blob: b835b203687f1b67a254bed8fdcb86f7c0a9063e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Tree
-- import Tree4

leaves Empty = []
leaves (Branch x Empty Empty) = [x]
leaves (Branch x t1 t2) = leaves t1 ++ leaves t2

internals Empty = []
internals (Branch x Empty Empty) = []
internals (Branch x t1 t2) = [x] : internals t1 ++ internals t2

atLevel Empty _ = []
atLevel (Branch x _ _) 1 = [x]
atLevel (Branch _ t1 t2) n = atLevel t1 (n-1) ++ atLevel t2 (n-1)