4 ms·
Rosetta Code: 99 Bottles of Beer in 117 Programming Languages
- gsivil 16y agoI would like to see the preference of other HNers and their arguments based only on that sample of the language. If you had only this post to choose a language what would be your preference? And why? C looks always archetypal. Simple, crisp and on the point
- mishmash 16y agoPerl 5's version made me laugh. Regexes for the iteration, what win.
- IChrisI 16y agoFor reference, Perl 5's version: http://99-bottles-of-beer.net/language-perl-737.html http://99-bottles-of-beer.net/language-perl-737.html My personal favorite is the Malbolge version because it made me read up on Malbolge :) http://99-bottles-of-beer.net/language-malbolge-995.html http://99-bottles-of-beer.net/language-malbolge-995.html
- mishmash 16y agoOh god this is a beautiful hack. I had to download and run it just to believe it, but jesus it works.
- sz 16y agoThe Inform 7 one is cool. It's almost not recognizable as a program. Imagine: programming by dictation.
- sz 16y agoCloser than one might think? http://blog.stephenwolfram.com/2010/11/programming-with-natural-language-is-actually-going-to-work/ http://blog.stephenwolfram.com/2010/11/programming-with-natu...
- GoneWacko 16y agoObviously I must point out the existence of http://99-bottles-of-beer.net/ http://99-bottles-of-beer.net/ which claims to have considerably more languages and variations and as such obviously wins this unwritten competition of site-with-more-implementations-of-classic-marching-song-reproducing-code.
- BigZaphod 16y agoI'm biased as I'm the creator of Whirl, but one my favorite 99-bottles implementations might just be this one: http://bigzaphod.org/whirl/kang-99.html http://bigzaphod.org/whirl/kang-99.html And of course, there's the one I did for another of my silly languages, Taxi: http://bigzaphod.org/taxi/99.txt http://bigzaphod.org/taxi/99.txt :) [edit: To clarify, I didn't write the one done in Whirl, that was sent to me by Kang Seonghoon.)
- djacobs 16y agoI think one of the most sarcastic entries may be the object-oriented solution in C++: http://rosettacode.org/wiki/99_Bottles_of_Beer/C%2B%2B/Object_Oriented http://rosettacode.org/wiki/99_Bottles_of_Beer/C%2B%2B/Objec... Compare with the simple solution: http://rosettacode.org/wiki/99_Bottles_of_Beer#The_simple_solution_2 http://rosettacode.org/wiki/99_Bottles_of_Beer#The_simple_so... As a recent OO -> functional convert, the comparison was amusing. (Not that there is anything functional about multiline print statements.)
- afshin 16y agoI'm not a very good K programmer, but no K example existed, so I posted mine: http://rosettacode.org/wiki/99_Bottles_of_Beer#K http://rosettacode.org/wiki/99_Bottles_of_Beer#K It fits in a tweet (exactly 140 characters right now ... but it can probably be shortened).
- iwr 16y agoApparently, there is no XSLT version. Well, here is one: The XML file: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="99bottles.xsl"?> <beer>99</beer> The XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform> http://www.w3.org/1999/XSL/Transform> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <html> <head> <title>Beer!</title> </head> <body> <xsl:call-template name="beer"> <xsl:with-param name="bottles" select="/beer"/> </xsl:call-template> </body> </html> </xsl:template> <xsl:template name="beer"> <xsl:param name="bottles" /> <xsl:if test="$bottles > 0"> <p> <xsl:value-of select="$bottles"/> <xsl:choose> <xsl:when test="$bottles = 1" > <xsl:text> bottle of beer on the wall</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> bottles of beer on the wall</xsl:text> </xsl:otherwise> </xsl:choose> <br/> <xsl:value-of select="$bottles"/> <xsl:choose> <xsl:when test="$bottles = 1" > <xsl:text> bottle of beer!</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> bottles of beer!</xsl:text> </xsl:otherwise> </xsl:choose> <br/> <xsl:text>You take one down, and pass it around</xsl:text> <br/> <xsl:choose> <xsl:when test="($bottles - 1) = 0" > <xsl:text>No bottles of beer on the wall!</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="$bottles - 1"/> <xsl:text> bottles of beer on the wall!</xsl:text> </xsl:otherwise> </xsl:choose> </p> <xsl:call-template name="beer"> <xsl:with-param name="bottles" select="$bottles - 1"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet>
- deleted 16y ago[deleted]