auto f=[&](int u){
for (int i=2;i<=u;++i){
if (u%i==0) return i;
}
};
What is this doing?
auto f=[&](int u){
for (int i=2;i<=u;++i){
if (u%i==0) return i;
}
};
What is this doing?
It’s a lambda function. It’s a little bit like a normal function, but it can steal variables from it’s surroundings. The function returns the smallest factor of u.
So, is this like declaration? f=[&] ( )
https://en.cppreference.com/w/cpp/language/lambda
You can read about it here. It’s called a capture, not a steal. My bad.