custom plus-like operator



Continuing the example (the infix declaration in (C1) was unnecessary)

> (C2) nary("aa");
> (D2)                               "AA"
> (C3) "aa"([x]):=apply(nounify("AA"),x);
> (D3)               "AA"([x]) := APPLY(NOUNIFY("AA"), x)

(C5) (1 aa 2) aa (3 aa 4);
(D5)                         (1 AA 2) AA (3 AA 4)

Compare this with

(C6) declare(nounify("AA"),nary);
(D6)                                 DONE
(C7) (1 aa 2) aa (3 aa 4);
(D7)                           1 AA 2 AA 3 AA 4

This becomes a bit clearer by tracing the operator (you need
mtrace.lisp from CVS Maxima for this to work)

(C8) trace("AA");
(D8)                                ["AA"]
(C9) trace_options("AA",lisp_print);
(D9)                             [LISP_PRINT]

and by delaying simplification

(C10) (1 aa 2) aa (3 aa 4),simp:false;
(1 ENTER $AA (1 2)) 
(1 EXIT $AA ((%AA) 1 2)) 
(1 ENTER $AA (3 4)) 
(1 EXIT $AA ((%AA) 3 4)) 
(1 ENTER $AA (((%AA) 1 2) ((%AA) 3 4))) 
(1 EXIT $AA ((%AA) ((%AA) 1 2) ((%AA) 3 4))) 
(D10)                          1 AA 2 AA 3 AA 4

Note that $AA is the verb form and %AA the noun form of the operator.

Anyway, I don't know if this is still related to the original
question...

Wolfgang