Regarding isSorted

bearophile bearophileHUGS at lycos.com
Tue Feb 5 16:33:29 PST 2013


This used to print true-false, now prints true-true. Is this a 
bug?


import std.stdio, std.algorithm;
void main() {
     auto x = "abcd";
     writeln(isSorted(x));
     auto y = "acbd";
     writeln(isSorted(y));
}


Maybe this line:

https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L9237

         for (; !ahead.empty; ahead.popFront(), ++i)

Should be:

         for (; !ahead.empty; ahead.popFront(), r.popFront(), ++i)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list