(defun clean-list (ll) "checks that it has a list, and calls clean-list1" (cond ((listp ll) (clean-list1 ll)) (t (format t "not a list")) ) ) (defun clean-list1 (ll) "" ; traverses the list recursively element by element ; it builds a result list which for each duplicate element ; includes only its last occurrence in the original list (cond ((null ll) nil) (t (if (member (car ll) (cdr ll)) (clean-list1 (cdr ll)) (cons (car ll) (clean-list1 (cdr ll))) ) ) ) )