(copy-tree (cdr tree)))
tree))
+(defun tree-equal (tree1 tree2 &key (test #'eql))
+ (if (atom tree1)
+ (and (atom tree2) (funcall test tree1 tree2))
+ (and (consp tree2)
+ (tree-equal (car tree1) (car tree2) :test test)
+ (tree-equal (cdr tree1) (cdr tree2) :test test))))
+
(defun subst (new old tree &key (key #'identity) (test #'eql))
(cond
((funcall test (funcall key tree) (funcall key old))
return-from revappend reverse rplaca rplacd second set setf
setq some string string-upcase string= stringp subseq subst
symbol-function symbol-name symbol-package symbol-plist
- symbol-value symbolp t tagbody third throw truncate unless
+ symbol-value symbolp t tagbody third throw tree-equal truncate unless
unwind-protect values values-list variable warn when write-line
write-string zerop))
(not (= (car (car foo))
(car (car bar))))))
+; TREE-EQUAL
+(test (tree-equal '(1 2 3) '(1 2 3)))
+(test (tree-equal '(1 (2 (3 4) 5) 6) '(1 (2 (3 4) 5) 6)))
+(test (tree-equal (cons 1 2) (cons 2 3)
+ :test (lambda (a b) (not (= a b)))))
+
; SUBST
; Can't really test this until EQUAL works properly on lists