<commit_before>#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

template<typename A>
class MappedRDD;

template <typename A>
class RDD {
public:
    vector<A> sequence;

    template<typename Func>
    auto map(Func f) -> RDD<decltype(f(A()))> {
        vector<decltype(f(A()))> result;
        result.resize(sequence.size());
        std::transform(sequence.begin(), sequence.end(), result.begin(), f);
        return MappedRDD<decltype(f(A()))>(result);
    }

    template<typename Func>
    auto fold(A init, Func f) -> decltype(f(A(), A())) {
        return std::accumulate(std::begin(sequence), std::end(sequence), init, f);
    }

//    virtual vector<A> compute() = 0;
};

template <typename A>
class MappedRDD: public RDD<A> {
public:
    vector<A> sequence;

    MappedRDD(vector<A> sequence): sequence(sequence) {}

//    vector<A> compute() {
//        vector<A> result;
//        return result;
//    }
};


int main() {
    cout << "Hello, World!" << endl;
    vector<int> data {1, 2, 3, 4};
    MappedRDD<int> rdd(data);
    auto r = rdd.map([](int a) -> double {
        return a * 2;
    }).map([](double a) -> double {
        return a + 5;
    });
    for (auto i = r.sequence.begin(); i != r.sequence.end(); ++i) {
        cout << *i << ' ' << endl;
    }
    cout << r.fold(0, [](int a, int b) -> int {
        return a + b;
    });
    return 0;
}<commit_msg>Working code<commit_after>#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

template<typename A>
class MappedRDD;

template <typename A>
class RDD {
public:
    vector<A> sequence;

    RDD() {}
    RDD(vector<A> sequence): sequence(sequence) {}

    template<typename Func>
    auto map(Func f) -> RDD<decltype(f(A()))> {
        vector<decltype(f(A()))> result;
        result.resize(sequence.size());
        std::transform(sequence.begin(), sequence.end(), result.begin(), f);
        return MappedRDD<decltype(f(A()))>(result);
    }

    template<typename Func>
    auto fold(A init, Func f) -> decltype(f(A(), A())) {
        return std::accumulate(std::begin(sequence), std::end(sequence), init, f);
    }

//    virtual vector<A> compute() = 0;
};

template <typename A>
class MappedRDD: public RDD<A> {
public:
    MappedRDD(vector<A> sequence): RDD<A>(sequence) {}
//    vector<A> compute() {
//        vector<A> result;
//        return result;
//    }
};

template<typename T>
void print_vector(vector<T> v) {
    for (auto i = v.begin(); i != v.end(); ++i) {
        cout << *i << ' ' << endl;
    }
}


int main() {
    cout << "Hello, World!" << endl;
    vector<int> data {1, 2, 3, 4};
    MappedRDD<int> rdd(data);
    auto r = rdd.map([](int a) -> double {
        return a * 2;
    }).map([](double a) -> double {
        return a + 5;
    });

    cout << "Printing numbers\n";
    print_vector(r.sequence);

    cout << "Printing sum\n";
    cout << r.fold(0, [](int a, int b) -> int {
        return a + b;
    });
    return 0;
}
{'fraction_non_alphanumeric': 0.19006335445148384, 'fraction_numerical': 0.006002000666888963, 'mean_word_length': 2.745318352059925, 'pattern_counts': {'":': 0, '<': 74, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '689714', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1048, 'n_words': 261}