aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/maps.erl
diff options
context:
space:
mode:
authorIgor Savchuk <[email protected]>2014-07-07 13:43:35 +0400
committerIgor Savchuk <[email protected]>2014-07-07 19:57:27 +0400
commit0cf5e4d5195b717590ac938df796c69399a4ca07 (patch)
treeab74a820c77cc61019baa624506c5029f252f5a4 /lib/stdlib/src/maps.erl
parenta801af8e99b847bc4bd00bf8ba76a638ff90768f (diff)
downloadotp-0cf5e4d5195b717590ac938df796c69399a4ca07.tar.gz
otp-0cf5e4d5195b717590ac938df796c69399a4ca07.tar.bz2
otp-0cf5e4d5195b717590ac938df796c69399a4ca07.zip
add maps:only/2
Diffstat (limited to 'lib/stdlib/src/maps.erl')
-rw-r--r--lib/stdlib/src/maps.erl11
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)]).