Q1)
Consider the following code;
(define (add1-iter a-list)
(define (add1-helper curr-list result-list)
(if (null? curr-list)
result-list
(add1-helper (cdr curr-list)
(cons (add1 (car curr-list))
result-list))))
(add1-helper a-list '()))
Is this an example of head or tail recursion? Why?
Q2)
Referring to the code in Part 1, use the substitution model to illustrate what the result of calling (add1-iter '(1 2 3)) will be. Why is the list reversed?