public static IEnumerable <char> Transduce(IEnumerable <char> input) { var encoder = new DecodeDigitPairs(); int state = encoder.q0; foreach (char c in input) { foreach (char d in encoder.Psi(state, (int)c)) { yield return(d); } state = encoder.Delta(state, (int)c); } if (encoder.F.Contains(state)) { foreach (char d in encoder.Psi(state, -1)) { yield return(d); } } else { throw new Exception("DecodeDigitPairs"); } }
public static IEnumerable<char> Transduce(IEnumerable<char> input) { var encoder = new DecodeDigitPairs(); int state = encoder.q0; foreach (char c in input) { foreach (char d in encoder.Psi(state, (int)c)) yield return d; state = encoder.Delta(state, (int)c); } if (encoder.F.Contains(state)) { foreach (char d in encoder.Psi(state, -1)) yield return d; } else throw new Exception("DecodeDigitPairs"); }