author | Christian Urban <christian.urban@kcl.ac.uk> |
Fri, 29 Nov 2024 18:58:18 +0000 | |
changeset 975 | ae5c03560d4d |
parent 436 | 9213b8298ca9 |
permissions | -rw-r--r-- |
415 | 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)) |
|
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
415
diff
changeset
|
8 |
case (c::s, r) => ders2(s, simp(der(c, r))) |
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
9 |
} |