Lab2
my @tracks = (
"Bohemian Rhapsody",
"Rhapsody Bohemian",
"Bohemian Slut",
"Bohemian Slut",
"Dingle Berry",
"Dingle Burry",
"Dingle Dungle",
"Stairway to Heaven",
"Hotel California",
"Imagine",
"Smells Like Teen Spirit",
"Smells Like Teen Spirit"
);
my %counts = ();
for @tracks -> $title {
# Convert title into an array of words
my @parsed_title = $title.words;
my $index = 0;
# While there is a succeeding word for the current word
while $index < @parsed_title.end {
%counts{@parsed_title[$index]}{@parsed_title[$index + 1]}++;
$index++;
}
}
say %counts;INFO