diff options
| author | Alexander Pankoff <ccntrq@screenri.de> | 2020-11-01 19:15:15 +0100 |
|---|---|---|
| committer | Alexander Pankoff <ccntrq@screenri.de> | 2020-11-01 19:18:26 +0100 |
| commit | 5e4a64fd61cbdee9134be45992f77ae7806e2ce3 (patch) | |
| tree | dbeb27a9766dbf547aeb3a8aa356c998933f6301 | |
| parent | 7e38a468ad7d224e003596ed2e172c218b6008a1 (diff) | |
| download | perlweeklychallenge-club-5e4a64fd61cbdee9134be45992f77ae7806e2ce3.tar.gz perlweeklychallenge-club-5e4a64fd61cbdee9134be45992f77ae7806e2ce3.tar.bz2 perlweeklychallenge-club-5e4a64fd61cbdee9134be45992f77ae7806e2ce3.zip | |
make `combinations` total
instead of `die`ing this now returns a empty list when no combinations
can be build
| -rw-r--r-- | challenge-083/alexander-pankoff/perl/lib/Combinations.pm | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/challenge-083/alexander-pankoff/perl/lib/Combinations.pm b/challenge-083/alexander-pankoff/perl/lib/Combinations.pm index 73b22cfa65..2fb005c0a7 100644 --- a/challenge-083/alexander-pankoff/perl/lib/Combinations.pm +++ b/challenge-083/alexander-pankoff/perl/lib/Combinations.pm @@ -4,19 +4,13 @@ use warnings; use feature qw(signatures); no warnings 'experimental::signatures'; -use Carp qw(croak); - use Exporter qw(import); our @EXPORT_OK = qw(combinations); # returns possible combinations of $length elements from @pool. sub combinations ( $count, @pool ) { - croak "cannot build combinations with $count elements from a list of " - . scalar(@pool) - . " elements" - if $count > @pool; - return () if $count == 0; + return () if $count == 0 || $count > @pool; return map { [$_] } @pool if $count == 1; my @combinations; |
