A Small Contribution to Phobos
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Jun 2 06:07:19 PDT 2013
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
More information about the Digitalmars-d
mailing list