Thread overview
[Issue 16724] RandomCover.popFront is a no-op for the first call
Dec 19, 2016
RazvanN
December 15, 2016
https://issues.dlang.org/show_bug.cgi?id=16724

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com
           Assignee|nobody@puremagic.com        |alexandru.razvan.c@gmail.co
                   |                            |m

--
December 19, 2016
https://issues.dlang.org/show_bug.cgi?id=16724

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
             Status|NEW                         |ASSIGNED
                 CC|                            |razvan.nitu1305@gmail.com
           Assignee|alexandru.razvan.c@gmail.co |razvan.nitu1305@gmail.com
                   |m                           |

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
PR here: https://github.com/dlang/phobos/pull/4957

--
December 19, 2016
https://issues.dlang.org/show_bug.cgi?id=16724

--- Comment #2 from github-bugzilla@puremagic.com ---
Commit pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/7c2dc1ccbadfb337325485cd045255598d536aa4 Merge pull request #4957 from RazvanN7/Issue_16724

Fix Issue 16724 - RandomCover.popFront is a no-op for the first call

--
December 19, 2016
https://issues.dlang.org/show_bug.cgi?id=16724

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--
January 07, 2017
https://issues.dlang.org/show_bug.cgi?id=16724

--- Comment #3 from github-bugzilla@puremagic.com ---
Commit pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/7c2dc1ccbadfb337325485cd045255598d536aa4 Merge pull request #4957 from RazvanN7/Issue_16724

--
January 16, 2017
https://issues.dlang.org/show_bug.cgi?id=16724

--- Comment #4 from github-bugzilla@puremagic.com ---
Commit pushed to newCTFE at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/7c2dc1ccbadfb337325485cd045255598d536aa4 Merge pull request #4957 from RazvanN7/Issue_16724

--
February 11, 2017
https://issues.dlang.org/show_bug.cgi?id=16724

Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joseph.wakeling@webdrake.ne
                   |                            |t

--- Comment #5 from Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> ---
Sorry to have missed this, but the fix is itself broken, because it strips out the lazy `front` of `randomCover`.

First, random algorithms (like random cover) ideally need to have a truly lazy initial `front` value, otherwise you can run into trivial errors like:

   auto arr = [1, 2, 3, 4, 5];
   auto cover = arr.randomCover;
   cover.writeln;  // three 'different' covers
   cover.writeln;  // but each of them with
   cover.writeln;  // the same first value

... so the check on already-chosen elements in `front` wasn't there by accident (although it may have needed further work in how it was implemented).

Second, I just tried running the above right now and got a never-ending stream of `5, 5, 5, 5, 5, ...` out of my computer before I killed it.  So I'm not sure that this new randomCover is working right at all :-(

--