Course of Raku / Advanced / More about built-in types / Sets, bags, and mixes / Exercises
Count in a bag
Problem
A bag is a natural fit for counting words. Take the sentence
the cat sat on the mat, split it into words, and build a
bag from them. Print two lines: how many times the word the
appears, and the total number of words counted.
Example
The program prints:
2
6