# HG changeset patch # User Christian Urban # Date 1443768536 -3600 # Node ID ac1187b2e5c96a4218c30f1a2cebeb8fcdf0d121 # Parent c49122dbcdd17977490c8280d82fc1bab050a89f updated program diff -r c49122dbcdd1 -r ac1187b2e5c9 progs/re3.scala --- a/progs/re3.scala Thu Oct 01 23:50:11 2015 +0100 +++ b/progs/re3.scala Fri Oct 02 07:48:56 2015 +0100 @@ -9,23 +9,19 @@ def simp(r: Rexp): Rexp = r match { case ALT(r1, r2) => { - val r1s = simp(r1) - val r2s = simp(r2) - (r1s, r2s) match { - case (NULL, _) => r2s - case (_, NULL) => r1s - case _ => if (r1s == r2s) r1s else ALT(r1s, r2s) + (simp(r1), simp(r2)) match { + case (NULL, r2s) => r2s + case (r1s, NULL) => r1s + case (r1s, r2s) => if (r1s == r2s) r1s else ALT(r1s, r2s) } } case SEQ(r1, r2) => { - val r1s = simp(r1) - val r2s = simp(r2) - (r1s, r2s) match { + (simp(r1), simp(r2)) match { case (NULL, _) => NULL case (_, NULL) => NULL - case (EMPTY, _) => r2s - case (_, EMPTY) => r1s - case _ => SEQ(r1s, r2s) + case (EMPTY, r2s) => r2s + case (r1s, EMPTY) => r1s + case (r1s, r2s) => SEQ(r1s, r2s) } } case NTIMES(r, n) => NTIMES(simp(r), n)