Table of contents
Collapse the table of content
Expand the table of content

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

Den Delimarsky|Last Updated: 8/18/2017
1 Contributor

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


input Type: Lazy<'T>


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.


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


10 factorial is 3628800


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

Core.ExtraTopLevelOperators Module (F#)

Microsoft.FSharp.Core Namespace (F#)

© 2020 Microsoft