combiner() = fun((Path::path(), Old::term(), New::term()) -> term())
abstract datatype: iterator()
An iterator representing the associations in a map with keys of type Key and values of type Value.
Created using deep_iterator/1
.
deep_next/1
.
path() = [term()]
A list of keys that are used to iterate deeper into a map of maps.
deep_find/2 | Returns a tuple {ok,Value} , where Value is the value associated with
Path , or error if no value is associated with Path in Map . |
deep_get/2 | Returns value Value associated with Path if Map contains Path . |
deep_get/3 | Returns value Value associated with Path if Map contains Path . |
deep_intersect/2 | Intersects two maps into a single map Map3 . |
deep_intersect_with/3 | Intersects two maps into a single map Map3 . |
deep_iterator/1 | Returns a map iterator Iterator that can be used by deep_next/1
to recursively traverse the path-value associations in a deep map structure. |
deep_merge/1 | Merges a list of maps recursively into a single map. |
deep_merge/2 | Equivalent to deep_merge([Map1, Map2]). |
deep_merge/3 | (Deprecated.) Merges a list of maps Maps recursively into a single map Target . |
deep_merge_with/2 | Merges a list of maps Maps recursively into a single map. |
deep_merge_with/3 | Merges a list of maps Maps recursively into a single map. |
deep_next/1 | Returns the next path-value association in Iterator and a new iterator for the remaining associations in the iterator. |
deep_put/3 | Associates Path with value Value and inserts the association into map
Map2 . |
deep_remove/2 | Removes the last existing key of Path , and its associated value from
Map1 and returns a new map Map2 without that key. |
deep_search/2 | Returns a tuple {ok,Value} where Value is the value associated
with Path , or {error, PartialPath, Value} if no value is associated with
Path in Map , where PartialPath represents the path to the last found
element in Map and Value is the value found at that path. |
deep_update/3 | If Path exists in Map1 , the old associated value is replaced by value
Value . |
deep_update_with/3 | Update a value in a Map1 associated with Path by calling Fun on the
old value to get a new value. |
deep_update_with/4 | Update a value in a Map1 associated with Path by calling Fun on the
old value to get a new value. |
inverse/1 | Inverts a map by inserting each value as the key with its corresponding key as the value. |
inverse/2 | Inverts a map by inserting each value as the key with its corresponding key as the value. |
deep_find(Path::path(), Map::map()) -> {ok, term()} | error
Returns a tuple {ok,Value}
, where Value is the value associated with
Path
, or error
if no value is associated with Path
in Map
.
{badmap,Map}
if Map
is not a map{badpath,Path}
if Path
is not a pathdeep_get(Path::path(), Map::map()) -> term()
Returns value Value
associated with Path
if Map
contains Path
.
{badmap,Map}
if Map
is not a map{badpath,Path}
if Path
is not a path{badvalue,P}
if a term that is not a map exists as a intermediate key at
the path P
{badkey,Path}
if no value is associated with path Path
deep_get(Path::path(), Map::map(), Default::term()) -> term()
Returns value Value
associated with Path
if Map
contains Path
. If
no value is associated with Path
, Default
is returned.
{badmap,Map}
if Map
is not a map{badpath,Path}
if Path
is not a path{badvalue,P}
if a term that is not a map exists as a intermediate key at
the path P
deep_intersect(Map1::map(), Map2::map()) -> Map3::map()
Equivalent to deep_intersect_with(fun (_, _, V) -> V end, Map1, Map2).
Intersects two maps into a single map Map3
. If a path exists in both
maps, the value in Map1
is superseded by the value in Map2
.
{badmap,Map}
exception if any of the maps is not a mapdeep_intersect_with(Fun::combiner(), Map1::map(), Map2::map()) -> Map3::map()
Intersects two maps into a single map Map3
.
If a path exists in both maps, the value in Map1
is combined with the
value in Map2
by the Combiner
fun. When Combiner
is applied the path
that exists in both maps is the first parameter, the value from Map1
is
the second parameter, and the value from Map2
is the third parameter.
{badmap,Map}
exception if any of the maps is not a mapbadarg
if Fun
is not a function of arity 3deep_iterator(Map::map()) -> iterator()
Returns a map iterator Iterator that can be used by deep_next/1
to recursively traverse the path-value associations in a deep map structure.
{badmap,Map}
exception if Map is not a map.
deep_merge(Maps::[map()]) -> map()
Equivalent to deep_merge(fun (_, V) -> V end, #{}, Maps).
Merges a list of maps recursively into a single map. If a path exist in several maps, the value in the first nested map is superseded by the value in a following nested map.
The call can raise the following exceptions:{badmap,Map}
exception if any of the maps is not a mapdeep_merge(Map1::map(), Map2::map()) -> map()
Equivalent to deep_merge([Map1, Map2]).
deep_merge(Fun::fun((Old::term(), New::term()) -> term()), Target::map(), Maps::map() | [map()]) -> map()
This function is deprecated: Use deep_merge_with/3
instead
Merges a list of maps Maps
recursively into a single map Target
. If a
path exist in several maps, the function Fun
is called with the previous and
the conflicting value to resolve the conflict. The return value from the
function is put into the resulting map.
{badmap,Map}
exception if any of the maps is not a mapdeep_merge_with(Fun::combiner(), Maps::[map()]) -> map()
Merges a list of maps Maps
recursively into a single map. If a path
exist in several maps, the function Fun
is called with the path, the
previous and the conflicting value to resolve the conflict. The return value
from the function is put into the resulting map.
{badmap,Map}
exception if any of the maps is not a mapbadarg
if Fun
is not a function of arity 3deep_merge_with(Fun::combiner(), Map1::map(), Map2::map()) -> map()
Merges a list of maps Maps
recursively into a single map. If a path
exist in several maps, the function Fun
is called with the path, the
previous and the conflicting value to resolve the conflict. The return value
from the function is put into the resulting map.
{badmap,Map}
exception if any of the maps is not a mapdeep_next(Iter::iterator()) -> {path(), term(), iterator()} | none
Returns the next path-value association in Iterator and a new iterator for the remaining associations in the iterator.
If the value is another map the iterator will first return the map as a value
with its path. Only on the next call the inner value with its path is
returned. That is, first {Path, map(), iterator()}
and then
{InnerPath, Value, iterator()}
.
none
is returned.
deep_put(Path::path(), Value::term(), Map1::map()) -> map()
Associates Path
with value Value
and inserts the association into map
Map2
. If path Path
already exists in map Map1
, the old associated value
is replaced by value Value
. The function returns a new map Map2
containing
the new association and the old associations in Map1
.
{badmap,Map}
if Map1
is not a map{badpath,Path}
if Path
is not a path{badvalue,P}
if a term that is not a map exists as a intermediate key at
the path P
deep_remove(Path::path(), Map::map()) -> map()
Removes the last existing key of Path
, and its associated value from
Map1
and returns a new map Map2
without that key. Any deeper non-existing
keys are ignored.
{badmap,Map}
if Map
is not a map{badpath,Path}
if Path
is not a pathdeep_search(Path, Map) -> any()
Returns a tuple {ok,Value}
where Value
is the value associated
with Path
, or {error, PartialPath, Value}
if no value is associated with
Path
in Map
, where PartialPath
represents the path to the last found
element in Map
and Value
is the value found at that path.
When no key in Path
exists in Map
, {error, [], Map}
is returned.
{badmap,Map}
if Map
is not a map{badpath,Path}
if Path
is not a pathdeep_update(Path::path(), Value::term(), Map1::map()) -> map()
If Path
exists in Map1
, the old associated value is replaced by value
Value
. The function returns a new map Map2
containing the new associated
value.
{badmap,Map}
if Map1
is not a map{badpath,Path}
if Path
is not a path{badvalue,P}
if a term that is not a map exists as a intermediate key at
the path P
{badkey,Path}
if no value is associated with path Path
deep_update_with(Path::path(), Fun::fun((term()) -> term()), Map1::map()) -> map()
Update a value in a Map1
associated with Path
by calling Fun
on the
old value to get a new value.
{badmap,Map}
if Map1
is not a map{badpath,Path}
if Path
is not a path{badvalue,P}
if a term that is not a map exists as a intermediate key at
the path P
{badkey,Path}
if no value is associated with path Path
badarg
if Fun
is not a function of arity 1deep_update_with(Path::path(), Fun::fun((term()) -> term()), Init::any(), Map1::map()) -> map()
Update a value in a Map1
associated with Path
by calling Fun
on the
old value to get a new value. If Path
is not present in Map1
then Init
will be associated with Path
.
{badmap,Map}
if Map1
is not a map{badpath,Path}
if Path
is not a path{badvalue,P}
if a term that is not a map exists as a intermediate key at
the path P
badarg
if Fun
is not a function of arity 1inverse(Map::map()) -> map()
Equivalent to inverse(Map, fun (V, _) -> V end).
Inverts a map by inserting each value as the key with its corresponding key as the value. If two keys have the same value, the value for the first key in map order will take precedence.
The call can raise the following exceptions:{badmap,Map}
if Map
is not a mapinverse(Map::map(), Fun::fun((Old::term(), New::term()) -> term())) -> map()
Inverts a map by inserting each value as the key with its corresponding
key as the value. If two keys have the same value in Map
, Fun
is called
with the old and new key to determine the resulting value.
{badmap,Map}
if Map
is not a mapbadarg
if Fun
is not a function of arity 2Generated by EDoc