Jump to content

Execute HQ9+: Difference between revisions

1,120 bytes added ,  13 years ago
Line 137:
 
See [[Execute HQ9+/Common Lisp]].
 
=={{header|D}}==
<lang d>import std.stdio, std.regex;
 
void main(string[] args) {
if (args.length != 2 || match(args[1], "^[hq9+]+$", "i").empty) {
writeln("not valid HQ9+ code");
return;
}
int accumulator;
foreach (c; args[1]) {
final switch(c) {
case 'Q', 'q':
writeln(args[1]);
break;
case 'H', 'h':
writeln("Hello, world!");
break;
case '9':
int bottles = 99;
while (bottles > 1) {
writeln(bottles, " bottles of beer on the wall,");
writeln(bottles, " bottles of beer.");
writeln("Take one down, pass it around,");
if (--bottles > 1) {
writeln(bottles, " bottles of beer on the wall.\n");
}
}
writeln("1 bottle of beer on the wall.\n");
break;
case '+':
accumulator++;
break;
}
}
}
</lang>
 
=={{header|E}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.