[Issue 4851] Three suggestions for std.random

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 29 16:13:30 PDT 2014


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



--- Comment #7 from bearophile_hugs at eml.cc 2014-03-29 16:13:21 PDT ---
If choice returns a reference you can do:


void knuthShuffle(T)(T[] r) {
    foreach_reverse (immutable i, ref ri; r[1 .. $ - 1])
        r[0 .. i + 1].choice.swap(ri);
}

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


More information about the Digitalmars-d-bugs mailing list