Execute HQ9+: Difference between revisions

Content added Content deleted
(Execute HQ9+ en BASIC256)
(added MiniScript example)
Line 1,419: Line 1,419:
" on the wall" <> If[n == 1, "", "\n\n"], {n, 99, 1, -1}]],
" on the wall" <> If[n == 1, "", "\n\n"], {n, 99, 1, -1}]],
"+", accumulator++], {chr, Characters@program}]; accumulator]</lang>
"+", accumulator++], {chr, Characters@program}]; accumulator]</lang>

=={{header|MiniScript}}==
<lang MiniScript>code = input("Enter HQ9+ program: ")

sing = function()
for i in range(99,2)
print i + " bottles of beer on the wall, " + i + " bottles of beer"
print "Take one down, pass it around, " + (i-1) + " bottle" + "s"*(i>2) + " of beer on the wall"
end for
print "1 bottle of beer on the wall, 1 bottle of beer"
print "Take one down, pass it around, no bottles of beer on the wall!"
end function

accumulator = 0
for c in code
c = c.lower
if c == "h" then print "Hello World"
if c == "q" then print code
if c == "9" then sing
if c == "+" then accumulator = accumulator + 1
end for</lang>
{{out}}
<pre>Enter HQ9+ program: hq9+
Hello World
hq9+
99 bottles of beer on the wall, 99 bottles of beer
Take one down, pass it around, 98 bottles of beer on the wall
98 bottles of beer on the wall, 98 bottles of beer
Take one down, pass it around, 97 bottles of beer on the wall
...
2 bottles of beer on the wall, 2 bottles of beer
Take one down, pass it around, 1 bottle of beer on the wall
1 bottle of beer on the wall, 1 bottle of beer
Take one down, pass it around, no bottles of beer on the wall!</pre>


=={{header|NetRexx}}==
=={{header|NetRexx}}==