Skip to content

Instantly share code, notes, and snippets.

@TyOverby
Last active December 15, 2015 21:59
Show Gist options
  • Select an option

  • Save TyOverby/5329761 to your computer and use it in GitHub Desktop.

Select an option

Save TyOverby/5329761 to your computer and use it in GitHub Desktop.
Lisp to Javascript compilation
var fact = (function (x) {
return (function () {
if ((x < 0)) {
return (-fact((-x)));
} else if ((x > 0)) {
return (x * fact((x - 1)));
} else if (true) {
return 1;
}
})();
});
(define fact (lambda (x)
(cond [(neg? x) (neg (fact (neg x)))]
[(pos? x) (* x (fact (- x 1)))]
[true 1])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment