[erlang-questions] lists:mapfind?

Lukas Larsson <>
Fri Aug 18 12:20:41 CEST 2017


We do like the idea, however some time has to be spent on figuring out what
the best API would be.

ListOfMaps = [#{ key => 1}, #{ key => 2}],
#{ key => 2 } == lists:keyfind(fun(#{ key := V }) -> V end, 2, ListOfMaps).

#{ key => 2 } == lists:keyfind(key, 2, ListOfMaps).

#{ key => 2 } == lists:find(fun(#{ key := V }) -> V end, 2, ListOfMaps).

#{ key => 2 } == lists:mapfind(key, 2, ListOfMaps).

#{ key => 2 } == maps:findinlist(key, 2, ListOfMaps).

Maybe there are other, better ideas?

My preferences are either lists:keyfind with a fun, or lists:mapfind. I
like lists:keyfind with a fun as it is more general, and allows me to use
any container within a list, it is however not as clear is lists:mapfind in
what the function does.

Also as I stated before, if we add calls for find, we should also add calls
for the other variations of the function.

On Fri, Aug 18, 2017 at 11:23 AM, Max Lapshin <> wrote:

> Ok.
>
> So I wanted to hear something like:
>
> a) it is already written, wait a bit
> b) not written but a good idea: spend some time and write it
> c) bad idea, will not accept it even if you write it.
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170818/1d848031/attachment.html>


More information about the erlang-questions mailing list