diff -r 65d1ea0e989f -r 24531cfaa36a progs/app51.scala --- a/progs/app51.scala Sat Sep 27 00:37:02 2014 +0100 +++ b/progs/app51.scala Sun Sep 28 18:07:58 2014 +0100 @@ -1,8 +1,8 @@ -abstract class Rexp +def OPT(r: Rexp) = ALT(r, EMPTY) -case object NULL extends Rexp -case object EMPTY extends Rexp -case class CHAR(c: Char) extends Rexp -case class ALT(r1: Rexp, r2: Rexp) extends Rexp -case class SEQ(r1: Rexp, r2: Rexp) extends Rexp -case class STAR(r: Rexp) extends Rexp +def NTIMES(r: Rexp, n: Int) : Rexp = n match { + case 0 => EMPTY + case 1 => r + case n => SEQ(r, NTIMES(r, n - 1)) +} +