Syntax:
patmatch(expr,pattern); or patmatch(expr, pattern, 's');
expr: the expression to be matched.
pattern: the pattern.
s: the returned variable with the substitution.
The patmatch function returns true if it can match expr to pattern, and returns false otherwise. If the matching is successful, s is assigned to a substitution set such that subs(s, pattern) = expr.
A pattern is an expression containing variables with type defined by "::"; for example, a::radnum means that is matched to an expression of type radnum. Note that, in a sum such as a::realcons+x, can be ; while in a product, such as a::realcons*x, can be . This behavior can be avoided by wrapping the keyword nonunit around the type: for example, a::nonunit(realcons)*x does not match .
Examples:
Matching a linear expression with real coefficients:
>
|
|
| (1.1.1) |
The following pattern matcher looks for type where is a sum of real constants:
>
|
|
| (1.1.2) |
keyword nonunit:
>
|
|
>
|
|