wxMaxima-developers / wxmaxima

A gui for the computer algebra system Maxima built with wxWidgets
https://wxMaxima-developers.github.io/wxmaxima/
Other
482 stars 99 forks source link

Maxima underscore function does not work properly any more #1935

Closed RolandSalz closed 3 months ago

RolandSalz commented 3 months ago

wxMaxima 21.05.2, Windows 10, Erzeugungsversion 19045

f(d,e):=[d,e]$ f(r,s)[1]$ _;

in wxMaxima returns

[f,simp]_1

instead of what it used to and what the Maxima console 5.45.1 gives and what is what function _ is supposed to return (it returns the last input):

f(r,s)_1

gunterkoenigsmann commented 3 months ago

That problem requires a lisp wizard => asked the maxima team for help. Let's see what they answer.

robert-dodier commented 3 months ago

After some investigation, looks like WXXML-ARRAY is not working correctly. Here is a patch which appears to fix the problem in limited testing.

diff --git a/src/wxMathML.lisp b/src/wxMathML.lisp
index 71a986c..fe3fb77 100644
--- a/src/wxMathML.lisp
+++ b/src/wxMathML.lisp
@@ -252,9 +252,8 @@ Submit bug reports by following the 'New issue' link on that page."))
 ;; array, not the contents thereof.
 ;;
 ;; Adapted from DIMENSION-ARRAY and DIMENSION-INDICES in Maxima src/displa.lisp.
-(defun wxxml-array (x l r &aux base-symbol)
-  (if (eq (caar x) 'mqapply)
-      (setq base-symbol (cadr x) x (cdr x))
+(defun wxxml-array (x l r &aux (base-symbol nil))
+  (unless (eq (caar x) 'mqapply)
       (setq base-symbol (caar x)))
   (let
       ((display-indices (safe-mget base-symbol 'display-indices))

Here are some test cases which you can try to judge whether the output is correct.

foo[x];
foo(y);
foo[x](y);
foo(x)[y];
foo[x][y];
1/foo(x)[y]+1;
1/(1/foo(x)[y]+1)+1;
1/(1/foo[x][y,z]+1/foo(a,b,c)(w,x)+1/foo(x,y)[a,b]);
1/(1/foo(a,b,c)(w,x)+1/foo[x][y,z][g,h]+1/foo(x,y)[a,b]);
foo[x](y)[z];
foo(x)[y](z);

Hope this helps,

Robert

daute commented 3 months ago

Thanks Robert. That - hopefully - solves the issue. The outputs from (command line) Maxima look similar to the wxMaxima-outputs.

RolandSalz commented 2 months ago

Thank you very much to all of you for designing and implementing the fix !! This bug for me was VERY severe. Most of my programs returned a mess with my "pretty print" output function which I use almost everywhere.