Language Clojure
(JVM-based functional language)
Date: | 06/08/08 |
Author: | Ravi Chugh / Zach Tatlock |
URL: | http://www.ravichugh.com |
Comments: | 5 |
Info: | http://clojure.sourceforge.net/ |
Score: | (2.98 in 65 votes) |
(def f (fn [b a] (str a " bottles of beer on the wall, " a " bottles of beer.\n" "Take one down and pass it around, " (- a 1) " bottles of beer on the wall.\n\n" b))) (print (reduce f "" (range 3 100))) (println (str "2 bottles of beer on the wall, 2 bottles of beer.\n" "Take one down and pass it around, 1 bottle of beer on the wall.\n\n" "1 bottle of beer on the wall, 1 bottle of beer.\n" "Take one down and pass it around, no more bottles of beer on the wall.\n\n" "No more bottles of beer on the wall, no more bottles of beer.\n" "Go to the store and buy some more, 99 bottles of beer on the wall.\n"))
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
More clojurisk and human readable versio | Thomas G. Kristensen | 03/08/10 | 0 | |
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
JR said on 02/02/09 16:48:34
@Amonymous: If you're concerned with 100 bytes more or less, stick to the assembler samples.
SeaDog said on 02/20/09 14:37:23
I don't care about saving memory. The problem is that you don't show how to really handle the situation. I look at this site to find out how to handle certain aspects of a language. Hard coding the hardest verses does not give me the jist of how to handle those situations.
bennett said on 04/11/09 21:21:10
hi zach.
barrym said on 09/13/10 06:39:29
William James' version is clearly superior to this one. Whether or not his is
the best code out of 1348 is another debate, but one in which I am not experienced
enough to participate!
barrym said on 09/18/10 07:56:14
By the way, JR: William James' version saves 350 (MUCH more than 100) string
literal keystrokes versus Chugh/Tatlock through some clever programming (without
resorting to assembly language), and I see that as a significant improvement in
any language for such a short program!