Rules for Pattern Matching
Pattern matching can be thought of as a special kind of equality test:
- Function names, constants and structure in the pattern must
be matched exactly by the input.
- (- ?x ?y) does not match (+ a b) .
- The pattern (+ (- ?x) ?y) does not match the input
(+ a b) .
- A variable in the pattern will match anything in the input,
but it must do so consistently.
- The pattern (- ?x ?x)
matches (- (sin theta) (sin theta))
but not (- (sin theta) (cos theta)) .
We implement this by letting a variable match anything the first time,
but it can only match the same thing thereafter.
Contents   
Page-10   
Prev   
Next   
Page+10   
Index