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

Instance Method Details

#and_or_simplifyFactbase::Term

Simplifies AND or OR expressions by removing duplicates

Returns:



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_simplifyFactbase::Term

Simplifies AND expressions by removing duplicates

Returns:



32
33
34
# File 'lib/factbase/terms/logical.rb', line 32

def and_simplify
  and_or_simplify
end

#or_simplifyFactbase::Term

Simplifies OR expressions by removing duplicates

Returns:



38
39
40
# File 'lib/factbase/terms/logical.rb', line 38

def or_simplify
  and_or_simplify
end