This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ,result)) ,(if (null? restriction) (collect-let-body bindings) `(filter (lambda (tuple) (let ,(collect-let-bindings bindings 0) ,(car restriction))) ,(collect-let-body bindings))))) (define-macro (collect result bindings . restriction) (make-collect-body result bindings restriction)) (define (prime-sum-pairs n) (collect (list i j (+ i j)) ((i (enumerate-interval 1 n)) (j (enumerate-interval 1 (-1+ i)))) (prime? (+ i j)))) (define (prime? n) (define (iter factor) (cond ((= factor n) #t) ((= (remainder n factor) 0) #f) (else (iter (1+ factor))))) (iter 2))...
View Full Document
This note was uploaded on 11/30/2010 for the course EECS 21281 taught by Professor Harvey during the Spring '10 term at University of California, Berkeley.
- Spring '10