This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename return_type, typename ...params> | |
auto _L( return_type (*fp) (params... args)) | |
{ return [fp] (params... args) { return fp(args...); }; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto map = [] (const auto &function, const auto &container ) | |
{ | |
auto retval = container; | |
retval.clear(); | |
for (const auto &elem : container) | |
retval.push_back(function(elem)); | |
return retval; | |
}; | |
vector<int> data {1,2,3,4}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto triple = [](auto a) { return a*3; }; | |
cout << (triple * incr *dbl)(5) << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto incr = [](auto a) {return a+1;}; | |
auto dbl = [](auto a) {return a*2;}; | |
auto output_decorate = [](auto a) {cout<<a<<" "<<endl; return a;}; | |
auto dbl_incr_decor = output_decorate * incr * dbl; | |
int x = dbl_incr_decor(5); | |
double y = dbl_incr_decor(.5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto lambda_plus = [] (auto x, auto y) { return x+y; }; | |
int z = lambda_plus(5,3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <functional> | |
using std::cout; | |
using std::endl; | |
template<typename return_type, typename ...params> | |
auto _L( return_type (*fp) (params... args)) | |
{ return [fp] (params... args) { return fp(args...); }; }; |
NewerOlder