Skip to content

Instantly share code, notes, and snippets.

@eiriklv
Last active August 29, 2015 14:13
Show Gist options
  • Save eiriklv/fbcf4a3c0b94bc61218c to your computer and use it in GitHub Desktop.
Save eiriklv/fbcf4a3c0b94bc61218c to your computer and use it in GitHub Desktop.
function cons(x, y) {
return function(w) { return w(x, y) };
};
function car(z) {
return z(function(x, y) { return x });
};
function cdr(z) {
return z(function(x, y) { return y });
};
var list = cons(1, cons(2, null));
document.writeln( car(list));
document.writeln( car(cdr(list)));
document.writeln( cdr(cdr(list)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment