所以我昨天开始学习 Lisp 并开始做一些问题。
我很难做的事情是在列表中插入/删除原子,同时保持列表相同 ex: (delete 'b '(g a (b) l))will give me (g a () l).
我遇到的问题也是这个问题。我想检查列表中的任何地方是否存在原子。
我追踪了它,它说它T在某个时候返回,但随后被 a 覆盖nil。
你们能帮忙吗:)?
我正在使用(appear-anywhere 'a '((b c) g ((a))))
在第 4 个函数调用时它返回T但随后变为nil.
(defun appear-anywhere (a l)
(cond
((null l) nil)
((atom (car l))
(cond
((equal (car l) a) T)
(T (appear-anywhere a (cdr l)))))
(T (appear-anywhere a (car l))(appear-anywhere a (cdr l)))))