RosettaCodeData/Task/Y-combinator/C++/y-combinator-3.cpp

7 lines
164 B
C++
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
template <typename A, typename B>
std::function<B(A)> Y (std::function<std::function<B(A)>(std::function<B(A)>)> f) {
2016-12-05 22:15:40 +01:00
return [f](A x) {
return f(Y(f))(x);
};
2015-11-18 06:14:39 +00:00
}