07/05/29 20:50:28
$ cat ./test.cpp && g++ test.cpp && ./a.out
#include <iostream>
#include <deque>
#include <boost/lambda/lambda.hpp>
using namespace std;
using namespace boost::lambda;
int main ()
{
typedef deque <double> Container;
Container c0;
for (size_t i (0); i < 10; ++ i)
c0.push_front (i);
Container c1 (c0);
cout << "max: " << *max_element (c0.begin (), c0.end ()) << '\n';
for_each (c0.begin (), c0.end (), _1 /= *max_element (c0.begin (), c0.end ()));
cout << "c0: "; for_each (c0.begin (), c0.end (), (cout << _1 << ' ')); cout << '\n';
for_each (c1.begin (), c1.end (), _1 /= 9);
cout << "c1: "; for_each (c1.begin (), c1.end (), (cout << _1 << ' ')); cout << '\n';
return 0;
}
max: 9
c0: 1 8 7 6 5 4 3 2 1 0
c1: 1 0.888889 0.777778 0.666667 0.555556 0.444444 0.333333 0.222222 0.111111 0
最近lamdaを使いはじめました
c0とc1の内容が異なってくるのですがこれはしょうがないんですかね
このへんの解説ページなんかあれば教えていただけるとうれしいのですが