antikythera v0.3.0 Antikythera.MapUtil View Source

Utility functions to work with maps.

Link to this section Summary

Functions

Update the key in map with the given function, only when the key exists. Unlike Map.update!/3, it returns :error if the key does not exist.

Link to this section Functions

Link to this function

difference(m1, m2)

View Source
difference(%{required(k) => v}, %{required(k) => v}) ::
  {%{required(k) => v}, %{required(k) => {v, v}}, %{required(k) => v}}
when k: any(), v: any()
Link to this function

map_values(m, f)

View Source
map_values(%{required(k) => v1}, ({k, v1} -> v2)) :: %{required(k) => v2}
when k: any(), v1: any(), v2: any()
Link to this function

update_existing(map, key, fun)

View Source
update_existing(map(), any(), (any() -> any())) :: {:ok, map()} | :error

Update the key in map with the given function, only when the key exists. Unlike Map.update!/3, it returns :error if the key does not exist.