Created
October 20, 2012 14:14
-
-
Save thomwiggers/3923394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
is_sorted :: Ord a => Tree a -> Bool | |
is_sorted Leaf = True | |
is_sorted (Node e left right) | |
-- de richting van <= en > is andersom, want prefixnotatie | |
= is_sorted' ((>=) e) left && is_sorted' ((<) e) right | |
where | |
is_sorted' :: Ord a => (a->Bool) -> Tree a -> Bool | |
is_sorted' _ Leaf = True | |
is_sorted' test (Node e left right) | |
| test e == False = False | |
| otherwise = is_sorted left && is_sorted right | |
&& is_sorted' test left && is_sorted' test right | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment