2004-11-26 01:24:00

2004-11-26 01:24:00
First shot at LISP

Beer

; beer.lisp
; Benjamin Bryan
; November 25, 2004 (midnight of course)
; This Program writes the lyrics to 99 bottles of beer on the wall.

(setf lyrics '((" bottles") (" of beer") (" on the wall ") (" take one down pass it around ")))

(defun bottles-of-beer (x)
  (princ x)
  (if (= x 1)
      (princ " bottle")
    (princ(first(first lyrics))))
  (princ(first(first(rest lyrics)))))

(defun display (x)
  (bottles-of-beer x)
  (princ(first(first(rest(rest lyrics)))))  (bottles-of-beer x)
  (princ(first(first(rest(rest(rest lyrics))))))
  (if (> x 1)
      (bottles-of-beer (- x 1))
    (princ "no more bottles of beer"))
  (princ(first(first(rest(rest lyrics))))))

(defun beer (x)
  (display x)
  (if (> x 1)
      (beer (- x 1))
    (format t "~%The End")))

(beer 99)

Leave a Comment