(define (square-tree lst)(cond ((null? lst) nil)((not (pair? lst)) (square lst))(else (cons (square-tree (car lst)) (square-tree (cdr lst))))))
(define (square x) (* x x))
run:
> (square-tree (list 1 (list 2 (list 3 4) 5) (list 6 7)))
{mcons
1
{mcons
{mcons
4
{mcons {mcons 9 {mcons 16 '()}} {mcons 25 '()}}}
{mcons {mcons 36 {mcons 49 '()}} '()}}}
>
(define (square-tree tree)(map (lambda (sub-tree)(if (pair? sub-tree)(square-tree sub-tree)(square sub-tree)))tree))(define (square x) (* x x))