Use the ISL loops (HtDP, page 313) to simplify the definitions of hit-wall?, clean-up, and e.v0:
hit-wall?
;; [Listof Posn] -> Boolean ;; is any of the drops touching the wall? (define (hit-wall?.v0 lop) (cond [(empty? lop) false] [else (or (hit-wall-1? (first lop)) (hit-wall? (rest lop)))])) ;; hit-wall-1? : Posn -> Boolean ;; is a single drop touching the wall? (define (hit-wall-1? p) (or (= (posn-x p) 0) (= (posn-x p) 100) (= (posn-y p) 0) (= (posn-y p) 100))) ;; Tests (equal? (hit-wall? (list (make-posn 10 10) (make-posn 100 50) (make-posn 10 10))) true) (equal? (hit-wall? (list (make-posn 10 10) (make-posn 10 10))) false)
Solution:
Grader: Ryan
;; [PTS 1: for ormap and correctness] (define (hit-wall? lop) (ormap hit-wall-1? lop))