(my-replace '(a (b c) d) '(b c) 'x)
-> ( axd ) -->this is what the result should be
My code is the following, please help
Code: Select all
* (defun my-replace( s1 s2 s3)
(cond ((null s1) "empty list")
((atom s1) "one element only")
(( = (num-sublists s1 ) 0) (substitute s3 s2 s1))
(t (substitute s3 s2 (my-replace (rest s1) s2 s3)))))