Loïc Grenié on Sat, 04 May 2024 10:15:27 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Simpler PARI/GP code than this? |
On 2024-05-03 18:19, Bill Allombert wrote:
> ...
> Also, if you just the latest GIT master branch, you can use a map for
> o:
>
> maplistput(~M,k,v) = mapapply(~M,k,(~y)->listput(~y,v),()->List(v));
> z(p) = znorder(Mod(2,p));
> o = Map(); forprime(p=3,2^16+1,maplistput(~o,z(p),p));
> foreach(Vec(o),i, print("-", i, ", ", strjoin(Vec(mapget(o,i)), ", "),
> ","));
>
> Cheers,
> Bill.
>
Thanks, good to know about map functions.
I thought about the problem again (I am a big fan t_VEC constructors
with "<-", 2-tuples and vecsort).
There are 6542 primes <2^16:
? primes(9999)[6542..6543]
[65521, 65537]
L is of type t_POL which is != compared to any t_INT.
Whitespace is not important, so this one-liner creates the same sequence
of numbers(!):
$ cat gen2.gp
foreach(vecsort([[znorder(Mod(2,p)),p]|p<-primes(6542)[2..6542]]),t,[o,p]=t;if(L!=o,L=o;print1(-o,","));print1(p,","))
$ gp -q < gen2.gp | head --bytes 65; echo
-2,3,-3,7,-4,5,-5,31,-7,127,-8,17,-9,73,-10,11,-11,23,89,-12,13,-
$ gp -q < gen2.gp | tail --bytes 65
65292,65293,-65308,65309,-65322,65323,-65356,65357,-65370,65371,