[Haskell-beginners] Problem "grouping" a list
Stephen Tetley
stephen.tetley at gmail.com
Tue Nov 23 15:25:18 EST 2010
Are you wanting this function for something like beam grouping - i.e.
notes less than a quarter note are grouped together until their values
sum to a quarter note?
If this is what you want, it can be quite a tough problem - I've done
it in concert with bar splitting (two problems!). Personally I'd use
direct recursion rather than a left-fold - you have to go from
left-to-right however you do it. To do it properly you'll probably
find you need to "borrow" durations from the next beam group, this is
why I wouldn't use a left fold:
For instance if you are splitting to quarter notes - a dotted quarter
note with "borrow" an eighth from the next beam group.
That said, I'd strongly caution against working with sheet music - it
is much more complicated than working with played sound - e.g. MIDI or
WAV files. Music type-setting has had 1000 years since Guido d'Arezzo
to develop notations with no concession to computer processing.
Best wishes
Stephen
More information about the Beginners
mailing list