Seq.countBy<'T,'Key> Function (F#)
Applies a key-generating function to each element of a sequence and return a sequence yielding unique keys and their number of occurrences in the original sequence.
Namespace/Module Path: Microsoft.FSharp.Collections.Seq
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature: Seq.countBy : ('T -> 'Key) -> seq<'T> -> seq<'Key * int> (requires equality) // Usage: Seq.countBy projection source
Note that 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 CountBy 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.countBy to determine the number of elements in a sequence that are odd or even.
(1, 50) (0, 50)