Quick actions

cmd+k|ctrl+k

Navigation

Languages

Lab2

Snippet info

Language

Raku

Visibility

public

Author

democracyforone

Created

2024-10-25T20:31:18.137457Z

Updated

2024-10-27T17:03:35.847537Z

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