diff Looping.pm @ 8:30da8c1da4d4 >>178

SmalltalkやScalar版のベンチマークを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Fri, 18 Feb 2011 19:58:26 +0900
parents 5e09f7cf87f5
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Looping.pm	Fri Feb 18 19:58:26 2011 +0900
@@ -0,0 +1,19 @@
+package Looping;
+
+sub new {
+  my $class = shift;
+  my $self = {
+    n0 => 1
+  };
+  bless $self, $class;
+}
+
+sub calc {
+  my $self = shift;
+  my $n = shift;
+  my $n1 = $self->{n0} + (1 - 2*($n%2));
+  $self->{n0} = $n;
+  return $n1;
+}
+
+1;