Skip to content

Instantly share code, notes, and snippets.

Created May 1, 2014 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/260ffb652a390fa9bb45 to your computer and use it in GitHub Desktop.
Save anonymous/260ffb652a390fa9bb45 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl6-m
# -*-Perl-*-
use v6;
my @files = <file1.txt file2.txt file3.txt>;
my @all_counts = await do for @files -> $filename {
start {
my %word_counts;
for slurp($filename).words {
%word_counts{$_}++;
}
%word_counts;
}
}
# Bring them together into a single result.
my %totals;
for @all_counts {
%totals{.key} += .value;
}
say %totals.elems;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment