A Small Contribution to Phobos
deadalnix
deadalnix at gmail.com
Sun Jun 2 09:38:49 PDT 2013
On Sunday, 2 June 2013 at 13:07:18 UTC, Andrei Alexandrescu wrote:
> On 6/2/13 1:58 AM, Meta wrote:
>>> For reference type ranges and input ranges which are not
>>> forward
>>> ranges, this
>>> will consume the range and return nothing.
>>
>> I originally wrote it to accept forward ranges and use save,
>> but I
>> wanted to make it as inclusive as possible. I guess I
>> overlooked the
>> case of ref ranges.
> [snip]
>
> Thanks for sharing your ideas.
>
> I think consuming all of a range evaluating front and doing
> nothing should be the role of reduce with only one parameter
> (the range). That overload would take the range to be
> "exhausted" and return void. Thus your example becomes:
>
> [1, 2, 3, 4].map!(n => n.writeln).reduce;
>
>
> Andrei
map being lazy, this can really do all kind of different stuff.
More information about the Digitalmars-d
mailing list