Created
June 27, 2013 06:53
-
-
Save JuanitoFatas/5874468 to your computer and use it in GitHub Desktop.
Common Lisp 代碼例子:Factorial
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
(defun factorial (n) | |
(declare (optimize speed)) | |
(labels ((fact (n acc) | |
(declare (type fixnum n) | |
(type bignum acc)) | |
(if (<= n 0) | |
acc | |
(fact (the fixnum (1- n)) | |
(the bignum (* n acc)))))) | |
(fact n 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When acc is not a bignum, will encouter another error