Scalable is a C++ library that wraps STL with interface that assures immutability and provides higher level abstractions of control flow, such as monadic operations. This helps to make the program more readable and highly reliable, as well as reduce total development and maintenance costs, especially in parts not crucial to performance. At the same time it works for dynamically as well as statically (functor/lambdas) called functionoids, which gives it efficiency on par with handrolled control flow. See the following example and unit tests for reference. Code is available on github and shared under MIT License.
You may want to take a look at my another take at the topic glues, a C++ library generating lazy evaluation procedures at compile time for maximum performance, as well as mc: a Python library with similiar functionality.
collect(std::set<int>{1,2,3,4,5})
.map([](int i ) {
return i * i;
})
.filter([](int j) {
return j < 18;
})
.flatMap([](int i) {
return std::set<int>{ i, i + 1, i + 2};
})
.groupBy([](int j) {
return j % 2 == 0;
})
.map([](bool v, std::vector<int> l) {
return collect(l)
.map([](int i) {
return std::to_string(i);
})
.reduce(fun([] (std::string lhs, std::string rhs){
return lhs + "_" + rhs;
}));
})
.get()
.at(true);
C++11 or newer required, tested with g++-5.2.
Header only library, include scalable/scalable.h. See unit tests in test.cxx for reference. Build tests with make, googletest is needed for that.