CS代考程序代写 (define x (list 1 2))

(define x (list 1 2))
(define y (list 3 4 5))
(define a (append x y))
(define b (list x y))
(define c (cons x y))

(define t (list (list 1 2 3) 4 (list 5 6 (list 7))))

(define (traverse t)
(cond ((null? t)) ;do nothing
((list? (car t)) (begin (traverse (car t))
(traverse (cdr t))))
(else (begin (display (car t)) (traverse (cdr t))))))

(define (scale-tree t factor)
(cond ((null? t) ‘())
((list? (car t)) (cons (scale-tree (car t) factor)
(scale-tree (cdr t) factor)))
(else (cons (* (car t) factor)
(scale-tree (cdr t) factor)))))

(define (tree-map t f)
(cond ((null? t) ‘())
((list? (car t)) (cons (tree-map (car t) f)
(tree-map (cdr t) f)))
(else (cons (f (car t))
(tree-map (cdr t) f)))))