ANNOUNCE: HasChorus - some modules for Haskore

Martin Schwenke Martin Schwenke" <martin@meltin.net
Wed, 21 Mar 2001 10:51:11 +1100


>>>>> "Robert" == Robert Jeschofnik <rejj@cs.mu.OZ.AU> writes:

    Robert> Even without having had a look at the code yet, I am led
    Robert> to wonder...

    >> BubbleSort.lhs:	    An implementation of bubble sort.
    >> Used by HasGroove.lhs.

    Robert> (I reformatted the quote so it wouldn't wrap over 80 chars)

    Robert> -Why- bubblesort?

That's what I initially thought when a colleague asked why I wasn't
using bubblesort!

The groove function takes a Haskore performance and rearranges it a
bit according to some parameters and normal distributions.  The idea
is to loosen things up a bit.  The performance is a very long list,
but is still roughly in order (otherwise I would just generate random
music to start with :-).  That is, nothing moves very far, but the
next stage in Haskore (conversion to MIDI) requires everything to be
in order.

My implementation of bubblesort iterates over the list until the list
is sorted and then stops.  Since the list is only a little bit out of
order, this doesn't take too many iterations.

My implementation is very declarative.  I could make it less so, but
my experiments have shown that the performance gain is minimal.  I'd
rather keep the code beautiful!  :-)

I tried things like quicksort and mergesort, but I couldn't minimize
the space requirements enough to make them work well.  I even
implemented a "window sort" algorithm that sorted within a window that
I "moved" along the list.  This worked quite well, but was a gross
hack.  I can't remember exactly, but I think bubblesort out-performed
it anyway!

Bubblesort rules!  ... within a very limited domain...  :-)

peace & happiness,
martin