[Haskell-cafe] Re: Unifcation and matching in Abelian groups

John D. Ramsdell ramsdell0 at gmail.com
Thu Aug 20 09:11:31 EDT 2009

On Wed, Aug 19, 2009 at 11:38 PM, Chung-chieh
Shan<ccshan at post.harvard.edu> wrote:

> Thanks!  Another small change that might shorten the code is to use
> Data.Map for linear combinations:

I chose to use association lists because I did not want to explain the
adjust function one would use to implement the add function.  I
thought it would make the code cryptic for beginners.

Your suggestion does raise an interesting question.  When is it faster
to to use associations list instead of Data.Map.  For some
applications of the matcher, the number of variables is usually, but
not always small, like less than three, so association lists may
actually be faster.  I never know the number of keys it takes to make
the overhead of Data.Map worthwhile.  I also never know the number
elements it takes to make the overhead of an array worthwhile over a
list in applications that do a lot of indexing.


More information about the Haskell-Cafe mailing list