progs/app52.scala
changeset 415 4ae59fd3b174
parent 399 5c1fbb39c93e
child 436 9213b8298ca9
equal deleted inserted replaced
414:065ca01b62ae 415:4ae59fd3b174
       
     1 def ders2(s: List[Char], r: Rexp) : Rexp = (s, r) match {
       
     2   case (Nil, r) => r
       
     3   case (s, ZERO) => ZERO
       
     4   case (s, ONE) => if (s == Nil) ONE else ZERO
       
     5   case (s, CHAR(c)) => if (s == List(c)) ONE else 
       
     6                        if (s == Nil) CHAR(c) else ZERO
       
     7   case (s, ALT(r1, r2)) => ALT(ders2(s, r2), ders2(s, r2))
       
     8   case (c::s, r) => ders2(s, der(c, r).simp)
       
     9 }