Anonymous user
Execute HQ9+: Difference between revisions
→{{header|Common Lisp}}: added D
m (→{{header|Haskell}}: fix link) |
(→{{header|Common Lisp}}: added D) |
||
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}}==
|