From 4ea66f577ee8d9a442b5863b72f5a8278e278e84 Mon Sep 17 00:00:00 2001 From: RNuttall Date: Sat, 9 Nov 2019 18:03:50 +0000 Subject: simplify loops --- .gitignore | 1 + challenge-033/rnuttall/perl6/ch-01.p6 | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..485dee64bc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/challenge-033/rnuttall/perl6/ch-01.p6 b/challenge-033/rnuttall/perl6/ch-01.p6 index f10e4cba2c..b2eb228afb 100644 --- a/challenge-033/rnuttall/perl6/ch-01.p6 +++ b/challenge-033/rnuttall/perl6/ch-01.p6 @@ -7,12 +7,8 @@ sub MAIN(*@files) { #Task 1 - a Test of Bag and Bag addition my Bag $counts = bag { 'a' .. 'z' => 0 }; - say @files; # Create a bag for each file and add counts using Bag addition ⊎ or (+) - for @files -> $file { - $counts ⊎= $file.IO.slurp.lc.comb.Bag; - } - for 'a' .. 'z' -> $letter { - say "$letter: $counts{$letter}"; - } + $counts ⊎= $_.IO.slurp.lc.comb.Bag for @files; + + say "$_: $counts{$_}" for 'a' .. 'z'; } -- cgit