Karim Belabas on Thu, 09 May 2024 18:41:48 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: apply / select are inconsistent on Maps
|
- To: Max Alekseyev <maxale@gmail.com>
- Subject: Re: apply / select are inconsistent on Maps
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Thu, 9 May 2024 18:41:43 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1715272905; c=relaxed/relaxed; bh=8BTFNOOvnCvIw/lyMqlrC6bNACE0y3Om6CXuduxHr9o=; h=DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; b=T6bbK7oluXt6GSQpkFEq4QteAIn91X9KtfbH4Z1MkBBl9W2ZmuSldu2dpJRbdsFlT14FW8WIt2v3yiUzhJuiTwXXcfy9rCi18LZYaqKzW7Y1AuFFtPQDqjaaX4B4zAFwuCmA6Pcbo+UhY5DzRhMoe6qf5NVlEutW/5ssyPB1NkqkgRdvOvJkuIOAxg0EF3PSnDF9oan6mMA+q6nqz9sMwnkaVEJyCiYFJi1mJ0ILM95YT027JREjDurdzD7yTbcb4TRmzoutNXhs9ujM6yDkr+w/oTLO6hLgBWon/JtSCN+yINW1KdcciZr2/mcAQWEag/WOyLt8iGkzLVdIoIUavqd8U5p1ivcWBN7zgtUxiJKpu1l6+IHi3ZFb40ybgBK/DSWoAmpMF7uAaKMUEV1RCqNZRWDzwTXki6AWIdXcEc4SLhZU5PFfSnJf30vm5HI4AOo9/qTb9fMgNJxUJ/k5EPd6HdMXKZjnRFTGeaqJ2hWbiBGbIC9P9Y4U4mm696rob3S8Xz8XJEl5InFKIhIqRF4ExZSp7OkFXmYWULp1A4iFqcorYynEILuVr0LD+xYckIMSaMrM7bQmkgrXD1aP4IOQpXIMIiz+Q8yJy2vULnMimX/7XmbxdaFH8g3Qv5zDtZblVAuuEC8JLXD9kFHo05vxVdfnq8sNvt3GafPNBBA=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1715272905; cv=none; b=jqYSkdB822QujtCYeeKXSJJtGCjIjYteXRkqXB4BfnMQc4K6dhzYgkBCjQ/DI2fVu/xew77p/+CTVbqYNMmnEpTSG7aHbS0ltyZAiDtdon+b8hP3LhM9duxxXGY6NvqF9FFRqqbs3yp/CDYE5jBKF8H3FAdcAp1PbjyopSawit5PsydTxaaz1VUHQvF3CY9zWyQhav5s8JnOXdbVVsDXqn3kFxxf/WjvKZzBJlribxB80Mh0vpPfpuetGHrEjtpZ0aY4kU6l+Uj2Q9hB9sElEP3jD0MWy679t9/Ddalx3cDsRC/tPVD+1WzTki9XwqlE7HOP/tiVn8k0WBS2aTbA/nnFcFZa8mELH21luy777Gjve+UG9ywd38exxcgqBMzXy5ubbsBEIxAZABaYtQLnYORoGRErYd4kYU5RTz4NlXaOMItn0mX1Q3CFSU2yIXYg1Dgz2xILBZo5OR2bWfdEzcqh4MIZh+JX6mPD5dAMx+O+txwPAFys7Wcs1tymg9oqykpQ4AKwRq6Y7e70Bi5dhSI4stwBqgVJAMIeLDX8/0XmL/eQ+Zj4Gnb60XRwAD3Am//LuVekLd5jepe+W8wZZGku7LnLQfSevPlGWdTkksLQMnmzj2jlqQg7ztDjw/Jruj8b2nTvBcMS3E8TEABbiciCYu/vfxlkr6yEU9oH5t0=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Cc: pari-users@pari.math.u-bordeaux.fr
- Delivery-date: Thu, 09 May 2024 18:41:48 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1715272905; bh=8BTFNOOvnCvIw/lyMqlrC6bNACE0y3Om6CXuduxHr9o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=leZwxRpVre7yohW8dqs5qV2Z40HP9PZAhcOwD1Z6BtfeOuKZQyoEu2oeIOo7vfd8+ ujiE3n4Y4M/C05uolEj28wZ90jbEwkJRSGJ0J1RIxsuaTnVvUnFI7Ls8E27ijvrKHL 3Sp3Ph1gmz6PiOg/BGL4B0r1KKtyh3Yh3lOdvAGqIN+b+eHg1hC/6YZPAL0UfEmGGj UPFtQOvsV/Uufkde4ijbbfTKzx3PJFKGvzRzFHeGZ6jkb0C2YkTVE/VFNkaXPMnjvs utGcEGY/gkqSVRdAIHpjyxsFDCsIyu4V6ArKjSVRfm2tD3/oC3/Pcfx0EMbqIQnbLv surR1QADDdJbpIoZizTOyrgGbWI+Xt/yEM72enLrUl3IEG0PuW/y3PucCQDXMbSkeZ RBHmJx6GqdQcsEP97s2IJgi+aD7Qv6uXPGW6HqT3dTxHIxW4Ut5ShqYudyKRthw3ET HbfrVlE9zKcr+TnCFMXG9SUNbL6oa0WOiikQ9dXIZ4GETW2EWEmhAIjzwa388DObDQ nIaaEYeepBOqckmNxDLOsgnL1XmhHKt/tloz3NevewCW26RE6G06L0hV26qi6YGj+S 2Nu87mft6UGa9ZAp5xVtGlc8hBsFAmoO5JD6a2WiZPUTgoP0reke21a2MElCdeBXyq lgHaRnK57QgrKci1YPJv2r2U=
- In-reply-to: <CAJkPp5O2jGJKFiq=3cP+NMHV7cMmZQVB2YUHF38LsP5-og6sdw@mail.gmail.com>
- Mail-followup-to: Max Alekseyev <maxale@gmail.com>, pari-users@pari.math.u-bordeaux.fr
- References: <CAJkPp5O0RdYjvGdotU43A+jzHEkNziDr1SywNoyxrr40J7qNQw@mail.gmail.com> <ZjzrEESV1EkQ491B@math.u-bordeaux.fr> <CAJkPp5O2jGJKFiq=3cP+NMHV7cMmZQVB2YUHF38LsP5-og6sdw@mail.gmail.com>
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/