Skip to content

maps #


maps is a module that provides utility functions to make working with maps easier.

fn filter #

fn filter[K, V](m map[K]V, f fn (key K, val V) bool) map[K]V

filter filters map entries by the given predicate function

fn flat_map #

fn flat_map[K, V, I](m map[K]V, f fn (key K, val V) []I) []I

flat_map maps map entries into arrays and flattens into a one-dimensional array

fn from_array #

fn from_array[T](array []T) map[int]T

from_array maps array into map with index to element per entry

fn invert #

fn invert[K, V](m map[K]V) map[V]K

invert returns a new map, created by swapping key to value and vice versa for each entry.

fn to_array #

fn to_array[K, V, I](m map[K]V, f fn (key K, val V) I) []I

to_array maps map entries into one-dimensional array

fn to_map #

fn to_map[K, V, X, Y](m map[K]V, f fn (key K, val V) (X, Y)) map[X]Y

to_map maps map entries into new entries and constructs a new map