I have an implementation of a function called modify list shown below but it only works for top level lists.
(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))))))
CL-USER 16 : 6 > (modify-list 'a 'x '(p a d g c a)) (P X D G C X) <-- GOOD!
CL-USER 17 : 6 > (modify-list 'a 'x '(p a d (g a) c a)) (P X D (G A) C X) <----NOT GOOD!
can anyone help me make this function work on nested lists?