Skip to content
/ lazy Public

STG-like lazy evaluation mechanism in JavaScript

License

Notifications You must be signed in to change notification settings

wasabi315/lazy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lazy.js

A STG-like lazy evaluation mechanism in 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 and the 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. https://doi.org/10.1145/1016848.1016856

About

STG-like lazy evaluation mechanism in JavaScript

Topics

Resources

License

Stars

Watchers

Forks