### The Maxima on-line user's manual

Algebra Calculator

#### Matchfix

Function: matchfix (<ldelimiter>, <rdelimiter>)

Function: matchfix (<ldelimiter>, <rdelimiter>, <arg_pos>, <pos>) Declares a matchfix operator with left and right delimiters <ldelimiter> and <rdelimiter>. The delimiters are specified as strings.

A "matchfix" operator is a function of any number of arguments, such that the arguments occur between matching left and right delimiters. The delimiters may be any strings, so long as the parser can distinguish the delimiters from the operands and other expressions and operators. In practice this rules out unparseable delimiters such as `%`, `,`, `\$` and `;`, and may require isolating the delimiters with white space. The right delimiter can be the same or different from the left delimiter.

A left delimiter can be associated with only one right delimiter; two different matchfix operators cannot have the same left delimiter.

An existing operator may be redeclared as a matchfix operator without changing its other properties. In particular, built-in operators such as addition `+` can be declared matchfix, but operator functions cannot be defined for built-in operators.

`matchfix (<ldelimiter>, <rdelimiter>, <arg_pos>, <pos>)` declares the argument part-of-speech <arg_pos> and result part-of-speech <pos>, and the delimiters <ldelimiter> and <rdelimiter>.

"Part of speech", in reference to operator declarations, means expression type. Three types are recognized: `expr`, `clause`, and `any`, indicating an algebraic expression, a Boolean expression, or any kind of expression, respectively. Maxima can detect some syntax errors by comparing the declared part of speech to an actual expression.

The function to carry out a matchfix operation is an ordinary user-defined function. The operator function is defined in the usual way with the function definition operator `:=` or `define`. The arguments may be written between the delimiters, or with the left delimiter as a quoted string and the arguments following in parentheses. `dispfun (<ldelimiter>)` displays the function definition.

The only built-in matchfix operator is the list constructor `[ ]`. Parentheses `( )` and double-quotes `" "` act like matchfix operators, but are not treated as such by the Maxima parser.

`matchfix` evaluates its arguments. `matchfix` returns its first argument, <ldelimiter>.

Examples:

* Delimiters may be almost any strings.

```          (%i1) matchfix ("@@", "~");
(%o1)                          @@
(%i2) @@ a, b, c ~;
(%o2)                      @@a, b, c~
(%i3) matchfix (">>", "<<");
(%o3)                          >>
(%i4) >> a, b, c <<;
(%o4)                      >>a, b, c<<
(%i5) matchfix ("foo", "oof");
(%o5)                          foo
(%i6) foo a, b, c oof;
(%o6)                     fooa, b, coof
(%i7) >> w + foo x, y oof + z << / @@ p, q ~;
>>z + foox, yoof + w<<
(%o7)                ----------------------
@@p, q~```

* Matchfix operators are ordinary user-defined functions.

```          (%i1) matchfix ("!-", "-!");
(%o1)                         "!-"
(%i2) !- x, y -! := x/y - y/x;
x   y
(%o2)                   !-x, y-! := - - -
y   x
(%i3) define (!-x, y-!, x/y - y/x);
x   y
(%o3)                   !-x, y-! := - - -
y   x
(%i4) define ("!-" (x, y), x/y - y/x);
x   y
(%o4)                   !-x, y-! := - - -
y   x
(%i5) dispfun ("!-");
x   y
(%t5)                   !-x, y-! := - - -
y   x```

```          (%o5)                         done
(%i6) !-3, 5-!;
16
(%o6)                         - --
15
(%i7) "!-" (3, 5);
16
(%o7)                         - --
15```

```(%o1)                                true
(%i2) ```

? matchfix;

Calculate

? matchfix;

Calculate