Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my $text = open 'shakespeare.txt';
- sub channeled {
- my Channel $read .= new;
- read-worker($text, $read);
- my @all-counts = await counter($read);
- @all-counts».say;
- }
- sub read-worker($text, $dest) {
- start {
- CATCH { $dest.fail($_) }
- $dest.send($_) for $text.lines;
- $dest.close
- }
- }
- sub counter($source) {
- my int @ic[3] = (0, 0, 0);
- start {
- for $source.list -> $line {
- for $line.comb -> $_ {
- when $_ (elem) Vowels { @ic[0]++ }
- when /<:Letter>/ { @ic[1]++ }
- default { @ic[2]++ }
- }
- }
- @ic
- }
- }
- channeled()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement