次の方法で共有


Seq.forall<'T> 関数 (F#)

更新 : 2010 年 8 月

シーケンスのすべての要素が、指定された述語を満たすかどうかをテストします。

名前空間/モジュール パス: Microsoft.FSharp.Collections.Seq

アセンブリ: FSharp.Core (FSharp.Core.dll)

// Signature:
Seq.forall : ('T -> bool) -> seq<'T> -> bool

// Usage:
Seq.forall predicate source

パラメーター

  • predicate
    型: 'T -> bool

    入力シーケンスの要素をテストする関数。

  • source
    型: seq<'T>

    入力シーケンス。

例外

例外

状態

ArgumentNullException

入力シーケンスが null の場合にスローされます。

戻り値

述語は入力シーケンスの要素に適用されます。 いずれかの適用結果として false が返された場合、全体の結果は false になり、残りの要素はテストされません。 それ以外の場合は、true を返します。

解説

この関数は、コンパイルされたアセンブリでは ForAll という名前です。 F# 以外の .NET 言語から、またはリフレクションを使用してこの関数にアクセスする場合は、この名前を使用します。

使用例

Seq.forall の使用例を次のコードに示します。

// This function can be used on any sequence, so the same function
// works with both lists and arrays.
let allPositive = Seq.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

参照

その他の技術情報

Collections.Seq モジュール (F#)

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

履歴の変更

日付

履歴

理由

2010 年 8 月

コード例を追加。

情報の拡充