Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] newbie: lambda to help in std::accumulate
From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2009-01-29 11:53:43


On Thu, Jan 29, 2009 at 4:06 PM, Micha³ Nowotka <mmmnow_at_[hidden]> wrote:
> Ok, i now I've corrected my method to:
>
> double evaluate(const vector<double>& win_probabls)
> {
> return accumulate (win_probabls.begin(), win_probabls.end(), 0,
> lambda::_1 + lambda::bind(log, lambda::_2) );
> }
>
>
> what I'm doing wrong?

There is one thing - change the 0 in the accumulate to 0.0, otherwise
the accumulator is typed as an integer. That's the source of the C4244
warning, and will also result in the wrong answer being returned.

Stuart Dootson


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net