my $match = $abc ~~ m/ <ABC::tune> /;
die "Tune not matched\n" unless $match ~~ Match;
my @notes = gather for $match<ABC::tune><music><line_of_music> -> $line
{
for $line<bar> -> $bar
{
for $bar<element>
{
when .<broken_rhythm> { take .<broken_rhythm><note>[0]; take .<broken_rhythm><note>[1]; }
when .<note> { take .<note>; }
}
}
}
@notes.map({.<pitch>.say});
I'm suspecting there is a lovely Perl 6 idiom I don't quite have yet to squish all the for statements into a series of maps, but this works fine for the time being.
No comments:
Post a Comment