[erlang-questions] Wanted additions to the maps module?
Jesper Louis Andersen
Wed Apr 13 13:09:53 CEST 2016
On Fri, Apr 8, 2016 at 8:31 PM, Björn-Egil Dahlberg <
> Have you repeated some code or built your own private lib to handle
> certain maps specific tasks and thought "why isn't this in the maps module?"
One function I like to have is "apply update via function", and I implement
it somewhat often:
maps_apply(F, K, Map) ->
V = maps:get(K, Map),
maps:put(K, F(V), Map).
But it can be made much faster in a direct implementation since I don't
have to first pick up the value: I can apply F when I sit with the value at
hand and thus avoid the "put" lookup path. It might, however, be nasty to
implement because F is in Erlang-context, whereas the maps operations are
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions