diff options
| -rw-r--r-- | challenge-193/james-smith/perl/ch-1.pl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/challenge-193/james-smith/perl/ch-1.pl b/challenge-193/james-smith/perl/ch-1.pl index 28da54e4e6..fe0ffaa757 100644 --- a/challenge-193/james-smith/perl/ch-1.pl +++ b/challenge-193/james-smith/perl/ch-1.pl @@ -5,9 +5,10 @@ use strict; use warnings; use feature qw(say); -say join ', ', binary($_) for 1..10; +say join ', ', all_binary($_) for 1..10; + +sub all_binary { ## Make a template so we don't have + my $t = "%0$_[0]b"; ## to do interpolation everytime + map { sprintf $t, $_ } 0 .. (1<<$_[0])-1 ## Need brackets as - is actioned +} ## before <<. -sub binary { - my $t = "%0$_[0]b"; - map { sprintf $t, $_ } 0.. (1<<$_[0])-1 -} |
