Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Vincent St-Amour
On Sat, 01 Oct 2016 15:44:18 -0500, Angus wrote: > > And it is now more obvious to me that in: > > (define (bigger w) > (interval (min (interval-big w) > (add1 (guess w))) > (interval-big w) (+ (interval-guesses w) 1))) > > The (interval... part is a constructor

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Angus
On Saturday, 1 October 2016 16:13:01 UTC+1, Ben Greenman wrote: > Maybe this will help: > > > > > (struct interval (small big guesses)) > > creates 5 new functions > interval, for making intervals. For example (interval 5 10 0) creates an > interval from 5 to 10 that has 0 guessesinterval?,

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Ben Greenman
Maybe this will help: (struct interval (small big guesses)) creates 5 new functions 1. interval, for making intervals. For example (interval 5 10 0) creates an interval from 5 to 10 that has 0 guesses 2. interval?, for testing if a value is an interval. For example (interval? 1) is

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Vincent St-Amour
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

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Robby Findler
I guess you're familiar with the dot operator (object.field) in C and Java? In Racket, we don't provide access to that directly, but instead put such operations in "selector functions". So when you see (interval-guesses w) that's something more like w.guesses In other words, you can think

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Angus
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) > >

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Angus
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) > >

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Vincent St-Amour
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