Hello,
Here's what I try to do. I want a "+"-like operator(s). I.e. they should
be nary, infix and loaded with some algebraic properties, like term
combining (a+0=a, a+a=2*a etc). My difficulties concern this algebraic
loading. As far as I understand, mplus and mtimes are a kind of
priviledged operators, since their processing is done inside of (is
dispatched by ?) simplifya. In MMA parlance I'd express what I want as
MyOp[x___, a_, a_, y___] :=MyOp[x,2 a, y] (MyOp should have ordered
arguments then?). So, how can I do this in Maxima?
/* Here "aa"'s body should be changed to do simplus-like processing,
buf alas! */
(C1) "aa"([x]):=(print(x),'"aa"(x));
(D1) AA([x]) := (PRINT(x), 'AA(x))
(C2) nary("aa");
(D2) "AA"
(C3) infix("aa");
(D3) "AA"
(C4) 1 aa 2 aa f aa 3;
[1, 2]
Wrong number of arguments to AA
#0: AA(x=[1,2])
#1: AA(x=1)
#2: AA(x=23)
-- an error. Quitting. To debug this try DEBUGMODE(TRUE);)
(C5)
Tellsimp'ing doesn't help:
(C1) (nary("aa"),infix("aa"))$
(C2) (matchdeclare(a,true),tellsimp(a aa a, 2*a))$
(C3) b aa a aa b;
(D3) b AA a AA b
(C4) a aa a aa b;
(D4) (2 a) AA b
(C5) declare("aa",commutative);
(D5) DONE
(C6) ''c3;
(D6) b AA a AA b
(C7)
--
Andrei Zorine