On Thursday, 3 October 2019 at 08:52:22 UTC, Andrea Fontana wrote:
On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote:
void main() {
    import std.range : iota;

    foreach (x; iota(1, 10).withHistory)
        writeln(x);
}


This doesn't work as expected, I think.

auto r = iota(1,10).withHistory;

writeln(r.front);
writeln(r.front);

Oops. That output should be the same, since popFront hasn't been called.
I made this mistake in my other ranges as well...

The code's also bad for preserving the entire history when only the
latest is needed for what it's doing.

Reply via email to