POV-Ray : Newsgroups : povray.off-topic : More random humous : Re: More random humous Server Time
7 Sep 2024 03:22:20 EDT (-0400)
  Re: More random humous  
From: Invisible
Date: 7 Oct 2008 06:45:55
Message: <48eb3de3$1@news.povray.org>
Warp wrote:

>   Wait a minute... Exactly how do you create a random number generator in
> Haskell?
> 
>   Not being able to create a RNG function would be rather restrictive in
> many applications...

You write a function that takes a PRNG state and returns a random number 
and a new PRNG state.

(That is, if you want *psuedo*-random numbers. If you're after truly 
random numbers, you'll obviously need to perform some kind of I/O to get 
them, since true randomness comes only from physical sources.)

This is a common idiom in Haskell; write a function that takes an 
initial state and returns an answer and a new, modified state. In fact, 
there's even a standard monad for automating this so you don't have to 
manually pass the state around by hand all the time.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.