Skip to content

Instantly share code, notes, and snippets.

@alirezameskin
Last active February 12, 2019 07:36
Show Gist options
  • Save alirezameskin/a3852af6690ca7b295568a40a0183d06 to your computer and use it in GitHub Desktop.
Save alirezameskin/a3852af6690ca7b295568a40a0183d06 to your computer and use it in GitHub Desktop.
object TrieApp extends App {
val trie = Trie[Int]
.insert("to", 7)
.insert("a", 15)
.insert("tea", 3)
.insert("ted", 4)
.insert("ten", 12)
.insert("i", 11)
.insert("in", 5)
.insert("inn", 9)
println(trie.search("ted")) // Some(4)
println(trie.search("ten")) // Some(12)
println(trie.search("invalid")) //None
val newTrie = trie
.delete("ted")
.delete("ten")
.delete("not existing")
println(newTrie.search("ted")) //None
println(newTrie.search("ten")) //None
println(newTrie.search("inn")) //Some(9)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment