Created
March 6, 2017 17:30
-
-
Save hamishdickson/115fedb88447fa624347e57cb1b1f88d to your computer and use it in GitHub Desktop.
binary search tree
This file contains hidden or 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
-- binary search tree | |
insert : Ord elem => elem -> Tree elem -> Tree elem | |
insert x Empty = Node Empty x Empty | |
insert x (Node left val right) = case compare x val of | |
LT => Node (insert x left) val right | |
EQ => Node left val right | |
GT => Node left val (insert x right) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment