--- a/progs/re1.scala Mon Oct 03 20:35:25 2016 +0100
+++ b/progs/re1.scala Tue Oct 04 12:00:23 2016 +0100
@@ -26,7 +26,7 @@
case SEQ(r1, r2) =>
if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))
else SEQ(der(c, r1), r2)
- case STAR(r) => SEQ(der(c, r), STAR(r))
+ case STAR(r1) => SEQ(der(c, r1), STAR(r1))
}
// derivative w.r.t. a string (iterates der)
@@ -58,7 +58,7 @@
def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n))
// the evil regular expression (a*)*b
-val EVIL2 = SEQ(STAR(CHAR('a')), CHAR('b'))
+val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
//for measuring time
def time_needed[T](i: Int, code: => T) = {
@@ -78,11 +78,11 @@
}
//test: (a*)* b
-for (i <- 1 to 6502 by 500) {
+for (i <- 1 to 20) {
println(i + " " + "%.5f".format(time_needed(2, matches(EVIL2, "a" * i))))
}
-for (i <- 1 to 6502 by 500) {
+for (i <- 1 to 20) {
println(i + " " + "%.5f".format(time_needed(2, matches(EVIL2, "a" * i))))
}