Skip to content
Functional Programming in C++14
C++ Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
Makefile
README.md
compose.h
compose_example1.cc

README.md

Compose

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

Example

#include "compose.h"
#include <iostream>

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, ...
You can’t perform that action at this time.