Ultra-pure map()?

David Nadlinger code at klickverbot.at
Fri Dec 27 17:46:42 PST 2013


On Saturday, 28 December 2013 at 01:41:35 UTC, David Held wrote:
> Can someone explain to me why map() is not equivalent to 
> foreach in the code above?  From what I can tell, map() doesn't 
> do anything at all on objs, even though it is a perfectly 
> legitimate range (as far as I can tell).

map() constructs a range that invokes a given function on the
source range if an element is requested – but only then. In other
words, map is fully lazy.

David


More information about the Digitalmars-d-learn mailing list