Skip to content

Instantly share code, notes, and snippets.

@verdammelt
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verdammelt/2417ee8be3802593d434 to your computer and use it in GitHub Desktop.
Save verdammelt/2417ee8be3802593d434 to your computer and use it in GitHub Desktop.
beer song implemented (nearly) as a single FORMAT statement.
(defun verse (start &optional (end start))
(format nil
"~:{~[~
No more bottles of beer on the wall, ~
no more bottles of beer.~%~
Go to the store and buy some more, ~
99 bottles of beer on the wall.~%~%~
~:;~
~:*~d bottle~:p of beer on the wall, ~
~:*~d bottle~:p of beer.~%~
Take ~[it~:;one~] down and pass it around, ~
~:*~[no more bottles~:;~:*~d bottle~:p~] of beer on the wall.~%~
~]~v%~}"
(loop for i from start downto end
collecting (list i (1- i)
(when (= start end) 0)))))
(defun sing (start &optional (end 0))
(verse start end))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment