共用方式為


Array.exists<'T> 函式 (F#)

測試陣列的任何元素是否滿足指定的述詞。

命名空間/模組路徑: Microsoft.FSharp.Collections.Array

組件:FSharp.Core (在 FSharp.Core.dll 中)

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

// Usage:
Array.exists predicate array

參數

  • predicate
    Type: 'T -> bool

    用來測試輸入項目的函式。

  • array
    Type: 'T []

    輸入陣列。

傳回值

true如果任何產生的predicate is true. 否則為 false。

備註

述詞會套用至輸入陣列的元素。 如果任何應用程式會傳回 true整體的結果則會是 true並沒有進一步的項目會測試

這個函式是名為 Exists中 已編譯的組件。 如果從一個語言,F # 以外,或透過反映存取函式使用這個名稱。

範例

下列範例示範如何使用 測試陣列的元素 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# 執行階段

支援版本:2.0、4.0

Silverlight

支援版本:3

請參閱

參考

Collections.Array 模組 (F#)

Microsoft.FSharp.Collections 命名空間 (F#)