Execute HQ9+: Difference between revisions
Content added Content deleted
m ({{omit from|GUISS}}) |
(Add Seed7 example) |
||
Line 633: | Line 633: | ||
println(hq9plus("HQ9+")) |
println(hq9plus("HQ9+")) |
||
</lang> |
</lang> |
||
=={{header|Seed7}}== |
|||
The program below accepts the HQ9+ program as command line parameter: |
|||
<lang seed7>$ include "seed7_05.s7i"; |
|||
const proc: runCode (in string: code) is func |
|||
local |
|||
var char: ch is ' '; |
|||
var integer: bottles is 0; |
|||
var integer: accumulator is 0; |
|||
begin |
|||
for ch range code do |
|||
case ch of |
|||
when {'H'}: writeln("Hello, world!"); |
|||
when {'Q'}: writeln(code); |
|||
when {'9'}: bottles := 99; |
|||
repeat |
|||
writeln(bottles <& " bottles of beer on the wall"); |
|||
writeln(bottles <& " bottles of beer"); |
|||
writeln("Take one down, pass it around"); |
|||
decr(bottles); |
|||
writeln(bottles <& " bottles of beer on the wall"); |
|||
writeln; |
|||
until bottles = 0; |
|||
when {'+'}: incr(accumulator); |
|||
end case; |
|||
end for; |
|||
end func; |
|||
const proc: main is func |
|||
begin |
|||
if length(argv(PROGRAM)) >= 1 then |
|||
runCode(argv(PROGRAM)[1]); |
|||
end if; |
|||
end func;</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |