RandomSample with specified random number generator

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Tue Jun 12 08:06:17 PDT 2012


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.


More information about the Digitalmars-d mailing list