Hi,
I'm declaring an operator "&", which is INFIX, RASSOCIATIVE. I input these lines:
(C1) INFIX("&");
(D1) "&"
(C2) DECLARE("&",RASSOCIATIVE);
(D2) DONE
(C3) X&Y&5;
Wrong number of arguments to "&"
-- an error. Quitting. To debug this try DEBUGMODE(TRUE);)
when I input X&Y&5, MAXIMA throw out this error. But I want to get
something like x & (y & 5)
I then define this operator as:
(C12) "&"(a,b):=(a-b)/(a*b);
a - b
(D12) a & b := -----
a b
this time I get
(C15) X&Y&5;
X - Y
X (----- - 5) Y
X Y
(D15) ---------------
5 (X - Y)
Not an error. But I don't want to define "&" now.
How can I get rid of the error before?
If I declare "&" as NARY, I can get the answer I want.
Must I declare a NARY operator?
But the MAXIMA manual doesn't describe how to define a NARY operator.
If I define a NARY "&" as:
(C29) "&"(a,b):=a+b;
(D29) a & b := a + b
(C30) x&y&5;
Too many arguments supplied to a & b:
[x, y, 5]
#0: \&(a=x,b=y)
#1: \&(a=x,b=y)
#2: \&(a=3,b=7)
-- an error. Quitting. To debug this try DEBUGMODE(TRUE);)
How can I define NARY operators?
Can anyone tell me? Thanks!
--
Wang Yin
DA Lab, Tsinghua University,
100084
Beijing China