aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/doc/src/maps.xml
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-05-19 10:16:47 +0200
committerBjörn-Egil Dahlberg <[email protected]>2015-05-19 10:16:47 +0200
commit3c7d5d09be54a602cc9bca3d47dd593e479d90d8 (patch)
tree3f50f70d6c6b149a305f5a178f3f56a248e362fe /lib/stdlib/doc/src/maps.xml
parenta3ccd5d0b7e51d67dd65aee37695bc4338f1a195 (diff)
parent48bd85fdfc0648facfc76078f8556a00b4f6febb (diff)
downloadotp-3c7d5d09be54a602cc9bca3d47dd593e479d90d8.tar.gz
otp-3c7d5d09be54a602cc9bca3d47dd593e479d90d8.tar.bz2
otp-3c7d5d09be54a602cc9bca3d47dd593e479d90d8.zip
Merge branch 'egil/maps-filter/OTP-12745'
* egil/maps-filter/OTP-12745: stdlib: Use lc to implement maps:map/2 stdlib: Test maps:filter/2 stdlib: Document maps:filter/2 stdlib: Add maps:filter/2
Diffstat (limited to 'lib/stdlib/doc/src/maps.xml')
-rw-r--r--lib/stdlib/doc/src/maps.xml22
1 files changed, 22 insertions, 0 deletions
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
@@ -33,6 +33,28 @@
<funcs>
<func>
+ <name name="filter" arity="2"/>
+ <fsummary>Choose pairs which satisfy a predicate</fsummary>
+ <desc>
+ <p>
+ Returns a map <c><anno>Map2</anno></c> for which predicate
+ <c><anno>Pred</anno></c> holds true in <c><anno>Map1</anno></c>.
+ </p>
+ <p>
+ The call will fail with a <c>{badmap,Map}</c> exception if
+ <c><anno>Map1</anno></c> is not a map or with <c>badarg</c> if
+ <c><anno>Pred</anno></c> is not a function of arity 2.
+ </p>
+ <p>Example:</p>
+ <code type="none">
+> 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} </code>
+ </desc>
+ </func>
+
+ <func>
<name name="find" arity="2"/>
<fsummary></fsummary>
<desc>