Arithmetic evaluation: Difference between revisions

m
→‎{{header|Ruby}}: slight rewording of explanation.
(added Ruby solution.)
m (→‎{{header|Ruby}}: slight rewording of explanation.)
Line 1,845:
 
=={{header|Ruby}}==
Function to convert infix arithmetic expression to binary tree. The resulting tree knows how to print and evaluate itself. Assumes expression is well-formed (matched parens, all operators have 2 operands). SourceAlgorithm: http://www.seas.gwu.edu/~csci131/fall96/exp_to_tree.html
<lang ruby>$op_priority = {"+" => 0, "-" => 0, "*" => 1, "/" => 1}
$op_function = {
Anonymous user