diff -r b47e140bcccd -r 47a299e7010f progs/nfa.scala --- a/progs/nfa.scala Thu Jul 25 14:39:37 2019 +0100 +++ b/progs/nfa.scala Sun Jul 28 01:00:41 2019 +0100 @@ -4,18 +4,18 @@ // needs :load dfa.scala for states -// type abbreviation for partial functions +// a type abbreviation for partial functions type :=>[A, B] = PartialFunction[A, B] -// return an empty set, when parial function is not defined +// return an empty set, when a parial function is not defined def applyOrElse[A, B](f: A :=> Set[B], x: A) : Set[B] = Try(f(x)) getOrElse Set[B]() // NFAs -case class NFA[A, C](starts: Set[A], // starting states - delta: (A, C) :=> Set[A], // transition function - fins: A => Boolean) { // final states +case class NFA[A, C](starts: Set[A], // the starting states + delta: (A, C) :=> Set[A], // the transition function + fins: A => Boolean) { // the final states // given a state and a character, what is the set of // next states? if there is none => empty set