Lazy.Create <'T> Metoda rozszerzenie (F#)
Tworzy leniwy obliczeń, dającą w wyniku danej funkcji, gdy zmuszony.
Ścieżka obszaru nazw/modułu: Microsoft.FSharp.Control.LazyExtensions
Zestaw: FSharp.Core (w FSharp.Core.dll)
// Signature:
type System.Lazy with
member static Create : Lazy<'T>
// Usage:
lazy.Create (creator)
Parametry
creator
Typ: jednostki -> 'TFunkcji wartość, gdy są potrzebne.
Wartość zwracana
Utworzony Lazy obiektu.
Przykład
Poniższy kod ilustruje użycie 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())
Dane wyjściowe są silni 10.
Platformy
Windows 8, Windows 7, Windows Server 2012 Windows Server 2008 R2
Informacje o wersji
F# Core wersji biblioteki
Obsługiwane: 2.0