Language clojure
(More clojurisk and human readable versio)
Date: | 03/08/10 |
Author: | Thomas G. Kristensen |
URL: | http://g2k.dk |
Comments: | 0 |
Info: | http://clojure.org |
Score: | (4.18 in 288 votes) |
(defn bottles-str [n] (str (cond (= 0 n) "no more bottles" (= 1 n) "1 bottle" :else (format "%d bottles" n)) " of beer")) (defn print-bottle [n] (println (format "%s on the wall, %s." (bottles-str n) (bottles-str n))) (println "Take one down and pass it around," (bottles-str (dec n)) "on the wall.")) (defn sing [n] (dorun (map print-bottle (reverse (range 1 (inc n))))) (println "No more bottles of beer on the wall, no more bottles of beer.") (println "Go to the store and buy some more," (bottles-str n) "on the wall.")) (sing 99)
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
JVM-based functional language | Ravi Chugh / Zach Tatlock | 06/08/08 | 5 | |
No cheating in this version. | William James | 03/06/09 | 4 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments