summaryrefslogtreecommitdiff
path: root/61-69/62a.hs
diff options
context:
space:
mode:
Diffstat (limited to '61-69/62a.hs')
-rw-r--r--61-69/62a.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/61-69/62a.hs b/61-69/62a.hs
new file mode 100644
index 0000000..a3a068b
--- /dev/null
+++ b/61-69/62a.hs
@@ -0,0 +1,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 = []