REDUCE

7.26 Declaring New Infix Operators

Users can add new infix operators by using the infix and precedence declarations. For example,

        infix mm;
        precedence mm,-;

The declaration infix mm; would allow one to use the symbol mm as an infix operator:

  a mm b  instead of   mm(a,b).

The declaration precedence mm,-; says that mm should be inserted into the infix operator precedence list just after the \(-\) operator. This gives it higher precedence than \(-\) and lower precedence than * . Thus

  a - b mm c - d  means   a - (b mm c) - d,

while

  a * b mm c * d  means   (a * b) mm (c * d).

Both infix and prefix operators have no transformation properties unless let statements or procedure declarations are used to assign a meaning.

We should note here that infix operators so defined are always binary:

  a mm b mm c  means   (a mm b) mm c.


Hosted by Download REDUCE Powered by MathJax