Check for duplicates in a list
General Forms: (no-duplicatesp x) (no-duplicatesp x :test 'eql) ; same as above (eql as equality test) (no-duplicatesp x :test 'eq) ; same, but eq is equality test (no-duplicatesp x :test 'equal) ; same, but equal is equality test
The guard for a call of
See equality-variants for a discussion of the relation between
(no-duplicatesp-eq x lst) is equivalent to(no-duplicatesp x lst :test 'eq) ;
(no-duplicatesp-equal x lst) is equivalent to(no-duplicatesp x lst :test 'equal) .
In particular, reasoning about any of these primitives reduces to reasoning
about the function
Function:
(defun no-duplicatesp-equal (l) (declare (xargs :guard (true-listp l))) (cond ((endp l) t) ((member-equal (car l) (cdr l)) nil) (t (no-duplicatesp-equal (cdr l)))))