Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Those compute the same value, but I think the point of the C++ stream version is to compute the value using a lazily evaluated infinite list.

The C++ equivalent of your Python would be something like:

    typedef boost::counting_iterator<int> ci;
    auto sum = std::accumulate(ci(0), ci(10), 0, [](auto x, auto y) { return x + (y*y); });
No special streaming library required.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: