We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4a8a753 commit 63853f6Copy full SHA for 63853f6
ITMOPrelude/Tree.hs
@@ -18,12 +18,17 @@ addToLeftLeaf x Leaf = Node x Leaf Leaf
18
addToRightLeaf x (Node a l r) = Node a l (addToRightLeaf x r)
19
addToRightLeaf x Leaf = Node x Leaf Leaf
20
21
--- rotations? which rotations
+leftRotate (Node x l (Node y l' r')) = Node y (Node x l l') r'
22
+leftRotate n = error "leftRotate: Incorrect tree"
23
+
24
+rightRotate (Node x (Node y l' r') r) = Node y l' (Node x r' r)
25
+rightRotate n = error "rightRotate: Incorrect tree"
26
27
tmap :: (a -> b) -> Tree a -> Tree b
28
tmap f Leaf = Leaf
29
tmap f (Node x l r) = Node (f x) (tmap f l) (tmap f r)
30
31
tfold :: (a -> b -> b) -> b -> Tree a -> b
32
tfold f z Leaf = z
-tfold f z (Node x l r) = f x (tfold f (tfold f z r) l)
33
+tfold f z (Node x l r) = f x (tfold f (tfold f z r) l)
34
0 commit comments