99 Bottles of Beer/Lisp: Difference between revisions

Content added Content deleted
(Lisp)
Line 55: Line 55:


=={{header|Lisp}}==
=={{header|Lisp}}==
Bit of a beginner in Lisp, but this seems to work:
</lang lisp>
(defun beer-verse (count)
"Recurses the verses"
(format t "~A bottle~:P of beer on the wall~%" count)
(format t "~A bottle~:P of beer~%" count)
(format t "Take one down, pass it round~%")
(format t "~A bottle~A of beer on the wall~%~%"
(if (= count 1)
"No"
(- count 1))
(if (/= count 2)
"s"
""))
(if (> count 1)
(beer-verse (- count 1))))
(beer-verse 99)
</lang>


{{Out}} (last three verses only):
<pre>
3 bottles of beer on the wall
3 bottles of beer
Take one down, pass it round
2 bottles of beer on the wall

2 bottles of beer on the wall
2 bottles of beer
Take one down, pass it round
1 bottle of beer on the wall

1 bottle of beer on the wall
1 bottle of beer
Take one down, pass it round
No bottles of beer on the wall
</pre>


=={{header|NewLISP}}==
=={{header|NewLISP}}==