25 Jan
2009
25 Jan
'09
1:51 p.m.
2009/1/25 Michał Nowotka
I want to compute sum of logarithms so i wrote:
#include <cmath>
double evaluate(const vector<double>& win_probabls) { return accumulate (win_probabls.begin(), win_probabls.end(), 0, lambda::_1 + log(lambda::_2) ); }
but this code doesn't compile. Does anyone know why?
--
Michał Nowotka
'log' is a function, so a call to it in a lambda expression has to be within a bind expression: double evaluate(const std::vector<double>& win_probabls) { using namespace boost::lambda; return accumulate (win_probabls.begin(), win_probabls.end(), 0, _1 + bind(log, _2) ); } Stuart Dootson