Anonymous user
99 Bottles of Beer/Lisp: Difference between revisions
no edit summary
m (Fixed syntax highlighting and duplicate headers.) |
imported>Rowsety Moid No edit summary |
||
Line 26:
(if (= n 2) 0 1))
(bottles-of-beer (- n 1)))))</syntaxhighlight>
===Acornsoft Lisp===
<syntaxhighlight lang="lisp">(defun bottles ((n . 99))
(loop
(bob n) (otw) (nl)
(bob n) (nl)
(tod-pia) (nl) (setq n (sub1 n))
(bob n) (otw) (nl)
(nl)
(until (zerop n))))
(defun nl ()
(printc))
(defun sing (w)
(princ w '! ))
(defun bob (n)
(map sing
(list (any? n) (plural? n 'bottle 'bottles) 'of 'beer)))
(defun otw ()
(map sing (list 'on 'the 'wall)))
(defun tod-pia ()
(map sing (list 'Take 'one 'down!, 'pass 'it 'around)))
(defun any? (n)
(cond ((zerop n) 'no)
(t n)))
(defun plural? (n sing plur)
(cond ((onep n) sing)
(t plur)))</syntaxhighlight>
===Common Lisp===
|