Rules for Pattern Matching
The preceding example illustrates some rules for pattern matching:
- Structure and constant parts of the pattern
must match the input exactly.
- (- ?x ?y) does not match (+ a b) .
- The pattern (+ (- ?x) ?y) does not match the input (+ a b) .
- Variables must match consistently.
A variable in the pattern can match anything in the input
the first time, but it must match the same thing thereafter.
- The pattern (- ?x ?x)
matches (- (sin theta) (sin theta))
but not (- (sin theta) (cos theta)) .
Contents   
Page-10   
Prev   
Next   
Page+10   
Index