STL freaks
For those of you who are STL freaks out there:
transform(x.begin(), x.end(), y.begin(), z.begin(), *);
does this: for all i, z[i] = x[i] * y[i];
then,
result = accumulate(z.begin(), z.end(), 0)
adds all z[i]'s together.
now can we merge these two without having to use the intermediate container z? Maybe using some kind of iterator adaptor or something?
transform(x.begin(), x.end(), y.begin(), z.begin(), *);
does this: for all i, z[i] = x[i] * y[i];
then,
result = accumulate(z.begin(), z.end(), 0)
adds all z[i]'s together.
now can we merge these two without having to use the intermediate container z? Maybe using some kind of iterator adaptor or something?
