comparison Looping.scala @ 7:69b8c75e9c24 default

Scalaのソースコードを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Fri, 18 Feb 2011 10:32:06 +0900
parents
children
comparison
equal deleted inserted replaced
6:5e09f7cf87f5 7:69b8c75e9c24
1 class LClass {
2 def calc(n:Int): Int = {
3 var n1 = n0 + (1 - 2*(n%2))
4 n0 = n;
5 return n1;
6 }
7 private var n0:Int = 0
8 }
9
10 object Looping {
11 def main(args :Array[String]):Unit = {
12 var o = new LClass()
13 var n = 1
14 var t1 = System.currentTimeMillis()
15 for(c <- 0 to Integer.MAX_VALUE - 1){
16 n = o.calc(n);
17 }
18 var t2 = System.currentTimeMillis()
19 println(n + "\nScala:\t" + (t2 - t1))
20 }
21 }