Anonymous user
Permutations: Difference between revisions
m
Oops. Previous change didn't fully work. Need "where T : IComparable<T>", not "where T : class"
(1) Needs to be in special class for extensions. 2) T needs to be scoped to class.) |
m (Oops. Previous change didn't fully work. Need "where T : IComparable<T>", not "where T : class") |
||
Line 2,026:
<lang csharp>public static class Extension
{
public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> values) where T :
{
if (values.Count() == 1)
return new[] { values };
return values.SelectMany(v => Permutations(values.Where(x => x.CompareTo(v) !=
}
}</lang>
|