Seq.exists<'T> 関数 (F#)
更新 : 2010 年 8 月
シーケンスのいずれかの要素が、指定された述語を満たすかどうかをテストします。
名前空間/モジュール パス: Microsoft.FSharp.Collections.Seq
アセンブリ: FSharp.Core (FSharp.Core.dll)
// Signature:
Seq.exists : ('T -> bool) -> seq<'T> -> bool
// Usage:
Seq.exists predicate source
パラメーター
例外
例外 |
状態 |
---|---|
入力シーケンスが 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 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
参照
その他の技術情報
Microsoft.FSharp.Collections 名前空間 (F#)
履歴の変更
日付 |
履歴 |
理由 |
---|---|---|
2010 年 8 月 |
コード例を追加。 |
情報の拡充 |