On Thursday, 26 December 2013 at 23:23:02 UTC, Gordon wrote:
But the "b" in "main" retains its original value of 42.

Try printing the b in main again AFTER printing c. You should see the change.

std.algorithm for the most part doesn't actually do any of its calculations until it has to. This allows it to save speed skipping work it doesn't need, and make it possible to map infinite series and stuff like that.

So the line c = map....; just prepares the calculation, it doesn't actually run the function. The writeln(c) forces evaluation. You can also force evaluation immediately by calling .array on the thing, which calculates it and puts the result in a new array.

Reply via email to