progs/re1.scala
changeset 631 f618dd4de24a
parent 623 47a299e7010f
child 647 180600c04da2
--- a/progs/re1.scala	Wed Sep 25 11:24:34 2019 +0100
+++ b/progs/re1.scala	Wed Sep 25 23:56:36 2019 +0100
@@ -38,7 +38,7 @@
 }
 
 // the main matcher function
-def matches(r: Rexp, s: String) : Boolean = 
+def matcher(r: Rexp, s: String) : Boolean = 
   nullable(ders(s.toList, r))
 
 
@@ -79,7 +79,7 @@
   val start = System.nanoTime()
   for (j <- 1 to i) code
   val end = System.nanoTime()
-  "%.5f".format((end - start) / (i * 1.0e9))
+  (end - start) / (i * 1.0e9)
 }
 
 
@@ -87,14 +87,14 @@
 println("Test (a?{n}) (a{n})")
 
 for (i <- 0 to 20 by 2) {
-  println(s"$i: ${time_needed(2, matches(EVIL1(i), "a" * i))}")
+  println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
 }
 
 // test: (a*)* b
 println("Test (a*)* b")
 
 for (i <- 0 to 20 by 2) {
-  println(s"$i: ${time_needed(2, matches(EVIL2, "a" * i))}")
+  println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
 }
 
 
@@ -137,5 +137,5 @@
 size(ders(("ab" * 200).toList, BIG))    // 366808
 
 for (i <- 0 to 200 by 10) {
-  println(s"$i: ${time_needed(2, matches(BIG, "ab" * i))}")
+  println(f"$i: ${time_needed(2, matcher(BIG, "ab" * i))}%.5f")
 }