aboutsummaryrefslogtreecommitdiff
path: root/challenge-238/lance-wicks/perl/lib/RunningSum.pm
blob: c23528c309f662266726dfb078575c7d9a8af066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package RunningSum;

use strict;
use warnings;

sub run {
    my $self  = shift;
    my @input = @_;

    my @out = ( $input[0] );

    for my $i ( 1 .. $#input ) {
        push @out, ( $out[ $i - 1 ] + $input[$i] );
    }

    return \@out;
}

1;