Remove the first pair with a given key from an association list
General Forms: (remove1-assoc key alist) (remove1-assoc key alist :test 'eql) ; same as above (eql as equality test) (remove1-assoc key alist :test 'eq) ; same, but eq is equality test (remove1-assoc key alist :test 'equal) ; same, but equal is equality test
Also see remove-assoc for a similar utility that deletes all pairs in an alist with a given key, rather than only the first such pair.
The guard for a call of
See equality-variants for a discussion of the relation between
(remove1-assoc-eq key alist)is equivalent to (remove1-assoc key alist :test 'eq); (remove1-assoc-equal key alist)is equivalent to (remove1-assoc key alist :test 'equal).
In particular, reasoning about any of these primitives reduces to reasoning
about the function
(defun remove1-assoc-equal (key alist) (declare (xargs :guard (alistp alist))) (cond ((endp alist) nil) ((equal key (caar alist)) (cdr alist)) (t (cons (car alist) (remove1-assoc-equal key (cdr alist))))))