Bunch v1.0.0 Bunch.KVList View Source

A bunch of helper functions for manipulating key-value lists (including keyword lists).

Key-value lists are represented as lists of 2-element tuples, where the first element of each tuple is a key, and the second is a value.

Link to this section Summary

Functions

Maps keys of list using function f

Maps values of list using function f

Link to this section Types

Link to this type

t(key, value) View Source
t(key, value) :: [{key, value}]

Link to this section Functions

Link to this function

map_keys(list, f) View Source
map_keys(t(k1, v), (k1 -> k2)) :: t(k2, v)
when k1: any(), k2: any(), v: any()

Maps keys of list using function f.

Example

iex> Bunch.KVList.map_keys([{1, :a}, {2, :b}], & &1+1)
[{2, :a}, {3, :b}]
Link to this function

map_values(list, f) View Source
map_values(t(k, v1), (v1 -> v2)) :: t(k, v2)
when k: any(), v1: any(), v2: any()

Maps values of list using function f.

Example

iex> Bunch.KVList.map_values([a: 1, b: 2], & &1+1)
[a: 2, b: 3]