Ruud H.G. van Tol on Tue, 12 Mar 2024 10:24:13 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Avoid using "listput()" if possible?
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: Avoid using "listput()" if possible?
- From: "Ruud H.G. van Tol" <rvtol@isolution.nl>
- Date: Tue, 12 Mar 2024 10:24:07 +0100
- Delivery-date: Tue, 12 Mar 2024 10:24:13 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=isolution.nl; s=soverin; t=1710235450; bh=dVQ6kulxylPOMJNP3XBXbLjvUblo3Hw46mUuxg22eWA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=l1RKwUxKLRQUaQ6XEnhCUsruK/U56Le7FXlUPVln+8m/uNat+oDKWm6YrM7VHJo03 1AnngOmIOjwhac43RAoeJMF0CdRMbNTIFRsEI5mztt8/EkDiB9XWTpLaESnGe5KJ1t g/zcG0lPLZB5kRFQeikDrF9oKxl/xbAXmF/ac24ibj4FvBpL8b/moljGolOm/l0U5L A+X/RD7r7s+p1XtXCuFHBasmccqhWG5xN1JCXvXENQEvP+Ls+7iOkumGg8mGRvz7bR ZZrpldsJnhfk2NZuN8DYxfreIjZ7yBgHAqxyJSrgGq83vL2XHMXCwZfbgotzTi+4sU gVNFZTvB/3djw==
- In-reply-to: <828080f4d966c56549c5ed0cea3be1cb@stamm-wilbrandt.de>
- References: <828080f4d966c56549c5ed0cea3be1cb@stamm-wilbrandt.de>
On 2024-03-12 09:06, hermann@stamm-wilbrandt.de wrote:
Yesterday I was happy to have working "SquaresRepresentations(n,k)"
using "for(...foreach(...listput(..)))".
[...]
I see that "listput()" is definitely needed in some scenarios.
Question is, whether using lists should be avoided if possible as
above? Without list above looks nicer to me; is a general statement
about runtimes with/without list on big inputs possible?
concat() is fine for vectors of short length.
? my(N=2^12, v=[]); for(i=1,N, v=concat([i],v));
cpu time = 119 ms, real time = 120 ms.
? my(N=2^12, v=List()); for(i=1,N, listput(v,i)); Vecrev(v);
cpu time = 3 ms, real time = 3 ms.
-- Ruud