author | Christian Urban <christian.urban@kcl.ac.uk> |
Fri, 16 Sep 2022 12:52:21 +0100 | |
changeset 875 | 49d21814a633 |
parent 399 | 5c1fbb39c93e |
permissions | -rw-r--r-- |
399
5c1fbb39c93e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1 |
def OPT(r: Rexp) = ALT(r, ONE) |
7 | 2 |
|
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
3 |
def NTIMES(r: Rexp, n: Int) : Rexp = n match { |
399
5c1fbb39c93e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
4 |
case 0 => ONE |
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
5 |
case 1 => r |
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
6 |
case n => SEQ(r, NTIMES(r, n - 1)) |
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
7 |
} |
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
8 |