view Looping.pm @ 11:b952a5d72c9f >>178

Luaのソースコードを追加。2ch.netからの転載。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Thu, 24 Feb 2011 22:23:25 +0900
parents 5e09f7cf87f5
children
line wrap: on
line source

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;