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 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Core.ExtraTopLevelOperators Module (F#)

Microsoft.FSharp.Core Namespace (F#)