diff --git a/HW1.fedorind.hs b/HW1.fedorind.hs index 0cc2240..883ebee 100644 --- a/HW1.fedorind.hs +++ b/HW1.fedorind.hs @@ -191,7 +191,10 @@ inorder = treeFoldr (:) [] -- True -- isBST :: Tree -> Bool -isBST tree = snd $ treeFoldl (\v (p, b) -> (v, b && v >= p)) (minInt tree, True) tree +isBST tree = snd $ treeFoldl accCompare (firstNum, True) tree + where + accCompare v (p, b) = (v, b && v >= p) + firstNum = leftmost tree -- | Check whether a number is contained in a binary search tree. -- (You may assume that the given tree is a binary search tree.)