{"id":13740734,"url":"https://github.com/giacomocavalieri/trie_again","last_synced_at":"2025-04-01T14:24:53.991Z","repository":{"id":175330810,"uuid":"653734986","full_name":"giacomocavalieri/trie_again","owner":"giacomocavalieri","description":"🌳 Tries in Gleam","archived":false,"fork":false,"pushed_at":"2024-02-10T22:23:43.000Z","size":39,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:00:04.073Z","etag":null,"topics":["data-structures","tries"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/trie_again/","language":"Gleam","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giacomocavalieri.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-14T16:08:19.000Z","updated_at":"2025-01-25T06:25:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"3491378b-be91-4e3f-bb97-e03d3e030d28","html_url":"https://github.com/giacomocavalieri/trie_again","commit_stats":null,"previous_names":["giacomocavalieri/trie_again"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomocavalieri%2Ftrie_again","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomocavalieri%2Ftrie_again/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomocavalieri%2Ftrie_again/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomocavalieri%2Ftrie_again/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giacomocavalieri","download_url":"https://codeload.github.com/giacomocavalieri/trie_again/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246652785,"owners_count":20812190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","tries"],"created_at":"2024-08-03T04:00:51.715Z","updated_at":"2025-04-01T14:24:53.963Z","avatar_url":"https://github.com/giacomocavalieri.png","language":"Gleam","funding_links":[],"categories":["Packages"],"sub_categories":["Data Structures"],"readme":"# trie_again\n\n[![Package Version](https://img.shields.io/hexpm/v/trie_again)](https://hex.pm/packages/trie_again)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/trie_again/)\n![CI](https://github.com/giacomocavalieri/trie_again/workflows/CI/badge.svg?branch=main)\n\n🌳 Tries in Gleam\n\n\u003e ⚙️ This package supports the Erlang and Javascript targets!\n\n## Why tries?\n\nA [trie](https://en.wikipedia.org/wiki/Trie) is a data structure that uses lists as keys. By taking advantage of this property it is possible to efficiently perform some queries: for example imagine you want to find all the elements that are associated with a key with the same prefix; with a trie the complexity of the lookup is linear in the size of the prefix you're looking for.\n\nThat is why tries can be used to implement autocompleting text dictionaries, spell checking or prefix matching algorithms.  \n\nIn this example a trie is used to store words (as lists of graphemes) as keys associated with a definition. With the `subtrie` function one can look for all the elements sharing a commong prefix in their key:\n\n```gleam\nimport trie\nimport string\n\nlet dictionary =\n  trie.new()\n  |\u003e trie.insert(at: string.to_graphemes(\"gleam\"), value: \"To produce a small, bright light\")\n  |\u003e trie.insert(at: string.to_graphemes(\"gleaming\"), value: \"Bright and shiny\")\n  |\u003e trie.insert(at: string.to_graphemes(\"beam\"), value: \"A line of light that shines from a bright object\")\n\ndictionary\n|\u003e trie.subtrie(at: [\"g\", \"l\"])\n|\u003e trie.to_list\n// -\u003e [\n//      #([\"g\", \"l\", \"e\", \"a\", \"m\"], \"To produce a small, bright light\"),\n//      #([\"g\", \"l\", \"e\", \"a\", \"m\", \"i\", \"n\", \"g\"], \"Bright and shiny\"),\n//    ]\n```\n\n## Installation\n\nTo add this package to your Gleam project:\n\n```sh\ngleam add trie_again\n```\n\n## Usage\n\nImport the `trie` module and write some code! You can find many examples of how the different functions work in the [project documentation](https://hexdocs.pm/trie_again/).\n\n```gleam\nimport trie\n\ntrie.new()\n|\u003e trie.insert(at: [\"c\", \"a\", \"r\"], value: 1)\n|\u003e trie.insert(at: [\"c\", \"a\", \"t\"], value: 10)\n|\u003e trie.get(at: [\"c\", \"a\", \"t\"])\n// -\u003e Ok(10)\n```\n\n## Contributing\n\nIf 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 💜\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiacomocavalieri%2Ftrie_again","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiacomocavalieri%2Ftrie_again","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiacomocavalieri%2Ftrie_again/lists"}