avk959 / LGenerics

Generic algorithms and data structures for Lazarus/Free Pascal
Apache License 2.0
113 stars 16 forks source link

TGArrayHelpUtil.RandomShuffle produces biased results #3

Closed WayneSherman closed 4 years ago

WayneSherman commented 4 years ago

https://github.com/avk959/LGenerics/blob/e8738d9d7fc10b41cd5537e77cfca68795107f2f/lgenerics/LGArrayHelpers.pas#L1662

J := Random(I); should be: J := Random(I+1);

References: https://forum.lazarus.freepascal.org/index.php/topic,36445.msg349000.html#msg349000 https://forum.lazarus.freepascal.org/index.php?topic=36445.msg349076#msg349076 https://bugs.freepascal.org/view.php?id=36696

avk959 commented 4 years ago

Yes, you're right, thanks. Done, see 3cfe0a0.