changeset 7 | 73cf4406b773 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app5.scala Thu Sep 27 11:59:41 2012 +0100 @@ -0,0 +1,8 @@ +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 +}