title: modify/replace in LISP
body: <p>I have an implementation of a function called modify list shown below but it only works for top level lists.  </p>
  
  <pre><code>(defun modify-list (old new a-list)
    (cond
     ((null a-list) nil)
     ((eql (car a-list) old) (cons new (modify-list old new (cdr a-list))))
     (T (cons (car a-list)(modify-list old new (cdr a-list))))))
  </code></pre>
  
  <p>CL-USER 16 : 6 > (modify-list 'a 'x '(p a d g c a))
  (P X D G C X) &lt;-- GOOD!</p>
  
  <p>CL-USER 17 : 6 > (modify-list 'a 'x '(p a d (g a) c a))
  (P X D (G A) C X) &lt;----NOT GOOD!</p>
  
  <p>can anyone help me make this function work on nested lists?</p>