An implementation of a Bidirectional Map (BiMap) in pure Gleam.
gleam add mapped@1
import mapped
pub fn main() {
let numbers_to_words = mapped.from_list([
#(1, "one")
#(2, "two")
#(3, "three")
#(4, "four")
#(5, "five")
])
let assert Ok(word) = mapped.get_by_left(4) // -> "four"
let assert Ok(number) = mapped.get_by_right("three") // -> 3
}
Further documentation can be found at https://hexdocs.pm/mapped.
gleam run # Run the project
gleam test # Run the tests