;"Right-thinking" way to set a field in an alist ;Strategy: ; 1. Cruise down alist, looking for a pair starting with field-name. ; 2. As we go, we're building a new alist of each pair that we examine. ; 3. If we get to pair that does start with field-name, we make a new ; pair with the value of the parmameter sent in, glue on the rest of ; the alist and we're done. ; 4. Otherwise we glue in the pair we just examined as is and continue ; looking down the rest of the list, until we get to the end (signaled ; by a null list). (defun setfield (field-name value alist) (interactive) (cond ((null alist) nil) ((equal field-name (caar alist)) (cons (cons (caar alist) value) (cdr alist))) (t (cons (car alist) (setfield field-name value (cdr alist)))) ) ) ;"Wrong-thinking" way to set a field in an alist (defun rsetfield (field-name value alist) (rplacd (assoc field-name alist) (list value)) )