Exercices on recursive types. Exercices with list and binary tree.
@@ -0,0 +1,6 @@
+data List = Ground | Leaf Integer List
+
+hyperSum xs = case xs of
+ Ground -> 0
+ Leaf x tail -> x + hyperSum tail
+data BinaryTree = Leaf | Node Integer BinaryTree BinaryTree
+height bigTree = case bigTree of
+ Leaf -> 0
+ Node _ leftTree rightTree -> 1 + max (height leftTree) (height rightTree)