New 99 Bottles D/Tango - just submitted
Mike
vertex at gmx.at
Tue Dec 18 19:47:04 PST 2007
I'm posting it here, I hope you like it :)
-Mike
/*
* 99 bottles of beer with D and Tango
*
* Please note: This is not intended to be maintained.
* Works with DMD 1.023 and Tango 0.99
* Written by Michael Mittner, 19 December 2007
*/
import tango.io.Stdout;
import tango.text.convert.Integer;
void main()
{
char[] text = "bottles of beer on the wallTake one down and pass it
aroundNoOneTwoThreeFourFiveSixSevenEightNineTen";
foreach (i, c; text)
{
Stdout.format(delegate char[]()
{
switch (i)
{
case 0: return "{0}{1}{3}{0}{3}{2}{3}";
case 99: return "{0}{1}";
default: return "{0}{1}{3}{3}{0}{1}{3}{0}{3}{2}{3}";
}
}(), delegate char[](uint num)
{
return delegate char[]()
{
switch (num)
{
case 0: return text[59..61];
case 1: return text[61..64];
case 2: return text[64..67];
case 3: return text[67..72];
case 4: return text[72..76];
case 5: return text[76..80];
case 6: return text[80..83];
case 7: return text[83..88];
case 8: return text[88..93];
case 9: return text[93..97];
case 10: return text[97..$];
default: return toUtf8(num);
}
}() ~ " " ~ (num == 1 ? text[0..6] ~ text[7..15] :
text[0..15]);
}(text.length - i - 1),
text[15..27],
text[27..59],
"\n");
}
}
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Digitalmars-d-announce
mailing list