[racket] Question #3 from Realm of Racket

From: Alexander D. Knauth (alexander at knauth.org)
Date: Mon Jun 30 12:12:40 EDT 2014

In this program, a world is just an interval.  

All of those w s could be replaced with ivl s, because a world is an interval, and the value of the parameter will always be an interval.  

However, (I’m guessing) using world or w makes it clear that the functions are meant to be used with big-bang.  

They could’ve also named the struct world instead of interval, but interval is a better name because its a lot more descriptive of what it represents.  

On Jun 30, 2014, at 11:43 AM, Steve Graham <jsgrahamus at yahoo.com> wrote:

> 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
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

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

Posted on the users mailing list.