[Issue 10959] std.algorithm.remove is highly bug-prone
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 23 01:52:26 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=10959
--- Comment #12 from daniel350 at bigpond.com 2014-01-23 01:52:09 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > I've just given up on this idiom, instead using:
> >
> > ```
> > import std.algorithm;
> > import std.stdio;
> >
> > void main() {
> > auto items = [10, 20, 30];
> > auto t = items.filter!(x => x != 20).copy(items);
> > items = items[0 .. $ - t.length];
> >
> > writeln(items);
> > }
> > ```
> >
> > Its the only option that has clear time and space semantics.
> >
> > Ref: http://dpaste.dzfl.pl/84273326
>
> How is that any different from:
> items = items.remove!(x => x == 20)()
> ?
A fair point, I'd forgotten about the predicate remove.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list