add support for unary plus/minus
This commit is contained in:
@@ -151,23 +151,6 @@ module RubyAlgebra
|
||||
end
|
||||
end
|
||||
|
||||
class Subtraction < Addition
|
||||
attr_reader :lhs, :rhs
|
||||
|
||||
def to_s
|
||||
need_parentheses_left = lhs.op_priority < op_priority || (lhs.op_priority == op_priority && op_assoc_type == :right)
|
||||
need_parentheses_right = rhs.op_priority < op_priority || (rhs.op_priority == op_priority && op_assoc_type == :left)
|
||||
|
||||
result = need_parentheses_left ? "(#{lhs}) - " : "#{lhs} - "
|
||||
result + (need_parentheses_right ? "(#{rhs})" : rhs.to_s)
|
||||
end
|
||||
|
||||
def type
|
||||
:sub
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Constant < Expression
|
||||
attr_reader :value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user