Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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