Bill Allombert on Fri, 02 Feb 2024 10:45:30 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: How to perform concat()s without errors on empty vectors or conversions on single-element vectors??
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: How to perform concat()s without errors on empty vectors or conversions on single-element vectors??
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Fri, 2 Feb 2024 10:45:25 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1706867127; c=relaxed/relaxed; bh=FrfXfq3GBBg91vMLWkuYya/Rclat1Lk29V2j9PPP/es=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=vKmBecy3yONwtrnJaYNgQBGaKtfhs/E7NvjGBJ/Ov2zf5KmZmal4KfzgVQaVSiP9w0dMc7eAYr0zJP9OYR9neSW1Vc/b/9EWSiOuXb5OSJwrHy9EIJAmZ5smxnnnGsZSufcGdhZqLlHBqQNYHpUhXpJxLn0HaoBT8N9kYpNm9kSkwY5h2m/UdPXGxu1e6Q3pJFr9M3tUhm63qRDHCeNByHv0DdHoi81Z9r0TDVW8puc0xK5GqFvTAnJIQS8TMgBhmZA9KHVKyHxqskBHKLpXwoJ6p41VyOoFrAxeIszSklxj6ShSiulkWTu0Hqp4si5mzPtDd+Wse47JwXFwT7YTxY0QFcwpVH/Go/Q5kzB4RDeEsYMTZnNZ9l/FCBBGAlc7UZ7oOvPq1x/vUJBfiL63YrUaQsSXl6k+P2VL2CzMriMFBg2k7Wkxa7jPLg79A8VRvf4E+7JDo7D3u0zv4UFVomYtDXwNCpMazw82DgsHDSMetMUPn42c2Io03um8+GDKavteqQ8uCVrm0bkFExNVZiwScU18g97WI1ARjDBDO8uEaJkqZ1gs76EEuw5dpb1OWA60eL+Se4zjOAFXNrUUrZlL/z0U/OdjdJ6pM8+NCIEExnPcYXNSPNhRPxB67OxRT62licKEmScCQnBe3EOU5V1t78F1NvR943LAWeoYpn8=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1706867127; cv=none; b=E6usqcoAstueYDK6ZlcGGKfCGM/e3TvzXwa3quDg9rt4Vq2vCiiw4KOMAbFINjdyLRZ0eIvXEX1AFp1omON15jaYA1aRWiUJLKPdjWG6dXnv2PAVwIJQy16b3YJ6txOlOhQ+YgStXqPRZ+w/QggKCOT+dyrjnyr6v7i3e162DuodJ3NMFxT6QF21T26mlpbJ8ukrBkfDUeuSu9IkyXWyfaydXo6ZNE2R+TGLukkBm0kMkPVoF8c+GGYTFK5nip4+LLfem+jA7npmzaNvbAcRw0DHHZ4XMBZlCz1sfaEaXL38lD5d8nyMs4vvMh9xu0nXOmz2NbeZR6XR1TW7HplkVqvOJUAgVD11vTkV9GVDPmt7TkrhLamwtdQNbmbeipNcW7fnh54FSjQISsIgV71+S6jeIFpg9RIctq+duzgPnHSY7OHfx032/m2a78jaKJErK6+Ypr4YYcof/twDjlcD1xW06cjVGkApRS7UGREXfzPULBh3szLvvmPJYn2L1RMijya65jIjPGcIyqwBBTF/uxXRuKODvBoi1eFeRbkgMqvUFI5k4S9yH7IjcdAADLzJ35Usal+40Ubo9+9gnTsDQnAmY9o18h8Xx7DRlmxAjNi2nSn2P0PIqKaaGKLcUnsyWIGoS1TtUS9b20dJc+ZFYpSqTFfPCIqPPLmhlgqiZfo=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Delivery-date: Fri, 02 Feb 2024 10:45:30 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1706867127; bh=FrfXfq3GBBg91vMLWkuYya/Rclat1Lk29V2j9PPP/es=; h=Date:From:To:Subject:References:In-Reply-To:From; b=d9RUcOz3kSdInfWUEQHsRrLzY7RFJCbl+NE3vfJ8Rtprh5hw/mnus4N3kvxbwwfPq InvCf2+cbkJotoox/q2tE5mKaSKyl2tLF49OyzuvMaU08GsA7Tt3uozxxr1mC5DeJG 78btxlNGmIo125jjBbljWG3ci9TwTLhjvZqLYxmJbOiWc2k4vMXwqUEilE+Lihu5VD fyxaYIIzw6jcfTbOXtvkUxMv2a5itM6MRa0ZGwoYCprp3cHrK53oqkNg8E6DG2iZw3 xkdmH08itYIZZqCkNjmt/SHed8KzqbO4XwxZP8D/K92fpxxChs2eG8l1jIer4OXVLz OH7puayqtWZWh60ZnZZd2wqC8z6jawhfmMRJ+RGs/pKbS49D1bg15/rMWs08onAvRV RiU9k5ZbWc7p2A/arPE55fgzr8bkxaBsSb787TIvbLyV44KTP91bbMTwinPhkw7TyV GsODXjzghnLGLKiokwh0qRrkOBOAx+Sp0pY888IiK5kHOSceWVRWh+gT7Zf5qTW2gg w9SQB4wqera6uMZ4itMdXges56mpwiipLnQDihk9+qucvWBeugPH4ZU29BOj/l32PX PXScaAJ/bmhvZdwc3lMTt5Z3skYsG7ArUw9CD4pwpP2ygv67W0fNZCir9fEPeKMVjk LLhy7QixnPrfZE/XsibXRDcA=
- In-reply-to: <CAEdMSjcJTMDqzLRkT=V2==iseHNCE9P-ADjbFOpgWre3XGup1w@mail.gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <CAEdMSjcJTMDqzLRkT=V2==iseHNCE9P-ADjbFOpgWre3XGup1w@mail.gmail.com>
On Fri, Feb 02, 2024 at 04:34:29PM +1100, Joe Slater wrote:
> I want to convert a vector whose members may be vectors into one long
> vector. This can be done using concat(), but I have two problems:
> 1) it fails when the vector is empty, rather than returning the empty
> vector; and
The issue is that there is not enough information to know that is the neutral
element of your monoid, it could be [], []~, "" etc.
> 2) when the vector has a single element it returns that element rather than
> a vector.
Same issue.
The fix is to put the neutral element as first element of the vector.
? concat([[],1,2])
%1 = [1,2]
? concat([[]~,1,2])
%2 = [1,2]~
? concat(["",1,2])
%3 = "12"
> I.e., I input:
> (16:29) > v=[[1,2],[1,[2,3]],[[1,2],[3,4]],[1],[]];
You should avoid inhomogenous lists like [1,[2,3]],
it is usually safer if all the elements have the same type: [[1],[2,3]]
Cheers,
Bill