RandomSample with specified random number generator

Artur Skawina art.08.09 at gmail.com
Thu Jun 14 22:58:35 PDT 2012


On 06/15/12 00:55, Joseph Rushton Wakeling wrote:
>     sample = randomSample(iota(0, 100), 5, rndGen);
> 
> ... should probably be disallowed on grounds of safety.

Considering the output of this program:

   import std.stdio;
   import std.random;

   void main() {
      foreach (i; 0..20)
         writeln(randomSample([0,1,2,4,5,6,7,8,9], 3, Random(unpredictableSeed)));
   }

I'd say the use of std.random should be disallowed on grounds of safety...

Does it work for someone else? (JIC it's only my old GDC installation that fails)

artur


More information about the Digitalmars-d mailing list