Sha256: a313175afd2b49e20484c38d45d2ee6fbc768ef824bb28ad52c7ef977db5e769

Contents?: true

Size: 456 Bytes

Versions: 7

Compression:

Stored size: 456 Bytes

Contents

module Stamina
  class Automaton

    #
    # Returns the complement automaton.
    #
    # A complement automaton is simply a complete automaton with all state
    # labels flipped.
    #
    def complement
      dup.complement!
    end

    #
    # Complements this automaton
    #
    def complement!
      complete!
      each_state do |s|
        s[:accepting] = !s.accepting?
      end
      self
    end

  end # class Automaton
end # module Stamina

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stamina-core-0.6.1 lib/stamina-core/stamina/automaton/complement.rb
stamina-core-0.6.0 lib/stamina-core/stamina/automaton/complement.rb
stamina-core-0.5.4 lib/stamina-core/stamina/automaton/complement.rb
stamina-core-0.5.3 lib/stamina-core/stamina/automaton/complement.rb
stamina-core-0.5.2 lib/stamina-core/stamina/automaton/complement.rb
stamina-core-0.5.1 lib/stamina-core/stamina/automaton/complement.rb
stamina-core-0.5.0 lib/stamina-core/stamina/automaton/complement.rb