http://d.puremagic.com/issues/show_bug.cgi?id=6106
Summary: Keep track of changes during replace function Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: josvanu...@gmail.com --- Comment #0 from josvanu...@gmail.com 2011-06-04 19:15:09 PDT --- Just had an idea, not sure if it makes sense. When I was writing a code that executes a Markov algorithm, I had to call std.array.replace(R, R, R), then depending on whether the replacement had made any actual changes, I had to either continue the loop or redo it. In order to find out if replace had made any changes I had to keep a copy and compare on every iteration. The relevant part of the code: redo: auto copy = tests[i]; foreach (c; capt) { tests[i] = replace(tests[i], c[0], c[2]); if (c[1] == ".") break; if (tests[i] != copy) goto redo; } It occurred to me that it would have been useful if the replace function had had an out parameter keeping track of the number of changes. My code could have looked like this: redo: int changed; foreach (c; capt) { tests[i] = replace(tests[i], c[0], c[2], changed); if (c[1] == ".") break; if (changed) goto redo; } I realize that you can't meet everybody's needs and preferences, but I thought I'd suggest it just in case it might be doable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------