99 Bottles of Beer/Lisp: Difference between revisions

Content added Content deleted
m (moved to Common Lisp)
m (updated Ol sample)
Line 96: Line 96:


=={{header|Ol}}==
=={{header|Ol}}==
<lang ol>
<lang scheme>
(setq nn 99)
(define nn 99)
(let loop ((n nn))
(print n " bottles of beer on the wall,")
(print n " bottles of beer.")
(print "Take one down, pass it around, ")
(if (eq? n 1)
(begin
(print "No more bottles of beer on the wall.")
(print))
(begin
(print (- n 1) " bottles of beer on the wall,")
(print)
(loop (- n 1)))))


(for-each (lambda (n)
(print "No more bottles of beer on the wall,")
(let ((bottle (lambda (n) (if (eq? n 1) " bottle" " bottles")))
(print "No more bottles of beer.")
(m (- n 1)))
(print "Go to the store and buy some more,")
(print
(print nn " bottles of beer on the wall.")
n (bottle n) " of beer on the wall, "
n (bottle n) " of beer." "\n"
"Take one down and pass it around, "
(if (eq? m 0) "no more" m)
(bottle m) " of beer on the wall.\n")))
(reverse (iota nn 1)))
(print
"No more bottles of beer on the wall, "
"no more bottles of beer." "\n"
"Go to the store and buy some more, "
nn " bottles of beer on the wall.")
</lang>
</lang>