lib/qlang/iq.rb in qlang-0.0.27 vs lib/qlang/iq.rb in qlang-0.0.141

- old
+ new

@@ -1,39 +1,18 @@ module Qlang module Iq - class Dydx::Algebra::Formula - # FIX: - def to_q - str = to_s.gsub(/\*\*/, '^').rm(' * ') - str.equalize! - end - end - - def self.execute(code) - ruby_code = Q.to_ruby.compile(code) - ruby_obj = eval(ruby_code) - - optimize_output(ruby_obj) - rescue SyntaxError - # TODO: emergency - case ruby_code - when /(\d)+(\w)/ - execute("#{$1} * #{$2}") - end - end - - def self.optimize_output(ruby_obj) + def execute(code) + ruby_obj = eval Q.to_ruby.compile(code) case ruby_obj - when Matrix, Vector, Dydx::Algebra::Formula + when Matrix, Vector ruby_obj.to_q when Float::INFINITY 'oo' when - Float::INFINITY '-oo' else - str = ruby_obj.to_s - str.equalize! + ruby_obj end end - + module_function :execute end end