更新 : 2010 年 8 月
マップ内の要素を検索し、要素がマップのドメイン内にある場合は Some 値を返し、そうでない場合は None を返します。
名前空間/モジュール パス: Microsoft.FSharp.Collections.Map
アセンブリ: FSharp.Core (FSharp.Core.dll 内)
// Signature:
Map.tryFind : 'Key -> Map<'Key,'T> -> 'T option (requires comparison)
// Usage:
Map.tryFind key table
パラメーター
key
型: 'Key入力キー。
table
型: Map<'Key,'T>入力マップ。
戻り値
見つかった Some 値または None。
解説
この関数は、コンパイルされたアセンブリでは TryFind という名前です。 F# 以外の言語から、またはリフレクションを使用してこの関数にアクセスする場合は、この名前を使用します。
使用例
Map.tryFind の使用方法を次のコード例に示します。
let map1 = [ for i in 1 .. 100 -> (i, i*i) ] |> Map.ofList
let result = Map.tryFind 50 map1
match result with
| Some x -> printfn "Found %d." x
| None -> printfn "Did not find the specified value."
出力
プラットフォーム
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 月 |
コード例を追加。 |
情報の拡充 |