lib/dydx/helper.rb in dydx-0.1.2 vs lib/dydx/helper.rb in dydx-0.1.3
- old
+ new
@@ -59,24 +59,35 @@
end
def combinable?(x, operator)
case operator
when :+
- self == x ||
(is_num? && x.is_num?) ||
- (multiplication? && (f == x || g == x)) ||
- (x.multiplication? && (x.f == self || x.g == self)) ||
+ (formula?(:*) && (f.is_num? || g.is_num?)) && x.is_num? ||
+ like_term?(x) ||
inverse?(:+, x)
when :*
self == x ||
(is_num? && x.is_num?) ||
inverse?(:*, x)
when :^
(is_num? && x.is_num?) || is_0? || is_1?
end
end
+ def like_term?(x)
+ boolean = if self == x
+ elsif formula?(:*) && include?(x)
+ elsif x.formula?(:*) && x.include?(self)
+ elsif ((formula?(:*) && formula?(:*)) && (([f, g] & [x.f, x.g]).any?{|x| x.is_a?(Symbol)}))
+ else
+ true
+ end
+
+ !boolean
+ end
+
def is_multiple_of(x)
if is_0?
e0
elsif self == x
e1
@@ -96,12 +107,9 @@
end
end
def rest(f_or_g)
([:f, :g] - [f_or_g]).first
- end
-
- def commutative?
end
def distributable?(operator)
end