diff options
Diffstat (limited to 'H62.hs')
-rw-r--r-- | H62.hs | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -0,0 +1,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) |