mapz

continous integrationhex.pm versionhex.pm licenseerlang versions

Function Reference

<br/>

mapz contains additions to the Erlang maps module, mostly functionality to nested map usage. It tries to stay as true as possible to the original maps API with the same or similar errors where applicable.

Features

Deep Access

Getting & Setting

1> Map = #{a => #{big => #{nested => #{map => with},some => values},
..         in => it,like => "hello"}}.
#{a =>
      #{big => #{nested => #{map => with},some => values},
        in => it,like => "hello"}}
2> mapz:deep_get([a, big, nested, map], Map).
with
3> mapz:deep_search([a, big, nested, list], Map).
{error,[a,big,nested],#{map => with}}
4> mapz:deep_remove([a, like], Map).
#{a =>
      #{big => #{nested => #{map => with},some => values},
        in => it}}

Merging

5> NewMap = mapz:deep_merge(Map, #{a => #{big => #{nested => #{list => [1,2,3]}}}}).
#{a =>
      #{big =>
            #{nested => #{list => [1,2,3],map => with},some => values},
        in => it,like => "hello"}}
6> mapz:deep_search([a, big, nested, list], NewMap).
{ok,[1,2,3]}

Inverse

1> mapz:inverse(#{a => 1, b => 2, c => 3}).
#{1 => a,2 => b,3 => c}