Just in time computation of combinations [duplicate]
问题 This question already has answers here : System.OutOfMemoryException when generating permutations (4 answers) Closed 3 years ago . I want to do something with every combination of ternaries for N variables: example with 1: T F U example with 2: TT FT UT TF FF UF UU Is there a way to compute this but only as needed: For example: var combinator = new Combinator<string>(2, {"T","F","U"}); List<String> tt = combinator.Next(); //tt contains {"T","T"} 回答1: You can implement it in an iterator method