--I am trying to debug my pattern matcher match function.
-- Am trying to implement * symbol as a Generic Wildcard, such:
--(match '(likes I computing) '(likes I *))
--Such that anything before and or after is considered.
--The bottom most function is from George F Luger, Antificial Intelligence 4th Ed.
--For the record, I am not a Student.
-- implement the * variable. (..... * .....)
-- (cond (t (+ 1 2)))
-- returns 3
(defun variable-p (x) (equal x '?))
(defun generic-a (x) (equal x '*))
(defun match-atom (pattern1 pattern2)
(or (equal pattern1 pattern2)
(variable-p pattern1)
(variable-p pattern2)
(generic-a pattern1)
(generic-a pattern2)))
--Having trouble with this function. HELP?
(defun match (pattern1 pattern2)
(cond ((or (atom pattern1) (atom pattern2)) (match-atom pattern1 pattern2))
(cond ((generic-a pattern1) (setq pattern1 (car pattern2)(setq pattern2 (cdr pattern2)))
(t (and (match (car pattern1) (car pattern2)) (match (cdr pattern1) (cdr pattern2))))))
(cond ((generic-a pattern2) (setq pattern1 (car pattern1)(setq pattern1 (cdr pattern2)))
(t (and (match (car pattern1) (car pattern2)) (match (cdr pattern1) (cdr pattern2)))))))))
--(defun match (pattern1 pattern2)
--(cond ((or (atom pattern1) (atom pattern1))
--(match-atom pattern1 pattern2))
--(t (and (match (car pattern1) (car pattern2))
--(match (cdr pattern1) (cdr pattern2))))))
