Comment

Comment by porphyra

I also find that, in C++,

    int sum = 0;
    for (int i = 0; i < n; ++i)
        sum += x[i];
    return sum
is a lot easier to understand than

    return std::accumulate(x.begin(), x.end(), 0, [](int a, b) {return a + b;});
Yet, the latter is considered more correct and better, with static analysis like cppcheck telling you to use the latter. It does have many advantages, like no mutable variables lying around, but gee it is annoying to read.
parent porphyra 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton