progs/dfa.scala
changeset 576 550186034b6e
parent 487 a697421eaa04
child 623 47a299e7010f
--- 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