Class: Factbase::Simplified
- Inherits:
-
Object
- Object
- Factbase::Simplified
- Defined in:
- lib/factbase/terms/simplified.rb
Overview
Simplified operands.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#initialize(operands) ⇒ Simplified
constructor
A new instance of Simplified.
-
#unique ⇒ Object
Removes duplicate operands.
Constructor Details
#initialize(operands) ⇒ Simplified
Returns a new instance of Simplified.
14 15 16 |
# File 'lib/factbase/terms/simplified.rb', line 14 def initialize(operands) @operands = operands end |
Instance Method Details
#unique ⇒ Object
Removes duplicate operands
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/factbase/terms/simplified.rb', line 19 def unique strs = [] ops = [] @operands.each do |o| o = o.simplify s = o.to_s next if strs.include?(s) strs << s ops << o end ops end |