Language MiniD
(something more than a for loop)
| Date: | 06/09/09 |
| Author: | Jarrett Billingsley |
| URL: | n/a |
| Comments: | 1 |
| Info: | http://www.dsource.org/projects/minid |
| Score: |
module beer
function bottleStr(num) =
num == 1 ? "bottle" : "bottles"
function num(num)
{
if(num == 0)
return "no more"
else if(num == -1)
return "99"
else
return toString(num)
}
function action(num) =
num == 0 ? "Go to the store and buy some more" : "Take one down and pass it around"
function cap(str) =
str[0].toUpper() ~ str[1..]
function sing(i = 99)
{
writefln("{} {} of beer on the wall, {} {1} of beer.", cap(num(i)), bottleStr(i), num(i))
writefln("{}, {} {} of beer on the wall.\n", action(i), num(i - 1), bottleStr(i - 1))
if(i != 0)
return sing(i - 1)
}
sing()
Download Source | Write Comment
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