Structural Similarity in Lisp
Structural similarity:
(defun match2 (p s)
(cond ((atom p)(atom s))
((atom s) nil)
((/= (length p)(length s)) nil)
((eval (cons 'and
(mapcar #'match2 p s) )) t)
(t nil) ) )
(match2 '(a (b c) d) '(w (x y) z)) ; => T
(match2 '(a (b c) d) '(w (x (y)) z)) ; => NIL
Previous slide
Next slide
Back to first slide
View graphic version