I get the error message below when I run my code. The code below add the elements that are not nil.
(summit2 '(0 nil 1 2))
Error: Received signal number -3 (function call stack overflow (delayed response))
[condition type: ASYNCHRONOUS-OPERATING-SYSTEM-SIGNAL]
I have tried changing null with nil. I also tried using eq as opposed to eql.
(defun summit2 (lst)
(if (eql (car lst) null)
(summit2 (cdr lst))
(+ (car lst) (summit2 (cdr lst)))))
the expected output should be 3, the sum of the elements in the list that are not nil