diff options
author | Igor Savchuk <[email protected]> | 2014-07-07 13:43:35 +0400 |
---|---|---|
committer | Igor Savchuk <[email protected]> | 2014-07-07 19:57:27 +0400 |
commit | 0cf5e4d5195b717590ac938df796c69399a4ca07 (patch) | |
tree | ab74a820c77cc61019baa624506c5029f252f5a4 /lib/stdlib | |
parent | a801af8e99b847bc4bd00bf8ba76a638ff90768f (diff) | |
download | otp-0cf5e4d5195b717590ac938df796c69399a4ca07.tar.gz otp-0cf5e4d5195b717590ac938df796c69399a4ca07.tar.bz2 otp-0cf5e4d5195b717590ac938df796c69399a4ca07.zip |
add maps:only/2
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/src/maps.erl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/stdlib/src/maps.erl b/lib/stdlib/src/maps.erl index 4ef1638e6d..b8b284db65 100644 --- a/lib/stdlib/src/maps.erl +++ b/lib/stdlib/src/maps.erl @@ -24,6 +24,7 @@ map/2, size/1, without/2, + only/2, get/3 ]). @@ -201,3 +202,13 @@ size(Map) when is_map(Map) -> without(Ks, M) when is_list(Ks), is_map(M) -> maps:from_list([{K,V}||{K,V} <- maps:to_list(M), not lists:member(K, Ks)]). + + +-spec only(Ks, Map1) -> Map2 when + Ks :: [K], + Map1 :: map(), + Map2 :: map(), + K :: term(). + +only(Ks, M) when is_list(Ks), is_map(M) -> + maps:from_list([{K,V}||{K,V} <- maps:to_list(M), lists:member(K, Ks)]). |