Anonymous user
Execute HQ9+/Python: Difference between revisions
no edit summary
(added + operator) |
imported>Katsumi No edit summary |
||
(6 intermediate revisions by 6 users not shown) | |||
Line 1:
{{collection|RCHQ9+}}{{implementation|HQ9+}}
This [[Python]] example implements 'H', 'Q', '9' and '+'.
<syntaxhighlight lang="python">
▲<lang python>import sys
def hello():
print
def quine():
print
def bottles():
for i in range(99,2,-1):
print
print
print
print
print()
print
print
print
print
print()
print
print
print
print
print()
print
print
print
print
print
def incr():
if len(sys.argv) != 2:
print
sys.exit(1)
else:
Line 48 ⟶ 50:
s = open(f,"r")
except IOError, e:
print
sys.exit(1)
acc = 0
src = s.read()
# Implement interpreter using a dispatch table
dispatch = {
'h': hello,
'+': incr
for i in src.lower():
if i
</syntaxhighlight>
▲ quine()
▲ bottles()
▲ acc += 1 # ?
▲ else:
|