Module: Resyma::Core::Utils

Defined in:
lib/resyma/core/utilities.rb

Class Method Summary collapse

Class Method Details

.automaton_accept?(automaton, input_array) ⇒ true, false

Whether an automaton accepts the input

Parameters:

Returns:

  • (true, false)

    Result



20
21
22
23
24
25
26
27
# File 'lib/resyma/core/utilities.rb', line 20

def self.automaton_accept?(automaton, input_array)
  current_state = automaton.start
  input_array.each do |word|
    current_state = automaton.destination(current_state, word)
    return false if current_state.nil?
  end
  automaton.accept? current_state
end

.big_union(sets) ⇒ Object



6
7
8
9
10
# File 'lib/resyma/core/utilities.rb', line 6

def self.big_union(sets)
  union = Set[]
  sets.each { |set| union.merge(set) }
  union
end