[Issue 11572] eager apply for ranges

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 21 13:30:19 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11572


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc


--- Comment #1 from bearophile_hugs at eml.cc 2013-11-21 13:30:11 PST ---
(In reply to comment #0)
> The use-case
> 
> foreach (c; "foobar".retro())
>     writeln(c);
> 
> "foobar".retro.apply!writeln();

This is a common need, perhaps such request is already in Bugzilla.


> Not sure about the name, maybe sink or apply.

"sink" is probably better left for output ranges, etc.

"apply" function usually has another meaning:
http://en.wikipedia.org/wiki/Apply

So I suggest names like "forEach", that underlines its imperative nature.


> Or we could modify std.algorithm.reduce to allow void functions.

Reduce has a different meaning. Here you are not "reducing".


> Currently one needs to mix foreach and UFCS.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list