[Haskell-beginners] combinatorial

Michael P. Mossey mpm at alumni.caltech.edu
Sun Nov 22 05:25:45 EST 2009

I'm trying to write a combinatorial search algorithm with evaluation, 
and kind of stuck. Not sure how to do this.

I'm constructing a musical phrase, which is a list of MidiPitch:


I have an evaluation function that determines the fitness of any given

eval :: [MidiPitch] -> Maybe Float

This returns Nothing if the phrase is completely unacceptable.

The idea is to build up a phrase one midi pitch at a time, choosing all 
possible next pitches (notes) from a range:

next pitch comes from: [10..90]

Most of the pitches will result in a phrase that evaluates to Nothing, 
so the combinatoral "explosion" will be limited.

I'd like to write a function that constructs a phrase of length n, and 
in fact will have to return a list of all phrases that have equal scores 
of the maximum.

--         <length of output phrase> -> <first pitch> -> <eval func> ->
--         <all tied phrases of best score>
coolFunc :: Int -> MidiPitch -> ([MidiPitch] -> Maybe Float) ->

I am stuck on how to write this.


More information about the Beginners mailing list