You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cadabra book says Lines always have to be terminated with either a “;” or a “:”.
In cadabra2-cli 2.4.2 this works with expressions "a:=something", but not with algorithms.
Algorithm with ":" produces an "invalid syntax" error.
Algorithm with ";" works as expected, with output.
Algorithm without ";" or ":" works without output, but does not modify "_" expression:
#!/usr/bin/cadabra2-cli
a:= a = a1:
substitute($b=b1$, $b1=b2$);
substitute(a, $a1=a2$)
print("print(_):", _)
print("print(a):", a)
Output ('_' contains result of first substitute, not last one):
b = b2
print(_): b = b2
print(a): a = a2
Adding '\' after substitute($b=b1$, $b1=b2$); suppresses output of this line and makes the next line to set "_". This is the only way I found to stack multiple algorithms with using "_" and without producing output.
It would be good to have better documentation to understand this behaviour...
The text was updated successfully, but these errors were encountered:
Yeah, this is a bit of a weird left-over from the days that Cadabra did not use Python for its programming language. If I ever find a few hours of spare time just sitting in a corner, I'll clean this up :-(
The first issue is, on second thought, actually intended. The logic is that if you use ; to display the last expression, then _ gets assigned a reference to the last expression. If you don't do that (if you do not terminate that substitute(...) with a ;) then _ remains unchanged. A simple workaround is
a:= a = a1:
substitute($b=b1$, $b1=b2$);
_ = substitute(a, $a1=a2$)
That is: set the 'last expression' variable '_' manually.
The other issues are now solved in 2248d92 (on the microtex branch, will become master soon).
The cadabra book says
Lines always have to be terminated with either a “;” or a “:”
.In cadabra2-cli 2.4.2 this works with expressions "a:=something", but not with algorithms.
Algorithm with ":" produces an "invalid syntax" error.
Algorithm with ";" works as expected, with output.
Algorithm without ";" or ":" works without output, but does not modify "_" expression:
Output ('_' contains result of first substitute, not last one):
Adding '\' after
substitute($b=b1$, $b1=b2$);
suppresses output of this line and makes the next line to set "_". This is the only way I found to stack multiple algorithms with using "_" and without producing output.It would be good to have better documentation to understand this behaviour...
The text was updated successfully, but these errors were encountered: