q1consider the following codedefine add1-iter


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?

Request for Solution File

Ask an Expert for Answer!!
Application Programming: q1consider the following codedefine add1-iter
Reference No:- TGS0501477

Expected delivery within 24 Hours