RandomSample with specified random number generator

Jens Mueller jens.k.mueller at gmx.de
Tue Jun 12 12:20:55 PDT 2012


Joseph Rushton Wakeling wrote:
> On 12/06/12 14:58, Jens Mueller wrote:
> >Right. These are inconsistent. This should be fixed. Can't we just use a
> >default argument like
> >auto randomSample(R, Random)(R r, size_t n, Random gen = Random(unpredictableSeed));
> >
> >Currently the documentation does not even state what is difference
> >between the versions accepting a random generator vs. the ones without a
> >random generator.
> 
> ... so can we agree that a given random sample should _always_
> lazily evaluate to the same output, whether or not it's been given a
> specified RNG?
> 
> i.e. that
> 
>       auto sample = randomSample(iota(0, 100), 5);
>       writeln(sample);
>       writeln(sample);
>       writeln(sample);
> 
> ... should produce 3 times the same output?
> 
> If so I'll get to work on a bug report and a patch set and unittest.

Yes, I'll agree with you. But I don't know about others. It'll be nice
if others share their opinion such that your efforts won't be wasted.
That code was mostly written by Andrei and David.

Jens


More information about the Digitalmars-d mailing list