Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conceptual/collections.list-module-[fsharp].md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ For an overview of lists in F#, see [Lists (F#)](Lists-%5BFSharp%5D.
|[countBy](list.countby%5B't,'key%5D-function-%5Bfsharp%5D.md)<br />**: ('T -&gt; 'Key) -&gt; 'T list -&gt; ('Key &#42; int) list**|Applies a key-generating function to each element of a list and returns a list yielding unique keys and their number of occurrences in the original list.|
|[distinct](list.distinct%5B't%5D-function-%5Bfsharp%5D.md)<br />**: 'T -&gt; 'T list**|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.|
|[empty](https://msdn.microsoft.com/library/bb4cb501-3429-47c1-8d5f-71180d3bded7)<br />**: 'T list**|Returns an empty list of the given type.|
|[exactlyOne](https://msdn.microsoft.com/library/bd14fd21-b645-4416-98e4-6a6c49f3a15c)<br />**: 'T list -&gt; 'T**|Returns the only element of the list.|
|[exists](https://msdn.microsoft.com/library/15a3ebd5-98f0-44c0-8220-7dedec3e68a8)<br />**: ('T -&gt; bool) -&gt; 'T list -&gt; bool**|Tests if any element of the list satisfies the given predicate.|
|[exists2](https://msdn.microsoft.com/library/7532b39e-3f4f-4534-a60b-d7721dc6fa7e)<br />**: ('T1 -&gt; 'T2 -&gt; bool) -&gt; 'T1 list -&gt; 'T2 list -&gt; bool**|Tests if any pair of corresponding elements of the lists satisfies the given predicate.|
|[filter](https://msdn.microsoft.com/library/11a8c926-547b-44dd-bbae-98d44f3dd248)<br />**: ('T -&gt; bool) -&gt; 'T list -&gt; 'T list**|Returns a new collection containing only the elements of the collection for which the given predicate returns **true**.|
Expand Down
66 changes: 66 additions & 0 deletions docs/conceptual/list.exactlyone['t]-function-[fsharp].md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: List.exactlyOne<'T> Function (F#)
description: List.exactlyOne<'T> Function (F#)
keywords: visual f#, f#, functional programming
author: erikschierboom
manager: danielfe
ms.date: 03/13/2017
ms.topic: language-reference
ms.prod: visual-studio-dev14
ms.technology: devlang-fsharp
ms.assetid: a4e46410-b7fa-4e45-8daf-f1a84b632210
---

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

Returns the only element of the list.

**Namespace/Module Path**: Microsoft.FSharp.Collections.List

**Assembly**: FSharp.Core (in FSharp.Core.dll)


## Syntax

```fsharp
// Signature:exactlyOne : 'T list -> 'T

// Usage: List.exactlyOne list
```

#### Parameters
*list*
Type: **'T**[list](https://msdn.microsoft.com/library/c627b668-477b-4409-91ed-06d7f1b3e4a7)


The input list.

## Exceptions
|Exception|Condition|
|----|----|
|[ArgumentException](https://msdn.microsoft.com/library/system.argumentexception.aspx)|Thrown when the input does not have precisely one element.|
|[ArgumentNullException](https://msdn.microsoft.com/library/system.argumentnullexception.aspx)|Thrown when the input list is null|


## Return Value
The last element of the list.


## Remarks
This function is named `ExactlyOne` in the .NET assembly. If accessing the member from a .NET language other than F#, or through reflection, use this name.


## 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 &#40;F&#35;&#41;](Collections.List-Module-%5BFSharp%5D.md)

[Microsoft.FSharp.Collections Namespace &#40;F&#35;&#41;](Microsoft.FSharp.Collections-Namespace-%5BFSharp%5D.md)