diff options
author | Björn-Egil Dahlberg <[email protected]> | 2015-05-18 10:19:24 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2015-05-18 10:58:39 +0200 |
commit | fc1967b11a65690c9ea8274c7c7fda94f7a338fa (patch) | |
tree | 54c1c26c7aa8d54bed9d60e8eac67fcde136c90d /lib/stdlib/doc | |
parent | c604ae034a79c3ca8d084de432b51af2affb2c48 (diff) | |
download | otp-fc1967b11a65690c9ea8274c7c7fda94f7a338fa.tar.gz otp-fc1967b11a65690c9ea8274c7c7fda94f7a338fa.tar.bz2 otp-fc1967b11a65690c9ea8274c7c7fda94f7a338fa.zip |
stdlib: Document maps:filter/2
Diffstat (limited to 'lib/stdlib/doc')
-rw-r--r-- | lib/stdlib/doc/src/maps.xml | 22 |
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> |