Execute HQ9+/Ruby: Difference between revisions

m
Fixed syntax highlighting.
m (make dispatch table a class constant)
m (Fixed syntax highlighting.)
 
(One intermediate revision by one other user not shown)
Line 1:
{{implementation|HQ9+}}{{collection|RCHQ9+}}
This [[Ruby]] program implements an [[HQ9+]] interpreter.
<langsyntaxhighlight lang="ruby">class HQ9plus
Dispatch = Hash.new(:unknown).merge({
'h' => :hello,
Line 45:
hq9 = HQ9plus.new(:program => '+qhp;+9Q')
hq9.run
puts hq9.accumulator</langsyntaxhighlight>
 
Output:
9,476

edits