Created
May 12, 2016 22:49
-
-
Save Masstronaut/c37b4370d61e03a88cc755197e15f09c to your computer and use it in GitHub Desktop.
Generic first-class function composition in c++
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
// This is my implementation submission for this page: http://www.programming-idioms.org/idiom/36/first-class-function-generic-composition | |
template<typename Pred1, typename Pred2> | |
auto compose(Pred1 f, Pred2 g){ | |
return [f,g](auto x){ return g(f(x)); }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment