Created
November 14, 2015 17:01
-
-
Save mikegogulski/d916d45b8e7d69a2b022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (verse v) | |
(let ( | |
(pl (lambda (n) (if (= n 1) "" "s"))) | |
(nth (lambda (c) (if (> c 0) (number->string c) "No more"))) | |
) | |
(let ((bot (lambda (b) ((nth b) " bottle " (pl v))))) | |
(if (= v 0) | |
(list "No more bottles of beer on the wall, no more bottles of beer," | |
"Go to the store and buy some more, 99 bottles of beer on the wall.") | |
(list | |
(string-append (nth v) " bottle" (pl v) " of beer on the wall, " | |
(bot v) " of beer,") | |
(string-append "Take one down and pass it around, " | |
(nth (- v 1)) " bottle" (pl (- v 1)) " of beer on the wall.")))))) | |
(apply display (apply append (map verse (reverse (range 0 3))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment