I'm helping a bit to Vadim in translating maxima info to Russian.
Is maxima's defmatch different from that in Macsyma?
Look at description I have a problem in translating defmatch:
Function: defmatch (<progname>, <pattern>, <x_1>, ..., <x_n>)
Creates a function `<progname> (<expr>, <y_1>, ..., <y_n>)' which
tests <expr> to see if it matches <pattern>.
<pattern> is an expression containing the pattern variables <x_1>,
..., <x_n> and pattern parameters, if any. The pattern variables
are given explicitly as arguments to `defmatch' while the pattern
parameters are declared by the `matchdeclare' function.
Description from Macsyma manual:
defmatch('progname, 'pattern, 'parm1, , 'parmn ) :::
Creates a function, progname, that tests an expression to see if it
matches pattern. The pattern is some expression containing pattern
variables and parameters. The parmi are the formal parameters in the
argument list of progname and are given explicitly as arguments to defmatch.
The pattern variables (if supplied) were given implicitly in a previous
matchdeclare function.
My question, do variables <x_1>, ..., <x_n> give pattern variables or
do they give the formal parameters as Macsyma manual says?
In my opinion (of non-English speaker) the Macsyma manual is written clearly.
Can we take the pieces from there to maxima?
Compare next two:
>From Macsyma:
"For example:
(c1) nonzeroandfreeof(x, e):= if e#0 and freeof(x, e)
then true else false$
This defines a function to test if the expression e is non-zero and free of x.
The command is(e#0 and
freeof(x, e)) is an equivalent function definition for nonzeroandfreeof.
(Macsyma already has a
function non zero and freeof which is described in Section 14.3.2, page 395.)
Now, definne some pattern variables: a to match an expression that is non-zero
and free of x, and b to
match an expression that is free of x:
(c2) matchdeclare(a, nonzeroandfreeof(x), b, freeof(x))$
Now, use defmatch to create a function, linear:
(c3) defmatch(linear, a*x+b, x)$"
And in maxima
Examples:
This `defmatch' defines the function `linearp (expr, y)', which
tests `expr' to see if it is of the form `a*y + b' such that `a'
and `b' do not contain `y'.
(%i1) matchdeclare (a, freeof(x), b, freeof(x))$
(%i2) defmatch (linearp, a*x + b, x)$
(%i3) linearp (3*z + (y+1)*z + y^2, z);