https://github.com/wasabi315/lazy
STG-like lazy evaluation mechanism in JavaScript
https://github.com/wasabi315/lazy
lazy-evaluation
Last synced: about 1 month ago
JSON representation
STG-like lazy evaluation mechanism in JavaScript
- Host: GitHub
- URL: https://github.com/wasabi315/lazy
- Owner: wasabi315
- License: mit
- Created: 2021-09-20T00:44:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-14T13:38:59.000Z (about 1 year ago)
- Last Synced: 2025-02-17T15:17:57.667Z (4 months ago)
- Topics: lazy-evaluation
- Language: JavaScript
- Homepage:
- Size: 54.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lazy.js
A STG-like lazy evaluation mechanism in JavaScript
```javascript
// fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
const fibs = Thunk(() => {
const xs = Thunk(() => tail(fibs));
const ys = Thunk(() => zipWith(add, fibs, xs));
const zs = Thunk(() => Cons(1n, ys));
return Cons(0n, zs);
});
```For usage and more examples, see [prelude.js](./prelude.js) and the [examples](./examples) directory.
### Environment
Only tested in deno.
## Reference
- Simon Marlow and Simon Peyton Jones. 2004. Making a fast curry: push/enter vs. eval/apply for higher-order languages. SIGPLAN Not. 39, 9 (September 2004), 4–15.