Method: Sequitur::Production#reduce_step

Defined in:
lib/sequitur/production.rb

#reduce_step(another) ⇒ Object

Given that the production P passed as argument has exactly 2 symbols in its rhs s1 s2, substitute in the rhs of self all occurrences of s1 s2 by a reference to P.

Parameters:



184
185
186
187
188
189
190
191
192
# File 'lib/sequitur/production.rb', line 184

def reduce_step(another)
  (symb1, symb2) = another.rhs.symbols
  pos = positions_of(symb1, symb2).reverse

  # Replace the two symbol sequence by the production
  pos.each { |index| rhs.reduce_step(index, another) }

  recalc_digrams
end