Lionello Lunesu wrote:
Andrei Alexandrescu wrote:
auto rng = Random(unpredictableSeed);
auto a = 0.0, b = 1.0;
auto x1 = uniform!("[]")(rng, a, b);
auto x2 = uniform!("[)")(rng, a, b);
auto x3 = uniform!("(]")(rng, a, b);
auto x4 = uniform!("()")(rng, a, b);

I love your templates as much as the next guy, but let's not forget the possibility of using different function names instead of templating everything!?

I couldn't find good names. uniformOpenClosed, uniformOC, uniformOpenLeft... what would be some good names?

And, as other have said, I'm ok with [) since that's what rand()%max boiled down to as well. Futhermore, since arrays in D are also [), users of D get used to it so it's not odd at all.

Ok. Let me just note that rand()%max is a lousy method of generating random numbers between 0 and max-1 and everybody should put that in the bin with Popular Examples That Should Never Be Used, together with exponential Fibonacci, linear-space factorial, and bubblesort.


Andrei

Reply via email to