3 ms·
FWIW, with folly::gen [1], this is just: using namespace folly::gen; byLine('/a/file/with/numbers') | eachTo<int> | sum; https://github.com/facebook/f
by ajtulloch 12y ago
FWIW, with folly::gen [1], this is just:
using namespace folly::gen;
byLine('/a/file/with/numbers') | eachTo<int> | sum;
https://github.com/facebook/folly/tree/master/folly/gen https://github.com/facebook/folly/tree/master/folly/gen
- seri 12y agoThank you for this. Got me really interested in folly now.
- nly 12y agoIt's only 2 lines even restricting yourself to the standard library #include <fstream> #include <iterator> #include <numeric> using namespace std; int main() { ifstream nf ("numbers.txt"); return accumulate (istream_iterator<int>(nf), istream_iterator<int>(), 0); }