progs/re3.scala
changeset 638 0367aa7c764b
parent 631 f618dd4de24a
child 647 180600c04da2
equal deleted inserted replaced
637:27f71d2755f0 638:0367aa7c764b
    86   (end - start)/(i * 1.0e9)
    86   (end - start)/(i * 1.0e9)
    87 }
    87 }
    88 
    88 
    89 
    89 
    90 //test: (a?{n}) (a{n})
    90 //test: (a?{n}) (a{n})
    91 for (i <- 0 to 7000 by 1000) {
    91 for (i <- 0 to 8000 by 1000) {
    92   println(f"$i: ${time_needed(2, matcher(EVIL1(i), "a" * i))}%.5f")
    92   println(f"$i: ${time_needed(3, matcher(EVIL1(i), "a" * i))}%.5f")
    93 }
    93 }
    94 
    94 
    95 //test: (a*)* b
    95 //test: (a*)* b
    96 for (i <- 0 to 6000000 by 500000) {
    96 for (i <- 0 to 6000000 by 500000) {
    97   println(f"$i: ${time_needed(2, matcher(EVIL2, "a" * i))}%.5f")
    97   println(f"$i: ${time_needed(3, matcher(EVIL2, "a" * i))}%.5f")
    98 }
    98 }
    99 
    99 
   100 
   100 
   101 // size of a regular expressions - for testing purposes 
   101 // size of a regular expressions - for testing purposes 
   102 def size(r: Rexp) : Int = r match {
   102 def size(r: Rexp) : Int = r match {