changeset 10:308cc64c24b9 >>178

Goのソースコードを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Thu, 24 Feb 2011 07:31:17 +0900
parents 30b521e712f5
children b952a5d72c9f
files Looping.go
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Looping.go	Thu Feb 24 07:31:17 2011 +0900
@@ -0,0 +1,32 @@
+package main
+
+import fmt "fmt"
+import tm "time"
+
+type Looping struct {
+	n0 int;
+}
+
+func (this *Looping) calc(n int) (int) {
+	var n1 = this.n0 + (1 - 2*(n%2))
+	this.n0 = n
+	return n1
+}
+
+func NewLooping () *Looping {
+	var o = new(Looping)
+	o.n0 = 0
+	return o
+}
+
+func main() {
+	var o = NewLooping()
+	var n = 1
+	var t1 = tm.Nanoseconds()
+	for c:=0; c<2147483647; c++ {
+		n = o.calc(n)
+	}
+	var t2 = tm.Nanoseconds()
+	fmt.Printf("%d\nGo:\t%f\n", n, ((float64)(t2 - t1))/1000000000)
+}
+