[racket] Question #3 from Realm of Racket

From: Steve Graham (jsgrahamus at yahoo.com)
Date: Mon Jun 30 11:43:05 EDT 2014

In Guess My Number I see the following definitions:

(define (smaller w)
  (interval (interval-small w)
            (max (interval-small w) (sub1 (guess w)))))
(define (bigger w)
  (interval (min (interval-big w) (add1 (guess w)))
            (interval-big w)))
(define (guess w)
  (quotient (+ (interval-small w) (interval-big w)) 2))
(define (render w)
  (overlay (text (number->string (guess w)) SIZE COLOR) MT-SC))
(define (render-last-scene w)
  (overlay (text "End" SIZE COLOR) MT-SC))
(define (single? w)
  (= (interval-small w) (interval-big w)))

Why is w (which is world?) included as a parameter?  For instance in guess, it seems the only thing needed to calculate it is access to the values of interval.


Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140630/9458ca7d/attachment.html>

Posted on the users mailing list.