Mercurial > op > Looping
view Looping.scala @ 9:30b521e712f5 >>178
JavaScript (xhtml) のソースコードを追加。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Wed, 23 Feb 2011 01:17:31 +0900 |
parents | 69b8c75e9c24 |
children |
line wrap: on
line source
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)) } }