diff 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 diff
--- /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))
+	}
+}