especially why using tailr , headr? not able understand.
(define (foo lst) (cond ((not (list? lst)) lst) ((null? lst) lst) (else (let* ((tail (cdr lst)) (head (car lst)) (tailr (foo tail)) (headr (foo head))) (append tailr (list headr))))))
it equivalent to:
(define (reverse-nested lst) (cond ((not (pair? lst)) lst) (else (reverse (map reverse-nested lst)))))
Comments
Post a Comment