2cl (pronounce "toccle") is a functional programming extension for C++
Nevar pievienot vairāk kā 25 tēmas
Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
|
#include "2CL.hpp"
|
|
#include <assert.h>
|
|
|
|
struct test_001{
|
|
test_001()
|
|
{
|
|
auto fn = cl::compose(
|
|
[](int a)->int{return a+2;},
|
|
[](int a)->int{return a*2;}
|
|
);
|
|
assert(fn(1)()==6);
|
|
}
|
|
};
|
|
|
|
test_001 run_001;
|
|
|
|
struct test_002{
|
|
test_002()
|
|
{
|
|
using namespace cl;
|
|
auto fn =
|
|
[](int a)->int{return a+2;}
|
|
* [](int a)->int{return a*2;};
|
|
assert(fn(2)()==8);
|
|
}
|
|
};
|
|
|
|
test_002 run_002;
|