On Sat, 01 Oct 2016 09:47:00 -0500,
Angus wrote:
> I don't understand.  How would I pass it an interval?
> 
> I am confused about the w parameter in smaller.  ie (define (smaller w)
> 
> what is w?  Is that the current interval held as state within big-bang?

Yes, that is correct.

Have a closer look at the docs for big-bang. They should explain how
big-bang passes the value of the world to the handlers which, in your
program, pass it in turn to your `smaller` function.

On Sat, 01 Oct 2016 09:53:56 -0500,
Angus wrote:
> 
> This seems to work:
> 
> (define (smaller w)
>   (interval (interval-small w)
>             (max (interval-small w) 
>                  (sub1 (guess w))) (+ (interval-guesses w) 1)))
> 
> But I don't understand why???
> 
> the first argument is passed as (interval w)
> 
> what does that mean?  Does it mean that interval-small should be set to the 
> current interval-small???

What is the current interval? An interval is just a structure. You could
have as many as you want. Imagine you're writing a 2-player version of
your game, or even a multi-player tournament version. You'd need an
interval for each player.

Since there's no intrinsic "right" interval, your code must be explicit
about which interval it want to get the `small` field of. In this case,
you care about the interval that corresponds to the current state of the
world, which is bound to the variable `w`.

> So then what does 
> 
> (+ (interval-guesses w) 1) mean?
> 
> set interval guesses to whatever the current state is (represented by w) plus 
> 1?

That code doesn't set anything. It simply computes the number of guesses
of the current state, plus 1 (as you said).

If you want to use that value as the new number of guesses for the next
value of the state of the world, then you need to create a new interval
(as your code is already doing), and use that new number as its number
of guesses.

Vincent

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to