Defining new operator syntax and printing correctly
Subject: Defining new operator syntax and printing correctly
From: Stavros Macrakis
Date: Wed, 9 Apr 2008 16:26:52 -0400
I want to define an operator (say %%) which has higher binding power
than "," and lower binding power than the logical and arithmetic
operations, so that
[ a + b %% c or q, d %% e ]
will parse the same as
[ ((a+b) %% (c or q)) , ( d %% e) ]
This is pretty straightforward:
infix("%%", 15, 15)$
foo: [ a + b %% c or q, d %% e ] $
/* Show fully parenthesized form: */
scanmap(nounify(""),foo) => ([(q), ((((b) + (a)) %% ((c) or (q)))),
(((d) %% (e)))])
However, on printout, Maxima inserts unnecessary parentheses:
foo => [b + a %% c or q, (d %% e)]
What can I do so that it won't?
-s