Filter |
|
(define (inside-unit-sphere? point)
(<= (point.to-origin point) 1))
(define (filter test list)
;; FILTER: (X->Boolean, X*) -> X*
(cond ((null? list) '())
((test (car list))
(cons (car list)
(filter test (cdr list))))
(else (filter test (cdr list)))))
(define (how-many-in-unit-sphere points)
(accumulate 0 +
(map (lambda (pt) 1)
(filter inside-unit-sphere?
points))))
| Jim Miller |