annotate Looping.pm @ 6:5e09f7cf87f5

Perl版のソースコードを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Thu, 17 Feb 2011 15:32:22 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
1 package Looping;
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
2
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
3 sub new {
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
4 my $class = shift;
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
5 my $self = {
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
6 n0 => 1
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
7 };
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
8 bless $self, $class;
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
9 }
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
10
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
11 sub calc {
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
12 my $self = shift;
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
13 my $n = shift;
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
14 my $n1 = $self->{n0} + (1 - 2*($n%2));
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
15 $self->{n0} = $n;
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
16 return $n1;
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
17 }
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
18
5e09f7cf87f5 Perl版のソースコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
19 1;