progs/nfa.scala
changeset 586 451a95e1bc25
parent 491 d5776c6018f0
child 623 47a299e7010f
equal deleted inserted replaced
585:6ee22f196884 586:451a95e1bc25
     5 
     5 
     6 
     6 
     7 // type abbreviation for partial functions
     7 // type abbreviation for partial functions
     8 type :=>[A, B] = PartialFunction[A, B]
     8 type :=>[A, B] = PartialFunction[A, B]
     9 
     9 
    10 // return an empty set when not defined
    10 // return an empty set, when parial function is not defined
    11 def applyOrElse[A, B](f: A :=> Set[B], x: A) : Set[B] =
    11 def applyOrElse[A, B](f: A :=> Set[B], x: A) : Set[B] =
    12   Try(f(x)) getOrElse Set[B]()
    12   Try(f(x)) getOrElse Set[B]()
    13 
    13 
    14 
    14 
    15 // NFAs
    15 // NFAs