Created
January 18, 2010 00:08
-
-
Save base10/279674 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/php | |
<?php | |
function bottle (&$i) { | |
$bottle; | |
switch ($i) { | |
case ($i == 1): | |
$bottle = 'bottle'; | |
break; | |
default: | |
$bottle = 'bottles'; | |
} | |
return $bottle; | |
} | |
$i = 99; | |
while ($i > 0) { | |
echo "$i " . bottle($i) . " of beer on the wall, $i " . bottle($i) . " of beer\n"; | |
$i--; | |
echo "take one down, pass it around, $i " . bottle($i) . " of beer on the wall\n"; | |
} | |
?> |
This file contains hidden or 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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use feature ':5.10'; | |
my $i = 99; | |
while ($i > 0) { | |
say "$i " . bottles($i) . " of beer on the wall, $i " . bottles($i) . " of beer."; | |
$i--; | |
say "take one down, pass it around, $i " . bottles($i) . " of beer on the wall."; | |
} | |
sub bottles { | |
my $i = shift; | |
my $bottle; | |
given ( $i ) { | |
when ($i == 1) {$bottle = 'bottle';} | |
default {$bottle = 'bottles';} | |
} | |
return $bottle; | |
} |
This file contains hidden or 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
#!/usr/bin/python | |
def bottle(n): # Return bottle or bottles, appropriately | |
"""Return bottle or bottles, appropriately""" | |
bot = '' | |
if n == 1: | |
bot = 'bottle' | |
else: | |
bot = 'bottles' | |
return bot | |
i = 99 | |
while i > 0: | |
print i, bottle(i), "of beer on the wall.", i, bottle(i), "of beer." | |
i = i - 1 | |
print "take one down, pass it around,", i, bottle(i), "of beer on the wall" |
This file contains hidden or 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
#!/usr/bin/env ruby | |
def bottle(i) | |
bot = String.new | |
case i | |
when 1 | |
bot = 'bottle' | |
else | |
bot = 'bottles' | |
end | |
bot | |
end | |
i = 99 | |
while (i > 0) | |
puts "#{i.to_s} #{bottle(i)} of beer on the wall, #{i.to_s} #{bottle(i)} of beer." | |
i = i - 1 | |
puts "Take one down, pass it around, #{i.to_s} #{bottle(i)} of beer on the wall." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment