# HG changeset patch # User "uncorrelated zombie" # Date 1297992726 -32400 # Node ID 69b8c75e9c247ba3cb3b54e54ce3fd50ac206ed9 # Parent 5e09f7cf87f55a3c05d2d53d3992963f9abf06d6 Scalaのソースコードを追加。 diff -r 5e09f7cf87f5 -r 69b8c75e9c24 Looping.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Looping.scala Fri Feb 18 10:32:06 2011 +0900 @@ -0,0 +1,21 @@ +class LClass { + def calc(n:Int): Int = { + var n1 = n0 + (1 - 2*(n%2)) + n0 = n; + return n1; + } + private var n0:Int = 0 +} + +object Looping { + def main(args :Array[String]):Unit = { + var o = new LClass() + var n = 1 + var t1 = System.currentTimeMillis() + for(c <- 0 to Integer.MAX_VALUE - 1){ + n = o.calc(n); + } + var t2 = System.currentTimeMillis() + println(n + "\nScala:\t" + (t2 - t1)) + } +}