Execute HQ9+: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed indentation, added/changed comments. -- ~~~~) |
|||
Line 712:
=={{header|REXX}}==
<lang rexx>/*REXX program to implement the
accumulator=0
do instructions=1 for length(pgm); ?=substr(pgm,instructions,1)
select▼
_=substr(pgm,instructions,1)▼
when ?=='H' then say "hello, world"
▲ select
when
when
when ?=='+' then
otherwise say 'invalid HQ9+ instruction:'
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────99 subroutine───────────────────────*/
end /*select*/▼
end /*instructions*/▼
99: do j=99 by -1 to 1
say j 'bottle's(j) "of beer the wall,"
Line 742 ⟶ 739:
say '99 bottles of beer on the wall.'
return
/*──────────────────────────────────S subroutine────────────────────────*/
s: if arg(1)==1 then return ''; return
'''output''' when using the input of: <tt> H+Q </tt>
<pre style="height:40ex;overflow:scroll">
hello, world
/*REXX program to implement the
accumulator=0
do instructions=1 for length(pgm); ?=substr(pgm,instructions,1)
when ?=='H' then say "hello, world"
when
when
when ?=='+' then
otherwise say 'invalid HQ9+ instruction:'
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────99 subroutine───────────────────────*/
99: do j=99 by -1 to 1
say j 'bottle's(j) "of beer the wall,"
Line 777 ⟶ 771:
say '99 bottles of beer on the wall.'
return
/*──────────────────────────────────S subroutine────────────────────────*/
s: if arg(1)==1 then return ''; return
</pre>
|