On Saturday, 1 October 2016 15:30:19 UTC+1, Vincent St-Amour wrote: > On Sat, 01 Oct 2016 09:13:25 -0500, > Angus wrote: > > Then I changed smaller (and bigger) like this: > > > > (define (smaller w) > > (interval (interval-small w) > > (max (interval-small w) > > (sub1 (guess w))))) > > > > to > > > > (define (smaller w) > > (interval (interval-small w) > > (max (interval-small w) > > (sub1 (guess w))) ((+ interval-guesses 1) w))) > > > > > > > > But with these changes, when I run the program I get: > > > > +: contract violation > > expected: number? > > given: #<procedure:interval-guesses> > > argument position: 1st > > other arguments...: > > 1 > > What is `interval-guesses`? Your code would like it to be a number, but > it's actually an *accessor*. If you pass it an interval, then you'll get > the number you want. > > Jumping ahead a little: you may also want to double-check how you're > constructing your intervals. > > Vincent
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??? So then what does (+ (interval-guesses w) 1) mean? set interval guesses to whatever the current state is (represented by w) plus 1? -- 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.