1 ;; Exercise 2.27. Modify your reverse procedure of exercise 2.18 to produce a deep-reverse procedure that takes a list as argument and returns as its value the list with its elements reversed and with all sublists deep-reversed as well. For example,
3 (define (deep-reverse tree)
4 (cond ((null? tree) '())
5 ((not (pair? tree)) tree)
7 (deep-reverse (cdr tree))
8 (list (deep-reverse (car tree)))))))
10 (define (test-case actual expected)
15 (display "Expected: ")
19 (define x (list (list 1 2) (list 3 4)))
21 (test-case (reverse x) '((3 4) (1 2)))
23 (test-case (deep-reverse x) '((4 3) (2 1)))