Peter Marsh wrote: > Paul Brannan wrote: >> On Sun, Apr 29, 2007 at 08:34:33AM +0900, Peter Marsh wrote: >>> precedence = {nil=>0,40=>0,42 =>2, 43=>1, 45=>1,47=>2} >> In general it's better not to explicitly specify ASCII values, so I'd >> write instead: > > Could you explain why please, I can't see how it makes any difference, > really (but I am a noob!). > In a high level language, it's good to use the high level functions. That way if low level representations of things ever change in a newer version, your existing scripts will be more likely to work in the newer version. Consider this example, even though it's probably not a very good one: What if the upcoming unicode support changed something with the internal representation of strings so that "*" was no longer represented as "42"? Then the entry in the hash {42 => 2} would no longer be applicable, but {?* => 2} will continue to work, because if ruby's internal representation of "*" changes in some version, so will the value of ?*. It also makes me happy that someone else is working on a converter from infix to postfix. I just (almost) finished implementing Dijkstra's Shunting Yard algorithm (http://en.wikipedia.org/wiki/Shunting_yard_algorithm) in Ruby, as part of a bigger project. If you want to look at it, it's at http://paste-bin.com/11526, but it's 227 lines of poorly commented meaty algorithm. It currently works on mathematical equations with variables. It doesn't do any evaluation, though--just parses to an array. Anyway, have fun. Dan