A Gleam interface to Erlang's array
module, for sparse, efficiently-implemented functional arrays. ๐
Erlang arrays are
Tuples are
glearray
's version of arrays are represented as a single tuple, so if you're solely doing lookups and don't need the sparse representation or dynamically resizeable arrays, glearray
will likely be faster than gary
.
Lists are
gleam add gary
import gary/array
pub fn main() {
list.range(1, 10)
|> array.from_list(default: -99)
|> array.drop(at: 5)
|> result.map(array.map(_, fn(_, v) { 2 * v }))
|> result.map(array.to_list)
// = Ok([2, 4, 6, 8, 10, -198, 14, 16, 18, 20])
}
Further documentation can be found at https://hexdocs.pm/gary.
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell