MoreEnumerablePermutationsT Method

Generates a sequence of lists that represent the permutations of the original sequence.

Definition

Namespace: MoreLinq
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
C#
public static IEnumerable<IList<T>> Permutations<T>(
	this IEnumerable<T> sequence
)

Parameters

sequence  IEnumerableT
The original sequence to permute.

Type Parameters

T
The type of the elements in the sequence.

Return Value

IEnumerableIListT
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 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