larztrie
A trie for autocomplete.
A trie stores words character by character so you can instantly check membership, test a prefix, and - the star feature - list every word with a given prefix. It's the structure behind autocomplete and spell-checkers, made readable.
larzscript pkg install trie
What you get
- insert / contains / starts_with
- words_with_prefix = autocomplete
- all_words + remove
- The structure behind autocomplete
Try it
import "trie" as trie
let t = trie.new()
for w in ["cat", "car", "card", "dog"] { trie.insert(t, w) }
print(trie.contains(t, "car"))
print(trie.starts_with(t, "ca"))
print(trie.words_with_prefix(t, "car"))Output
true true [car, card]
Why it's in the Larz Stack
larztrie is a real Larzscript package (larzscript pkg install trie) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.