Max Alekseyev on Sun, 12 Oct 2025 18:58:18 +0200


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

variable vector assignments in loop


Hello,

PARI/GP well supports assignments like
[a,b] = [1,2];

However, this does not work in loops like

? foreach(factor(100)~, [p,k], print([p,k]) )
  ***   variable name expected: foreach(factor(100)~,[p,k],print([p,k]))
  ***                                                ^-------------------

Currently we can only get vectors as whole, but not unpack them:

? foreach(Vec(factor(100)~), pk, print(pk) )
[2, 2]~
[5, 2]~

PS. This particular example would allow us to easily parse primes and their powers from the factorization.

Regards,
Max