I am currently using DrRacket on Mac OS X and choose the language "R5RS", but when I enter
(random 100)
I get the error message:
reference to undefined identifier: random
What's the problem here? Is it caused by a missing package?
As dyoo points out, the function random
is not defined in R5RS.
If you want to use "foreign" functions in the R5RS language in DrRacket,
you can use #%require
to import them.
In this case search for random
in the Racket documentation. Notice that random
is part of the module racket/base
. Now write:
(#%require (only racket/base random))
(random 10)
Using only
ensure that you only import the function random
and any other non-R5RS construct present in racket/base
.
Is ‘random‘ a function provided by R5RS? I look for it in the index of the spec, but I don't see it there. R5RS is a minimal language mode, and when Racket is in R5RS mode, it really restricts itself.
Racket does have a native random function. If you are using ‘#lang racket‘, it's automatically available. Is there a reason you're using the R5RS language mode?
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