September 27, 2013 [Issue 11128] New: std.algorithm.reduce one-argument version cannot always be chained using UFCS | ||||
---|---|---|---|---|
| ||||
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@puremagic.com ReportedBy: daniel350@bigpond.com --- Comment #0 from daniel350@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: ------- |
September 27, 2013 [Issue 11128] std.algorithm.reduce one-argument version cannot always be chained using UFCS | ||||
---|---|---|---|---|
| ||||
Posted in reply to daniel350@bigpond.com | http://d.puremagic.com/issues/show_bug.cgi?id=11128 Peter Alexander <peter.alexander.au@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |peter.alexander.au@gmail.co | |m Resolution| |DUPLICATE --- Comment #1 from Peter Alexander <peter.alexander.au@gmail.com> 2013-09-27 14:43:37 PDT --- Yep, it's irritating, and a known issue. Closing as dupe. *** This issue has been marked as a duplicate of issue 8755 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation