School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,16 @@
; 12. Write a function that substitutes an element through another one at all levels of a given list.
; substitute-element (old new lst):
; new if lst is atom and equal to old
; lst if lst is atom and not equal to old
; (substitute-element old new x) for each x in lst otherwise
(defun substitute-element (old new lst)
(cond ((and (atom lst) (equal lst old)) new)
((atom lst) lst)
(t (mapcar #'(lambda (x) (substitute-element old new x)) lst))))
(print (substitute-element 'a 'z '(a (b a) (c (d a e)))))
(exit)