bradengroom/scala-automata-library

implement substitute(charx, chary)

Closed this issue · 1 comments

This method should go through each transition and change its character to chary if it matches charx.

 def substitute(oldChar: Char, newChar: Char): Automaton = {
   this.states.foreach(state => {
     state.getTransitions.filter(_.char == oldChar).foreach(transition => {
         state.addTransition(new Transition(transition.end, newChar))
         state.removeTransition(transition)
     })
   })
   this
 }