Table of contents
TOC
Collapse the table of content
Expand the table of content

Seq.contains<'T> Function (F#)

liboz|Last Updated: 8/18/2017
|
1 Contributor

Evaluates to true if the given element is in the input sequence.

Namespace/Module Path: Microsoft.FSharp.Collections.Seq

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

Syntax

// Signature:
Seq.contains : 'T -> seq<'T> -> bool

// Usage:
Seq.contains element source

Parameters

element Type: 'T

The element to find.

source Type: seq<'T>

The input sequence.

Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when the input sequence is null.

Return Value

Evaluates to true if the given element is in the input sequence. Otherwise, it will return false.

Remarks

This function is named Contains in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

Example

The following code shows how to use Seq.contains.

let seq1 = seq { 1..10 }
let seq2 = Seq.empty

//The following line prints true
printfn "%A" (Seq.contains 5 seq1)

//The following line prints false
printfn "%A" (Seq.contains 5 seq2)

Output

true
false

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.Seq Module (F#)

Microsoft.FSharp.Collections Namespace (F#)

© 2018 Microsoft