Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/christianparpart/compose

Functional Programming in C++14
https://github.com/christianparpart/compose

cpp cpp11 cpp14 functional-programming library

Last synced: 3 days ago
JSON representation

Functional Programming in C++14

Awesome Lists containing this project

README

        

### Compose

That's my little library for allowing myself to code in fuctional style in C++14.

### Example
```cpp
#include "compose.h"
#include

int main() {
auto v = {1, 2, 3, 4, 5, 6, 7, 8};

auto range = compose(v)
.map([](auto x) { return x * x; })
.select([](auto x) { return !(x % 2); })
.take(3);

for (auto a: range) {
std::cout << "a: " << a << std::endl;
}
}
```

### Functions API

- `map(func)`
- `select(predicate)`
- `take(count)`
- `fold(init, func)`
- `size()`
- ... (more to come, by dragons)

### TODO
- support more functional patterns, such as zip, foldLeft, ...