[Issue 11128] New: std.algorithm.reduce one-argument version cannot always be chained using UFCS

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 26 22:53:19 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11128

           Summary: std.algorithm.reduce one-argument version cannot
                    always be chained using UFCS
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: daniel350 at bigpond.com


--- Comment #0 from daniel350 at bigpond.com 2013-09-26 22:53:16 PDT ---
Example:

arr1.reduce!((s, x) => s + (x / 3));

Because the natural seed value is arr1.front, depending on the type, this will
return an incorrect result, so you therefore need to provide a seed, using the
one-argument version of std.algorithm.reduce, this cannot be done.

You are therefore forced to use the standard syntax:

reduce!((s, x) => s + (x / 3))(0, arr1);

Or:

0.reduce!((s, x) => s + (x / 3))(arr1);



This seems counter-intuitive, compared to:

arr1.reduce!((s, x) => s + (x / 3))(0);


This change wouldn't play pretty.

-- 
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