On Wed, 22 Apr 2009 13:49:18 -0400, Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote:

tama wrote:
On Mon, 20 Apr 2009 16:09:09 +0900, Walter Bright
<newshou...@digitalmars.com> wrote:


This is a major revision to Phobos, including Andrei's revolutionary
new range support.

http://www.digitalmars.com/d/2.0/changelog.html
http://ftp.digitalmars.com/dmd.2.029.zip

Range is so cool!

Though...
I tried following code:

void main()
{
    writeln("Case1");
    {
        Mt19937 gen = Mt19937(0);
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
    writeln("---");
    {
        Mt19937 gen = Mt19937(0);
        advance(gen, 1);  // skip 1 element
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
    writeln("\nCase2");
    {
        Mt19937 gen;
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
    writeln("---");
    {
        Mt19937 gen;
        advance(gen, 1);  // skip 1 element
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
}

Result:

Case1
2357136044 (1)
2546248239 (2)
---
2546248239 (2)
3071714933 (3)

Case2
581869302  (1)
3890346734 (2)
---
581869302  (1)?
3890346734 (2)?

I think 'Case1' is correct, but 'Case2' is wrong.
Mt19937's bug?


If you initialize the Mersenne twister with no seed it will start with
seed 5489u.

I think his point is in the second part of Case2, he skipped one element, but it appears that it didn't skip anything.

-Steve

Reply via email to