15 lines
280 B
Scheme
15 lines
280 B
Scheme
#lang sicp
|
|
|
|
(define (dr-aux x acc)
|
|
(if (null? x)
|
|
acc
|
|
(let ((head (car x))
|
|
(tail (cdr x)))
|
|
(if (pair? head)
|
|
(dr-aux tail
|
|
(cons (deep-reverse head)
|
|
acc))
|
|
(dr-aux tail
|
|
(cons head acc))))))
|
|
(define (deep-reverse x)
|
|
(dr-aux x '()))
|