Lazy.Create<'T> 拡張メソッド (F#)

強制されたときに指定された関数の結果と評価される遅延計算を作成します。

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

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

// Signature:
type System.Lazy with
  member static Create : Lazy<'T>

// Usage:
lazy.Create (creator)

パラメーター

  • creator
    型: unit -> 'T

    必要に応じて値を提供する関数。

戻り値

作成された遅延オブジェクト。

使用例

次のコードは、Create の使用例です。

let lazyValue n = Lazy.Create (fun () ->
    let rec factorial n =
        match n with
        | 0 | 1 -> 1
        | n -> n * factorial (n - 1)
    factorial n)
let lazyVal = lazyValue 10
printfn "%d" (lazyVal.Force())

出力は 10 の階乗になります。

  

プラットフォーム

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

バージョン情報

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

サポート: 2.0

参照

関連項目

Control.LazyExtensions モジュール (F#)

Lazy<T>

遅延計算 (F#)