hermann on Tue, 05 Sep 2023 21:28:49 +0200


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

Re: Questions on PARI/GP formatting


On 2023-09-05 18:22, Bill Allombert wrote:
We offer this tutorial:

<https://pari.math.u-bordeaux.fr/Events/PARI2019b/talks/prog.pdf>

Thanks, looks good.

I added whitespace where it helped me, but overall it is not consistent.
Are there best practices wrt GP optional whitespace use?

Examples seem to indicate mostly not to use optional whitespace.

I use "break", should it be "break()" instead?

Yes, because break has an optional argument.

I added "()" to my script breaks -- tutorial example on page 8 misses "()" as well.


I changed my gist, should now look mostly like the examples in tutorial:
https://gist.github.com/Hermann-SW/50514eaf06b4d91ec6bcee5e49732dff


Few followup questions:

1)
I cannot put "my()" in first line of function, because in some cases need to break() before.
Is that OK?

2)
Multi assignment seems to work in "my()", is that OK?
...
test(v)=
{
  if(#v<4,
    break());
  my([l,n,p,q]=v,pnr,qnr,sqrtm1);
...

3)
Variable "n" is not used, but needed for multi assignment to work.
Are there anonymous variables to indicate that?

4)
"for*" loops work multiline only inside "{...}".
I had to put braces around last loop calling "test()" to get multiline foreach working.
Is that OK?

...
};

{
  foreach(rsa,v,
    test(v));
}


Regards,

Hermann.