g Exercise 5.9 [h] Winston and Horn's book Lisp presents a good pattern-matching program. Compare their implementation
Question:
g Exercise 5.9 [h] Winston and Horn's book Lisp presents a good pattern-matching program. Compare their implementation with this one. One difference is that they handle the case where the first element of the pattern is a segment variable with the following code (translated into our notation):
(or (pat-match (rest pattern) (rest input) bindings)
(pat-match pattern (rest input) bindings))
This says that a segment variable matches either by matching the first element of the input, or by matching more than the first element. It is much simpler than our approach using posi ti on, partly because they don't update the binding list. Can you change their code to handle bindings, and incorporate it into our version of pat -match? Is it still simpler? Is it more or less efficient?
Step by Step Answer:
Paradigms Of Artificial Intelligence Programming Case Studies In Common Lisp
ISBN: 9781558601918
1st Edition
Authors: Peter Norvig