[erlang-questions] lists module functions for maps?

Dmitry Belyaev be.dmitry@REDACTED
Tue Sep 24 14:10:55 CEST 2019


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.
>
>
>-- 
>     -Vance
>_______________________________________________
>erlang-questions mailing list
>erlang-questions@REDACTED
>http://erlang.org/mailman/listinfo/erlang-questions

-- 
Kind regards,
Dmitry Belyaev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190924/eb78b23a/attachment.htm>


More information about the erlang-questions mailing list