我有一个子程序:
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);
}
那么如何在main函数中调用呢?
static void Main(string[] args)
{
string input = "abcdefghijk";
IEnumerable<string> summary;
summary= permutations<string>(IEnumerable<string> input);// obviously wrong, but how??
}