<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 24, 2010, at 11:14 AM, Martin Drautzburg wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">Another question is: how much past and future knowledge do I need. (I believe<span class="Apple-converted-space">&nbsp;</span><br>the fundamental property of music is that things are ordered). &nbsp;In order to<span class="Apple-converted-space">&nbsp;</span><br>compute Volumes from Moments I can get pretty much away without the past, but<span class="Apple-converted-space">&nbsp;</span><br>computing Moments from Volumes definitely requires knowing "where I am",<span class="Apple-converted-space">&nbsp;</span><br>because each new Moment has to be placed after a preceding Moment.<br></span></blockquote></div><div><br></div><div>You can use pattern matching against lists. &nbsp;For example:</div><div><br></div><div><font class="Apple-style-span" face="Courier">process_rhythm_scheme :: RhythmScheme -&gt; Rhythm</font></div><div><font class="Apple-style-span" face="Courier">process_rhythm_scheme ( (Just foo, &nbsp;Just bar )</font></div><div><font class="Apple-style-span" face="Courier"></font><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>&nbsp;&nbsp; &nbsp; &nbsp;: (Just foo', Just bar')</span></div><div><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: (Just foo'', Just bar'')</span></div><div><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>&nbsp;&nbsp; &nbsp; &nbsp;: rest&nbsp;) = undefined</span></div><div><span class="Apple-style-span" style="font-family: Courier; "><br></span></div><div>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.</div><div><br></div><div>I think "View Patterns" could help control the complexity of these patterns. &nbsp;<a href="http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns">http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns</a>. &nbsp;That page has quite a few nice constructs that could apply to your problem. &nbsp;("Both patterns", "iterator style")</div></body></html>