Lazy evaluation.

Lazy evaluation example with ES6 generators.
This commit is contained in:
hemanth.hm 2015-03-30 16:22:39 +05:30
parent 18f85ba9c5
commit 5a836308db

View file

@ -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
---