I am doing a program which accepts one list and two atoms and replace atom-1 with atom-2 if atom-1 appears in list.
I am doing programming in a text editor using an Ubuntu system
Below is my code:
#! /usr/bin/clisp
(defun my-replace (lst x y)
(cond
((eq lst nil) nil)
((eq (cdr lst) nil) nil)
((eq (car lst) x) (setq (car lst) y))
( t (my-replace ((cdr lst) x y)))))
When I try to execute this, Clisp shows this error:
*** - SYSTEM::%EXPAND-FORM: (CDR LST) should be a lambda expression
I am beginner in Lisp.
Please tell me how to solve this error.