A common mistake involving recursion takes the following
form: Suppose we want to write our own version of the Lisp
function if. We might try this as follows:
> (defun our-if (condition then-action else-action)
(cond (condition then-action) (t else-action)))
OUR-IF
> (our-if (< 4 5) 'yes 'no)
YES
> (our-if (> 4 5) 'yes 'no)
NO
our-if seems to work. But what might happen if we use
our-if inside a recursive definition? For example,
suppose we wrote factorial in terms of our-if:
> (defun factorial (n)
(our-if (zerop n) 1 (* n (factorial (1- n)))))
FACTORIAL
> (factorial 5)
What happens in this case? Why? [This question was taken
from your text, Common Lispcraft by R. Wilensky. It is a rather
tricky question. Please don't just run to someone else,
but think about is carefully yourself.]