Created
October 14, 2018 18:19
-
-
Save pmurias/b4b147048a70e333e61ec8c298096491 to your computer and use it in GitHub Desktop.
99 Bottles of Beer
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
for 99...1 -> $bottles { | |
sing $bottles, :wall; | |
sing $bottles; | |
say "Take one down, pass it around"; | |
sing $bottles - 1, :wall; | |
say ""; | |
} | |
#| Prints a verse about a certain number of beers, possibly on a wall. | |
sub sing( | |
Int $number, #= Number of bottles of beer. | |
Bool :$wall, #= Mention that the beers are on a wall? | |
) { | |
my $quantity = $number == 0 ?? "No more" !! $number; | |
my $plural = $number == 1 ?? "" !! "s"; | |
my $location = $wall ?? " on the wall" !! ""; | |
say "$quantity bottle$plural of beer$location" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment