[Issue 4851] New: Three suggestions for std.random

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 10 15:07:02 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4851

           Summary: Three suggestions for std.random
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-09-10 15:06:37 PDT ---
It's handy to set a default random generator for randomShuffle() too, like:
void randomShuffle(Range, RandomGen = Random)(Range r, ref RandomGen gen =
rndGen); 


Maybe a specified (with default) random generator is useful for randomSample()
too:
RandomSample!(R, RandomGen) randomSample(R, RandomGen = Random)(R r, size_t n,
ref RandomGen gen = rndGen, size_t total);


Very often I need to pick a single random item from a collection. In Python for
this there is the random.choice() function. I suggest to add a simple similar
function to std.random too, that is semantically similar to:
randomCover(a, rndGen).front

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list