Language Common Lisp
(standard version)
Date: | 04/20/05 |
Author: | Rebecca Walpole |
URL: | n/a |
Comments: | 5 |
Info: | n/a |
Score: | (3.00 in 172 votes) |
;; 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
Stefan Scholl said on 08/14/05 21:26:21
Minor code cleanup:
Chris said on 03/07/06 09:15:38
Seeing as Common Lisp supports object orientation, I was surprised that this was procedural. I don't know any Lisp, but I DO know Common Lisp has OOP. Allegro CL is a good example. Well, their documentation is. The IDE, however, is a crash addict.
Tel said on 04/23/06 04:45:51
Chris,
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.
blink said on 09/27/07 20:41:21
clisp --- Nice and simple. Elegant.
mr said on 09/28/07 06:37:10
I'm interested in seeing a non-recursive (i.e. DO or LOOP-based) version, with sane FORMAT strings (unlike the one already on the site). I'd try to code one up now, but I don't have access to a CL implementation at the moment.