6 ms·
That’s still multiple lines of code. Here’s one in c++ that uses only a single line of code (excluding function headers) // How do I format this as code? vec
by hasmanean 2y ago
That’s still multiple lines of code.
Here’s one in c++ that uses only a single line of code (excluding function headers)
// How do I format this as code?
vector<string> split( const string& s)
{
return accumulate(s.begin(), s.end(), vector<string>(1),
[=](auto acc, char c) {
if (c == ‘,’){ acc.push_back(string()); }
else { acc.back( ) += c; }
return acc;
} );
}