[Issue 11738] New: partialShuffle actually shuffles the entire input

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 14 02:30:46 PST 2013


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

           Summary: partialShuffle actually shuffles the entire input
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: joseph.wakeling at webdrake.net


--- Comment #0 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-12-14 02:30:43 PST ---
Created an attachment (id=1301)
Test case to illustrate the bug.

partialShuffle(input, n) is supposed to shuffle input[0 .. n] and leave input[n
.. $] untouched.  In fact it shuffles the entire input.

This is illustrated by the attached code, where the second half of the
partially shuffled array should still read 5, 6, 7, 8, 9 but is actually
randomly rearranged.

It's trivially fixable: on std/random.d:L1480 the second argument to uniform()
should be n - i, not r.length - i.  A copy-paste error from an earlier
iteration of randomShuffle, perhaps? :-)

-- 
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