This commit is contained in:
Aaro Koivukangas
2025-12-24 13:27:38 +02:00
parent aba0c1d0b1
commit 03617c894b
+4 -1
View File
@@ -155,7 +155,10 @@ cull val Empty = Empty
-- (Node 3 Empty Empty)) ==> True
isOrdered :: Ord a => Tree a -> Bool
isOrdered = todo
isOrdered (Node val t1 t2)
| allValues (val>) t1 && allValues (val<) t2 = isOrdered t1 && isOrdered t2
| otherwise = False
isOrdered Empty = True
------------------------------------------------------------------------------
-- Ex 8: a path in a tree can be represented as a list of steps that