def evaluate(formula, fail_result = 0)
        if value = eval(formula)
          last_match = $1
          (formula =~ /^c\(?\d+=~/) ? last_match : value
        else
          fail_result
        end   
      end
def evaluate(formula, fail_result = 0)
        if value = eval(formula)
          last_match = $1
          (formula =~ /^c\(?\d+=~/) ? last_match : value
        else
          fail_result
        end   
      end
def evaluate ( formula , fail_result = 0 ) if value = eval ( formula ) last_match = $1 ( formula =~ / \( \d / ) ? last_match : value else fail_result end end
Evaluate a formula
 Example invokation
     evaluate("n1+n2", 0)
     evaluate("c1+c2", "failed")
     evaluate("c0=~/\\.(\\d{4})/", "0")
Evaluate a formula Example invokation evaluate ( n1 + n2 0 ) evaluate ( c1 + c2 failed ) evaluate ( c0 = ~ / \\ . ( \\ d { 4 } ) / 0 )