Seq.groupBy<'T,'Key> Function (F#)
Applies a key-generating function to each element of a sequence and yields a sequence of unique keys and a sequence of all elements that have each key.
Namespace/Module Path: Microsoft.FSharp.Collections.Seq
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature: Seq.groupBy : ('T -> 'Key) -> seq<'T> -> seq<'Key * seq<'T>> (requires equality) // Usage: Seq.groupBy projection source
This function returns a sequence that traverses the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence.
This function is named GroupBy in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.
The following example demonstrates the use of Seq.groupBy to group the odd and even numbers in a sequence into two separate sequences.
(1, seq [1; 3; 5; 7; ...]) (0, seq [2; 4; 6; 8; ...])