I implemented the lambda-calculus in C++, but now I don't know how to get out of it. I would like to test if my functions return the right thing, but I cant compare the result, since it is a funtion. Does anyone have an idea how I could test my code?
#include <functional>
class function :
public std::function<function (function)> {
public: using type =
std::function<function (function)>;
public: using type::function;
};
function True = [](function x) {
return [&](function y) {
return x;
};
};
function False = [](function x) {
return [&](function y) {
return y;
};
};
function If = [](function x) {
return [&](function y) {
return [&](function z) {
return x(y)(z);
};
};
};
function And = [](function x) {
return [&](function y) {
return x(y)(x);
};
};
function Or = [](function x) {
return [&](function y) {
return x(x)(y);
};
};
// ...
int main()
{
// ?
}