Assigning map result, and in-place map

Pelle pelle.mansson at gmail.com
Fri Sep 3 03:24:55 PDT 2010


On 09/03/2010 11:42 AM, Bert van Leeuwen wrote:

> 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.)

I don't know if this is intended to be supported, but at least for now 
this works:

     int[] xs = [1,2,3,4,5,6,7];
     copy(map!`a*a`(xs), xs);

     writeln(xs);

[1, 4, 9, 16, 25, 36, 49]


More information about the Digitalmars-d mailing list