I need to write a function that counts all occurrences of a given atom inside of a list. This is what I have:
(defun my-count (a L)
(cond
((null L) nil)
((equal a (car L))(+ 1 (my-count a (cdr L))))
(t (my-count a(cdr L)))
)
)
By my understanding this should work. However when I run a trace I find that when (equals a car L) evaluates to true it makes the recursive call but doesn't initialize the + 1. There is obviously something I am missing.