Last active
December 15, 2015 21:59
-
-
Save TyOverby/5329761 to your computer and use it in GitHub Desktop.
Lisp to Javascript compilation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| })(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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