From 5a836308db969933ed5d5249d3c6a135fa4ef12e Mon Sep 17 00:00:00 2001 From: "hemanth.hm" Date: Mon, 30 Mar 2015 16:22:39 +0530 Subject: [PATCH] Lazy evaluation. Lazy evaluation example with ES6 generators. --- readme.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/readme.md b/readme.md index 38b2b68..b316106 100644 --- a/readme.md +++ b/readme.md @@ -121,6 +121,22 @@ referential transparent. --- +## Lazy evalution +> aka call-by-need is an evaluation machanism which delays the evaluation of an expression until its value is needed. + +```js +let rand = function*() { + while(1<2) { + yield Math.random(); + } +} +``` +``` +let randIter = random(); +randIter.next(); // Each exectuion gives a random value, expression is evluated on need. +``` +--- + ## Monoid ---