Execute HQ9+: Difference between revisions

Added 11l
(initial submission of php 7.x solution to this problem)
(Added 11l)
Line 4:
Implement a   ''' [[HQ9+]] '''   interpreter or compiler.
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F hello()
print(‘Hello, world!’)
 
String src
F quine()
print(:src)
 
F bottles()
L(i) (99.<2).step(-1)
print(‘#. bottles of beer on the wall’.format(i))
print(‘#. bottles of beer’.format(i))
print(‘Take one down, pass it around’)
print(‘#. bottles of beer on the wall’.format(i - 1))
print()
 
print(‘2 bottles of beer on the wall’)
print(‘2 bottles of beer’)
print(‘Take one down, pass it around’)
print(‘1 bottle of beer on the wall’)
print()
 
print(‘1 bottle of beer on the wall’)
print(‘1 bottle of beer’)
print(‘Take one down, pass it around’)
print(‘No more bottles of beer on the wall’)
print()
 
print(‘No more bottles of beer on the wall’)
print(‘No more bottles of beer on the wall’)
print(‘Go to the store and buy some more’)
print(‘99 bottles of beer on the wall.’)
print()
 
V acc = 0
F incr()
:acc++
 
:start:
src = File(:argv[1]).read()
 
[Char = (() -> N)] dispatch
dispatch[Char(‘h’)] = hello
dispatch[Char(‘q’)] = quine
dispatch[Char(‘9’)] = bottles
dispatch[Char(‘+’)] = incr
 
L(i) src.lowercase()
I i C dispatch
dispatch[i]()</lang>
 
=={{header|8080 Assembly}}==
1,480

edits