Anonymous user
Execute HQ9+/Python: Difference between revisions
Replace if ... elif ... elif ... with dispatch table.
(no need to remark on +) |
(Replace if ... elif ... elif ... with dispatch table.) |
||
Line 36:
print "99 bottles of beer on the wall."
print
def incr():
if len(sys.argv) != 2:
Line 51 ⟶ 54:
acc = 0
src = s.read()
# Implement interpreter using a dispatch table
dispatch = {
'h': hello,
'+': incr
for i in src.lower():
if i
▲ quine()
▲ bottles()
▲ acc += 1 # ?
▲ else:
|