Sounds like two questions wrapped into one. When it comes to setting
names to values, Scheme programming encourages the use of a "let"
expression to bind values to names inside of a (usually narrow) scope
rather than assigning a value to a variable. See more here:
https://docs.racket-lang.org/guide/let.html

As for the typed random value, the Flonum from (random) should be fine
since a Flonum is also a Real. Can you provide a short example of
runnable code that exposes the problem you're having?

On Wed, Jul 5, 2017, at 08:39 PM, Alasdair McAndrew wrote:
> I'm doing a little programming which requires the use of some random
> numbers.  Basically I add a random value at one stage, and subtract it a
> bit later.  Something like this pseudo-code (where "x" is an existing
> variable):
> 
>    set rand_value <- (random)
>    set new_value <- x + rand_value
> 
>    ... do stuff ...
> 
>    set new_value <- new_value  - rand_value
> 
> All values may be considered Reals.  I tried to do this in Typed Racket,
> where x was of type "Real" and got errors about mismatched types:
> "(random)" produces a "flonum".  I was also using "set!" for the
> assignment of the random value, which I understand to be poor practice:
> how would I do something like the above in a more "rackety" manner? 
> Thank you!
> 
> -- 
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to