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)

Join Ben's Newsletter

Subscribe and get my 88 favorite Linux commands 🔻




(I won't share your email with anyone; unsubscribe any time)

Leave a Comment