1

Groovy can make a complete combination from a n of n elements. A example of this would be:

[[1,2,3], [true,false], [A,B,C]].combinations()

result in:

[[1,true,A],[2,true,A],[3,true,A], [1,false,A],[2, false,A],[3, false,A], [1,false,B],[2, false,B],[3, false,B], [1,true,B],[2, true,B],[3, true,B] etc....

I am looking for something similar in java 11 like: combinations({1,2,3}, {true, false}, {A,B,C})

I haven't had any luck. I prefer to use a library.

Dasma
  • 1,023
  • 13
  • 34
  • 1
    Looks like you want a cartesian product. See https://stackoverflow.com/questions/714108/cartesian-product-of-arbitrary-sets-in-java – user Jul 01 '20 at 17:28
  • 1
    If you're fine with using a library, you can also add the Groovy collections library to your Java project, perhaps – user Jul 01 '20 at 17:31

0 Answers0