次の方法で共有


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

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

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

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

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

// Usage:
Seq.exists predicate source

パラメーター

  • predicate
    型: 'T ->bool

    入力シーケンスの各項目をテストする関数。

  • source
    型: seq<'T>

    入力シーケンス。

例外

例外

状態

ArgumentNullException

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

戻り値

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

解説

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

使用例

Seq.exists の使用方法を次のコードに示します。

// Use Seq.exists to determine whether there is an element of a sequence
// that satisfies a given Boolean expression.
// containsNumber returns true if any of the elements of the supplied sequence match 
// the supplied number.
let containsNumber number seq1 = Seq.exists (fun elem -> elem = number) seq1
let seq0to3 = seq {0 .. 3}
printfn "For sequence %A, contains zero is %b" seq0to3 (containsNumber 0 seq0to3)

出力

  

プラットフォーム

Windows 8、Windows 7、Windows Server 2012 で Windows Server 2008 R2

バージョン情報

F# コア ライブラリのバージョン

サポート: ポータブル 2.0、4.0

参照

関連項目

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

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