progs/matcher/re1.sc
changeset 965 94f5cce73a4f
parent 961 c0600f8b6427
child 981 14e5ae1fb541
equal deleted inserted replaced
964:da1f8c033b8e 965:94f5cce73a4f
    98   (end - start) / (i * 1.0e9)
    98   (end - start) / (i * 1.0e9)
    99 }
    99 }
   100 
   100 
   101 
   101 
   102 // test: (a?{n}) (a{n})
   102 // test: (a?{n}) (a{n})
       
   103 @main
   103 def test1() = {
   104 def test1() = {
   104   println("Test (a?{n}) (a{n})")
   105   println("Test (a?{n}) (a{n})")
   105 
   106 
   106   for (i <- 0 to 20 by 2) {
   107   for (i <- 0 to 20 by 2) {
   107     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
   108     println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
   108   }
   109   }
   109 }
   110 }
   110 
   111 
   111 // test: (a*)* b
   112 // test: (a*)* b
       
   113 @main
   112 def test2() = {
   114 def test2() = {
   113   println("Test (a*)* b")
   115   println("Test (a*)* b")
   114 
   116 
   115   for (i <- 0 to 20 by 2) {
   117   for (i <- 0 to 20 by 2) {
   116     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
   118     println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
   159 size(ders("aaaaaaaaaaaa".toList, BIG))  // 536
   161 size(ders("aaaaaaaaaaaa".toList, BIG))  // 536
   160 
   162 
   161 
   163 
   162 size(ders(("a" * 30).toList, BIG))      // 31010539
   164 size(ders(("a" * 30).toList, BIG))      // 31010539
   163 
   165 
   164 
   166 @main
   165 def test3() = {
   167 def test3() = {
   166   println("Test (a + aa)*")
   168   println("Test (a + aa)*")
   167 
   169 
   168   for (i <- 0 to 30 by 5) {
   170   for (i <- 0 to 30 by 5) {
   169     println(f"$i: ${time_needed(2, matcher(BIG, "a" * i))}%.5f")
   171     println(f"$i: ${time_needed(2, matcher(BIG, "a" * i))}%.5f")
   171 }
   173 }
   172 
   174 
   173 @main
   175 @main
   174 def all() = { test1(); test2() ; test3() } 
   176 def all() = { test1(); test2() ; test3() } 
   175 
   177 
   176 //all()
   178 
       
   179 
       
   180