aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorMarcus Arendt <[email protected]>2014-08-26 16:22:59 +0200
committerMarcus Arendt <[email protected]>2014-08-26 16:22:59 +0200
commit3703b8964991fee50ea36f71fba115c6abc10e0b (patch)
treeaf154cc510accfa02026a8577d117b9b074d6c2c /lib/stdlib/src
parent83113d9f1df48dc73fbff82705e8aa3fb3af6723 (diff)
parent09ed7cb41a89b56db84dd5e0b15b2fa27d198e71 (diff)
downloadotp-3703b8964991fee50ea36f71fba115c6abc10e0b.tar.gz
otp-3703b8964991fee50ea36f71fba115c6abc10e0b.tar.bz2
otp-3703b8964991fee50ea36f71fba115c6abc10e0b.zip
Merge branch 'kittee/maps_only' into maint
* kittee/maps_only: maps:only/2 -> maps:with/2 add maps:only/2
Diffstat (limited to 'lib/stdlib/src')
-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 3f019aa35a..ba4d6a5c87 100644
--- a/lib/stdlib/src/maps.erl
+++ b/lib/stdlib/src/maps.erl
@@ -24,6 +24,7 @@
map/2,
size/1,
without/2,
+ with/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 with(Ks, Map1) -> Map2 when
+ Ks :: [K],
+ Map1 :: map(),
+ Map2 :: map(),
+ K :: term().
+
+with(Ks, M) when is_list(Ks), is_map(M) ->
+ maps:from_list([{K,V}||{K,V} <- maps:to_list(M), lists:member(K, Ks)]).