| title | List.distinct<'T> Function (F#) |
|---|---|
| description | List.distinct<'T> Function (F#) |
| keywords | visual f#, f#, functional programming |
| author | liboz |
| manager | danielfe |
| ms.date | 7/20/2016 |
| ms.topic | language-reference |
| ms.prod | visual-studio-dev14 |
| ms.technology | devlang-fsharp |
| ms.assetid | ea0e0598-c63d-4973-8e73-4e3544c6e47d |
Returns a list that contains no duplicate entries according to generic hash and equality comparisons on the entries. If an element occurs multiple times in the list then the later occurrences are discarded.
Namespace/Module Path: Microsoft.FSharp.Collections.List
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature:
List.distinct : 'T list -> 'T list (requires equality)
// Usage:
List.distinct sourcesource Type: 'Tlist
The input list.
| Exception | Condition |
|---|---|
| ArgumentNullException | Thrown when the input list is null |
The result list.
This function is named Distinct 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 List.distinct. The example generates the binary representation of a number as a list. It then determines that the only unique numbers are 0 and 1.
[!code-fsharpMain]
Output
[1; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0]
[1; 0]
Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2
F# Core Library Versions
Supported in: 4.0, Portable