aboutsummaryrefslogtreecommitdiff
path: root/challenge-033
diff options
context:
space:
mode:
authorholli.holzer <holli.holzer@gmail.com>2019-11-10 19:36:41 +0100
committerholli.holzer <holli.holzer@gmail.com>2019-11-10 19:36:41 +0100
commitda04bd4174b39d163d0ea5f4b0fe9297a3b95983 (patch)
tree70ec056637a457af84605d7b10f71fc596790074 /challenge-033
parente2543e5151c83e1cd1b10aa577be19c6ed8e0f26 (diff)
downloadperlweeklychallenge-club-da04bd4174b39d163d0ea5f4b0fe9297a3b95983.tar.gz
perlweeklychallenge-club-da04bd4174b39d163d0ea5f4b0fe9297a3b95983.tar.bz2
perlweeklychallenge-club-da04bd4174b39d163d0ea5f4b0fe9297a3b95983.zip
fixed oopsie, clearer scopes
Diffstat (limited to 'challenge-033')
-rw-r--r--challenge-033/markus-holzer/perl6/ch-2.pl612
1 files changed, 6 insertions, 6 deletions
diff --git a/challenge-033/markus-holzer/perl6/ch-2.pl6 b/challenge-033/markus-holzer/perl6/ch-2.pl6
index abe1fdd28c..42113bf6e3 100644
--- a/challenge-033/markus-holzer/perl6/ch-2.pl6
+++ b/challenge-033/markus-holzer/perl6/ch-2.pl6
@@ -1,21 +1,21 @@
# this works for all n
-sub MAIN( $n = 11 )
+sub MAIN( Int $n = 11 )
{
my $ln = ( $n * $n ).Str.chars + 1;
my $li = $n.chars + 1;
- header( $n );
- line( $_, $n ) for ( 1 .. $n );
+ header;
+ line $_ for ( 1 .. $n );
- sub line( $i, $n )
+ sub line( $i )
{
- my @n = ( ( $i .. $n ) X* $n ).map({ sprintf( "%{$ln}s", $_ ) });
+ my @n = ( ( $i .. $n ) X* $i ).map({ sprintf( "%{$ln}s", $_ ) });
my @e = ( ' ' xx ( $ln * ( $i - 1 ) ) );
say sprintf( "%{$li}s", $i ), '|', @e.join, @n.join;
}
- sub header( $n )
+ sub header
{
my @h = ( 1 .. $n ).map({ sprintf( "%{$ln}s", $_ ) });
say sprintf( "%{$li}s", "x" ), '|', @h.join;