Bill Allombert on Wed, 29 Apr 2026 20:31:18 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

multivar for loop variables


Dear PARI developers,

I have commited an experimental change (39f42a6ce5)
That allow to use multivar for loop variables as well:

for example, instead of writing 

foreach(factor(5!)~,pe,my([p,e]=pe);print(p,"^",e))

one can now write

foreach(factor(120)~,[p,e],print(p,"^",e))

Or instead of

forvec(ab=[3,3],my([a,b]=ab);print([a,b]))

forvec([a,b]=[3,3],print([a,b]))

or even

parforprime(p=2,1000,my(N=2^p-1);[N,ispseudoprime(N)],[N,t],if(t,print(p,":",N)))

The drawback is that this is not supported by GP2C and this might be difficult to
implement correctly in all case, given the various way iterators are implemented
in GP2C.

Cheers,
Bill