[Haskell-beginners] Simple Chess Program for Learning FP

Daniel Fischer daniel.is.fischer at web.de
Tue Jun 1 17:28:20 EDT 2010


On Tuesday 01 June 2010 22:54:38, Jordan Cooper wrote:
> Thank you, Daniel and Yitzchak! I think that will be enough to get me
> started. As a general question, at what number of elements does it
> become impractical to use Lists?

That utterly depends on what you're doing and how important performance is.
If performance is *very* important, you can write faster code already to 
replace very short lists. That code will be far far longer and far far 
uglier than list-using code, though.
We have a great number of very nice functions for manipulating lists, that 
makes writing list-using code nice easy and fast. If you use other data 
structures (where lists are a natural choice), the code and coding tends to 
be less pleasant. And most of the time, not so very much faster.
Haskell implementations (well, certainly GHC and hugs, haven't tried others 
much) are pretty good with lists.
If you consume your lists in the order they are produced, lists of several 
million elements can have nice performance. If your use-pattern isn't so 
good, lists of a few hundred elements can give really stinking performance.

If your code contains many (!!), you are doing something wrong.
If your code contains "length list == 0" (or "== 1", "== 2"), you are doing 
something horribly wrong.


More information about the Beginners mailing list