0

I have a certain number (m) of lists of variable length (the lists don't have always the same length), for example m=4

List1: {1,2,3,4,5}
List2: {6,7}
List3: {8,9,10}
List4: {11,12,13,14,15,16}

I would like to realize a method like this:

method(list1, list2, list3, list4, n)

where n is the n-wise combinations to take.

For example n=2 all pairs, n=3 all triples.. as we can do with NUnit.

Is there a method like this in the framework?

All lists are strings lists

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • NUnit is open source, and is sourced under the MIT license. If you want a piece of MIT, go and take it. The code seems to be here: https://github.com/nunit/nunit/blob/master/src/NUnitFramework/framework/Internal/Builders/CombinatorialStrategy.cs – xanatos Dec 24 '20 at 12:04
  • 1
    do numbers from different lists make a pair or a pair is just a pair of 2 lists? It is not clear – canbax Dec 24 '20 at 12:07
  • the question is unclear, what does the variable m is needed? and which number should you take to the new list? – styx Dec 24 '20 at 12:08
  • It is the approach used in combinatorial testing, as described here https://en.wikipedia.org/wiki/All-pairs_testing N-wise testing with variable taking values from m different lists. I don't know how to explain this better N=2 means all possible couples of elements from the m different lists, N=3 all possibile triples etc. – Paolo Amato Dec 24 '20 at 12:11
  • how do you want to form pairs from 4 lists? – user287107 Dec 24 '20 at 13:14
  • Do searches for "n-Ary Cartesian Product". Eric Lippert has some [great examples](https://stackoverflow.com/a/4073806/2330053). – Idle_Mind Dec 24 '20 at 14:51

1 Answers1

0

Regarding your method(list1, list2, list3, list4, n), you're looking for the params keyword

AdrAs
  • 676
  • 3
  • 14