www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3098] New: std.algorithm.reduce example can not compile

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3098

           Summary: std.algorithm.reduce example can not compile
           Product: D
           Version: 2.030
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: samhu.samhu gmail.com
                CC: bugzilla digitalmars.com


Below example is from std.algorithm.reduce:
double[] a = [ 3.0, 4, 7, 11, 3, 2, 5 ];

// Compute minimum and maximum in one pass
auto r = reduce!(min, max)(a);
// The type of r is Tuple!(double, double)
assert(r.field[0] == 2);  // minimum
assert(r.field[1] == 11); // maximum

// Compute sum and sum of squares in one pass
r = reduce!("a + b", "a + b * b")(0.0, 0.0, a);
assert(r.field[0]==35);
assert(r.field[1]=233);

Can't compile.Error msg:
testFormat.d(22): Error: template std.algorithm.Reduce!("a + b","a + b *
b").reduce(E,Range) does not match any function template declaration
testFormat.d(22): Error: template std.algorithm.Reduce!("a + b","a + b *
b").reduce(E,Range) cannot deduce template function from argument types
!()(double,double,double[])

Not sure whether this is a bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 27 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3098


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





23:44:22 PDT ---
Fixed documentation:

- r = reduce!("a + b", "a + b * b")(0.0, 0.0, a);
+ r = reduce!("a + b", "a + b * b")(tuple(0.0, 0.0), a);

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