Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Latest commit

 

History

History
71 lines (51 loc) · 1.98 KB

File metadata and controls

71 lines (51 loc) · 1.98 KB
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

List.distinct<'T> Function (F#)

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)

Syntax

// Signature:
List.distinct : 'T list -> 'T list (requires equality)

// Usage:
List.distinct source

Parameters

source Type: 'Tlist

The input list.

Exceptions

Exception Condition
ArgumentNullException Thrown when the input list is null

Return Value

The result list.

Remarks

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.

Example

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]

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 4.0, Portable

See Also

Collections.List Module (F#)

Microsoft.FSharp.Collections Namespace (F#)