Karim Belabas on Mon, 08 May 2023 17:24:53 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: boolean values for [] and List()
|
- To: Max Alekseyev <maxale@gmail.com>
- Subject: Re: boolean values for [] and List()
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Mon, 8 May 2023 17:23:25 +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=1683559397; c=relaxed/relaxed; bh=0PIUX2qaWZW4SdeT4ZjenidZFhSQnpmCJjYgvYDAXJQ=; 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=EKu3uMbpHgndfe/uo4tsVb9Te4FUPE9k0jkSsKfHYylV9aHB2pKfWxeE/wxLmbX7KMWutvjanIynmik4BFiAMptX7ylJnYpvlWCYfJz4sX+SQoY9TrizH3NGj2A2xoDqrvUnVpnF2S2jGLb868G2pm2AOOU994hmDTzw+2rr88spEHaQdop7yRZDjXo01Yr/QGSp8JK/B1ECq/tYLS4+uj+Yv+T/2p+NsgUDHagIHlPRSDOPhMYRLcT43+laGsYG4wXeybiFSUHn0mcWKih7XVEJdN7w4U5LrhLUqk6X5VJ9DGLYWVmEK54eN66lKngbvAmnWPrjwmQTdqeytN66lbjzbsK7uhilXyzcw5ZDflKtX3lx1rLsPcZPmsITGwODrI9XtkYhWuY5K7pno/CfcFrpWzb1W1klrCV4bR+H4YMgWl4IpV34FxWqi1q03JIBiYO6rubac9cW4RwAEVqYyGqk0QiZk7a+mzHxHNvPT0upNKhz7tof7dhHSJVIfcnbRhvmE9Nl+Cl9H0uB+zJv+SilRUiwRsXY/dExWT48KeD9RHGFHZtF/2/dU0/cckK3FUwtqu8LT4HRtVx7rqnnQtYTr+fdQVzljROO3qKAiONVRVO/vMPYob9ad7LxanYoviWh6lLLXXPmRV1ABq9hw7ZxX1mCeyHXUoPj6WGgYeU=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1683559397; cv=none; b=CrS/J1INochDs5HULLH+PrQpqi52VJNG5mcIvAsabb4wZGBgoyzwnmyWkxRJDjh2cSaSE3XksibNrejBMTx9ZcXou/QDBzqWCIfdPRCLW0+7V919mps71zWEdYPJpSNRffTkzt22POhwoeU7tW0LczoCAjBuSf5srRyrNrMASf59KF4ZuanLB4+sw02hpf8h5lxzMU84GRBR7PyO2a7kZ24lcUrNpixOHFoa4QPMRCAYeBhldlu0pJFlXwyyj9Fy9d4CEKizWm/0VrI4FcE1CdOktmq5J6uCMpwjMztxPBQqDPvchHXYWA/oCQdsHqCDygCoJ9/7IS8TKqFculT5iQHT+29KPVtEyDKE82GVmEeS/cAmODqj+e4eOpx6ZSdGnLF7Gig3B97IWiL18GjB1azYk7hoUEHaTWyarHyQKAbQebGg2+0jk65eAvenyJkknVrtIPnG1f4D+ARma2I3P6whJe28tQoVWRaDrjmDzJq2TQqWJDwhQ6Dm0ksoDutumLTJIESrdMKBd4MOsN2kkSz5u9QBYuKhKGthXsAFF5E0IYd/AQPxNyGiTdfYXl0WDVSWoFIUGdTVHPVlOd+X0klmjHUCmqbM2LJlUj0shqD/ecve+YvOF0PrwnRRA/+1sVN3jakg+KxurdyBmdLpD9m54LFAj+CS119vSV311Ng=
- 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: Mon, 08 May 2023 17:24:53 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1683559397; bh=0PIUX2qaWZW4SdeT4ZjenidZFhSQnpmCJjYgvYDAXJQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eL8VgbaL6pdL+hPRSuvxDYxKdCefMLGx/Qc4ysyF4NEDjRgyeMc7jAB3X1dNamRAE efa6Ff8mZ/MNNtY4jpUcfDaUOUQ7THR8f8nk0Jw1b1iDdOtjLCMuzv5ANtiqH5HPnQ I+HzTvXkvftzNzZo4cKMKUu0/aL5zOGMEN7lYPn5DP+qBhriZyg5v874IxOwEdZgMX Vc6tB/8Y6AErug/QlE71LCyYR14PTvQCMfYuyTLky1aXDBHxMoiU3E+3i3v6fTBNun z5B+7fyp2CYw5YRLa0vIZIbQ9XonyXB/3/M14RQTlYSe/aNF1LB8ZGt0La6EhP+y0X xTNrLwekalWGehr8GoZ2/r+9RmES8ufF0vaDsYNPhgqPKR3IwOEcTv3Ut8/ZDt/GcP afXz36SUZili/F5eNgsYCKztot+HB52Nq5AMHYiWaQCsDj8UI+oPLr6thOtLGn4o4o 3/Bud8Gym5plKtHbTUrMGWwKX242kouI912QP7SjIuM/N2xunkyqw6DAOCO1deK1gz NVNZahn+w9cKvodEE/zo0S8ApP0RVgTKmt4uBMKVz3OOqx5GArNaHa0omcu6oE5vA9 A+pIS1HZ392hfUca6BRsodhAsr4z2lhJhDiDy5Ortzrq1wkTlrKOxYUbk6d7g1PZrS 0ehitU09RmOn01QUYVh1LuFE=
- In-reply-to: <CAJkPp5MrQ64o4vJR=7BANfEJRWtSAosjs-FGQHQozoNsHjbXtA@mail.gmail.com>
- Mail-followup-to: Max Alekseyev <maxale@gmail.com>, pari-users@pari.math.u-bordeaux.fr
- References: <CAJkPp5MrQ64o4vJR=7BANfEJRWtSAosjs-FGQHQozoNsHjbXtA@mail.gmail.com>
* Max Alekseyev [2023-05-08 16:55]:
> Why is there a discrepancy between empty vector and empty list?
>
> ? if([], print("yes"), print("no"))
> no
> ? if(List(), print("yes"), print("no"))
> yes
Side effect of other definitions and design choices: PARI's '==' (here == 0)
operator is dodgy, use '===' if you want more consistent semantics.
The definition for a == b when it doesn't obviously makes sense is to
check whether a - b evaluates to 0, where an evaluation error is
interpreted as 'NO'. A t_LIST is not an arithmetic type and doesn't
support subtraction, so List() - 0 is an error (whereas [] - 0 is [],
which evaluates to 0 by another convention).
In short, a t_LIST is always 'non-0'.
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/