測試陣列的所有項目是否都滿足所指定的述詞。
命名空間/模組路徑: Microsoft.FSharp.Collections.Array
組件:FSharp.Core (在 FSharp.Core.dll 中)
// Signature:
Array.forall : ('T -> bool) -> 'T [] -> bool
// Usage:
Array.forall predicate array
參數
傳回值
true如果所有的陣列元素滿足述詞。 否則會傳回 false。
備註
述詞套用至輸入集合的項目。 如果有任何應用程式傳回 false,則整體結果為 false,而且不會測試之後的任何項目。
這個函式是名為 ForAll中 已編譯的組件。 如果從一個語言,F # 以外,或透過反映存取函式使用這個名稱。
範例
下列範例會顯示使用 Array.forall測試元素的 陣列。
let allPositive = Array.forall (fun elem -> elem > 0)
printfn "%A" (allPositive [| 0; 1; 2; 3 |])
printfn "%A" (allPositive [| 1; 2; 3 |])
平台
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