Changeset 6801 for lang/scala/sandbox
- Timestamp:
- 02/17/08 12:27:20 (10 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/scala/sandbox/src/jp/gr/java_conf/mizu/util/Memoization.scala
r6800 r6801 18 18 fix(definition) _ 19 19 } 20 def main(args: Array[String]) { 21 def printTime[T](message :String)(block : => T) { 22 print(message + ": ") 23 val startTime = System.nanoTime 24 val result = block 25 printf( 26 "result = {0}, time = {1}ns", 27 result, System.nanoTime - startTime 28 ) 29 println 30 } 31 val fib = define[Int, Int]{(fib, n) => 32 n match { 33 case 0 => 1 34 case 1 => 1 35 case _ => fib(n - 1) + fib(n - 2) 36 } 37 } 38 printTime("fib(40)"){fib(40)} 39 } 20 40 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)