Bill Allombert on Fri, 25 Oct 2013 00:10:50 +0200

 Re: parallel pari: parfirst

• To: pari-dev@pari.math.u-bordeaux.fr
• Subject: Re: parallel pari: parfirst
• From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
• Date: Fri, 25 Oct 2013 00:10:36 +0200
• Delivery-date: Fri, 25 Oct 2013 00:10:50 +0200
• Mail-followup-to: pari-dev@pari.math.u-bordeaux.fr
• References: <20131023211658.GB8496@yellowpig> <CAMLkfFS8=1csHSy6dogTGYjn6vR3zpiVpT3D7W0NVRCbmxOASw@mail.gmail.com>
• User-agent: Mutt/1.5.21 (2010-09-15)

```On Wed, Oct 23, 2013 at 11:43:52PM +0200, Loïc Grenié wrote:
> 2013/10/23 Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>:
>     C'est là que mes itérateurs reprennent du poil de la bête:
>
> I = iterlinearinit(1); [iterlinearinit(a,b,s) itèrerait de a à b par pas de s]
> inline(chkell);
> chkell(p)=a->my(E=ellinit([1,a],p));isprime(ellcard(E));
> ellp(p)=parfirst(chkell(p),I);

Loïc was suggesting to add 'iterators' to GP so that parfirst could be
applied to potentially infinite lists.

Unrelatedy, if you want to define iterator in GP you can do

mkiter(v,fun,name)=my(x__=[v,fun,name]);eval(Str(name,"=x__"));
a__.value=a__[1];
a__.next=my(x__=a__[2](a__[1]));eval(Str(a__[3],"[1]=x__"));

? mkiter(1,x->x++,"iter1");
? iter1.value
%3 = 1
? iter1.next
%4 = 2
? iter1.value
%5 = 2
? iter1.next
%6 = 3

Cheers,
Bill.

```