maps

maps

Module

maps

Module summary

Maps Processing Functions

Description

This module contains functions for maps processing.

Exports

filter(Pred, Map1) -> Map2

Types:

Pred = fun((Key, Value) -> boolean())
Key = Value = term()
Map1 = Map2 = #{}

Returns a map Map2 for which predicate Pred holds true in Map1.

The call will fail with a {badmap,Map} exception if Map1 is not a map or with badarg if Pred is not a function of arity 2.

Example:

> M = #{a => 2, b => 3, c=> 4, "a" => 1, "b" => 2, "c" => 4},
  Pred = fun(K,V) -> is_atom(K) andalso (V rem 2) =:= 0 end