6 ms·
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++ equivalen
by jlarocco 12y ago
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.