Sha256: 21b8e6a0ecc4ee77649297bcea95c8244d5f65d064226b7f1976ea4052fc4994
Contents?: true
Size: 817 Bytes
Versions: 4
Compression:
Stored size: 817 Bytes
Contents
require 'dydx' include Dydx 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.encode('utf-8')) ruby_obj = eval(ruby_code) optimize_output(ruby_obj).encode('utf-8') rescue SyntaxError # TODO: emergency case ruby_code when /(\d)+(\w)/ execute("#{$1} * #{$2}") end end def self.optimize_output(ruby_obj) case ruby_obj when Matrix, Vector, Dydx::Algebra::Formula ruby_obj.to_q when Float::INFINITY 'oo' when - Float::INFINITY '-oo' else str = ruby_obj.to_s str.equalize! end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
qlang-0.0.27182121 | lib/qlang/iq.rb |
qlang-0.0.27182120 | lib/qlang/iq.rb |
qlang-0.0.27182110 | lib/qlang/iq.rb |
qlang-0.0.27182100 | lib/qlang/iq.rb |