Late to the party but I'll post 'em anyway.
I found the bottle song hard to do in a 'nice' way. First you have to learn lisp and then you have to learn the language format uses as well.
Can a lisper please tell me how I can use ~r for the numbers except for 0 where I want "no more" instead of "zero"? I got pissed off in the end and used a function outside of format. At least I have all the words of the song typed just once.
(defun pre-format (number)
(if (= 0 number) "no more bottles" (format nil "~r bottle~:p" number)))
(loop :for numbottles :from 99 :downto 0 :do
(format t "~@(~a~) of beer on the wall, ~:*~a of beer.~%" (pre-format numbottles))
(if (< 0 numbottles)(format t "Take one down, pass it around, ~a of beer on the wall. ~2%" (pre-format (1- numbottles)))
(format t "Go to the store and buy some more, ninety-nine bottles of beer on the wall.~2%")))
Also couldn't work out how to do the condition for the last line of the song inside the format call and used two formats where I guess only one is needed.
Also had a go at the number guessing game.
It was a much uglier beast using 'loop' before I saw a previous effort which showed that 'do' has all the control needed for this game, including getting all the variable scope right. Feel like I cheated after that, but once you see a nice idea you just can't get it out of your head...
(defun make-em-guess (tellemwottodo)
(format t "~a: " tellemwottodo)
(or (parse-integer (read-line) :junk-allowed t)
(make-em-guess "Not an integer. Try again")));If input is not an integer, re-call make-em-guess with error message.
(do ((secretnumber (+ 1 (random 100)))
(numberofgoes 1 (1+ numberofgoes))
(wotdidtheysay (make-em-guess "Pick a number between 1 and 100") ;Set'wotdidtheysay' by calling make-em-guess with the initial instruction.
(make-em-guess (if (< wotdidtheysay secretnumber) "Too low, pick a higher number" "Too high, try something lower")))) ;Each loop 'wotdidtheysay' is reset by calling make-em-guess with appropriate instruction.
((= wotdidtheysay secretnumber);End test for 'do' loop.
(format t "You won in ~a goes!" numberofgoes)))