[erlang-questions] lists module functions for maps?

Karl Velicka karolis.velicka@REDACTED
Tue Sep 24 14:41:36 CEST 2019


I agree with Dmitry - if the pattern is common enough then a new module for
dealing with such structures seems like the best way forward. Invisible to
those that don't need it but available and performant to those that do.

Karl

On Tue, 24 Sep 2019, 15:11 Dmitry Belyaev, <be.dmitry@REDACTED> wrote:

> If it's all about lists, you've got all you need: lists:search/2 or as
> previously mentioned lists:dropwhile.
>
> To me presence of lists:key... functions is a serious legacy which is
> justified only because there are tons of code using it. I'm glad we don't
> have all of the 'sofs' functions in 'lists' module.
> Of course it would be nice to have faster versions than handcrafted
> functions, but I'd like them to be introduced in a separate module, e.g.
> list_of_maps.
>
> On 24 September 2019 3:32:55 pm AEST, Vance Shipley <vances@REDACTED>
> wrote:
>>
>> On Tue, Sep 24, 2019 at 10:48 AM Richard O'Keefe <raoknz@REDACTED> wrote:
>>
>>> I would argue that the focus of these functions is the maps, not the lists they happen to be inside.
>>>
>>
>> In my mind this is all about lists. Think small maps and big lists.
>> That the terms are maps is a detail I have to deal with in processing
>> my lists. I just want the lists module to be orthogonal. If we aren't
>> going to move all the lists:key* functions to a 'records' module
>> (please don't) let's simply add support for the new term type which
>> "replaces" records.
>>
>> Your example is certainly all about maps but it doesn't help my use cases.
>>
>> Perhaps the whole thing is inside out.  Perhaps what's really needed
>>> is something that says
>>>  - here is a list of maps and a key
>>>  - give me a map of lists and a list
>>>  If {M,R} = maps:transpose(Ms, K)
>>>  then R is the filter of Ms by the condition "does not have key K"
>>>  and M is a map from V to the filter of Ms by the condition "has V as
>>> value for key K".
>>> Only do the linear scan once.
>>>
>>
>>
> --
> Kind regards,
> Dmitry Belyaev
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190924/3b213f91/attachment.htm>


More information about the erlang-questions mailing list