MoreEnumerable.Permutations<T> Method |
Generates a sequence of lists that represent the permutations of the original sequence.
Namespace: MoreLinqAssembly: MoreLinq (in MoreLinq.dll) Version: 2.0.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.Generic.IEnumerable<T>
The original sequence to permute
Type Parameters
- T
- The type of the elements in the sequence
Return Value
Type:
IEnumerable<IList<T>>A 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
IEnumerable<T>. 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