定义带有列表L和符号A的函数'occ',并计算L中符号A的出现.例如:(occ'(((s)o)d)'f) - > 0
到目前为止我得到了什么:
(defun occ(list a)
(setq counter 0)
;Checks if the given list is has an nested list
(if (consp list)
; Breaking the list down atom by atom and recursing
(or (occ a (car list))
(occ a (cdr list)))
; checks if symbols are the same
(if(eq a list)
(setq counter(1+ counter)))))
Run Code Online (Sandbox Code Playgroud)
但是我的输出继续说Nil而不是显示计数器值.我不能使用任何更高级别的LISP功能.