Compartir a través de


ExtraTopLevelOperators.Lazy<'T> Active Pattern (F#)

An active pattern to force the execution of values of type Lazy.

Namespace/Module Path: Microsoft.FSharp.Core.ExtraTopLevelOperators

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
( |Lazy| ) : Lazy<'T> -> 'T

Parameters

  • input
    Type: Lazy<'T>

Remarks

This function is named LazyPattern in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

Example

The following code illustrates the use of the Lazy active pattern.

let rec factorial n = match n with 0 | 1 -> 1 | n -> n * (factorial (n-1))
let lazyValue = lazy ( factorial (10) )
// No computation occurs until the match expression executes. 
match lazyValue with
| Lazy value -> printfn "10 factorial is %d" value

Output

10 factorial is 3628800

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Reference

Core.ExtraTopLevelOperators Module (F#)

Microsoft.FSharp.Core Namespace (F#)