Trie[V]: an immutable map from strings to values, iterated in key
order, with prefix queries (Effect's Trie)::
t = Trie.make(("she", 0), ("shells", 1), ("sea", 2))
list(t.keys_with_prefix("she")) # ["she", "shells"]
t.longest_prefix_of("shellsort") # Some(("shells", 1))Keys are ordered by their UTF-16 code units, as JavaScript compares strings
(so a character past U+FFFF sorts below U+E000, where Python's < puts it
above). The empty string is a key like any other, first in order. Every
update returns a new trie and leaves this one as it was; like Effect's, the
trie is persistent, so an update copies only the nodes along its key.
Classes#
On This Page
Classes