Modify an association list by associating a value with a key
General Forms: (put-assoc name val alist) (put-assoc name val alist :test 'eql) ; same as above (eql as equality test) (put-assoc name val alist :test 'eq) ; same, but eq is equality test (put-assoc name val alist :test 'equal) ; same, but equal is equality test
The guard for a call of
See equality-variants for a discussion of the relation between
(put-assoc-eq name val alist) is equivalent to(put-assoc name val alist :test 'eq) ;
(put-assoc-equal name val alist) is equivalent to(put-assoc name val alist :test 'equal) .
In particular, reasoning about any of these primitives reduces to reasoning
about the function
Function:
(defun put-assoc-equal (name val alist) (declare (xargs :guard (alistp alist))) (cond ((endp alist) (list (cons name val))) ((equal name (caar alist)) (cons (cons name val) (cdr alist))) (t (cons (car alist) (put-assoc-equal name val (cdr alist))))))