I have a subroutine:
private static IEnumerable<IEnumerable<T>> permutations<T>(IEnumerable<T> source)
{
var c = source.Count();
if (c == 1)
yield return source;
else
for (int i = 0; i < c; i++)
foreach (var p in permutations(source.Take(i).Concat(source.Skip(i + 1))))
yield return source.Skip(i).Take(1).Concat(p);
}
Then how to call it in main function?
static void Main(string[] args)
{
string input = "abcdefghijk";
IEnumerable<string> summary;
summary= permutations<string>(IEnumerable<string> input);// obviously wrong, but how??
}
Calling the function is easy, you just need:
This will give you a result that is a sequence of characters sequences. To convert the inner
IEnumerable<char>into strings just useSelect.