[Haskell-beginners] Improving Performance

Robert Heumüller mailing at heum.de
Tue Jun 19 16:37:57 CEST 2012


in order to tune my brain to "functional thinking" I've decided to
start writing some "real" programs. After having spent a couple of days
figuring out how to translate an imperative algorithm into stateless
haskell I beleive I've now managed a simple implementation of the DBSCAN
clustering algorithm.


This code has several drawbacks (and probably it doesn't work correctly
after all) but I would like to tune its performance.
Obviously the code calls several functions multiply with the same
arguments. Haskell, being stateless should thus always yield the same
resuts, correct? In this case performing the same calculations multiply
seems pointless.

My question: 
How would you go about improving this code? 
In any imperative language I would simply cache distances/neighborhoods
in a matrix. Obviously this is not what the way to go in haskell?

Thank you very much

More information about the Beginners mailing list