Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brackets and #write #262

Closed
vsht opened this issue Feb 8, 2018 · 2 comments
Closed

brackets and #write #262

vsht opened this issue Feb 8, 2018 · 2 comments
Labels
question Question about FORM

Comments

@vsht
Copy link

vsht commented Feb 8, 2018

I would like to use brackets to simplify the output of FORM before passing it to other programs. However,
it seems that the brackets do not survive a #write instruction, even if there is no intermediate sort inbetween. Consider for example

off statistics;
S a,b,z,y;
L exp = a*y^2 + 3*a + z*b+ z^3*b;
.sort
bracket a, b;
print exp;
#$a1 = exp;
#write <exp.frm> "%$",$a1;
.end

the print statement produces

   exp =
       + b * ( z + z^3 )

       + a * ( 3 + y^2 );

which is exactly what I want, but the content of my exp.frm is nevertheless

b*z+b*z^3+3*a+a*y^2

A naive workaround is to use a "fake" collect

off statistics;
S a,b,z,y;
CF head;
L exp = a*y^2 + 3*a + z*b+ z^3*b;
.sort
bracket a, b;
.sort
collect head;
.sort
print exp;
#$a1 = exp;
#write <exp.frm> "%$",$a1;
.end

and remove head in a later step. However, this probably would not work for very large expressions and in general appears to be an ugly hack. I believe that I'm not the first person to encounter this complication, so I wonder what is the recommended workaround.

Cheers,
Vladyslav

@vermaseren
Copy link
Owner

vermaseren commented Feb 8, 2018 via email

@vsht
Copy link
Author

vsht commented Feb 8, 2018

Perfect, many thanks!

@vsht vsht closed this as completed Feb 8, 2018
@tueda tueda added the question Question about FORM label Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about FORM
Projects
None yet
Development

No branches or pull requests

3 participants