Matching with Bindings in an Assoc. List
(defun match4 (p s)
(cond
((and (null p)(null s)) '((:yes . :yes)))
((or (atom p)(atom s)) nil)
((equalp (car p) (car s))
(match4 (cdr p)(cdr s)) )
((and (= (length (car p)) 2)
(eql (caar p) '?)
(let ((rest-match
(match4 (cdr p)(cdr s))))
(if rest-match
(acons (cadar p)
(car s) rest-match) ) ) ) )
(t nil) ) )
Previous slide
Next slide
Back to first slide
View graphic version