Created
March 21, 2017 17:21
-
-
Save zwilias/d0b27f2b83140aafc83b65bb5489cdf6 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
isValidBst : Tree comparable -> Bool | |
isValidBst tree = | |
case tree of | |
Empty -> | |
True | |
Node value left right -> | |
all (\x -> x < value) left | |
&& all (\x -> x > value) right | |
&& isValidBst left | |
&& isValidBst right | |
all : (comparable -> comparable -> Bool) -> Tree comparable -> Bool | |
all condition tree = | |
case tree of | |
Empty -> | |
True | |
Node value left right -> | |
condition value | |
&& all condition left | |
&& all condition right |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment