Lazy evaluation

This concept is very simple. By default, F# follows the eager evaluation (https://en.wikipedia.org/wiki/Eager_evaluation) strategy, or an expression is evaluated as soon as it is bound. The alternative strategy available in other functional programming languages is to postpone the calculations until their result is absolutely necessary. F# can be explicitly told where to use lazy evaluation; by default, it uses lazy evaluations only for sequences. Expressing lazy evaluation if F# is not complicated syntactically, the following binding serves the purpose as shown:

let name = lazy ( expression ) 

Here, name is bound to the result of calculating expression, but the calculation itself is postponed. The type of value name is a special ...

Get F# 4.0 Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.