Skip to content

Instantly share code, notes, and snippets.

@aboekhoff
Created May 14, 2010 22:40
Show Gist options
  • Save aboekhoff/401787 to your computer and use it in GitHub Desktop.
Save aboekhoff/401787 to your computer and use it in GitHub Desktop.
;; silly example tail-elimination from cps style to javascript
(EV '(let* (f (fn (k x)
(k (op* * x x)))
g (fn (k _f x)
(_f k x))
h (fn (k _f)
(k (fn (_k x)
(_f _k x))))
(Array (h (fn (k*) (k* (fn (x) x) 42)) f))
h))
var g_0
g_0 = (42 * 42)
result = Array(g_0, (function (g_2, g_3) {
var g_1;
g_1 = g_2((function (g_5, g_6) {
var g_4;
g_4 = g_3(g_5, g_6);
return g_4;
}));
return g_1;
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment