2.20
(define (same-parity . lst)
(define is-odd (odd? (car lst)))
(define (proc l)
(if (null? l)
l
(let ((x (proc (cdr l)))
(y (car l)))
(if (equal? (odd? y) is-odd)
(cons y x)
x))))
(proc lst))
2.21
(define (square-list items)
(if (null? items)
items
(cons (expt (car items) 2)
(square-list (cdr items)))))
(define (square-list2 items)
(map (lambda (x) (* x x)) items))
2.23
(define (for-each f lst)
(if (null? lst)
#t
(cond (else (f (car lst))
(for-each f (cdr lst))))))