Bug 8314 – randomSample primes with constant

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-27T23:35:00Z
Last change time
2013-02-05T13:00:05Z
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2012-06-27T23:35:08Z
import std.random, std.range, std.stdio; void main() { foreach (_; 0 .. 100) { immutable seed = unpredictableSeed(); writeln(seed, " => ", randomSample(iota(100), 1, Random(seed)).front); } } -------- The random generator is assigned to the Range only after it was primed and the default constructed random generator always returns the same first value.
Comment #1 by github-bugzilla — 2012-07-22T19:50:32Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/aa896e08ccbdb3deee98658f09022bdb4c5dc503 set random generator in constructor - Bug 8314 was already fixed by adding a _first flag https://github.com/D-Programming-Language/phobos/commit/92335506d309d4f06e1757b149c5069d02ac1174 Merge pull request #654 from dawgfoto/fix8314 fix issue 8314