progs/app51.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 22 Feb 2016 22:09:31 +0000 (2016-02-22)
changeset 397 cf3ca219c727
parent 261 24531cfaa36a
child 399 5c1fbb39c93e
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
261
24531cfaa36a updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
     1
def OPT(r: Rexp) = ALT(r, EMPTY)
7
73cf4406b773 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     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 {
24531cfaa36a updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
     4
  case 0 => EMPTY
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