Mercurial > op > Looping
annotate Looping.pm @ 7:69b8c75e9c24 default
Scalaのソースコードを追加。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Fri, 18 Feb 2011 10:32:06 +0900 |
parents | 5e09f7cf87f5 |
children |
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; |