Skip to content

Instantly share code, notes, and snippets.

@mikegogulski
Created November 14, 2015 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikegogulski/d916d45b8e7d69a2b022 to your computer and use it in GitHub Desktop.
Save mikegogulski/d916d45b8e7d69a2b022 to your computer and use it in GitHub Desktop.
(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