Introduction to Artificial Intelligence
Worksheet #6
Pattern Matching and Recognizing Sequences with Function Match
Look over a detailed trace of the
newer version of match
- Modify one of the match programs: original version (match.lsp),
or newer style version (match2000.lsp).
Create Match7.lsp so that the application of a predicate can be to sequences
of elements of S, rather than only to individual elements of S.
For example, suppose that (INCREASING L) returns true if L is a list of
increasing integers. Match7 will work like this:
- (match7 '(101 (increasing x) (increasing y))
'(101 2 4 6 8 3 5 7))
- Returns True (using the original version of match.lsp)
- The newer versions returns ((X 2 4 6 8)(Y 3 5 7)(:YES . :YES))
- To do this, you'll have to write a function INCREASING.
- (increasing '(2 4 6 8)) --> True
- (increasing '(8 4 2)) --> Nil