progs/app5.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 27 Nov 2013 21:36:30 +0000
changeset 208 bd5a8a6b3871
parent 93 4794759139ea
child 261 24531cfaa36a
permissions -rw-r--r--
added

def nullable (r: Rexp) : Boolean = r match {
  case NULL => false
  case EMPTY => true
  case CHAR(_) => false
  case ALT(r1, r2) => nullable(r1) || nullable(r2)
  case SEQ(r1, r2) => nullable(r1) && nullable(r2)
  case STAR(_) => true
}