[erlang-questions] Guards syntax for multiple values

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Mon Mar 25 19:02:58 CET 2019


On Mon, Mar 25, 2019 at 6:03 PM Florent Gallaire <fgallaire@REDACTED>
wrote:

> For reasons of taste, I prefer Erlang over Elixir, and my "in list"
> operator need comes obviously from my important Python experience.
>
>
Thinking out loud, I think it might be beneficial to look at two additions:

lists:member - because length(..) is in the set of Valid GuardSeqs and is
O(n)
maps:is_key
maps:get

The latter map variants are arguably even stronger since they have good
lookup time, even for very large maps. Writing maps:is_key(X, #{ a => true,
b => true }) should be fast and since it is a literal, it can be optimized
in a number of ways by the compiler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190325/46a8ef0e/attachment.htm>


More information about the erlang-questions mailing list