Ultra-pure map()?

David Held dmd at wyntrmute.com
Fri Dec 27 17:52:57 PST 2013


On 12/27/2013 5:46 PM, David Nadlinger wrote:
> 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.

Functional programming was surely invented by labor unions!

Dave




More information about the Digitalmars-d-learn mailing list