Daron, I agree it's pretty confusing how a recursive function can deliver a result other than the input when it reverses the process upon exit.
Consider the MAKE10 function above. If you set a breakpoint and add n to the watch window, it's obvious that n is decrementing to the original input as the recursion backtraces. But it has already returned a value of 10. The important thing - as Keith mentions - is not to place any call after the recursive call because that would then be the result.
Try rewrite the MAKE10 function to this:
(defun make10 (n)
(if (>= n 10) n
(make10 (1+ n))
)
n
)
This is perhaps the most common error to make in a recursive function. It will drag its own backtrace along and return the original input - to itself.
(make10 6) -> 6
In trace window:
Entering (MAKE10 6)
Entering (MAKE10 7)
Entering (MAKE10 8)
Entering (MAKE10 9)
Entering (MAKE10 10)
Result: 10
Result: 9
Result: 8
Result: 7
Result: 6
The explicit return value will cause the function to receive whatever it pops off the stack. In this example it will return the value of n to itself - thus decrementing the value while popping it off.
When it's not superceded by another call - like in the original MAKE10 - there is nothing to return but n=10.
As for APPEND, it is by nature a recursive function due to how a list is represented with CONS pairs. I doubt it is written as a recursion in the ARX module rather than an iterative one but it is pretty easy to write your own APPEND as a recursive function:
(defun myAppend (a b)
(cond ((null a) b)
((cons (car a) (myAppend (cdr a) b)))
)
)