// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <vector>
#include <numeric>

using std::string;
using std::vector;
using std::reduce;
using std::next;
using std::cout;
using std::endl;

string join(vector<string> elements, string seperator)
{
    if (elements.empty())
    {
        return string("");
    }
    return reduce(next(elements.begin()), elements.end(), elements[0], [seperator](string a, string s) {
        return a + seperator + s;
    });
}

int main(int argc, char* argv[])
{
    vector<string> strings = { "Hello", "World", ",", "Oh", "Wait", "no", "the", "world", "is", "on", "fire" };
    cout << join(strings, string(" ")) << endl;
    return 0;
}
