trie_again

Package Version Hex Docs CI

Tries in Gleam 🌳

⚙️ This package supports the Erlang and Javascript targets!

A trie, also known as prefix tree, is a data structure that stores values associated with a key that is made of a list of elements.

By taking advantage of the structure of the keys, a trie can allow to efficiently perform operations like looking for elements whose keys share a common prefix.

Installation

To add this package to your Gleam project:

gleam add trie_again

Usage

Import the trie module and write some code! You can find many examples of how the different functions work in the project documentation.

import trie

trie.new()
|> trie.insert(at: ["c", "a", "r"], value: 1)
|> trie.insert(at: ["c", "a", "t"], value: 10)
|> trie.get(at: ["c", "a", "t"])
// -> Ok(10)

Contributing

If you think there’s any way to improve this package, or if you spot a bug don’t be afraid to open PRs, issues or requests of any kind! Any contribution is welcome 💜

Search Document