Skip to content

Instantly share code, notes, and snippets.

@c650
Created August 10, 2020 16:11
Show Gist options
  • Save c650/aef27b4930722cf75c1e9bcb565d5c30 to your computer and use it in GitHub Desktop.
Save c650/aef27b4930722cf75c1e9bcb565d5c30 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
std::vector<int> v{1,2,3,4};
std::vector<int> b;
std::transform(v.begin(), v.end(), std::back_inserter(b), [](int a){return 2 * a;});
for (const auto& e : b) {
std::cout << e << "\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment