[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Flying off the handle: one more time on SUBST
- To: common-lisp at SU-AI
- Subject: Flying off the handle: one more time on SUBST
- From: STEELE at CMU-20C
- Date: Sat, 04 Sep 1982 04:38:00 -0000
The last (second) try was buggy; here's a corrected version.
Note the use of &REST with &KEY, and the slick use of APPLY:
(defun subst (old new tree @rest x @key test test-not key)
(cond ((atom tree)
(if (satisfies-the-test old tree :test test
:test-not test-not :key key)
new tree))
(t (let ((a (apply #'subst old new (car tree) x))
(d (apply #'subst old new (cdr tree) x)))
(if (and (eq a (car tree)) (eq d (cdr tree)))
tree
(cons a d))))))
--Guy
-------