Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;; with default optimizations
- (defun factorial (n)
- (cond ((= n 0) 1)
- (t (* n (factorial (- n 1))))))
- ;;;-----------------------
- ;;; usage:
- ;;;
- ;;; $ clisp, ecl or cmucl
- ;;; (load "fact.lisp")
- ;;; (test1)
- ;;; or
- ;;; (test2)
- ;;; poor, c conversion, :)
- #+:clisp
- (defun test1 ()
- (format t "~S~&" (factorial 6000)))
- #+:clisp
- (defun test2 ()
- (compile 'factorial)
- (format t "~S~&" (factorial 40000)))
- ;;;------------------------
- ;;; better, :)
- #+:ecl
- (defun test1 ()
- (format t "~S~&" (factorial 12000)))
- #+:ecl
- (defun test2 ()
- (compile 'factorial)
- (format t "~S~&" (factorial 80000)))
- ;;;--------------------------
- ;;; this is already optimized by default
- #+:cmu
- (defun test1 ()
- (format t "~S~&" (factorial 100000)))
- #+:cmu
- (defun test2 ()
- (compile 'factorial)
- (format t "~S~&" (factorial 200000)))
- ;;; Note:
- ;;;
- ;;; - the numbers are random, that means i didn't try to find a limit,
- ;;; just stop before 'stack overflow' for clisp and ecl, first hit
- ;;; from cmucl
- ;;; - no declaration to optimze the compiled code in a specific way
Add Comment
Please, Sign In to add comment