| hermann on Fri, 06 Oct 2023 19:37:08 +0200 | 
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: "my(...)" scoping question | 
On 2023-10-06 19:14, hermann@stamm-wilbrandt.de wrote:
I added "if(n%8!=7,assert(F[4]==0));" as last line into main "{ ... }"
block (to prove that really sum of 3 squares got computed):
{
  foreach(rsa,r,[l,n]=r;
    my(F=foursquarep(n));
    print(l," ",F);
    assert(vecsum([x^2|x<-F])==n));
    if(n%8!=7,assert(F[4]==0));
}
Although output for RSA-2048 as well as vecsum assert are good, the
following assert "thinks" F is a t_POL:
Sorry, my fault.
I missed to move the closing ")" from foreach after now last statement.
Now all is fine (I had to change condition to "if(n%4==1..." as well):
{
  foreach(rsa,r,[l,n]=r;
    my(F=foursquarep(n));
    print(l," ",F);
    assert(vecsum([x^2|x<-F])==n);
    if(n%4==1,assert(F[4]==0)));
}
Regards,
Hermann.