changeset 415 | 4ae59fd3b174 |
parent 399 | 5c1fbb39c93e |
child 436 | 9213b8298ca9 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/app52.scala Tue Aug 23 12:26:13 2016 +0200 @@ -0,0 +1,9 @@ +def ders2(s: List[Char], r: Rexp) : Rexp = (s, r) match { + case (Nil, r) => r + case (s, ZERO) => ZERO + case (s, ONE) => if (s == Nil) ONE else ZERO + case (s, CHAR(c)) => if (s == List(c)) ONE else + if (s == Nil) CHAR(c) else ZERO + case (s, ALT(r1, r2)) => ALT(ders2(s, r2), ders2(s, r2)) + case (c::s, r) => ders2(s, der(c, r).simp) +}