hap.random: a new random number library for D

Joseph Rushton Wakeling via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jun 10 04:10:33 PDT 2014


On Tuesday, 10 June 2014 at 10:21:39 UTC, bearophile wrote:
> I have appreciated to use this generator (but I am not yet sure 
> how much good it is. I have seen it's fast and sufficiently 
> good for some of my simpler purposes):
> http://en.literateprograms.org/R250/521_%28C%29

Should be straightforward enough to implement. :-)

> Is it worth having a fully pure generator that takes a constant 
> state and returns the modified state? (The state should be 
> small, so Mersenne Twister is not fit for this). Writing such 
> generator is easy, but then how do you use it with the API of 
> the functions of the random module?

The API as given is of course designed to create ranges of random 
variates, and that in turn means that you're dealing with weakly 
pure class methods.

However, I don't see any reason why one couldn't have a strongly 
pure function that purely transforms state, which could be 
wrapped by an RNG class or otherwise used as needed.


More information about the Digitalmars-d-announce mailing list