Last active
October 12, 2016 22:02
-
-
Save evmorov/ea7b271f04668faaebf605f684b0b835 to your computer and use it in GitHub Desktop.
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
data Tree | |
= Leaf | |
| Node Int | |
Tree | |
Tree | |
deriving (Show) | |
insertOrder :: Tree -> Int -> Tree | |
insertOrder Leaf new = Node new Leaf Leaf | |
insertOrder (Node num left right) new | |
| new < num = Node num (insertOrder left new) right | |
| otherwise = Node num left (insertOrder right new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment