[Issue 8755] New: Change the order of reduce arguments
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 4 09:09:37 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8755
Summary: Change the order of reduce arguments
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: adamsibson at hotmail.com
--- Comment #0 from adamsibson at hotmail.com 2012-10-04 09:03:45 PDT ---
Reduce cannot have a seed applied elegantly when used with UFCS due to the
argument order being range, seed. A newly named version with the argument order
reversed would allow the use of the full range of reduce's capabilities with
UFCS arguments.
Suggestion:
auto fold(range, seed) {}
to allow:
[1,2,3,4,5].fold!((a, b) => a + b * b)(0).writeln;
With the possibility of a longer chain in place of the array argument, a normal
use with UFCS. At present only a few uses such as sum, max and min are usable
with the unseeded form, limiting the usefulness of reduce.
Giving it a default of "a + b" would also improve its use as summing is
probably the most common use case.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list