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
Parameters
predicate
Type: 'T ->boolThe function to test the input elements.
array
Type: 'T[]The input array.
Return Value
true if any result from predicate is true. Otherwise, false.
Remarks
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.
Example
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 |])
true false false
Platforms
Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2
Version Information
F# Core Library Versions
Supported in: 2.0, 4.0, Portable