Collapse the table of content
Expand the table of content
Expand Minimize

Array.exists<'T> Function (F#)

Tests if any element of the array satisfies the given predicate.

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

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

// Signature:
Array.exists : ('T -> bool) -> 'T [] -> bool

// Usage:
Array.exists predicate array


Type: 'T -> bool

The function to test the input elements.


Type: 'T []

The input array.

true if any result from predicate is true. Otherwise, false.

The predicate is applied to the elements of the input array. If any application returns true then the overall result is true and no further elements are tested.

This function is named Exists 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 how to test the elements of an array by using Array.exists.

let allNegative = Array.exists (fun elem -> abs (elem) = elem) >> not
printfn "%A" (allNegative [| -1; -2; -3 |])
printfn "%A" (allNegative [| -10; -1; 5 |])
printfn "%A" (allNegative [| 0 |])


Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

F# Runtime

Supported in: 2.0, 4.0


Supported in: 3

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft