MoreEnumerablePermutationsT Method |
Generates a sequence of lists that represent the permutations of the original sequence.
Namespace:
MoreLinq
Assembly:
MoreLinq (in MoreLinq.dll) Version: 2.2.0
Syntax public static IEnumerable<IList<T>> Permutations<T>(
this IEnumerable<T> sequence
)
<ExtensionAttribute>
Public Shared Function Permutations(Of T) (
sequence As IEnumerable(Of T)
) As IEnumerable(Of IList(Of T))
public:
[ExtensionAttribute]
generic<typename T>
static IEnumerable<IList<T>^>^ Permutations(
IEnumerable<T>^ sequence
)
[<ExtensionAttribute>]
static member Permutations :
sequence : IEnumerable<'T> -> IEnumerable<IList<'T>>
Parameters
- sequence
- Type: System.Collections.GenericIEnumerableT
The original sequence to permute
Type Parameters
- T
- The type of the elements in the sequence
Return Value
Type:
IEnumerableIListTA sequence of lists representing permutations of the original sequence
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Remarks
A permutation is a unique re-ordering of the elements of the sequence.
This operator returns permutations in a deferred, streaming fashion; however, each
permutation is materialized into a new list. There are N! permutations of a sequence,
where N => sequence.Count().
Be aware that the original sequence is considered one of the permutations and will be
returned as one of the results.
See Also