Lazy Functional Lists

This is a simple demonstration of lazily-evaluated functional linked lists in JavaScript.

When we can build lists using lazy cons and map:

var xs = cons(1, fn0(cons(2, fn0(cons(3, fn0(nil()))))));
var ys = map(squared, xs);
var zs = map(squared, map(squared, xs));

We get lists that evaluate to the following:

Most of the interesting stuff is happening behind the scenes in JavaScript. Check out this page's source to dig into it.