Преглед на файлове

Merge branch 'exo'

Exercices on recursive types.
Exercices with list and binary tree.
DricomDragon преди 5 години
родител
ревизия
640f9c9434
променени са 2 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 6 0
      list.hs
  2. 6 0
      tree.hs

+ 6 - 0
list.hs

@@ -0,0 +1,6 @@
+data List = Ground | Leaf Integer List
+
+hyperSum xs = case xs of
+	Ground -> 0
+	Leaf x tail -> x + hyperSum tail
+

+ 6 - 0
tree.hs

@@ -0,0 +1,6 @@
+data BinaryTree = Leaf | Node Integer BinaryTree BinaryTree
+
+height bigTree = case bigTree of
+	Leaf -> 0
+	Node _ leftTree rightTree -> 1 + max (height leftTree) (height rightTree)
+