From ececd3c155ddaf3e7d0634031db73912f99bf410 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 28 Nov 2022 15:53:10 +0000 Subject: Update ch-1.pl --- challenge-193/james-smith/perl/ch-1.pl | 11 ++++++----- 1 file 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 -} -- cgit