lib/dydx/algebra/formula.rb in dydx-0.0.5 vs lib/dydx/algebra/formula.rb in dydx-0.0.6
- old
+ new
@@ -49,11 +49,30 @@
def openable?(x)
x.is_num? && (f.is_num? || g.is_num?)
end
+ # TODO: interchangeable
def ==(x)
to_s == x.to_s
+ end
+
+ def common_factors(formula)
+ nil unless formula.is_a?(Formula)
+ if f == formula.f
+ [:f, :f]
+ elsif g == formula.g
+ [:g, :g]
+ elsif f == formula.g
+ [:f, :g]
+ elsif g == formula.f
+ [:g, :f]
+ end
+ end
+
+ def commutate!
+ @f, @g = @g, @f
+ self
end
end
end
end
\ No newline at end of file