Max Alekseyev on Thu, 09 May 2024 19:11:20 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: apply / select are inconsistent on Maps


Support for binary function would be most general and helpful.
Regards,
Max

On Thu, May 9, 2024, 12:41 PM Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> wrote:
According to its documentation, apply() shouldn't be expected to work either.

In this case, there is a "natural" definition by composing the
functions, i.e., applying the function to the map values. So it does
make sense to fix the documentation of apply.

In the case of select(), should one select the map entries according to
properties of keys ? values ? pairs of (key,values) ? The most natural
for me would be the last one, requiring a function of arity 2
[in terms of which users can easily emulate the other behaviours]
But isn't that totally obscure ?

Cheers,

      K.B.

* Max Alekseyev [2024-05-09 18:18]:
> Hi Karim,
>
> But why not extend the functionality of select() to Maps, just making it
> consistent with how apply() works?
>
> Regards,
> Max
>
> On Thu, May 9, 2024 at 11:26 AM Karim Belabas <
> Karim.Belabas@math.u-bordeaux.fr> wrote:
>
> > Hi Max,
> >
> > * Max Alekseyev [2024-05-09 16:39]:
> > > Hello,
> > > The following example shows that
> > > (i) apply() and select() disagree on what is argument of the function
> > when
> > > applied to Map; and
> > > (ii) select() produces List rather than Map as a result.
> >
> > Undefined behavior: select() is not documented to apply to maps.
> > (In fact, it somehow applies because maps are internally implemented as
> > t_LISTs.)
> >
> > select should just throw an exception on this input.
> >
> > Cheers,
> >
> >     K.B.
> > --
> > Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
> > Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
> > http://www.math.u-bordeaux.fr/~kbelabas/
> >

    K.B.
--
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/