Created
December 22, 2011 07:03
-
-
Save shanemhansen/1509312 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
install(Word,none) -> | |
{Word,1,none,none}; | |
install(Word,Tree) when Word<element(1,Tree) -> | |
{OtherWord,Count,Left,Right}=Tree, | |
{ | |
OtherWord, | |
Count, | |
install(Word,Left), | |
Right | |
}; | |
install(Word,Tree) when Word>element(1,Tree) -> | |
{OtherWord,Count,Left,Right}=Tree, | |
{ | |
OtherWord, | |
Count, | |
Left, | |
install(Word,Right) | |
}; | |
install(Word,Tree) when Word =:= element(1,Tree) -> | |
{_,Count,Left,Right}=Tree, | |
{ | |
Word, | |
Count+1, | |
Left, | |
Right | |
} | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment