diff -r 065ca01b62ae -r 4ae59fd3b174 progs/re1.scala --- a/progs/re1.scala Mon Aug 22 23:05:43 2016 +0200 +++ b/progs/re1.scala Tue Aug 23 12:26:13 2016 +0200 @@ -55,7 +55,8 @@ } // the evil regular expression a?{n} a{n} -def EVIL(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n)) +def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n)) +val EVIL2 = SEQ(STAR(CHAR('a')), CHAR('b')) //for measuring time def time_needed[T](i: Int, code: => T) = { @@ -66,8 +67,11 @@ } -for (i <- 1 to 29) { - println(i + ": " + "%.5f".format(time_needed(1, matches(EVIL(i), "a" * i)))) +for (i <- 1 to 20) { + println(i + ": " + "%.5f".format(time_needed(2, matches(EVIL1(i), "a" * i)))) } +for (i <- 1 to 6502 by 500) { + println(i + " " + "%.5f".format(time_needed(2, matches(EVIL2, "a" * i)))) +}