;;;; bottles5.lsp

;;; Solution using functions for bottle representation
;;;
(defun bottles (X)
 "Song '99 bottles on the wall'"
  (let ((stock (make_bottles X) ))
    (mapc #'(lambda (Y)
	      (progn
		(funcall Y)
		(format t "Take one down, and pass it around.~%")))
	  stock)
    (format t "Now, they are all gone.")))

(defun make_bottles (X)
  (cond ((zerop X) nil)
	(t (cons (bottle X) (make_bottles (1- X))))))

(defun bottle (X)
  (if (= X 1)
      #'(lambda () (format t "1 bottle of beer on the wall. "))
      #'(lambda () (format t "~a bottles of beer on the wall. " X))))
