Bill Allombert on Fri, 25 Oct 2013 00:10:50 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: parallel pari: parfirst |
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.