From: Stavros M. <mac...@gm...> - 2025-08-15 17:45:11
|
Robert, I was surprised that the noun-operators work just fine.... But '"=" seems to be the one bad case: ' "*"(a,' "+"(b,c),d) => a (b + c) d << parens necessary ' "+"(a,' "*"(b,c),d) => a + b c + d << parens not necessary ' "."(a,' "+"(b,c),d) => a . (b + c) . d ' "+"(a,' "."(b,c),d) => a + b . c + d "="(a,b+1) => a = b + 1 << correct rendering with regular "=" ' "="(a,b+1) => a = (b + 1) << BAD, parens are not necessary On Sun, Aug 10, 2025 at 6:41 PM Robert Dodier <rob...@gm...> wrote: > On Fri, Aug 8, 2025 at 1:50 AM Oleg Nesterov <ol...@re...> wrote: > > > (%i1) '"+"(2,2) = 4; > > (%o1) 2 + 2 = 4 > > Huh, I'm a little surprised (although not very much) that this has the > expected effect ... I guess that's a %MPLUS expression instead of > MPLUS, and the simplification rules for MPLUS aren't also implemented > for %MPLUS. OK by me. > > > (%i2) '"."(matrix([1, 2], [3, 4]), matrix([1], [2])) = > matrix([5],[11]); > > ┌ ┐ ┌ ┐ ┌ ┐ > > │ 1 2 │ │ 1 │ │ 5 │ > > (%o2) (│ │) . (│ │) = │ │ > > │ 3 4 │ │ 2 │ │ 11 │ > > Here the issue is that the operator is %MNCTIMES which does not have a > right or left binding power (precedence) defined for it. Try this: > > :lisp (setf (get '%mnctimes 'rbp) (get 'mnctimes 'rbp)) > :lisp (setf (get '%mnctimes 'lbp) (get 'mnctimes 'lbp)) > > which gives %MNCTIMES the same precedence, and therefore parentheses > in the same places, as MNCTIMES. > > > (%i4) a = b . c; > > (%o4) a = b . c > > (%i5) '"="(a, b.c); > > (%o5) a = (b . c) > > (%i6) :lisp (defprop %mequal 80. lbp) > > (%i6) :lisp (defprop %mequal 80. rbp) > > Likewise I guess we would say > > :lisp (setf (get '%mequal 'rbp) (get 'mequal 'rbp)) > :lisp (setf (get '%mequal 'lbp) (get 'mequal 'lbp)) > > I don't see why the nounified operators should not have the same > binding powers as the un-nounified -- I will try to remember to update > grind.lisp. > > Robert > > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |