Sha256: f15e2ee438d8f6ccd0d0b49af5ff9047511787d1a653e391c63f2cc5567c06b4
Contents?: true
Size: 970 Bytes
Versions: 1
Compression:
Stored size: 970 Bytes
Contents
module DpllSolver module Formulas class Clause attr_accessor :literals def initialize(*args) @literals = Set.new(args) end def add(literal) @literals.add(literal) self end def delete(literal) literal_array = @literals.to_a literal_array.delete(literal) @literals = Set.new(literal_array) self end def unit? @literals.count == 1 end def empty? @literals.empty? end def include?(literal) @literals.to_a.include?(literal) end def union(other) @literals = @literals + other.literals self end def get_unit_literal @literals.first if unit? end def ==(other) other.class == self.class && other.literals == @literals end def to_s "{#{@literals.to_a.map(&:to_s).join(', ')}}" end alias eql? == end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dpll_solver-0.0.1 | lib/dpll_solver/formulas/clause.rb |