
On Jun 24, 2010, at 11:14 AM, Martin Drautzburg wrote:
Another question is: how much past and future knowledge do I need. (I believe the fundamental property of music is that things are ordered). In order to compute Volumes from Moments I can get pretty much away without the past, but computing Moments from Volumes definitely requires knowing "where I am", because each new Moment has to be placed after a preceding Moment.
You can use pattern matching against lists. For example: process_rhythm_scheme :: RhythmScheme -> Rhythm process_rhythm_scheme ( (Just foo, Just bar ) : (Just foo', Just bar') : (Just foo'', Just bar'') : rest ) = undefined will match a RhythmScheme where the first three entries are wholly defined, and will bind its values to foo, bar, foo', bar', rest, and so on. I think "View Patterns" could help control the complexity of these patterns. http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns. That page has quite a few nice constructs that could apply to your problem. ("Both patterns", "iterator style")