views:

91

answers:

1

Hi,

I have v1 and v2 , how should I got a new v like below?

v1 = {1,2}
v2 = {3,4,5}

v = {f(1,3) , f(1,4) , f(1,5) f(2,3) ,f(2,4) ,f(2,5)}

I know I could do it using two loops, But If there is more idiomatic way like using STL algorithm?

//using two loops
for iter1 of v1 
     for iter2 of v2
           v.push_back(f(v1,v2))

EDIT:

v1 and v2 not necessary have same size.

+1  A: 

This looks almost exactly like what you're asking for:

http://stackoverflow.com/questions/979436

Tim Sylvester