pattern matching



On 3/10/08, Marcello Musso <musso at physics.utexas.edu> wrote:

>  (%i1) matchdeclare([arg,t],all);
>  (%o1) done
>  (%i2) defmatch(check,diff(arg,t));
>  (%o2) check
>  (%i3) depends(N,t);
>  (%o3) [N(t)]
>  (%i3) check(diff(N,t));
>  (%o3) false

Maxima distinguishes so-called noun and verb expressions.
defmatch(check, diff(arg, t)) matches against a verb.
Looks like defmatch(check, 'diff(arg, t)) (note the quote mark)
matches against a derivative noun (i.e. something displayed by
Maxima as dfoo/dx) as expected.

matchdeclare ([arg, t], all);
defmatch (check, 'diff (arg, t));
disprule (check);
 => check : darg/dt -> []
depends (N, t);
check (diff (N, t));
 => [t = t, arg = N]

Hope this helps,

Robert Dodier