[erlang-questions] lists:mapfind?

Richard A. O'Keefe ok@REDACTED
Tue Aug 22 03:13:12 CEST 2017



On 21/08/17 7:30 PM, Roger Lipscombe wrote:
> On 20 August 2017 at 23:46, Richard A. O'Keefe <ok@REDACTED> wrote:
>>  (1) lists: is absolutely the wrong place for them.
>
> The thing I missed at first is this:
>
> In Lukas's suggestion, these are *list of maps*, and we're searching
> the *list* for the *map* with the specified K/V pair. If we're dealing
> with *lists* (of maps), then the 'lists' module is, at first glance, a
> reasonable place to put this functionality.

The problem is that lists are such a general-purpose data structure.
Suppose we had an analogue of select(2) that took a list of io devices
and returned one of them that was ready, would we put that in the
lists: module or would we expect it to be in io:?

For me, the important thing is not whether the elements are
held in a list or a tuple or a set or whatever but what are
the focal things we're acting on.

Of course, this is arguably an instance of the expression problem,
and such there may be no best answer.




More information about the erlang-questions mailing list