On Friday, 19 December 2025 at 12:21:16 UTC, Brother Bill wrote:
I notice that std.algorithm and std.algorithm.mutate return a
new dynamic array.
Are there any libraries out there that do modifications in
place?
mutation is a big no no for the range concept as pushed by aa;
whats in the compiler is just some checks you have the right
function names tho.
I have a concept of a mutmap :
```d
import std;
auto mutmap(alias F,R)(R r){
struct map{
R r;
auto ref front()=>r.front;
void popFront(){
r.popFront;
if(r.empty){return;}
r.front=F(r.front);
}
bool empty()=>r.empty;
}
r.front=F(r.front);
return map(r);
}
unittest{
auto foo=[1,2,3,4,5];
foo.mutmap!(a=>a+1).each!writeln;
auto bar=foo.mutmap!(a=>a*2).find!(a=>a==6);
foo.writeln;
bar.each!writeln;
}
```
you can just do things, but when you open this pandoras box you
have to know whats going on with the underlining algorithms