Language Common Lisp
(standard version)
Date: | 04/20/05 |
Author: | Rebecca Walpole |
URL: | n/a |
Comments: | 5 |
Info: | n/a |
Score: | ![]() |
;; Bottles by Rebecca Walpole (walpolr@cs.orst.edu) ;; tested in Austin Kyoto Common Lisp version 1.615 ;; Note: the ~p takes care of plurals. ;; (defun bottles (n) "Prints the lyrics to '99 Bottles of Beer'" (if (< n 1) (format t "~%Time to go to the store.~%") (progn (format t "~% ~a bottle~:p of beer on the wall." n) (format t "~% ~a bottle~:p of beer." n) (format t "~% Take one down, pass it around.") (format t "~% ~a bottle~:p of beer on the wall.~%" (- n 1)) (bottles (- n 1)) ) ) ) (bottles 99)
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Common Lisp does indeed support object orientation; however, it is only one of many abstrations CL supports. In this case, it is much easier to use recursive abstraction than to invoke the overhead of defining objects using CLOS, the Common Lisp Object System, though it is native to all major implementations of CL.