From fc1967b11a65690c9ea8274c7c7fda94f7a338fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Mon, 18 May 2015 10:19:24 +0200 Subject: stdlib: Document maps:filter/2 --- lib/stdlib/doc/src/maps.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/stdlib/doc/src/maps.xml b/lib/stdlib/doc/src/maps.xml index e46068230a..7345a9357a 100644 --- a/lib/stdlib/doc/src/maps.xml +++ b/lib/stdlib/doc/src/maps.xml @@ -32,6 +32,28 @@ + + + Choose pairs which satisfy a predicate + +

+ 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, + maps:filter(Pred,M). +#{a => 2,c => 4} +
+
+ -- cgit v1.2.3