aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordasJake <no_mail@github.com>2021-11-27 17:38:05 +0100
committerdasJake <no_mail@github.com>2021-11-27 17:38:05 +0100
commit73f2a2d0f35b4150d3fb5d226fa22b9cfd0af5cb (patch)
tree50fe53ab0d4ee2bdd4568f2ec63f63878acb78e9
parentb8230b5d16e0d0e44c47dee28a9e00a33f1b8d25 (diff)
downloadperlweeklychallenge-club-73f2a2d0f35b4150d3fb5d226fa22b9cfd0af5cb.tar.gz
perlweeklychallenge-club-73f2a2d0f35b4150d3fb5d226fa22b9cfd0af5cb.tar.bz2
perlweeklychallenge-club-73f2a2d0f35b4150d3fb5d226fa22b9cfd0af5cb.zip
140 add ch-2.pl with alternative dereferencing
-rw-r--r--challenge-140/jake/perl/ch-2.pl15
1 files changed, 6 insertions, 9 deletions
diff --git a/challenge-140/jake/perl/ch-2.pl b/challenge-140/jake/perl/ch-2.pl
index 830111b0c6..901d2f89e8 100644
--- a/challenge-140/jake/perl/ch-2.pl
+++ b/challenge-140/jake/perl/ch-2.pl
@@ -36,22 +36,19 @@ sub aggregate_multiplication_table {
sub _aggregate_multiplication_table {
my ( $vertical_range, $horizontal_range, $height_increment, $horizontal_values, $all_values ) = @_;
- # access lists from references
- my @horizontal_values = @{$horizontal_values // []};
- my @all_values = @{$all_values // []};
-
# once all lines of the table have been written we can return @all_values
- return \@all_values if $height_increment > $vertical_range;
+ #push @$all_values,;
+ return \@$all_values if $height_increment > $vertical_range;
# we 'write' the first line of the multiplication table.
# after that we run over each value in this first adding each new value to the accumulator @all_values.
# we will repeat this for every line that needs to be added to the table.
- @horizontal_values = 1 ... $horizontal_range;
- foreach ( @horizontal_values ) {
- push @all_values, $_ * $height_increment;
+ @$horizontal_values = 1 ... $horizontal_range;
+ foreach ( @$horizontal_values ) {
+ push @$all_values, $_ * $height_increment;
}
# we need to increase our line counter upon iteration.
# this is necessary for our foreach loop to add the next line in the following iteration.
- return _aggregate_multiplication_table ( $vertical_range, $horizontal_range, $height_increment + 1, \@horizontal_values, \@all_values );
+ return _aggregate_multiplication_table ( $vertical_range, $horizontal_range, $height_increment + 1, \@$horizontal_values, \@$all_values );
} \ No newline at end of file