mirror of
https://github.com/rjNemo/functional-programming-jargon
synced 2026-06-06 02:26:43 +00:00
Lazy evaluation.
Lazy evaluation example with ES6 generators.
This commit is contained in:
parent
18f85ba9c5
commit
5a836308db
1 changed files with 16 additions and 0 deletions
16
readme.md
16
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
|
||||
|
||||
---
|
||||
|
|
|
|||
Loading…
Reference in a new issue