1.33 (累积互素数)
(define (filtered-accumulate filter? combiner null-value term a next b) (define (iter a result) (cond ((> a b) result) ((filter? a) (iter (next a) (combiner (term a) result))) (else (iter (next a) result)))) (iter a null-value)) (define (coprime? i n) (and (< i n) (= 1 (gcd i n)))) (define (product-of-coprimes n) (filtered-accumulate (lambda (x) (coprime? x n)) * 1 (lambda (x) x) 1 (lambda (x) (+ x 1)) n)) (product-of-coprimes 10)