Module: Factbase::Logical
- Included in:
- Term
- Defined in:
- lib/factbase/terms/logical.rb
Overview
Logical terms.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#and_or_simplify ⇒ Factbase::Term
Simplifies AND or OR expressions by removing duplicates.
-
#and_simplify ⇒ Factbase::Term
Simplifies AND expressions by removing duplicates.
-
#or_simplify ⇒ Factbase::Term
Simplifies OR expressions by removing duplicates.
Instance Method Details
#and_or_simplify ⇒ Factbase::Term
Simplifies AND or OR expressions by removing duplicates
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/factbase/terms/logical.rb', line 16 def and_or_simplify strs = [] ops = [] @operands.each do |o| o = o.simplify s = o.to_s next if strs.include?(s) strs << s ops << o end return ops[0] if ops.size == 1 self.class.new(@op, ops) end |
#and_simplify ⇒ Factbase::Term
Simplifies AND expressions by removing duplicates
32 33 34 |
# File 'lib/factbase/terms/logical.rb', line 32 def and_simplify and_or_simplify end |
#or_simplify ⇒ Factbase::Term
Simplifies OR expressions by removing duplicates
38 39 40 |
# File 'lib/factbase/terms/logical.rb', line 38 def or_simplify and_or_simplify end |