progs/re1.scala
changeset 467 b5ec11e89768
parent 454 edb4ad356c56
child 469 1f4e81950ab4
equal deleted inserted replaced
466:9ec26df6d289 467:b5ec11e89768
    60 
    60 
    61 // the evil regular expression (a*)*b
    61 // the evil regular expression (a*)*b
    62 val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
    62 val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
    63 
    63 
    64 //for measuring time
    64 //for measuring time
    65 def time_needed[T](i: Int, code: => T) = {
    65 def time_needed[T](i: Int, code => T) = {
    66   val start = System.nanoTime()
    66   val start = System.nanoTime()
    67   for (j <- 1 to i) code
    67   for (j <- 1 to i) code()
    68   val end = System.nanoTime()
    68   val end = System.nanoTime()
    69   (end - start)/(i * 1.0e9)
    69   (end - start)/(i * 1.0e9)
    70 }
    70 }
    71 
    71 
    72 //test: (a?{n}) (a{n})
    72 //test: (a?{n}) (a{n})