Sha256: 062874a1aa70c667a9b2fd0e89e193ad21c944e8c0d647318fa12862462cac72
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require 'dydx/algebra/formula' require 'dydx/algebra/set' require 'dydx/algebra/operator/formula' require 'dydx/algebra/operator/symbol' require 'dydx/algebra/operator/num' require 'dydx/algebra/operator/general' module Dydx module Algebra include Set module Set Symbol.class_eval{ include Operator::Symbol } Fixnum.class_eval do %w(+ - * / ^).each do |operator| define_method(operator) do |g| if g.is_a?(Symbol) || g.is_a?(Formula) || g.is_a?(Base) Num.new(self).send(operator.to_sym, g) elsif operator == '^' && g.is_a?(Fixnum) result = 1 g.times{ result *= self } result else (to_f.send(operator.to_sym, g)).to_i end end end end class Num; include Operator::Num; end class E; include Operator::General; end class Pi; include Operator::General; end class Log; include Operator::General; end class Sin; include Operator::General; end class Cos; include Operator::General; end class Tan; include Operator::General; end end class Formula; include Operator::Formula; end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dydx-0.0.4 | lib/dydx/algebra.rb |
dydx-0.0.3 | lib/dydx/algebra.rb |