Exercise 7.x2: Suppose that the reverse-onto
procedure, defined
internally to reverse on pages 181-182, were instead
defined
separately. Now consider the following procedure definition:
(define mystery
(lambda (list1 list2)
(reverse-onto (reverse list1)
list2)))
Describe clearly what the mystery procedure does, and how
you
know that it does that.
Write a procedure that has the same effect as the mystery
procedure, but which generates a linearly recursive
process and calls only on itself and the built-in procedures
cons,
car, cdr, and null?.
Do exercise 7.21 on page 187.
Do exercise 7.49 on page 208. Your procedure should work even when given an empty list. To understand what the correct answer is for an empty list, consider this: all elements of a list are postive if there are none that are not positive. In addition to providing your procedure definition, you should explain whether it generates an interative or recursive process.