How do I convert a value of the form 20.2
into something that (random ...)
accepts?
I've tried these:
;; x defined by some earlier maths and of form 20.2
(random (round x))
(random (floor x))
But both return:
random: contract violation
expected: (or/c (integer-in 1 4294967087) pseudo-random-generator?)
given: 20.0
quotient : (integer integer -> integer) Purpose: to divide the first integer (exact or inexact) into the second; try (quotient 3 4) and (quotient 4 3)
Also note that if your programming language doesn't support negative numeric literals, you can still get at negative numbers by subtracting from zero. Example: (- 0 12) gets us -12 . Professional Racket will support the shorthand: (- 12) to negate 12 as well.
What you need to do is test each element in the list to see if it satisfies a condition (being an integer, in this case). When you evaluate (integer? (car list)) on a list of integers, you're checking if the first element in the list is an integer, and that's fine.
The numbers game, also known as the numbers racket, the Italian lottery, Mafia lottery or the daily number, is a form of illegal gambling or illegal lottery played mostly in poor and working class neighborhoods in the United States, wherein a bettor attempts to pick three digits to match those that will be randomly ...
These also work, and according to the documentation they're just shorthands for your approach:
(random (exact-round x))
(random (exact-floor x))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With