Paul Graham's 'On Lisp' errata page states:
p. 23. our-find-if would recurse infinitely if no element matches. Caught by Markus Triska.
The function definition as shown in the book is:
(defun our-find-if (fn lst)
(if (funcall fn (car lst))
(car lst)
(our-find-if fn (cdr lst))))
And here is my probably poor fix for it:
(defun our-find-if (fn lst)
(if (funcall fn (car lst))
(car lst)
(if (cdr lst)
(our-find-if fn (cdr lst))
nil)))
Is this correct? Is my version of 'our-find-if' still tail recursive? (I think so...)
Better alternatives welcome.
TIA