I think that the contract is overly specific on the 2 argument case. But on the 1 argument case, I don't think 0 makes sense:
"When called with an integer argument k, returns a random exact integer in the range 0 to k-1."[k <- 0] =_v "When called with an integer argument 0, returns a random exact integer in the range 0 to -1." Jay On Thu, Mar 2, 2017 at 4:41 PM, 'John Clements' via Racket Users <racket-users@googlegroups.com> wrote: > I have a bunch of students this quarter that are writing code like this: > > (- (random 1 9) 1) > > Why? because they tried writing > > (random 0 8) > > and got a contract error, to wit: > > > random: contract violation > expected: (integer-in 1 4294967087) > given: 0 >> > > I’m assuming that this contract was written by someone who imagined that the > recipient would realize that the first argument could be omitted entirely, > but my sample suggests that’s not the case. > > Would it be all right to just change the contract to allow zero as a first > argument? I’d be happy to submit a pull request, if so. > > John > > > > -- > 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. -- -=[ Jay McCarthy http://jeapostrophe.github.io ]=- -=[ Associate Professor PLT @ CS @ UMass Lowell ]=- -=[ Moses 1:33: And worlds without number have I created; ]=- -- 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.