view Looping.scala @ 7:69b8c75e9c24 default

Scalaのソースコードを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Fri, 18 Feb 2011 10:32:06 +0900
parents
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))
	}
}