;; bottle-song.lisp --
;;
;; Execute with:
;; * sbcl --noinform --load bottle-song.lisp --eval '(quit)'
;; * clisp bottle-song.lisp
(in-package :cl-user)
(defun bottle-song (&optional (in-stock 99) (stream *standard-output*))
;; Original idea by Geoff Summerhayes
;; Formatting idea by Fred Gilham
;; Actual formatting & minor recoding by Kent M Pitman
;;
;; Redone for conformance to
;; by Michael Weber .
(format
stream
"~v{~1&~0%~
~000000%~
~000000%~
~000000%~
~00000000%~
~:/bottles/ ~
of beer on ~000%~
the wall, ~001:*~
~99/bottles/ of ~
beer.~1:*~%~[Go ~
to the store and~
~000@* buy some ~
more, ~/bottles/~
~00% of beer on ~
the wall.~01%~:;~
Take one down an~
d pass it around~
, ~999/bottles/ ~
~:*of beer on th~
e wall.~002%~]~}"
(1+ in-stock)
(loop for bottle from in-stock downto 0 collect bottle)))
(defun bottles (stream arg &optional colonp atp &rest args)
(declare (ignore atp args))
(format stream "~[~:[n~;N~]o more bottles~:;~:*~A bottle~:*~P~]"
arg colonp))
(bottle-song)
#||
Alternative version, prints numbers as words:
[...]
Two bottles of beer on the wall, two bottles of beer.
Take one down and pass it around, one bottle of beer on the wall.
One bottle of beer on the wall, one bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, ninety-nine bottles of beer on the wall.
(defun bottles (stream arg &optional colonp atp &rest args)
(declare (ignore atp args))
(format stream "~[~:[n~;N~]o more bottles~:;~
~:[~2:*~R~;~2:*~@(~R~)~] bottle~:*~P~]"
arg colonp))
||#