Created
February 14, 2011 10:46
-
-
Save vladimir-vg/825720 to your computer and use it in GitHub Desktop.
This file contains 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
;; simple | |
(define (fac acc n) | |
(if (= n 1) | |
acc | |
(fac (* acc n) (- n 1)))) | |
;; not | |
(define (fac n) | |
(if (= n 1) | |
1 | |
(* n (fac (- n 1))))) | |
;; both can be compiled with tail-call optimization. | |
;; first variant can be optimized more easily. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment