On 12/22/08, martin <ms_usenet at gmx.de> wrote:
> matchdeclare(
> sym1_pat, symbolp,
> int1_pat, integerp,
> all1_pat, all
> )$
Pattern matching is more predictable if the predicates associated
with pattern variables are mutually exclusive. How about this.
matchdeclare (dd, diffp);
matchdeclare (not_dd, lambda ([e], not diffp (e) and e # 1));
diffp (e) := not atom (e) and (op (e) = nounify (diff) or op (e) =
verbify (diff));
defrule (r1, not_dd * dd, FOO (not_dd, dd));
expr1: 25 * a * 'diff(f(x),x)$
expr2: 25 * a * 'diff(f(x),x) * 'diff(g(x),x)$
apply1 (expr1, r1);
=> FOO(25*a,'diff(f(x),x,1))
apply1 (expr2, r1);
=> FOO(25*a,'diff(f(x),x,1)*'diff(g(x),x,1))
Notes. (1) For + and * operators, defrule and tellsimpafter rules will
collect all terms that match each match variable. (That's the origin
of the product of 'diff expressions in the 2nd example.)
(2) For + and * operators, defrule and tellsimpafter rules will impute
the presence of 0 and 1, respectively. That's the reason for the e # 1
in the declaration of not_dd (matches only nontrivial terms).
Not sure what you're trying to do, but maybe this helps in some way.
best
Robert Dodier