comparison Looping.pm @ 6:5e09f7cf87f5

Perl版のソースコードを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Thu, 17 Feb 2011 15:32:22 +0900
parents
children
comparison
equal deleted inserted replaced
5:861b93741d60 6:5e09f7cf87f5
1 package Looping;
2
3 sub new {
4 my $class = shift;
5 my $self = {
6 n0 => 1
7 };
8 bless $self, $class;
9 }
10
11 sub calc {
12 my $self = shift;
13 my $n = shift;
14 my $n1 = $self->{n0} + (1 - 2*($n%2));
15 $self->{n0} = $n;
16 return $n1;
17 }
18
19 1;