#include <hpx/hpx_main.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/parallel/algorithms/transform_inclusive_scan.hpp>

int main(int argc, char *argv[]) {
    std::vector<int> test{1, 10, 100, 1000};
    std::vector<int> output(test.size());
    auto pol    = hpx::parallel::execution::par(hpx::parallel::execution::task);
    auto result = hpx::parallel::transform_inclusive_scan(
                      pol, test.cbegin(), test.cend(), output.begin(),
                      [](int acc, int xs) -> int {
                          hpx::cout << acc << "+" << xs << hpx::endl;
                          if(acc < xs) {
                              return acc + xs;
                          } else {
                              return -10000;
                          }
                      },
                      [](int el) -> int { return el; }, 0)
                      .get();
    for(auto el : output) {
        hpx::cout << el << hpx::endl;
    }
    return 0;
}