--- a/progs/dfa.scala Tue Oct 09 08:25:40 2018 +0100
+++ b/progs/dfa.scala Fri Oct 12 10:16:54 2018 +0100
@@ -4,6 +4,7 @@
// type abbreviation for partial functions
type :=>[A, B] = PartialFunction[A, B]
+
case class DFA[A, C](start: A, // starting state
delta: (A, C) :=> A, // transition (partial fun)
fins: A => Boolean) { // final states
@@ -38,10 +39,11 @@
case (Q4, 'b') => Q4 }
val dfa = DFA(Q0, delta, Set[State](Q4))
+dfa.accepts("aaabbb".toList)
dfa.accepts("bbabaab".toList) // true
dfa.accepts("baba".toList) // false
-
+dfa.accepts("abc".toList) // false
// another DFA test with a Sink state
abstract class S