0

Lets say that I have a vector of vector of integers. <1,2,3,4> , <5,6,7,8>, <10,11,12,13>

how do I make a function that creates vector of vector of every different patterns?

<1,5,10> , <1,5,11>, <1,5,12>, <1,5,13> <1,6,10> , <1,6,11>, <1,6,12>, <1,6,13> <1,7,10> , <1,7,11>, <1,7,12>, <1,7,13> <1,8,10>, <1,8,11>, <1,8,12>, <1,8, 13> <2,5,10>, <2,5,11>, <2,5,12>, <2,5,13>

This function should be able to take in any number of vector of integers.

What I want is Cartesian product of my vectors but i can't find a recursive function that could take any number of vector of integers.

If I had the set number of vector of integers, I would only have to nested for loops but i need it to be recursive so that it could take any number of vector of integers.

  • 3
    Welcome to SO. It's clear what you're looking for, but what have you tried? We want to see where you're having trouble. – John Mar 26 '13 at 19:23
  • You're looking for the _Cartesian product_ of your vectors. See http://stackoverflow.com/questions/2405242/cartesian-product-of-several-vectors. – Andrew Cheong Mar 26 '13 at 19:27

0 Answers0