aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2022-11-28 15:53:10 +0000
committerGitHub <noreply@github.com>2022-11-28 15:53:10 +0000
commitececd3c155ddaf3e7d0634031db73912f99bf410 (patch)
tree88d1e49b6ef85745b98e7bcad924af80393d0c1d
parentdcf2530588db81ad20f5bb7aece05969fe681642 (diff)
downloadperlweeklychallenge-club-ececd3c155ddaf3e7d0634031db73912f99bf410.tar.gz
perlweeklychallenge-club-ececd3c155ddaf3e7d0634031db73912f99bf410.tar.bz2
perlweeklychallenge-club-ececd3c155ddaf3e7d0634031db73912f99bf410.zip
Update ch-1.pl
-rw-r--r--challenge-193/james-smith/perl/ch-1.pl11
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
-}