On Dec 2, 10:19 pm, Alex Shulgin <alex.shul... / gmail.com> wrote: > > #!/usr/bin/ruby > > $prec_tbl = { > ['*', '+'] => true, > ['*', '-'] => true, > ['/', '+'] => true, > ['/', '-'] => true, > ['-', '-'] => true, > ['/', '/'] => true Um... I think, I'm missing this here: ['/', '*'] => true > > } [snip] > > STDIN.each do |line| > arr = line.split(/\s+/) > begin > res = infix(arr) > throw "invalid postfix expression" unless arr.empty? > puts "#{res} => #{eval(res)}" And it chokes on division by zero due to the eval() w/o printing the infix form... :-/ > rescue > STDERR.puts $! > end > end Anyway I think it addresses the basic problem. Nice quiz! :-) -- Alex